{ "pandav:/dist/maptalks.video.es.js": { "cubeCode": "Cube(\"pandav:/npm/@maptalks/video-layer/0.102.5/dist/maptalks.video.es\", [\"pandav:/npm/maptalks/1.2.1\", \"pandav:/npm/@maptalks/gl/0.108.1\"], function (module, exports, require, load, process, global) {\n\n function _typeof(o) {\"@babel/helpers - typeof\";return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {return typeof o;} : function (o) {return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;}, _typeof(o);}\n Object.defineProperty(exports, \"__esModule\", {\n value: true });\n\n exports.VideoSurface = exports.VideoLayer = void 0;\n var _maptalks = _interopRequireWildcard(require('pandav:/npm/maptalks/1.2.1'));\n var t = _maptalks;\n var _gl = require('pandav:/npm/@maptalks/gl/0.108.1');\n function _getRequireWildcardCache(e) {if (\"function\" != typeof WeakMap) return null;var r = new WeakMap(),t = new WeakMap();return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {return e ? t : r;})(e);}\n function _interopRequireWildcard(e, r) {if (!r && e && e.__esModule) return e;if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e };var t = _getRequireWildcardCache(r);if (t && t.has(e)) return t.get(e);var n = { __proto__: null },a = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var u in e) if (\"default\" !== u && {}.hasOwnProperty.call(e, u)) {var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];}return n.default = e, t && t.set(e, n), n;}\n function _readOnlyError(r) {throw new TypeError('\"' + r + '\" is read-only');}\n function _classCallCheck(a, n) {if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\");}\n function _defineProperties(e, r) {for (var t = 0; t < r.length; t++) {var o = r[t];o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);}}\n function _createClass(e, r, t) {return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e;}\n function _toPropertyKey(t) {var i = _toPrimitive(t, \"string\");return \"symbol\" == _typeof(i) ? i : i + \"\";}\n function _toPrimitive(t, r) {if (\"object\" != _typeof(t) || !t) return t;var e = t[Symbol.toPrimitive];if (void 0 !== e) {var i = e.call(t, r || \"default\");if (\"object\" != _typeof(i)) return i;throw new TypeError(\"@@toPrimitive must return a primitive value.\");}return (\"string\" === r ? String : Number)(t);}\n function _callSuper(t, o, e) {return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));}\n function _possibleConstructorReturn(t, e) {if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e;if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\");return _assertThisInitialized(t);}\n function _assertThisInitialized(e) {if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e;}\n function _isNativeReflectConstruct() {try {var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));} catch (t) {}return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {return !!t;})();}\n function _superPropGet(t, o, e, r) {var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);return 2 & r && \"function\" == typeof p ? function (t) {return p.apply(e, t);} : p;}\n function _get() {return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {var p = _superPropBase(e, t);if (p) {var n = Object.getOwnPropertyDescriptor(p, t);return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;}}, _get.apply(null, arguments);}\n function _superPropBase(t, o) {for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););return t;}\n function _getPrototypeOf(t) {return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {return t.__proto__ || Object.getPrototypeOf(t);}, _getPrototypeOf(t);}\n function _inherits(t, e) {if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\");t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e);}\n function _setPrototypeOf(t, e) {return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {return t.__proto__ = e, t;}, _setPrototypeOf(t, e);}\n for (var c = [], u = 0; u < 6; u++) c[u] = [];\n var p = [];\n function f(t, e, i) {\n var s, r, o, n, a, h, l, d, u, f, _, g, x, w, y, b, O;\n r = (s = t)[0], o = s[1], n = s[2], a = s[3], h = s[4], l = s[5], d = s[6], u = s[7], f = s[8], _ = s[9], g = s[10], x = s[11], w = s[12], y = s[13], b = s[14], O = s[15], m(c[0], a - r, u - h, x - f, O - w), m(c[1], a + r, u + h, x + f, O + w), m(c[2], a + o, u + l, x + _, O + y), m(c[3], a - o, u - l, x - _, O - y), m(c[4], a - n, u - d, x - g, O - b), m(c[5], a + n, u + d, x + g, O + b);\n for (var S = 0; S < 6; S++) {\n var T = c[S];\n if (p[0] = T[0] > 0 ? e[1][0] : e[0][0], p[1] = T[1] > 0 ? e[1][1] : e[0][1], p[2] = T[2] > 0 ? e[1][2] : e[0][2], v(T, p) < 0) return !1;\n }\n return !0;\n }\n function m(t, e, i, s, r) {\n var o = 1 / Math.sqrt(e * e + i * i + s * s);\n return t[0] = e * o, t[1] = i * o, t[2] = s * o, t[3] = r * o, t;\n }\n function v(t, e) {\n return t[0] * e[0] + t[1] * e[1] + t[2] * e[2] + t[3];\n }\n var _ = {\n vert: \"\\n attribute vec3 aPosition;\\n attribute vec2 aTexCoord;\\n uniform mat4 projViewModelMatrix;\\n uniform mat4 positionMatrix;\\n uniform mat4 modelMatrix;\\n varying vec2 vTexCoords;\\n #include \\n void main()\\n {\\n mat4 localPositionMatrix = getPositionMatrix();\\n vec4 localPosition = getPosition(aPosition);\\n gl_Position = projViewModelMatrix * localPositionMatrix * localPosition;\\n vTexCoords = aTexCoord;\\n }\\n\",\n frag: \"\\n precision mediump float;\\n uniform sampler2D videoTexture;\\n uniform float opacity;\\n\\n varying vec2 vTexCoords;\\n void main() {\\n vec4 color = texture2D(videoTexture, vTexCoords);\\n gl_FragColor = color * opacity;\\n }\\n\",\n uniforms: [{\n name: \"projViewModelMatrix\",\n type: \"function\",\n fn: function fn(t, e) {\n return _gl.mat4.multiply([], e.projViewMatrix, e.modelMatrix);\n } },\n \"texture\", \"opacity\"],\n positionAttribute: \"POSITION\",\n extraCommandProps: {\n depth: {\n enable: !0,\n func: \"always\" },\n\n cull: {\n enable: !1,\n face: \"back\" },\n\n frontFace: \"cw\",\n blend: {\n enable: !0,\n func: {\n src: \"src alpha\",\n dst: \"one minus src alpha\" },\n\n equation: \"add\" } } },\n\n\n\n g = [1, 0, 3, 3, 2, 1];\n var x = function (_t$renderer$CanvasRen) {\n function x(t) {\n var _this;\n _classCallCheck(this, x);\n _this = _callSuper(this, x, [t]), _this.t = {};\n return _this;\n }\n _inherits(x, _t$renderer$CanvasRen);\n return _createClass(x, [{\n key: \"draw\",\n value: function draw(t, e) {\n this.prepareCanvas(), this.i(e);\n } },\n {\n key: \"drawOnInteracting\",\n value: function drawOnInteracting(t, e, i) {\n this.i(i);\n } },\n {\n key: \"needToRedraw\",\n value: function needToRedraw() {\n return !0;\n } },\n {\n key: \"hitDetect\",\n value: function hitDetect() {\n return !1;\n } },\n {\n key: \"createContext\",\n value: function createContext() {\n if (this.canvas.gl && this.canvas.gl.wrap) this.gl = this.canvas.gl.wrap(), this.regl = this.canvas.gl.regl;else {\n var _t = this.layer.options.glOptions || {\n alpha: !0,\n depth: !0,\n stencil: !0 };\n\n this.glOptions = _t, this.gl = this.gl || this.o(this.canvas, _t), this.regl = (0, _gl.createREGL)({\n gl: this.gl,\n extensions: [\"ANGLE_instanced_arrays\", \"OES_texture_float\", \"OES_texture_half_float\", \"OES_texture_float_linear\", \"OES_texture_half_float_linear\", \"EXT_shader_texture_lod\", \"OES_element_index_uint\", \"OES_standard_derivatives\", \"WEBGL_depth_texture\"],\n optionalExtensions: this.layer.options.glExtensions || [] });\n\n }\n this.h(), this.l();\n var t = this.layer.getVideoSurfaces();\n for (var _e = 0; _e < t.length; _e++) this.u(t[_e]);\n } },\n {\n key: \"o\",\n value: function o(t, e) {\n var i = [\"webgl\", \"experimental-webgl\"];\n var s = null;\n for (var _r = 0; _r < i.length; ++_r) {\n try {\n s = t.getContext(i[_r], e);\n } catch (t) {}\n if (s) break;\n }\n return s;\n } },\n {\n key: \"l\",\n value: function l() {\n var t = this.layer.getMap(),\n e = new _gl.reshader.Renderer(this.regl);\n this.renderer = e, this.p = {\n projMatrix: t.projMatrix,\n projViewMatrix: t.projViewMatrix,\n viewMatrix: t.viewMatrix,\n halton: [.2107, -.0202],\n uHalton: [.2107, -.0202],\n uCameraPosition: t.cameraPosition,\n cameraPosition: t.cameraPosition,\n globalTexSize: [t.width, t.height] };\n\n } },\n {\n key: \"m\",\n value: function m() {\n return this.regl;\n } },\n {\n key: \"h\",\n value: function h() {\n var _this2 = this;\n this.viewport = {\n x: 0,\n y: 0,\n width: function width() {\n return _this2.canvas ? _this2.canvas.width : 1;\n },\n height: function height() {\n return _this2.canvas ? _this2.canvas.height : 1;\n } },\n this.v();\n } },\n {\n key: \"v\",\n value: function v() {\n this._ && this._.dispose(), this.layer.options.showTopAlways ? (_.extraCommandProps.depth.mask = !1, _.extraCommandProps.depth.range = [0, 0]) : (delete _.extraCommandProps.depth.mask, delete _.extraCommandProps.depth.range), _.extraCommandProps.cull.enable = !this.layer.options.doubleSide, this._ = new _gl.reshader.MeshShader(_);\n } },\n {\n key: \"u\",\n value: function u(t) {\n var e = this.regl.texture(),\n i = new _gl.reshader.Material({\n videoTexture: e,\n opacity: 1 }),\n\n s = t.getCoordinates(),\n _this$O = this.O(s),\n r = _this$O.worldCenter,\n o = _this$O.points,\n n = this.S(o),\n a = new _gl.reshader.Mesh(n, i);\n this.T(a, r);\n var l = new _gl.reshader.Scene(a),\n d = t.C();\n this.t[d] = l;\n } },\n {\n key: \"M\",\n value: function M(t) {\n var e = t.C(),\n i = this.t[e].getMeshes()[0],\n s = t.getCoordinates();\n i.geometry.dispose();\n var _this$O2 = this.O(s),\n r = _this$O2.worldCenter,\n o = _this$O2.points,\n n = this.S(o);\n i.geometry = n, this.T(i, r);\n } },\n {\n key: \"i\",\n value: function i(t) {\n var e = this.layer.getVideoSurfaces().filter(function (t) {\n return t.isVisible();\n });\n if (!e.length) return;\n var i = this.P(e);\n if (!i) return;\n var s = null;\n t && (s = t.renderTarget && t.renderTarget.fbo), this.renderer.render(this._, this.p, i, s);\n } },\n {\n key: \"S\",\n value: function S(t) {\n return new _gl.reshader.Geometry({\n POSITION: t,\n TEXCOORD: [0, 0, 1, 0, 1, 1, 0, 1] },\n g, 0, {\n primitive: \"triangles\",\n positionAttribute: \"POSITION\",\n uv0Attribute: \"TEXCOORD\",\n normalAttribute: \"NORMAL\",\n positionSize: 3 });\n\n } },\n {\n key: \"O\",\n value: function O(e) {\n var i = [];\n var s = this.getMap(),\n r = new t.Polygon(e).getCenter(),\n o = w(s, r, 0);\n return this.V = o, s && e.forEach(function (e) {\n var r = new t.Coordinate(e[0], e[1]),\n n = s.altitudeToPoint(e[2] || 0, s.getGLRes()),\n a = w(s, r, n);\n a[0] = a[0] - o[0], a[1] = a[1] - o[1], i = i.concat(a);\n }), {\n worldCenter: o,\n points: i };\n\n } },\n {\n key: \"P\",\n value: function P(t) {\n var e = [],\n i = this.layer.getMap();\n for (var _s = 0; _s < t.length; _s++) {\n var _r2 = t[_s],\n _o = this.t[_r2.C()];\n if (!_o) continue;\n var _n = _o.getMeshes();\n for (var _t2 = 0; _t2 < _n.length; _t2++) {\n var _s2 = _n[_t2],\n _o2 = _s2.getMaterial(),\n _a = _o2.get(\"videoTexture\");\n _a && _r2.A() && (_a(_r2.video), _o2.set(\"opacity\", _r2.getOpacity())), f(i.projViewMatrix, _s2.getBoundingBox()) && e.push(_s2);\n }\n }\n return e.length ? new _gl.reshader.Scene(e) : null;\n } },\n {\n key: \"T\",\n value: function T(t, e) {\n _gl.mat4.fromRotationTranslationScale(t.localTransform, _gl.quat.fromEuler([], 0, 0, 0), e, [1, 1, 1]);\n } },\n {\n key: \"remove\",\n value: function remove() {\n this._ && this._.dispose(), _superPropGet(x, \"remove\", this, 3)([]);\n } },\n {\n key: \"clearCanvas\",\n value: function clearCanvas() {\n this.canvas && (this.regl.clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0 }),\n _superPropGet(x, \"clearCanvas\", this, 3)([]));\n } },\n {\n key: \"k\",\n value: function k(t) {\n var e = this.t[t];\n if (!e) return;\n e.getMeshes().forEach(function (t) {\n t.geometry.dispose(), t.material && t.material.dispose(), t.dispose();\n });\n } }]);\n\n }(t.renderer.CanvasRenderer);\n function w(t, e, i) {\n if (!t) return null;\n var s = t.coordinateToPointAtRes(e, t.getGLRes());\n return [s.x, s.y, i];\n }\n var y = exports.VideoSurface = function (_e2) {\n function y(t, e) {\n var _this3;\n _classCallCheck(this, y);\n _this3 = _callSuper(this, y, [e]), _this3.setCoordinates(t), _this3.I();\n return _this3;\n }\n _inherits(y, _e2);\n return _createClass(y, [{\n key: \"setCoordinates\",\n value: function setCoordinates(t) {\n this.R = t;\n } },\n {\n key: \"getCoordinates\",\n value: function getCoordinates() {\n return this.R;\n } },\n {\n key: \"setVideo\",\n value: function setVideo(t) {\n this.D = \"stop\", this.options.url = t, delete this.options.elementId, this.I();\n } },\n {\n key: \"setElementId\",\n value: function setElementId(t) {\n this.D = \"stop\", this.options.elementId = t, delete this.options.url, this.I();\n } },\n {\n key: \"I\",\n value: function I() {\n var _this4 = this;\n this.D = \"stop\";\n var t = this.options.url,\n e = this.options.elementId;\n var i = document.getElementById(e);\n if (t && (i = document.createElement(\"video\"), i.src = t), !i) throw new Error(\"there is no element or url setting for video mask\");\n i.autoplay = !0, i.loop = !0, i.muted = !0, i.play(), i.addEventListener(\"playing\", function () {\n _this4.D = \"playing\", _this4.fire(\"playing\", {\n state: _this4.D,\n url: t });\n\n }), i.addEventListener(\"pause\", function () {\n _this4.D = \"pause\", _this4.fire(\"pause\", {\n state: _this4.D,\n url: t });\n\n }), i.addEventListener(\"error\", function () {\n throw _this4.D = \"pause\", _this4.fire(\"error\", {\n state: _this4.D,\n url: t }),\n new Error(\"video resource load error\");\n }), this.video = i;\n } },\n {\n key: \"getVideo\",\n value: function getVideo() {\n return this.video;\n } },\n {\n key: \"L\",\n value: function L(t) {\n this.j = t;\n } },\n {\n key: \"C\",\n value: function C() {\n return this.j;\n } },\n {\n key: \"addTo\",\n value: function addTo(t) {\n if (this.F) throw new Error(\"VideoSurface cannot be added to two or more layers at the same time.\");\n return t.addSurfaces(this), this;\n } },\n {\n key: \"show\",\n value: function show() {\n return this.options.visible = !0, this;\n } },\n {\n key: \"hide\",\n value: function hide() {\n return this.options.visible = !1, this;\n } },\n {\n key: \"isVisible\",\n value: function isVisible() {\n return this.options.visible;\n } },\n {\n key: \"play\",\n value: function play() {\n this.video && this.video.play();\n } },\n {\n key: \"pause\",\n value: function pause() {\n this.video && this.video.pause();\n } },\n {\n key: \"setAudio\",\n value: function setAudio(t) {\n this.video.muted = t;\n } },\n {\n key: \"setOpacity\",\n value: function setOpacity(t) {\n this.options.opacity = t;\n } },\n {\n key: \"getOpacity\",\n value: function getOpacity() {\n return this.options.opacity;\n } },\n {\n key: \"remove\",\n value: function remove() {\n delete this.video;\n var t = this.getLayer();\n t && t.removeVideoSurfaces(this), this.endEdit();\n } },\n {\n key: \"getLayer\",\n value: function getLayer() {\n return this.F;\n } },\n {\n key: \"A\",\n value: function A() {\n return \"playing\" === this.D;\n } },\n {\n key: \"startEdit\",\n value: function startEdit() {\n var _this5 = this;\n var t = this.getLayer();\n if (!t) return void console.warn(\"videosurface should be added to a map before edit\");\n var e = t.getMap();\n if (!e) return void console.warn(\"videosurface should be added to a map before edit\");\n if (this.N(), !this.G) {\n var _i = t.getId();\n this.G = new _maptalks.VectorLayer(\"internal_\".concat(_i, \"_edit\"), {\n enableAltitude: !0 }).\n addTo(e);\n }\n var i = this.getCoordinates();\n this.H = new _maptalks.Polygon(i, {\n symbol: {\n lineColor: \"#34495e\",\n lineWidth: 2,\n polygonFill: \"rgb(135,196,240)\",\n polygonOpacity: .1 } }).\n\n addTo(this.G), this.H.startEdit({\n newVertexHandleSymbol: {\n polygonFill: \"rgba(0, 0, 0, 0)\",\n polygonOpacity: 0,\n markerType: \"ellipse\",\n markerWidth: 1,\n markerHeight: 1 } }),\n\n this.H.on(\"shapechange\", function (e) {\n var i = e.target.getCoordinates()[0].slice(0, 4).map(function (t) {\n return [t.x, t.y, 0];\n });\n _this5.setCoordinates(i);\n t.getRenderer().M(_this5);\n }, this);\n } },\n {\n key: \"endEdit\",\n value: function endEdit() {\n this.G && (this.H.endEdit(), this.H.remove(), this.G.remove()), delete this.G, delete this.H;\n } },\n {\n key: \"N\",\n value: function N() {\n this.G && this.G.clear(), delete this.H;\n } }]);\n\n }((0, _maptalks.Eventable)((0, _maptalks.Handlerable)(_maptalks.Class)));\n y.mergeOptions({\n opacity: 1,\n visible: !0 });\n\n var b = exports.VideoLayer = function (_n2) {\n function b(t, e, i) {\n var _this6;\n _classCallCheck(this, b);\n !e || Array.isArray(e) || e instanceof y || (i = e, e = null), _this6 = _callSuper(this, b, [t, i]), _this6.W = {}, _this6.videoId = 0, _this6.W = {}, _this6.videoId = 0, e && _this6.addSurfaces(e);\n return _this6;\n }\n _inherits(b, _n2);\n return _createClass(b, [{\n key: \"addSurfaces\",\n value: function addSurfaces(t) {\n var _this7 = this;\n if (t) if (Array.isArray(t)) t.forEach(function (t) {\n _this7.addMarker(t);\n });else {\n t.F = this, this.W[this.videoId] = t, t.L(this.videoId);\n var _e3 = this.getRenderer();\n _e3 ? _e3.m() && _e3.u(t) : this.on(\"renderercreate\", function (e) {\n e.renderer.m() && e.renderer.u(t);\n }), this.videoId++;\n }\n } },\n {\n key: \"showTopAlways\",\n value: function showTopAlways(t) {\n this.options.showTopAlways = t;\n var e = this.getRenderer();\n e && e.v();\n } },\n {\n key: \"setDoubleSide\",\n value: function setDoubleSide(t) {\n this.options.doubleSide = t;\n var e = this.getRenderer();\n e && e.v();\n } },\n {\n key: \"getVideoSurfaces\",\n value: function getVideoSurfaces() {\n var t = [];\n for (var _e4 in this.W) t.push(this.W[_e4]);\n return t;\n } },\n {\n key: \"removeVideoSurfaces\",\n value: function removeVideoSurfaces(t) {\n var _this8 = this;\n if (Array.isArray(t)) t.forEach(function (t) {\n _this8.removeVideoSurfaces(t);\n });else {\n var _e5 = t.C(),\n _i2 = this.getRenderer();\n _i2 && _i2.k(_e5), delete this.W[_e5];\n }\n } },\n {\n key: \"remove\",\n value: function remove() {\n this.clear(), _superPropGet(b, \"remove\", this, 3)([]);\n } },\n {\n key: \"clear\",\n value: function clear() {\n var t = this.getVideoSurfaces();\n for (var _e6 = 0; _e6 < t.length; _e6++) t[_e6].remove();\n } }]);\n\n }(_maptalks.Layer);\n b.mergeOptions({\n renderer: \"gl\",\n doubleBuffer: !1,\n glOptions: null,\n markerEvents: !0,\n forceRenderOnZooming: !0,\n forceRenderOnMoving: !0,\n forceRenderOnRotating: !0,\n showTopAlways: !0,\n doubleSide: !0 }),\n b.registerJSONType(\"VideoLayer\"), b.registerRenderer(\"gl\", x);\n \"undefined\" != typeof console && console.log(\"@maptalks/video-layer v0.102.5\");return module.exports;});", "requires": [], "buildLevel": 0, "fileName": "/dist/maptalks.video.es.js" }, "pandav:/dist/maptalks.video.js": { "cubeCode": "Cube(\"pandav:/npm/@maptalks/video-layer/0.102.5/dist/maptalks.video\", [\"pandav:/npm/maptalks/1.2.1\", \"pandav:/npm/@maptalks/gl/0.108.1\"], function (module, exports, require, load, process, global) {\n\n function _readOnlyError(r) {throw new TypeError('\"' + r + '\" is read-only');}\n function _classCallCheck(a, n) {if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\");}\n function _defineProperties(e, r) {for (var t = 0; t < r.length; t++) {var o = r[t];o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);}}\n function _createClass(e, r, t) {return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e;}\n function _toPropertyKey(t) {var i = _toPrimitive(t, \"string\");return \"symbol\" == _typeof(i) ? i : i + \"\";}\n function _toPrimitive(t, r) {if (\"object\" != _typeof(t) || !t) return t;var e = t[Symbol.toPrimitive];if (void 0 !== e) {var i = e.call(t, r || \"default\");if (\"object\" != _typeof(i)) return i;throw new TypeError(\"@@toPrimitive must return a primitive value.\");}return (\"string\" === r ? String : Number)(t);}\n function _callSuper(t, o, e) {return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));}\n function _possibleConstructorReturn(t, e) {if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e;if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\");return _assertThisInitialized(t);}\n function _assertThisInitialized(e) {if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e;}\n function _isNativeReflectConstruct() {try {var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));} catch (t) {}return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {return !!t;})();}\n function _superPropGet(t, o, e, r) {var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);return 2 & r && \"function\" == typeof p ? function (t) {return p.apply(e, t);} : p;}\n function _get() {return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {var p = _superPropBase(e, t);if (p) {var n = Object.getOwnPropertyDescriptor(p, t);return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;}}, _get.apply(null, arguments);}\n function _superPropBase(t, o) {for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););return t;}\n function _getPrototypeOf(t) {return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {return t.__proto__ || Object.getPrototypeOf(t);}, _getPrototypeOf(t);}\n function _inherits(t, e) {if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\");t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e);}\n function _setPrototypeOf(t, e) {return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {return t.__proto__ = e, t;}, _setPrototypeOf(t, e);}\n function _typeof(o) {\"@babel/helpers - typeof\";return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {return typeof o;} : function (o) {return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;}, _typeof(o);}\n !function (t, e) {\n \"object\" == (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) && \"undefined\" != typeof module ? e(exports, require('pandav:/npm/maptalks/1.2.1'), require('pandav:/npm/@maptalks/gl/0.108.1')) : \"function\" == typeof define && define.amd ? define([\"exports\", \"maptalks\", \"@maptalks/gl\"], e) : e((t = \"undefined\" != typeof globalThis ? globalThis : t || self).maptalks = t.maptalks || {}, t.maptalks, t.maptalks);\n }(void 0, function (t, e, i) {\n \"use strict\";\n\n function s(t) {\n var e = Object.create(null);\n return t && Object.keys(t).forEach(function (i) {\n if (\"default\" !== i) {\n var s = Object.getOwnPropertyDescriptor(t, i);\n Object.defineProperty(e, i, s.get ? s : {\n enumerable: !0,\n get: function get() {\n return t[i];\n } });\n\n }\n }), e.default = t, Object.freeze(e);\n }\n for (var r = s(e), o = [], n = 0; n < 6; n++) o[n] = [];\n var a = [];\n function h(t, e, i) {\n var s, r, n, h, d, u, p, f, m, g, v, _, x, y, w, b, O;\n r = (s = t)[0], n = s[1], h = s[2], d = s[3], u = s[4], p = s[5], f = s[6], m = s[7], g = s[8], v = s[9], _ = s[10], x = s[11], y = s[12], w = s[13], b = s[14], O = s[15], l(o[0], d - r, m - u, x - g, O - y), l(o[1], d + r, m + u, x + g, O + y), l(o[2], d + n, m + p, x + v, O + w), l(o[3], d - n, m - p, x - v, O - w), l(o[4], d - h, m - f, x - _, O - b), l(o[5], d + h, m + f, x + _, O + b);\n for (var T = 0; T < 6; T++) {\n var S = o[T];\n if (a[0] = S[0] > 0 ? e[1][0] : e[0][0], a[1] = S[1] > 0 ? e[1][1] : e[0][1], a[2] = S[2] > 0 ? e[1][2] : e[0][2], c(S, a) < 0) return !1;\n }\n return !0;\n }\n function l(t, e, i, s, r) {\n var o = 1 / Math.sqrt(e * e + i * i + s * s);\n return t[0] = e * o, t[1] = i * o, t[2] = s * o, t[3] = r * o, t;\n }\n function c(t, e) {\n return t[0] * e[0] + t[1] * e[1] + t[2] * e[2] + t[3];\n }\n var d = {\n vert: \"\\n attribute vec3 aPosition;\\n attribute vec2 aTexCoord;\\n uniform mat4 projViewModelMatrix;\\n uniform mat4 positionMatrix;\\n uniform mat4 modelMatrix;\\n varying vec2 vTexCoords;\\n #include \\n void main()\\n {\\n mat4 localPositionMatrix = getPositionMatrix();\\n vec4 localPosition = getPosition(aPosition);\\n gl_Position = projViewModelMatrix * localPositionMatrix * localPosition;\\n vTexCoords = aTexCoord;\\n }\\n\",\n frag: \"\\n precision mediump float;\\n uniform sampler2D videoTexture;\\n uniform float opacity;\\n\\n varying vec2 vTexCoords;\\n void main() {\\n vec4 color = texture2D(videoTexture, vTexCoords);\\n gl_FragColor = color * opacity;\\n }\\n\",\n uniforms: [{\n name: \"projViewModelMatrix\",\n type: \"function\",\n fn: function fn(t, e) {\n return i.mat4.multiply([], e.projViewMatrix, e.modelMatrix);\n } },\n \"texture\", \"opacity\"],\n positionAttribute: \"POSITION\",\n extraCommandProps: {\n depth: {\n enable: !0,\n func: \"always\" },\n\n cull: {\n enable: !1,\n face: \"back\" },\n\n frontFace: \"cw\",\n blend: {\n enable: !0,\n func: {\n src: \"src alpha\",\n dst: \"one minus src alpha\" },\n\n equation: \"add\" } } },\n\n\n\n u = [1, 0, 3, 3, 2, 1];\n var p = function (_r$renderer$CanvasRen) {\n function p(t) {\n var _this;\n _classCallCheck(this, p);\n _this = _callSuper(this, p, [t]), _this.t = {};\n return _this;\n }\n _inherits(p, _r$renderer$CanvasRen);\n return _createClass(p, [{\n key: \"draw\",\n value: function draw(t, e) {\n this.prepareCanvas(), this.i(e);\n } },\n {\n key: \"drawOnInteracting\",\n value: function drawOnInteracting(t, e, i) {\n this.i(i);\n } },\n {\n key: \"needToRedraw\",\n value: function needToRedraw() {\n return !0;\n } },\n {\n key: \"hitDetect\",\n value: function hitDetect() {\n return !1;\n } },\n {\n key: \"createContext\",\n value: function createContext() {\n if (this.canvas.gl && this.canvas.gl.wrap) this.gl = this.canvas.gl.wrap(), this.regl = this.canvas.gl.regl;else {\n var _t = this.layer.options.glOptions || {\n alpha: !0,\n depth: !0,\n stencil: !0 };\n\n this.glOptions = _t, this.gl = this.gl || this.o(this.canvas, _t), this.regl = i.createREGL({\n gl: this.gl,\n extensions: [\"ANGLE_instanced_arrays\", \"OES_texture_float\", \"OES_texture_half_float\", \"OES_texture_float_linear\", \"OES_texture_half_float_linear\", \"EXT_shader_texture_lod\", \"OES_element_index_uint\", \"OES_standard_derivatives\", \"WEBGL_depth_texture\"],\n optionalExtensions: this.layer.options.glExtensions || [] });\n\n }\n this.h(), this.l();\n var t = this.layer.getVideoSurfaces();\n for (var _e = 0; _e < t.length; _e++) this.u(t[_e]);\n } },\n {\n key: \"o\",\n value: function o(t, e) {\n var i = [\"webgl\", \"experimental-webgl\"];\n var s = null;\n for (var _r = 0; _r < i.length; ++_r) {\n try {\n s = t.getContext(i[_r], e);\n } catch (t) {}\n if (s) break;\n }\n return s;\n } },\n {\n key: \"l\",\n value: function l() {\n var t = this.layer.getMap(),\n e = new i.reshader.Renderer(this.regl);\n this.renderer = e, this.p = {\n \"projMatrix\": t.projMatrix,\n \"projViewMatrix\": t.projViewMatrix,\n \"viewMatrix\": t.viewMatrix,\n \"halton\": [.2107, -.0202],\n \"uHalton\": [.2107, -.0202],\n \"uCameraPosition\": t.cameraPosition,\n \"cameraPosition\": t.cameraPosition,\n \"globalTexSize\": [t.width, t.height] };\n\n } },\n {\n key: \"m\",\n value: function m() {\n return this.regl;\n } },\n {\n key: \"h\",\n value: function h() {\n var _this2 = this;\n this.viewport = {\n x: 0,\n y: 0,\n width: function width() {\n return _this2.canvas ? _this2.canvas.width : 1;\n },\n height: function height() {\n return _this2.canvas ? _this2.canvas.height : 1;\n } },\n this.v();\n } },\n {\n key: \"v\",\n value: function v() {\n this._ && this._.dispose(), this.layer.options.showTopAlways ? (d.extraCommandProps.depth.mask = !1, d.extraCommandProps.depth.range = [0, 0]) : (delete d.extraCommandProps.depth.mask, delete d.extraCommandProps.depth.range), d.extraCommandProps.cull.enable = !this.layer.options.doubleSide, this._ = new i.reshader.MeshShader(d);\n } },\n {\n key: \"u\",\n value: function u(t) {\n var e = this.regl.texture(),\n s = new i.reshader.Material({\n videoTexture: e,\n opacity: 1 }),\n\n r = t.getCoordinates(),\n _this$O = this.O(r),\n o = _this$O.worldCenter,\n n = _this$O.points,\n a = this.T(n),\n h = new i.reshader.Mesh(a, s);\n this.S(h, o);\n var l = new i.reshader.Scene(h),\n c = t.C();\n this.t[c] = l;\n } },\n {\n key: \"M\",\n value: function M(t) {\n var e = t.C(),\n i = this.t[e].getMeshes()[0],\n s = t.getCoordinates();\n i.geometry.dispose();\n var _this$O2 = this.O(s),\n r = _this$O2.worldCenter,\n o = _this$O2.points,\n n = this.T(o);\n i.geometry = n, this.S(i, r);\n } },\n {\n key: \"i\",\n value: function i(t) {\n var e = this.layer.getVideoSurfaces().filter(function (t) {\n return t.isVisible();\n });\n if (!e.length) return;\n var i = this.P(e);\n if (!i) return;\n var s = null;\n t && (s = t.renderTarget && t.renderTarget.fbo), this.renderer.render(this._, this.p, i, s);\n } },\n {\n key: \"T\",\n value: function T(t) {\n return new i.reshader.Geometry({\n POSITION: t,\n TEXCOORD: [0, 0, 1, 0, 1, 1, 0, 1] },\n u, 0, {\n primitive: \"triangles\",\n positionAttribute: \"POSITION\",\n uv0Attribute: \"TEXCOORD\",\n normalAttribute: \"NORMAL\",\n positionSize: 3 });\n\n } },\n {\n key: \"O\",\n value: function O(t) {\n var e = [];\n var i = this.getMap(),\n s = new r.Polygon(t).getCenter(),\n o = f(i, s, 0);\n return this.V = o, i && t.forEach(function (t) {\n var s = new r.Coordinate(t[0], t[1]),\n n = i.altitudeToPoint(t[2] || 0, i.getGLRes()),\n a = f(i, s, n);\n a[0] = a[0] - o[0], a[1] = a[1] - o[1], e = e.concat(a);\n }), {\n worldCenter: o,\n points: e };\n\n } },\n {\n key: \"P\",\n value: function P(t) {\n var e = [],\n s = this.layer.getMap();\n for (var _i = 0; _i < t.length; _i++) {\n var _r2 = t[_i],\n _o = this.t[_r2.C()];\n if (!_o) continue;\n var _n = _o.getMeshes();\n for (var _t2 = 0; _t2 < _n.length; _t2++) {\n var _i2 = _n[_t2],\n _o2 = _i2.getMaterial(),\n _a = _o2.get(\"videoTexture\");\n _a && _r2.A() && (_a(_r2.video), _o2.set(\"opacity\", _r2.getOpacity())), h(s.projViewMatrix, _i2.getBoundingBox()) && e.push(_i2);\n }\n }\n return e.length ? new i.reshader.Scene(e) : null;\n } },\n {\n key: \"S\",\n value: function S(t, e) {\n i.mat4.fromRotationTranslationScale(t.localTransform, i.quat.fromEuler([], 0, 0, 0), e, [1, 1, 1]);\n } },\n {\n key: \"remove\",\n value: function remove() {\n this._ && this._.dispose(), _superPropGet(p, \"remove\", this, 3)([]);\n } },\n {\n key: \"clearCanvas\",\n value: function clearCanvas() {\n this.canvas && (this.regl.clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0 }),\n _superPropGet(p, \"clearCanvas\", this, 3)([]));\n } },\n {\n key: \"k\",\n value: function k(t) {\n var e = this.t[t];\n if (!e) return;\n e.getMeshes().forEach(function (t) {\n t.geometry.dispose(), t.material && t.material.dispose(), t.dispose();\n });\n } }]);\n\n }(r.renderer.CanvasRenderer);\n function f(t, e, i) {\n if (!t) return null;\n var s = t.coordinateToPointAtRes(e, t.getGLRes());\n return [s.x, s.y, i];\n }\n var m = function (_e$Eventable) {\n function m(t, e) {\n var _this3;\n _classCallCheck(this, m);\n _this3 = _callSuper(this, m, [e]), _this3.setCoordinates(t), _this3.j();\n return _this3;\n }\n _inherits(m, _e$Eventable);\n return _createClass(m, [{\n key: \"setCoordinates\",\n value: function setCoordinates(t) {\n this.I = t;\n } },\n {\n key: \"getCoordinates\",\n value: function getCoordinates() {\n return this.I;\n } },\n {\n key: \"setVideo\",\n value: function setVideo(t) {\n this.R = \"stop\", this.options.url = t, delete this.options.elementId, this.j();\n } },\n {\n key: \"setElementId\",\n value: function setElementId(t) {\n this.R = \"stop\", this.options.elementId = t, delete this.options.url, this.j();\n } },\n {\n key: \"j\",\n value: function j() {\n var _this4 = this;\n this.R = \"stop\";\n var t = this.options.url,\n e = this.options.elementId;\n var i = document.getElementById(e);\n if (t && (i = document.createElement(\"video\"), i.src = t), !i) throw new Error(\"there is no element or url setting for video mask\");\n i.autoplay = !0, i.loop = !0, i.muted = !0, i.play(), i.addEventListener(\"playing\", function () {\n _this4.R = \"playing\", _this4.fire(\"playing\", {\n state: _this4.R,\n url: t });\n\n }), i.addEventListener(\"pause\", function () {\n _this4.R = \"pause\", _this4.fire(\"pause\", {\n state: _this4.R,\n url: t });\n\n }), i.addEventListener(\"error\", function () {\n throw _this4.R = \"pause\", _this4.fire(\"error\", {\n state: _this4.R,\n url: t }),\n new Error(\"video resource load error\");\n }), this.video = i;\n } },\n {\n key: \"getVideo\",\n value: function getVideo() {\n return this.video;\n } },\n {\n key: \"D\",\n value: function D(t) {\n this.L = t;\n } },\n {\n key: \"C\",\n value: function C() {\n return this.L;\n } },\n {\n key: \"addTo\",\n value: function addTo(t) {\n if (this.F) throw new Error(\"VideoSurface cannot be added to two or more layers at the same time.\");\n return t.addSurfaces(this), this;\n } },\n {\n key: \"show\",\n value: function show() {\n return this.options.visible = !0, this;\n } },\n {\n key: \"hide\",\n value: function hide() {\n return this.options.visible = !1, this;\n } },\n {\n key: \"isVisible\",\n value: function isVisible() {\n return this.options.visible;\n } },\n {\n key: \"play\",\n value: function play() {\n this.video && this.video.play();\n } },\n {\n key: \"pause\",\n value: function pause() {\n this.video && this.video.pause();\n } },\n {\n key: \"setAudio\",\n value: function setAudio(t) {\n this.video.muted = t;\n } },\n {\n key: \"setOpacity\",\n value: function setOpacity(t) {\n this.options.opacity = t;\n } },\n {\n key: \"getOpacity\",\n value: function getOpacity() {\n return this.options.opacity;\n } },\n {\n key: \"remove\",\n value: function remove() {\n delete this.video;\n var t = this.getLayer();\n t && t.removeVideoSurfaces(this), this.endEdit();\n } },\n {\n key: \"getLayer\",\n value: function getLayer() {\n return this.F;\n } },\n {\n key: \"A\",\n value: function A() {\n return \"playing\" === this.R;\n } },\n {\n key: \"startEdit\",\n value: function startEdit() {\n var _this5 = this;\n var t = this.getLayer();\n if (!t) return void console.warn(\"videosurface should be added to a map before edit\");\n var i = t.getMap();\n if (!i) return void console.warn(\"videosurface should be added to a map before edit\");\n if (this.N(), !this.G) {\n var _s = t.getId();\n this.G = new e.VectorLayer(\"internal_\".concat(_s, \"_edit\"), {\n enableAltitude: !0 }).\n addTo(i);\n }\n var s = this.getCoordinates();\n this.H = new e.Polygon(s, {\n symbol: {\n lineColor: \"#34495e\",\n lineWidth: 2,\n polygonFill: \"rgb(135,196,240)\",\n polygonOpacity: .1 } }).\n\n addTo(this.G), this.H.startEdit({\n newVertexHandleSymbol: {\n polygonFill: \"rgba(0, 0, 0, 0)\",\n polygonOpacity: 0,\n markerType: \"ellipse\",\n markerWidth: 1,\n markerHeight: 1 } }),\n\n this.H.on(\"shapechange\", function (e) {\n var i = e.target.getCoordinates()[0].slice(0, 4).map(function (t) {\n return [t.x, t.y, 0];\n });\n _this5.setCoordinates(i);\n t.getRenderer().M(_this5);\n }, this);\n } },\n {\n key: \"endEdit\",\n value: function endEdit() {\n this.G && (this.H.endEdit(), this.H.remove(), this.G.remove()), delete this.G, delete this.H;\n } },\n {\n key: \"N\",\n value: function N() {\n this.G && this.G.clear(), delete this.H;\n } }]);\n\n }(e.Eventable(e.Handlerable(e.Class)));\n m.mergeOptions({\n opacity: 1,\n visible: !0 });\n\n var g = function (_e$Layer) {\n function g(t, e, i) {\n var _this6;\n _classCallCheck(this, g);\n !e || Array.isArray(e) || e instanceof m || (i = e, e = null), _this6 = _callSuper(this, g, [t, i]), _this6.W = {}, _this6.videoId = 0, _this6.W = {}, _this6.videoId = 0, e && _this6.addSurfaces(e);\n return _this6;\n }\n _inherits(g, _e$Layer);\n return _createClass(g, [{\n key: \"addSurfaces\",\n value: function addSurfaces(t) {\n var _this7 = this;\n if (t) if (Array.isArray(t)) t.forEach(function (t) {\n _this7.addMarker(t);\n });else {\n t.F = this, this.W[this.videoId] = t, t.D(this.videoId);\n var _e2 = this.getRenderer();\n _e2 ? _e2.m() && _e2.u(t) : this.on(\"renderercreate\", function (e) {\n e.renderer.m() && e.renderer.u(t);\n }), this.videoId++;\n }\n } },\n {\n key: \"showTopAlways\",\n value: function showTopAlways(t) {\n this.options.showTopAlways = t;\n var e = this.getRenderer();\n e && e.v();\n } },\n {\n key: \"setDoubleSide\",\n value: function setDoubleSide(t) {\n this.options.doubleSide = t;\n var e = this.getRenderer();\n e && e.v();\n } },\n {\n key: \"getVideoSurfaces\",\n value: function getVideoSurfaces() {\n var t = [];\n for (var _e3 in this.W) t.push(this.W[_e3]);\n return t;\n } },\n {\n key: \"removeVideoSurfaces\",\n value: function removeVideoSurfaces(t) {\n var _this8 = this;\n if (Array.isArray(t)) t.forEach(function (t) {\n _this8.removeVideoSurfaces(t);\n });else {\n var _e4 = t.C(),\n _i3 = this.getRenderer();\n _i3 && _i3.k(_e4), delete this.W[_e4];\n }\n } },\n {\n key: \"remove\",\n value: function remove() {\n this.clear(), _superPropGet(g, \"remove\", this, 3)([]);\n } },\n {\n key: \"clear\",\n value: function clear() {\n var t = this.getVideoSurfaces();\n for (var _e5 = 0; _e5 < t.length; _e5++) t[_e5].remove();\n } }]);\n\n }(e.Layer);\n g.mergeOptions({\n renderer: \"gl\",\n doubleBuffer: !1,\n glOptions: null,\n markerEvents: !0,\n forceRenderOnZooming: !0,\n forceRenderOnMoving: !0,\n forceRenderOnRotating: !0,\n showTopAlways: !0,\n doubleSide: !0 }),\n g.registerJSONType(\"VideoLayer\"), g.registerRenderer(\"gl\", p), t.VideoLayer = g, t.VideoSurface = m, \"undefined\" != typeof console && console.log(\"@maptalks/video-layer v0.102.5\");\n });return module.exports;});", "requires": [], "buildLevel": 0, "fileName": "/dist/maptalks.video.js" } }