var VR = function(e, t, i, r, n) {this.scene = e, this.renderer = t, this.container = i, AVR.initDomStyle(i), AVR.setCameraPara(this, r, n), this.vrbox = {radius: 2,widthSegments: 180,heightSegments: 180,width: 2,height: 2,depth: 2}, this.video = null, this.audio = null, this.toolBar = null, this.clock = new THREE.Clock, this.VRObject =new THREE.Object3D, this.defaultAutoHideLeftTime = 3, this.defaultVoiceHideLeftTime = 2, this.defaultVolume = .3, this.sliceSegment = 0, this._controlTarget = new THREE.Vector3(0, 0, 1e-4), this._cubeCameraTimes = .96, this.resType = {video: "video",box: "box",slice: "slice",sliceVideo: "sliceVideo"}, this.asteroidConfig = {enable: !1,asteroidFPS: 10,asteroidFov: 135,asteroidForwardTime: 2600,asteroidWaitTime: 2e3,asteroidDepressionRate: .5,asteroidTop: 1,cubeResolution: 2048,rotationAngleOfZ: 0}, this.VRhint = "请取消屏幕翻转锁定后装入VR盒子中", this.camera = new THREE.PerspectiveCamera(this.cameraPara.fov, this.cameraPara.aspect, this.cameraPara.near, this.cameraPara.far), this.camera.lookAt(this._controlTarget),this.cameraEvt = {controlGroup: function() {},updatePosition: function() {},hover: function() {},leave: function() {}}, this._takeScreenShot = !1, this.camera.position.set(this.cameraPosition.x, this.cameraPosition.y, this.cameraPosition.z), this.loadProgressManager = new THREE.LoadingManager(function(e) {console.log("loaded")}, function(e, t, i) {console.log("item=", e, "loaded", t, "total=", i)}, function(e, t) {console.log(e, t)}), this.scene.add(this.camera), this.scene.add(this.VRObject), this.effect = AVR.stereoEffect(this.renderer), AVR.bindOrientationEnevt(this, this._controlTarget)};VR.prototype.init = function(e) {function t() {v.controls && v.controls.reset()}function i(e) {b.isMouseDown = !0;var t = e.clientX || e.changedTouches[0].clientX,i = e.clientY || e.changedTouches[0].clientY;f.set(t, i), p.set(t, i), v.autoHideLeftTime = v.defaultAutoHideLeftTime, b.isActive = !0}function r(e) {b.isMouseDown = !1}function n(e) {if (e.preventDefault(), v.autoHideLeftTime = v.defaultAutoHideLeftTime, v.toolBar.isActive = !0, b.isMouseDown) {var t = e.clientX || e.changedTouches[0].clientX,i = e.clientY || e.changedTouches[0].clientY,r = p.y - i;r >= 5 && a(6), r <= -5 && a(-10), p.set(t, i)}}function o(e) {if (void 0 === v.controls.defaultDampingFactor && (v.controls.defaultDampingFactor = v.controls.dampingFactor), void 0 === v.controls.object.defaultFov && (v.controls.object.defaultFov = v.controls.object.fov), e) {var t = 0,i = [];[].forEach.call(e, function(e) {var r = T[e.identifier];if (r && (r.y = e.pageY, r.x = e.pageX, i.push(e.identifier)), t++, t >= 2) {var n = T[i[0]],o = T[i[1]],a = Math.sqrt(Math.pow(n.x - o.x, 2) + Math.pow(n.y - o.y, 2)),s = (a - y) / 4;return v.controls.object.fov - s < 140 && v.controls.object.fov - s > 10 && y && (v.controls.enable = !1, v.controls.object.fov -= s, v.controls.dampingFactor = v.controls.defaultDampingFactor * v.controls.object.defaultFov / v.controls.object.fov), y = a, void(t = 0)}})}}function a(e) {var t = setInterval(function() {var i = b.toolbar.clientHeight + e;i >= b.defaultHeight && i <= b.defaultMaxHeight ? (b.toolbar.style.height = i + "px", b.isActive = !0) : (clearInterval(t), e > 0 ? (b.isActive = !0, b.moreBtn.style.transform = "rotate(-180deg)", b.moreBtn.style.webkitTransform = "rotate(-180deg)",b.toolbar.style.height = b.defaultMaxHeight + "px", b.about.style.display = "block") : (b.isActive = !1, b.moreBtn.style.transform = "rotate(0deg)", b.moreBtn.style.webkitTransform = "rotate(0deg)", b.toolbar.style.height = b.defaultHeight + "px",b.about.style.display = "none")), v.autoHideLeftTime = v.defaultAutoHideLeftTime}, 1)}function s(e) {v.autoHideLeftTime = v.defaultAutoHideLeftTime, b.isActive = !0;var t = e.clientX || e.changedTouches[0].clientX,i = e.clientY || e.changedTouches[0].clientY;b.isMouseDown && (b.moreList.scrollLeft += 2.5 * (p.x - t)), p.set(t, i)}function c(e) {v.camera.fov += .05 * e, v.camera.updateProjectionMatrix()}function l(e) {if (e.style.borderColor = "green", e.style.color = "green", v.cameraEvt.controlGroup.length) {var t = v.cameraEvt.controlGroup.getObjectByName("__focus");t.visible = !0}}function d(e) {if (e.style.borderColor = "white", e.style.color = "white", v.cameraEvt.controlGroup.length) {var t = v.cameraEvt.controlGroup.getObjectByName("__focus");t.visible = !1}}function u() {var e = v.video || v.audio;if (e) {b.voice_bar.style.display = "block";var t, i = b.voice_bar,r = i.firstChild,n = r.firstChild,o = (n.firstChild, !1),a = 0,s = 0;e.volume = v.defaultVolume;var c = b.voice_bar.clientHeight,l = (v.container.clientHeight - c) / 2,d = c + l;n.style.height = e.volume * c + "px", i.addEventListener("mousedown", function(e) {i.style.opacity = 1}, !1), r.addEventListener("click", function(t) {var i = (t.clientY || t.changedTouches[0].clientY) - v.container.offsetTop;v.voiceHideLeftTime = v.defaultVoiceHideLeftTime;var r = d - i;r / c <= 1 && (n.style.height = r + "px", e.volume = r / c)}, !1), i.addEventListener("mouseout", function(e) {o = !1}, !1), i.addEventListener("mousedown", function(e) {o = !0}, !1), i.addEventListener("mouseup", function(e) {o = !1}, !1), i.addEventListener("mousemove", function(t) {var i = (t.clientY || t.changedTouches[0].clientY) - v.container.offsetTop;if (v.voiceHideLeftTime = v.defaultVoiceHideLeftTime, o) {var r = d - i;n.style.height = r + "px", r / c <= 1 && (e.volume = r / c)}}, !1), i.addEventListener("touchstart", function(e) {e.preventDefault(), v.voiceHideLeftTime = v.defaultVoiceHideLeftTime, t = n.clientHeight,a = e.touches[0].pageY, i.style.opacity = 1}, !1), i.addEventListener("touchmove", function(i) {i.preventDefault(), v.voiceHideLeftTime = v.defaultVoiceHideLeftTime, s = i.touches[0].pageY;var r = t + (a - s);r / c <= 1 && (n.style.height = r + "px", e.volume = r / c)}, !1), i.addEventListener("touchend", function(e) {t = 0}, !1), setInterval(function() {v.voiceHideLeftTime <= 0 ? i.style.opacity = 0 : v.toolBar.isActive ? null : v.voiceHideLeftTime--}, 1e3)}}function m() {var t = v.container.offsetWidth,i = v.container.offsetHeight;if (v.camera.aspect = t / i, AVR.isMobileDevice() && AVR.isCrossScreen() ? (v.cameraEvt.updatePosition(), v.effect.setSize(t, i), v.effect.render(v.scene, v.camera)) : (v.renderer.setSize(t, i), v.renderer.setClearColor(new THREE.Color(16777215)), v.renderer.render(v.scene, v.camera)), v._takeScreenShot) {v._takeScreenShot = !1;var r = v.renderer.domElement.toDataURL("image/jpeg");v._takeScreenShotCallback(r)}v.camera.updateProjectionMatrix(), v.controls && v.controls.update(), e()}function h() {m(), requestAnimationFrame(h)}var v = this,f = new THREE.Vector2,p = new THREE.Vector2;v.toolBar = AVR.toolBar(v.container);var g, E, b = v.toolBar,T = {},y = 0;b.defaultHeight = b.toolbar.clientHeight, b.defaultMaxHeight = 5 * b.defaultHeight, b.isMouseDown = !1, v.container.addEventListener("click", function() {v.autoHideLeftTime = v.defaultAutoHideLeftTime, b.toolbar.style.display = "block"}), b.gyroBtn.addEventListener("click", function() {v.gyroBtnClick()}, !1), b.vrBtn.addEventListener("click", function() {v.vrBtnClick()}, !1), b.moreBtn.addEventListener("click", function() {v.moreBtnClick()}, !1), v.container.addEventListener("touchstart", function(e) {v.touchStart(e)}, !1), v.container.addEventListener("touchmove", function(e) {v.touchMove(e)}, !1), v.container.addEventListener("touchend", function(e) {v.touchEnd(e)}, !1), b.gyroResetBtn.addEventListener("click", t, !1), b.toolbar.addEventListener("mousedown", i, !1), b.toolbar.addEventListener("touchstart", i, !1), b.toolbar.addEventListener("mousemove", n, !1), b.toolbar.addEventListener("touchmove", n, !1), b.toolbar.addEventListener("mouseup", r, !1), b.toolbar.addEventListener("touchend", r, !1), b.toolbar.addEventListener("mouseout", function(e) {v.autoHideLeftTime = v.defaultAutoHideLeftTime, b.isActive = !1}, !1), v.renderer.domElement.addEventListener("wheel", function(e) {var t = e.deltaY > 0 ? 15 : -15;v.camera.fov + .05 * t >= 10 && v.camera.fov + .05 * t <= 120 && c(t)}, !1), b.moreList.addEventListener("mousemove", s, !1), b.moreList.addEventListener("touchmove", s, !1), v.moreBtnClick = function(e) {a(b.toolbar.clientHeight > b.defaultHeight ? -10 : 6)}, v.vrBtnClick = function(e) {var t = v.toolBar.vrBtn;AVR.isMobileDevice() ? AVR.OS.isWeixin() && !AVR.OS.isiOS() ? "landscape" == v.video.getAttribute("x5-video-orientation") ? (v.video.setAttribute("x5-video-orientation", "portraint"), d(t)) : (v.video.setAttribute("x5-video-orientation", "landscape"), l(t)) : AVR.isCrossScreen() ? (l(t),AVR.fullscreen(v.container)) : (d(t), AVR.msgBox(v.VRhint, 5, v.container)) : (t.getAttribute("fullscreen") ? (d(t), t.removeAttribute("fullscreen")) : (l(t), t.setAttribute("fullscreen", "true")), AVR.fullscreen(v.container))}, v.gyroBtnClick = function(e) {var t = v.toolBar.gyroBtn;"active" == t.getAttribute("active") ? (v.controls.gyroFreeze(), d(t), d(b.circle1), d(b.circle2), t.removeAttribute("active")) : (v.controls.gyroUnfreeze(), t.setAttribute("active", "active"), l(t), l(b.circle1), l(b.circle2))}, v.touchStart = function(e) {e.targetTouches && ([].forEach.call(e.targetTouches, function(e) {T[e.identifier] || (T[e.identifier] = new THREE.Vector2(0, 0))}), E = setInterval(function() {o(g)}, 1))}, v.touchEnd = function(e) {e.targetTouches && ([].forEach.call(e.changedTouches, function(e) {var t = T[e.identifier];t && delete T[e.identifier]}), 0 === e.targetTouches.length && (y = 0, v.controls.enable = !0, clearInterval(E)))}, v.touchMove = function(e) {g = e.touches}, v.windowResize = function() {AVR.isFullscreen() ? AVR.isMobileDevice() ? AVR.isCrossScreen() ? l(v.toolBar.vrBtn) : d(v.toolBar.vrBtn) : l(v.toolBar.vrBtn) : AVR.OS.isWeixin() && !AVR.OS.isiOS() ? ("landscape" == v.video.getAttribute("x5-video-orientation") ? l(v.toolBar.vrBtn) : d(v.toolBar.vrBtn), AVR.isCrossScreen() ? l(v.toolBar.vrBtn) : d(v.toolBar.vrBtn)) : (AVR.isCrossScreen() ? l(v.toolBar.vrBtn) : d(v.toolBar.vrBtn), d(v.toolBar.vrBtn))}, window.addEventListener("resize", function() {u()}, !1), v._play = function() {b.btn.style.border = "none", b.btn.style.fontWeight = 800, b.btn.innerHTML = "<b>||</b>"}, v._pause = function() {b.btn.innerText = "", b.btn.style.borderTop = "0.6rem solid transparent", b.btn.style.borderLeft ="1rem solid white", b.btn.style.borderBottom = "0.6rem solid transparent"}, v.bindVolumeBar = u, h(), setInterval(function() {b.isActive || (v.autoHideLeftTime < 0 ? (b.toolbar.style.display = "none", v.autoHideLeftTime = v.defaultAutoHideLeftTime, b.isActive = !1) : v.autoHideLeftTime--), v.windowResize()}, 1e3)}, VR.prototype.takeScreenShot = function(e) {this._takeScreenShot = !0, this._takeScreenShotCallback = e}, VR.prototype.playPanorama = function(e, t) {function i(e) {x.paused ? (d._play(), x.play()) : (d._pause(), x.pause())}function r(e) {var t = (e.clientX || e.changedTouches[0].clientX) - d.container.offsetLeft;x.currentTime = x.duration * (t / this.clientWidth)}function n(e) {d.video.buffTimer || (d.video.buffTimer = setInterval(function(e) {var t = 0;0 != x.buffered.length && (t += x.buffered.end(0)), t >= x.duration && clearInterval(d.video.buffTimer), u.loadedProgress.style.width = t / x.duration * 100 + "%"}, 500))}function o(e, t) {t = t || !1, material = new THREE.MeshBasicMaterial({overdraw: !0,map: e});var i = d.VRObject.getObjectByName("__mxrealityDefault");if (i) i.material = material;else {var r = -Math.PI / 2,n = new THREE.SphereBufferGeometry(d.vrbox.radius, d.vrbox.widthSegments, d.vrbox.heightSegments,r);n.scale(-1, 1, 1), mesh = new THREE.Mesh(n, material), mesh.visible = !1, mesh.name ="__mxrealityDefault", t && (mesh.matrixAutoUpdate = !1, mesh.updateMatrix(), d.toolBar.timeInfo.style.display = "none"), d.VRObject.add(mesh)}d.asteroidConfig.enable && (d.asteroidForward = function(e) {a(e)})}function a(e) {d.controls && (d.controls.reset(), d.controls.enable = !1);var t = d.asteroidConfig,i = d.camera.fov,r = d._containerRadius * (.9 * d._cubeCameraTimes);d.camera.position.y = r * t.asteroidTop, d.camera.rotation.x = THREE.Math.degToRad(-90), d.camera.fov = t.asteroidFov;var n = t.asteroidForwardTime * t.asteroidFPS / 300,o = r / n,a = d.camera.fov - i,s = a / n,c = (Math.PI / 2 / n, !1),l = !1,u = new THREE.Vector3(d._controlTarget.x, d._controlTarget.y, d._controlTarget.z);setTimeout(function() {var r = setInterval(function() {t.asteroidTop * d.camera.position.y - o >= 0 ? (d.camera.position.y -= o * t.asteroidTop, d.camera.lookAt(u), u.z *= 1.25) : c = !0, d.camera.fov - s >=i ? d.camera.fov -= s : l = !0, c && l && (clearInterval(r), d.controls.enable = !0, d.camera.position.y = 0, d.camera.fov = i, void 0 !== e && e())}, t.asteroidFPS)}, t.asteroidWaitTime)}var s = ["__mxrealitySkybox", "__mxrealitySlice", "__mxrealityDefault"];for (var c in s) {var l = this.VRObject.getObjectByName(s[c]);l && (l.visible = !1), this.cubeCameraSphere && (this.cubeCameraSphere.visible = !1)}var d = this,u = d.toolBar;if (d._containerRadius = d.resType.box == t || d.resType.slice == t ? d.vrbox.width / 2 : d.vrbox.radius, d.autoHideLeftTime = d.defaultAutoHideLeftTime, d.voiceHideLeftTime = d.defaultVoiceHideLeftTime, d.resType.box == t) {d.toolBar.timeInfo.style.display = "none";var m = [],h = [],v = new Image;v.crossOrigin = "Anonymous", v.src = e, v.onload = function() {for (var e, t, i = v.height, r = 0; r < 6; r++) m[r] = new THREE.Texture, e = document.createElement("canvas"), t = e.getContext("2d"), e.height = i, e.width = i, t.drawImage(v, i *r, 0, i, i, 0, 0, i, i), m[r].image = e, m[r].needsUpdate = !0, h.push(new THREE.MeshBasicMaterial({map: m[r]}));var n = d.VRObject.getObjectByName("__mxrealitySkybox");if (n) n.material = h;else {var n = new THREE.Mesh(new THREE.CubeGeometry(d.vrbox.width, d.vrbox.height, d.vrbox.depth),new THREE.MultiMaterial(h));n.applyMatrix((new THREE.Matrix4).makeScale(1, 1, -1)), n.visible = !1, n.name ="__mxrealitySkybox", n.matrixAutoUpdate = !1, n.updateMatrix(), d.VRObject.add(n), u.btn.addEventListener("click", function(e) {d.controls.autoRotate ? d._pause() : d._play(), d.controls.autoRotate = !d.controls.autoRotate})}d.loadProgressManager.onLoad()}} else if (d.resType.slice == t) {d.toolBar.timeInfo.style.display = "none";var f = new THREE.TextureLoader(d.loadProgressManager);f.mapping = THREE.UVMapping;for (var h = [], c = 0; c < e.length; c++) {var p = f.load(e[c]);h.push(new THREE.MeshBasicMaterial({map: p}))}for (var g = new THREE.CubeGeometry(d.vrbox.width, d.vrbox.height, d.vrbox.depth, d.sliceSegment, d.sliceSegment, d.sliceSegment), E = 0, b = [new THREE.Vector2(0, 0), new THREE.Vector2(1, 0),new THREE.Vector2(1, 1), new THREE.Vector2(0, 1)], c = 0, T = g.faces.length; c < T; c += 2) g.faces[c].materialIndex = E, g.faces[c + 1].materialIndex = E, g.faceVertexUvs[0][c] = [b[3], b[0], b[2]], g.faceVertexUvs[0][c + 1] = [b[0], b[1],b[2]], E++;var l = d.VRObject.getObjectByName("__mxrealitySlice");if (l) l.material = h, l.geometry = g, l.updateMatrix();else {var y = new THREE.Mesh(g, h);y.applyMatrix((new THREE.Matrix4).makeScale(1, 1, -1)), y.name = "__mxrealitySlice", y.visible = !1, y.matrixAutoUpdate = !1, y.updateMatrix(), d.VRObject.add(y), d.cubeCamera = new THREE.CubeCamera(d._containerRadius, d.cameraPara.far, d.asteroidConfig.cubeResolution);var w = d.cubeCamera.renderTarget.texture;w.minFilter = THREE.LinearMipMapLinearFilter, d.VRObject.add(d.cubeCamera), material = new THREE.MeshBasicMaterial({envMap: d.cubeCamera.renderTarget.texture,side: THREE.BackSide}), d.cubeCameraSphere = new THREE.Mesh(new THREE.SphereGeometry(d._containerRadius * d._cubeCameraTimes, 180, 180), material), d.cubeCameraSphere.position.set(0, 0, 0), d.cubeCameraSphere.name = "__mxrealitySlice", d.cubeCameraSphere.visible = !1, d.cubeCameraSphere.matrixAutoUpdate = !1, d.cubeCameraSphere.updateMatrix(), d.VRObject.add(d.cubeCameraSphere), u.btn.addEventListener("click", function(e) {d.controls.autoRotate ? d._pause() : d._play(), d.controls.autoRotate = !d.controls.autoRotate})}d.asteroidConfig.enable ? (d.cubeCameraSphere.visible = !0, d.asteroidForward = function(e) {d.cubeCamera.update(d.renderer, d.scene), a(e)}) : d.cubeCameraSphere.visible = !1} else if (d.resType.video == t || d.resType.sliceVideo == t) {if (d.video)for (var x = d.video, R = 0; R < x.childNodes.length; R++) x.removeChild(x.childNodes[R]);else var x = d.video = AVR.createTag("video", {"webkit-playsinline": !0,playsinline: !0,preload: "auto","x-webkit-airplay": "allow","x5-playsinline": !0,"x5-video-player-type": "h5","x5-video-player-fullscreen": !0,"x5-video-orientation": "portrait",style: "object-fit: fill",loop: "loop"}, {allowsInlineMediaPlayback: !0,crossOrigin: "Anonymous"});if (d.resType.sliceVideo == t)if (AVR.OS.isAndroid() && AVR.OS.isWeixin()) {var A = AVR.createTag("source", {src: e,type: "application/x-mpegURL"}, null);x.appendChild(A)} else if (Hls.isSupported()) d.hls = new Hls, d.hls.attachMedia(x), d.hls.loadSource(e), d.hls.on(Hls.Events.MANIFEST_PARSED,function() {x.play()});else {var A = AVR.createTag("source", {src: e,type: "application/x-mpegURL"}, null);x.appendChild(A)} else x.canPlayType("application/vnd.apple.mpegurl") ? x.src = e : x.src = e;x.removeEventListener("canplaythrough", n), u.progressBar.removeEventListener("click", r), u.btn.removeEventListener("click", i), x.addEventListener("canplaythrough", n, !1), u.progressBar.addEventListener("click", r, !1), u.btn.addEventListener("click", i, !1), x.load(), x.play(), d.video.buffTimer = null;var p = new THREE.VideoTexture(x);p.generateMipmaps = !1, p.minFilter = THREE.LinearFilter, p.magFilter = THREE.LinearFilter, p.format = THREE.RGBAFormat, o(p), d.video.progressTimer = setInterval(function(e) {u.playProgress.style.width = x.currentTime / x.duration * 100 + "%", u.curTime.innerText = AVR.formatSeconds(x.currentTime), u.totalTime.innerText = AVR.formatSeconds(x.duration), d.autoHideLeftTime < 0 && !x.paused ? u.toolbar.style.display = "none" : d.autoHideLeftTime--}, 1e3), d.loadProgressManager.onLoad()} else new THREE.TextureLoader(d.loadProgressManager).load(e, function(e) {o(e, !0)})}, VR.prototype.sphere2BoxPano = function(e, t, i, r) {function n(e, t, i, r) {var n = e.createTexture();if (!n) return console.log("Failed to create the texture object!"), !1;var a = e.getUniformLocation(t, "u_Sampler");return o(e, i, n, a, r), !0}function o(e, t, i, n, o) {m.asteroidConfig.enable && e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, -1), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, i), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texImage2D(e.TEXTURE_2D, 0, e.RGB, e.RGB, e.UNSIGNED_BYTE, o),e.uniform1i(n, 0), e.clear(e.COLOR_BUFFER_BIT), e.drawArrays(e.TRIANGLE_STRIP, 0, t), f < 5 ? f++ : r(u())}function a(e, t) {var i = new Float32Array([-1, 1, 0, 1, -1, -1, 0, 0, 1, 1, 1, 1, 1, -1, 1, 0]),r = 4,n = e.createBuffer();if (!n) return console.log("Failed to create the buffer object!"), -1;e.bindBuffer(e.ARRAY_BUFFER, n), e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW);var o = i.BYTES_PER_ELEMENT,a = e.getAttribLocation(t, "a_Position");e.vertexAttribPointer(a, 2, e.FLOAT, !1, 4 * o, 0), e.enableVertexAttribArray(a);var s = e.getAttribLocation(t, "a_TexCoord");return e.vertexAttribPointer(s, 2, e.FLOAT, !1, 4 * o, 2 * o), e.enableVertexAttribArray(s), r}function s(e, t) {var i, r = c(e, t),n = c(e);return i = e.createProgram(), e.attachShader(i, n), e.attachShader(i, r), e.linkProgram(i), e.getProgramParameter(i, e.LINK_STATUS) ? (e.useProgram(i), e.enableVertexAttribArray(i.vertexPositionAttribute), i.vertexColorAttribute = e.getAttribLocation(i, "aVertexColor"), i.pMatrixUniform = e.getUniformLocation(i, "uPMatrix"), i.mvMatrixUniform = e.getUniformLocation(i,"uMVMatrix"), i) : null}function c(e, t) {var i, r;if (t) {if (i = l(t), !i) return null;r = e.createShader(e.FRAGMENT_SHADER)} else i = d(), r = e.createShader(e.VERTEX_SHADER);return e.shaderSource(r, i), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.log(e.getShaderInfoLog(r)), null)}function l(e) {var t = "",i ="\n        precision mediump float;\n        varying vec2 v_TexCoord;\n        uniform sampler2D u_Sampler;\n        uniform float PI;\n",r ="\n        if(abs(theta)>PI){\n            if(theta>PI){\n                theta -= 2.0*PI;\n            }else{\n                theta += 2.0*PI;\n            }\n        }\n        if(abs(phi)>PI/2.0){\n            if(phi>PI/2.0){\n                phi -= PI;\n            }else{                phi += PI;\n            }\n        }\n        float x = theta/PI*0.5 + 0.5;\n        float y = phi/PI*2.0*0.5 + 0.5;\n        gl_FragColor = texture2D(u_Sampler, vec2(x,y));\n";return "z" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(0.5-v_TexCoord.x,v_TexCoord.y-0.5);\n\t\t\t\tfloat theta = atan(orig.x,r);\n\t\t\t\tfloat phi = atan(orig.y*cos(theta),r);" +r + "\n\t\t\t}\n" : "nz" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(0.5-v_TexCoord.x,v_TexCoord.y-0.5);\n\t\t\t\tfloat theta = atan(orig.x,r);\n\t\t\t\tfloat phi = atan(orig.y*cos(theta),r);\n        \t\ttheta = theta+PI;\n" +r + "\n\t\t\t}\n" : "x" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(v_TexCoord.x-0.5,v_TexCoord.y-0.5);\n\t\t\t\tfloat theta = atan(r,orig.x);\n\t\t\t\tfloat phi = atan(orig.y*sin(theta),r);" +r + "\n\t\t\t}\n" : "nx" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(v_TexCoord.x-0.5,v_TexCoord.y-0.5);\n\t\t\t\tfloat theta = atan(r,orig.x);\n\t\t\t\tfloat phi = atan(orig.y*sin(theta),r);\n        \t\ttheta = theta+PI;" +r + "\n\t\t\t}\n" : "y" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(0.5-v_TexCoord.x,0.5-v_TexCoord.y);\n        \t\tfloat theta = atan(orig.x,orig.y);\n        \t\tfloat phi = atan(r*sin(theta),orig.x);" +r + "\n\t\t\t}\n" : "ny" == e ? t = i +"\n\t\t\tvoid main() {\n\t\t\t\tfloat r = 0.5;\n\t\t\t\tvec2 orig = vec2(0.5-v_TexCoord.x,v_TexCoord.y-0.5);\n\t\t\t\tfloat theta = atan(orig.x,orig.y);\n\t\t\t\tfloat phi = atan(r*sin(theta),orig.x);\n\t\t\t\tphi = -phi;" +r + "\n\t\t\t}\n" : console.error("shader fragment type error!"), t}function d() {var e ="\n        attribute vec4 a_Position;\n        attribute vec2 a_TexCoord;\n        varying vec2 v_TexCoord;\n        void main() {\n            gl_Position= a_Position;\n            v_TexCoord = a_TexCoord;\n        }\n";return e}function u() {var e = document.createElement("canvas"),r = e.getContext("2d");e.width = 6 * t, e.height = i;var n = document.createElement("canvas"),o = n.getContext("2d");n.width = t, n.height = i;var a = 180 * Math.PI / 180;if (o.rotate(a), m.sliceSegment) {var s = [],c = document.createElement("canvas");c.width = i / m.sliceSegment, c.height = i / m.sliceSegment;var l = c.getContext("2d");for (var d in v) {o.drawImage(v[d], 0, 0, -t, -i);for (var u = 0; u < m.sliceSegment; u++)for (var h = 0; h < m.sliceSegment; h++) l.putImageData(o.getImageData(h * (i / m.sliceSegment),u * (i / m.sliceSegment), i * (h + 1) / m.sliceSegment, i * (u + 1) / m.sliceSegment), 0, 0), s.push(c.toDataURL("image/jpeg"))}return s}for (var d in v) o.drawImage(v[d], 0, 0, -t, -i), r.drawImage(n, t * d, 0, t, i);return e.toDataURL("image/jpeg")}var m = this,h = {x: "x",nx: "nx",ny: "ny",y: "y",z: "z",nz: "nz"},v = [],f = 0,p = 0,g = new Image;g.crossOrigin = "Anonymous", g.src = e, g.onload = function() {for (var e in h) {var r = document.createElement("canvas");r.width = t, r.height = i, r.id = "face_" + e, v[p] = r;var o = r.getContext("webgl", {preserveDrawingBuffer: !0}),c = s(o, e),l = a(o, c),d = o.getUniformLocation(c, "PI");o.uniform1f(d, Math.PI), o.clearColor(0, 0, 0, 1), n(o, c, l, g) || console.log("Failed to intialize the texture."), p++}}};var AR = function(e, t, i, r, n) {var o = this;this.scene = e, this.renderer = t, this.container = i, AVR.setCameraPara(o, r, n), this.constraints = {}, this.video = null, this.openAudio = !1, this.cameraIndex = 1, this._controlTarget = new THREE.Vector3(1e-4, 0,0), this.camera = new THREE.PerspectiveCamera(this.cameraPara.fov, this.cameraPara.aspect, this.cameraPara.near, this.cameraPara.far), this.camera.position.set(this.cameraPosition.x, this.cameraPosition.y, this.cameraPosition.z), this.cameraReady = !1, this.scene.add(this.camera), this.clock = new THREE.Clock, this.tempCanvas = document.createElement("canvas"), this.effect = AVR.stereoEffect(this.renderer), this._takeScreenShot = !1};AR.prototype.init = function() {function e(e) {i.video.srcObject = e}function t(e) {alert(e)}var i = this;if (AVR.bindOrientationEnevt(i, i._controlTarget), this.video = AVR.createTag("video", {"webkit-playsinline": !0,playsinline: !0,preload: "auto","x-webkit-airplay": "allow","x5-playsinline": !0,"x5-video-player-type": "h5","x5-video-player-fullscreen": !0,"x5-video-orientation": "portrait",style: "object-fit: fill",autoplay: "autoplay"}, {allowsInlineMediaPlayback: !0}), this.video.style.zIndex = "-99999", this.video.style.position = "absolute", this.video.style.left ="0px", this.video.style.top = "0px", this.video.style.width = "2px", this.video.style.height = "2px",document.body.appendChild(this.video), this.video.oncanplaythrough = function() {i.cameraReady = !0, i.video.readyState === i.video.HAVE_ENOUGH_DATA && (i.cameraTexture = new THREE.VideoTexture(i.video), i.cameraTexture.generateMipmaps = !1, i.cameraTexture.format = THREE.RGBAFormat, i.cameraTexture.maxFilter = THREE.NearestFilter, i.cameraTexture.minFilter = THREE.NearestFilter, i.scene.background = i.cameraTexture, i.cameraTexture.needsUpdate = !0)}, navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia, window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL, navigator.getUserMedia) {var r = {audio: i.openAudio,video: {facingMode: {exact: i.cameraIndex ? "environment" : "user"}}};navigator.getUserMedia(r, e, t)} else alert("Native device meadia streaming(getUserMdeia) not supported in this browser.")}, AR.prototype.takeCameraPhoto = function() {var e = this.tempCanvas.getContext("2d");return e.clearRect(0, 0, window.innerWidth, window.innerHeight), e.drawImage(this.video, 0, 0, window.innerWidth, window.innerHeight), e.toDataURL("image/jpeg")}, AR.prototype.takeScreenShot = function(e) {this._takeScreenShot = !0, this._takeScreenShotCallback = e}, AR.prototype.play = function() {function e() {if (i._takeScreenShot) {i._takeScreenShot = !1;var e = i.renderer.domElement.toDataURL("image/jpeg");i._takeScreenShotCallback(e)}if (i.cameraReady) {var t = window.innerWidth,r = window.innerHeight;i.camera.aspect = t / r, i.cameraTexture.repeat.y = r / i.video.videoHeight, i.cameraTexture.offset.x =0, i.cameraTexture.offset.y = 0, AVR.isMobileDevice() && AVR.isCrossScreen() ? (i.cameraTexture.repeat.x = t / (2 * i.video.videoWidth), i.effect.setSize(t, r), i.effect.render(i.scene, i.camera)) : (i.cameraTexture.repeat.x = t / i.video.videoWidth, i.renderer.setSize(t, r), i.renderer.setClearColor(new THREE.Color(16777215)), i.renderer.render(i.scene, i.camera)), i.camera.updateProjectionMatrix()}i.controls && i.controls.update(i.clock.getDelta())}function t() {requestAnimationFrame(t), e()}var i = this;t()};var AVR = {debug: !1,startGyro: function(e) {function t(t) {e(t)}window.addEventListener("deviceorientation", t, !1)},stereoEffect: function(e) {this.separation = 1, this.focalLength = 15;var t, i, r, n, o, a, s, c, l, d, u, m, h = new THREE.Vector3,v = new THREE.Quaternion,f = new THREE.Vector3,p = new THREE.PerspectiveCamera,g = new THREE.PerspectiveCamera;return e.autoClear = !1, this.setSize = function(r, n) {t = r / 2, i = n, e.setSize(r, n)}, this.render = function(E, b) {E.updateMatrixWorld(), void 0 === b.parent && b.updateMatrixWorld(), b.matrixWorld.decompose(h,v, f), r = THREE.Math.radToDeg(2 * Math.atan(Math.tan(.5 * THREE.Math.degToRad(b.fov)))), c = b.near / this.focalLength, d = Math.tan(.5 * THREE.Math.degToRad(r)) * this.focalLength, l = .5 * d * b.aspect, a = d * c, s = -a, u = (l + this.separation / 2) / (2 *l), m = 1 - u, n = 2 * l * c * m, o = 2 * l * c * u, p.projectionMatrix.makePerspective(-n, o, a, s, b.near, b.far), p.position.copy(h), p.quaternion.copy(v), p.translateX(-this.separation / 2), g.projectionMatrix.makePerspective(-o, n, a, s, b.near, b.far), g.position.copy(h), g.quaternion.copy(v), g.translateX(this.separation / 2), e.setViewport(0,0, 2 * t, i), e.setViewport(0, 0, t, i), e.render(E, p), e.setViewport(t, 0, t, i), e.render(E, g)}, this},orbitControls: function(e, t) {var i = function(e, t) {function i() {return 2 * Math.PI / 60 / 60 * p.autoRotateSpeed}function r(e) {p.defaultDirectionOfRotation ? p.usingGyro ? T.theta -= e : T.theta += e : T.theta -= e}function n(e) {p.defaultDirectionOfRotation ? p.usingGyro ? T.phi -= e : T.phi += e : T.phi -= e}function o(e, t, i, r) {var n, o, a, s = e * t + i * r;if (s > .499) {a = 2 * Math.atan2(e, r), n = Math.PI / 2, o = 0;var c = new THREE.Vector3(n, o, a);return c}if (s < -.499) {a = -2 * Math.atan2(e, r), n = -Math.PI / 2, o = 0;var c = new THREE.Vector3(n, o, a);return c}var l = e * e,d = t * t,u = i * i;a = Math.atan2(2 * t * r - 2 * e * i, 1 - 2 * d - 2 * u), n = Math.asin(2 * s), o = Math.atan2(2 * e * r - 2 * t * i, 1 - 2 * l - 2 * u);var c = new THREE.Vector3(n, o, a);return c}function a(e, t) {return 2 * Math.PI * e / t * p.rotateSpeed}function s(e, t) {return 2 * Math.PI * e / t * p.rotateSpeed}function c(e) {_ = !0;var t = e.clientX || e.changedTouches[0].clientX,i = e.clientY || e.changedTouches[0].clientY;y.set(t, i)}function l(e) {var t = e.clientX || e.changedTouches[0].clientX,i = e.clientY || e.changedTouches[0].clientY;w.set(t, i), x.subVectors(w, y);var o = void 0 !== p.domElement.clientWidth ? p.domElement.clientWidth : window.innerWidth;r(a(x.x, o));var c = void 0 !== p.domElement.clientHeight ? p.domElement.clientHeight : window.innerHeight;n(s(x.y, c)), y.copy(w)}function d(e) {_ = !1}function u(e) {_ = !0, y.set(e.touches[0].pageX, e.touches[0].pageY), p.usingGyro = !1}function m(e) {e.preventDefault(), w.set(e.touches[0].pageX, e.touches[0].pageY), x.subVectors(w, y);var t = void 0 != p.domElement.clientWidth ? p.domElement.clientWidth : window.innerWidth;r(a(x.x, t));var i = void 0 !== p.domElement.clientHeight ? p.domElement.clientHeight : window.innerHeight;n(s(x.y, i)), y.copy(w), R.x += a(x.x, t) + s(x.y, i), p.usingGyro = !1}function h(e) {p.usingGyro = !!AVR.OS.isMobile(), _ = !1}function v(e) {p.deviceOrientation = e, void 0 === p.beginAlpha && (p.beginAlpha = p.deviceOrientation.alpha)}function f(e) {p.screenOrientation = window.orientation || 0}this.domElement = void 0 !== t ? t : document, this.object = e, this.object.rotation.reorder("YXZ"), this.enable = !0, this.target = new THREE.Vector3, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -(1 / 0), this.maxAzimuthAngle = 1 / 0,this.enableDamping = !1, this.dampingFactor = .05, this.rotateSpeed = .25, this.autoRotate = !1, this.autoRotateSpeed = 1, this.deviceOrientation = {}, this.screenOrientation = 0;var p = this;p.defaultDirectionOfRotation = !0, p.gyroEnable = !1, p.usingGyro = !!AVR.OS.isMobile(), p._defaultTargetY = p.target.y, p._defaultCameraFov = p.object.fov, p._defaultCameraY = p.object.position.y;var g = {type: "change"},E = 1e-6,b = new THREE.Spherical,T = new THREE.Spherical,y = new THREE.Vector2,w = new THREE.Vector2,x = new THREE.Vector2,R = new THREE.Vector3(0, 0, 0),A = 0,H = 0,S = 0,C = 0,L = 0;this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.rotation0 = this.object.rotation.clone(), this.zoom0 = this.object.zoom, this.getPolarAngle = function() {return b.phi}, this.getAzimuthalAngle = function() {return b.theta}, this.saveState = function() {p.target0.copy(p.target), p.position0.copy(p.object.position), p.rotation0.copy(p.object.rotation), p.zoom0 = p.object.zoom}, this.reset = function(e) {this.resetVar(), p.dispatchEvent(g), e && e.target0 ? p.target.copy(e.target0) : p.target.copy(p.target0), e && e.position0 ? p.object.position.copy(e.position0) : p.object.position.copy(p.position0), e && e.rotation0 ? p.object.rotation.copy(e.rotation0) : p.object.rotation.copy(p.rotation0), e && e.zoom0 ? p.zoom =zoom0 : p.zoom0}, this.resetVar = function() {S = 0, C = 0, L = 0, A = 0, H = 0};var V = function() {var e = new THREE.Vector3(0, 0, 1),t = new THREE.Euler,i = new THREE.Quaternion,r = new THREE.Quaternion((-Math.sqrt(.5)), 0, 0, Math.sqrt(.5));return function(n, o, a, s, c) {t.set(a, o, -s, "YXZ"), n.setFromEuler(t), n.multiply(r), n.multiply(i.setFromAxisAngle(e, -c))}}();this.update = function() {var t = new THREE.Vector3,n = (new THREE.Quaternion).setFromUnitVectors(e.up, new THREE.Vector3(0, 1, 0)),a = n.clone().inverse(),s = new THREE.Vector3,c = new THREE.Quaternion;return function(e) {if (p.enable) {e = e || {};var l = p.deviceOrientation.alpha ? THREE.Math.degToRad(void 0 === p.beginAlpha ? p.deviceOrientation.alpha : p.deviceOrientation.alpha - p.beginAlpha) : 0,d = p.deviceOrientation.beta ? THREE.Math.degToRad(p.deviceOrientation.beta) : 0,u = p.deviceOrientation.gamma ? THREE.Math.degToRad(p.deviceOrientation.gamma) : 0,m = p.screenOrientation ? THREE.Math.degToRad(p.screenOrientation) : 0;p.gyroEnable ? (S = l, C = d, L = u) : (l = S, d = C, u = L);var h = (new THREE.Quaternion).copy(p.object.quaternion);V(h, l, d, u, m);var v = o(h.x, h.y, h.z, h.w);e.init || r(A - v.z), H = v.y, A = v.z;var f = p.object.position;return t.copy(f).sub(p.target), t.applyQuaternion(n), b.setFromVector3(t), p.autoRotate && r(i()), b.theta += T.theta, b.phi += T.phi, b.theta =Math.max(p.minAzimuthAngle, Math.min(p.maxAzimuthAngle, b.theta)), b.phi = Math.max(p.minPolarAngle, Math.min(p.maxPolarAngle, b.phi)), b.makeSafe(), t.setFromSpherical(b), t.applyQuaternion(a), f.copy(p.target).add(t), p.deviceOrientation && p.gyroEnable ? V(p.object.quaternion, l + Math.PI + R.x, d + R.y, u + R.z, m) : p.object.lookAt(p.target), p.enableDamping && !p.gyroEnable ? (T.theta *= 1 - p.dampingFactor, T.phi *= 1 - p.dampingFactor) : T.set(0, 0, 0), (s.distanceToSquared(p.object.position) > E || 8 * (1 - c.dot(p.object.quaternion)) > E) && (p.dispatchEvent(g), s.copy(p.object.position), c.copy(p.object.quaternion), !0)}}}();var _ = !1;window.addEventListener("orientationchange", f, !1), window.addEventListener("deviceorientation", v, !1), this.gyroFreeze = function() {p.gyroEnable = !1}, this.gyroUnfreeze = function() {p.gyroEnable = !0}, this.rotationLeft = r, this.rotationUp = n, this.domElement.addEventListener("mousedown",c, !1), this.domElement.addEventListener("mousemove", function(e) {p.enable && _ && l(e)}, !1), this.domElement.addEventListener("mouseup", d, !1), this.domElement.addEventListener("touchstart", u, !1), this.domElement.addEventListener("touchend", h, !1),this.domElement.addEventListener("touchmove", m, !1);var M = void 0 !== this.domElement.clientWidth ? this.domElement.clientWidth : window.innerWidth,P = void 0 !== this.domElement.clientHeight ? this.domElement.clientHeight : window.innerHeight;return y.set(M / 2, P / 2), setTimeout(function() {p.update({init: !0}), p.saveState()}, 10), this};return i.prototype = Object.create(THREE.EventDispatcher.prototype), i.prototype.constructor = i, new i(e, t)},setCameraPara: function(e, t, i) {if (e.cameraPara = {fov: 90,aspect: e.container.innerWidth / e.container.innerHeight,near: .001,far: 1e3}, e.cameraPosition = {x: 0,y: 0,z: 0}, t)for (var r in t) e.cameraPara[r] = t[r];if (i)for (var r in i) e.cameraPosition[r] = i[r]},formatSeconds: function(e) {var t = parseInt(e),i = 0,r = 0;t > 60 && (i = parseInt(t / 60), t = parseInt(t % 60), i > 60 && (r = parseInt(i / 60), i = parseInt(i %60)));var n = "" + (parseInt(t) < 10 ? "0" + parseInt(t) : parseInt(t));return n = i >= 0 && r > 0 ? (parseInt(r) < 10 ? "0" + parseInt(r) : parseInt(r)) + ":" + (parseInt(i) <10 ? "0" + parseInt(i) : parseInt(i)) + ":" + n : i > 0 && 0 == r ? 60 == i ? "01:00:" + n : (parseInt(i) < 10 ? "0" + parseInt(i) : parseInt(i)) + ":" + n : 60 == t ? "01:00" : "00:" + n},cameraVector: function(e, t) {var i = new THREE.Vector3(0, 0, (-1)),r = i.applyQuaternion(e.quaternion),n = r.clone(),o = new THREE.Vector3;return t && (o.x = r.x * t, o.y = r.y * t, o.z = r.z * t), {vector: n,timesVector: o}},bindRaycaster: function(e, t, i) {var r = AVR.screenPosTo3DCoordinate(e, t.container, t.camera),n = new THREE.Raycaster(t.camera.position, r.sub(t.camera.position).normalize()),o = n.intersectObjects(t.scene.children, !0);o.length ? i.success(o) : i.empty()},bindCameraEvent: function(e, t) {t = t || {trigger: function(e) {},empty: function(e) {},move: function(e) {}};var i = this,r = t.scale || .022,n = t.vectorRadius,o = n * r,a = n * (r / 6),s = 2,c = t.tubularSegments || 60,l = t.speed || 36,d = new THREE.Group;d.name = "__controlHandle";for (var u = new THREE.TorusGeometry(o, a, s, c, 2 * Math.PI), m = [], h = 0; h < u.faces.length /2; h++) m[h] = new THREE.MeshBasicMaterial({color: 15194842,depthTest: !1});for (var v = 0, f = [new THREE.Vector2(0, 0), new THREE.Vector2(1, 0), new THREE.Vector2(1, 1),new THREE.Vector2(0, 1)], h = 0, p = u.faces.length; h < p; h += 2) u.faces[h].materialIndex = v, u.faces[h + 1].materialIndex = v, u.faceVertexUvs[0][h] = [f[3], f[0], f[2]], u.faceVertexUvs[0][h + 1] = [f[0],f[1], f[2]], v++;var g = new THREE.Mesh(u, m);g.name = "__wait", g.visible = !1, d.add(g);var E = new THREE.Mesh(new THREE.CircleGeometry(a, 4), new THREE.MeshBasicMaterial({color: 15194842,wireframe: !0,depthTest: !1}));E.lookAt(e.camera.position), E.name = "__focus", E.material.depthTest = !1, E.visible = !1, d.add(E), d.position.set(0, 0, .1);var b = (new THREE.Vector3, function() {d.lookAt(0, 0, 0), g.lookAt(0, 0, 0);var r = i.cameraVector(e.camera, n);E.visible = !0, d.position.set(r.timesVector.x, r.timesVector.y, r.timesVector.z);var o = new THREE.Raycaster(e.camera.position, r.vector),a = o.intersectObjects(e.scene.children, !0);a.length ? t.move(a) : t.empty(a)}),T = null,y = function(e) {g.visible = !0;var i = 0,r = 0;T || (T = setInterval(function() {r < u.faces.length / 4 ? (m[r].color = new THREE.Color(14710133), u.needsUpdate = !0, u.faces[i].materialIndex = r, u.faces[i + 1].materialIndex = r, u.faceVertexUvs[0][i] = [f[3], f[0], f[2]], u.faceVertexUvs[0][i + 1] = [f[0], f[1], f[2]], i += 2) : (clearInterval(T), T = null, t.trigger(e)), r++}, l))},w = function(e) {clearInterval(T), T = null, v = 0;for (var t = 0, i = u.faces.length; t < i; t += 2) m[v].color = new THREE.Color(15194842), u.needsUpdate = !0, u.faces[t].materialIndex = v, u.faces[t + 1].materialIndex = v, u.faceVertexUvs[0][t] = [f[3], f[0], f[2]], u.faceVertexUvs[0][t + 1] = [f[0], f[1], f[2]],v++;g.visible = !1};e.VRObject.add(d), e.cameraEvt.controlGroup = d, e.cameraEvt.updatePosition = b, e.cameraEvt.hover = y,e.cameraEvt.leave = w},screenPosTo3DCoordinate: function(e, t, i) {var r = e.clientX || (e.touches ? e.touches[0].clientX : 0),n = e.clientY || (e.touches ? e.touches[0].clientY : 0),o = document.body.scrollTop || document.documentElement.scrollTop,a = document.body.scrollLeft || document.documentElement.scrollLeft,s = t.offsetTop,c = t.offsetLeft,l = r - (c - a),d = n - (s - o);l = l >= 0 ? l : 0, d = d >= 0 ? d : 0;var u = t.clientWidth,m = t.clientHeight,h = new THREE.Vector2;h.x = 2 * l / u - 1, h.y = 1 - 2 * d / m;var v = new THREE.Vector3(h.x, h.y, 0).unproject(i);return v.sub(i.position).normalize()},objectPosToScreenPos: function(e, t, i) {var r = new THREE.Vector3;r.setFromMatrixPosition(e.matrixWorld).project(i);var n = r.x,o = r.y,a = t.clientWidth,s = t.clientHeight,c = new THREE.Vector2;return c.x = a / 2 * (n + 1), c.y = s / 2 * (1 - o), c},fullscreen: function(e) {var t = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || !1;t ? document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen ? document.webkitExitFullscreen() : "" : e.requestFullscreen && e.requestFullscreen() || e.mozRequestFullScreen && e.mozRequestFullScreen() ||e.webkitRequestFullscreen && e.webkitRequestFullscreen() || e.msRequestFullscreen && e.msRequestFullscreen()},isFullscreen: function() {return document.fullscreenElement || document.msFullscreenElement || document.mozFullScreenElement ||document.webkitFullscreenElement || !1},toolBar: function(e) {function t(e) {for (var t = e.match(/&#(\d+);/g), i = "", r = 0; r < t.length; r++) i += String.fromCharCode(t[r].replace(/[&#;]/g, ""));return i}var i = "_toolBar",r = this.createTag("div", {style: "-moz-user-select:none;-webkit-user-select:none;user-select:none;position:absolute;background:rgba(0,0,0,.2);width:100%;height:2.2rem;bottom:0rem","class": i + "Area"}),n = this.createTag("div", {style: "position:inherit;border-top:0.6rem solid transparent;border-left:1rem solid white;border-bottom:0.6rem solid transparent;bottom:0.25rem;left:1rem;color:#fff;font-weight:800;cursor:pointer","class": i + "Btn"});r.appendChild(n);var o = this.createTag("div", {style: "position:inherit;bottom:0.25rem;left:2.8rem;color:#fff;font-size:0.75rem"}),a = this.createTag("span", null, {innerText: "00:00"});o.appendChild(a);var s = this.createTag("span", null, {innerText: "/"});o.appendChild(s);var c = this.createTag("span", null, {innerText: "00:00"});o.appendChild(c), r.appendChild(o);var l = document.styleSheets[0];l.insertRule("@keyframes moreTip{from {top:0.75rem;} to{top:1rem}}", 0), AVR.Broswer.isIE() || l.insertRule("@-webkit-keyframes moreTip{from {top:0.75rem;} to{top:1rem}}", 0);var d = this.createTag("span", {style: "width:2.2rem;height:2.2rem;position:inherit;left:50%;margin-left:-1.1rem;margin-top:-0.75rem;color:#fff;font-size:1.5rem;cursor:pointer;margin-top:1rem;border:0.0625rem dotted #ccc;height:0.0625rem;"}, {innerHTML: ""}),u = this.createTag("div", {style: "width:100%;height:auto;position:inherit;background:rgba(0,0,0,0);top:2.4rem;bottom:1.8rem;overflow: hidden;"}, null),m = this.createTag("ul", {style: "display:flex;display: -webkit-flex;display: -webkit-box;display: -moz-box;display: -ms-flexbox;margin:0;padding:0;list-style:none;height:100%;"}, null);u.appendChild(m), r.appendChild(d), r.appendChild(u);var h = this.createTag("div", {style: "width:2.2rem;height:2.2rem;position:inherit;right:1rem;margin-left:-1.1rem;margin-top:0.6rem;color:#fff;font-size:1.2rem;cursor:pointer;display:none",copy: "&#67;&#111;&#112;&#121;&#114;&#105;&#103;&#104;&#116;&#32;&#169;&#32;&#50;&#48;&#49;&#56;&#32;&#87;&#87;&#87;&#46;&#77;&#88;&#82;&#69;&#65;&#76;&#73;&#84;&#89;&#46;&#67;&#78;&#46;&#32;&#65;&#108;&#108;&#32;&#114;&#105;&#103;&#104;&#116;&#115;&#32;&#114;&#101;&#115;&#101;&#114;&#118;&#101;&#100;&#46;"}, {innerText: "？"});h.addEventListener("click", function() {var e = this.getAttribute("copy");alert(t(e))}, !1), h.addEventListener("mouseover", function() {var e = this.getAttribute("copy");this.setAttribute("title", t(e))}, !1), r.appendChild(h);var v = this.createTag("div", {style: "border:0.125rem solid white;border-radius:1rem;width:1rem;height:1rem;position:inherit;right:5.8rem;line-height:1rem;bottom:0.25rem;cursor:pointer"}),f = this.createTag("div", {style: "border:0.08rem solid white;border-radius:8rem;background:rgba(240,240,240,0.6);width:0.3rem;left:0.26rem;top:0.26rem;height:0.3rem;position:inherit;line-height:0.3rem;cursor:pointer"});v.appendChild(f), r.appendChild(v);var p = this.createTag("div", {style: "border:0.125rem solid white;border-radius:1rem;width:1.4rem;height:1rem;position:inherit;right:3.5rem;line-height:1rem;bottom:0.25rem;cursor:pointer"}),g = this.createTag("div", {style: "position:inherit;width:1.235rem;height:0.4rem;line-height:0.4rem;border:0.0625rem solid white;border-radius:0.6rem/0.2rem;margin-top:0.25rem;margin-left:0.055rem;"});p.appendChild(g);var E = this.createTag("div", {style: "position:inherit;width:1rem;height:0.4rem;line-height:0.4rem;border:0.0625rem solid white;border-radius:0.6rem/0.2rem;margin-top:0.25rem;margin-left:0.175rem;transform:rotate(90deg)"});p.appendChild(E), r.appendChild(p);var b = this.createTag("div", {style: "position:inherit;right:1rem;width:1.4rem;height:1rem;line-height:1rem;border:0.125rem solid white;border-radius:0.125rem;bottom:0.25rem;text-align:center;font-weight:800;color:#fff;font-size:0.75rem;cursor:pointer"}, {innerText: "VR"});r.appendChild(b);var T = this.createTag("div", {style: "position:inherit;top:0rem;width:100%;height:0.1rem;background:rgba(255,255,255,.3);cursor:pointer"}),y = this.createTag("div", {style: "position:inherit;width:0%;height:0.1rem;background:rgba(255,255,255,.3)"});T.appendChild(y);var w = this.createTag("div", {style: "position:inherit;width:0%;height:0.1rem;background:rgba(28, 175, 252,.6)"});T.appendChild(w), r.appendChild(T), e.appendChild(r);var x = this.createTag("div", {style: "-moz-user-select:none;-webkit-user-select:none;user-select:none;position:absolute;width:2rem;height:60%;background:rgba(0,0,0,0);left:0rem;top:20%;text-align:center;display:none;border-radius:1rem;"}),R = this.createTag("div", {style: "position:inherit;width:0.25rem;background:rgba(255,255,255,.1);height:100%;left:0.875rem;cursor:pointer;border-radius:1rem;"});x.appendChild(R);var A = this.createTag("div", {style: "position:inherit;width:100%;background:rgba(255, 255, 255,.6);bottom:0rem;;border-radius:1rem;"});return R.appendChild(A), e.appendChild(x), {toolbar: r,btn: n,timeInfo: o,curTime: a,splitTime: s,totalTime: c,moreBtn: d,moreList: u,moreListUl: m,vrBtn: b,progressBar: T,loadedProgress: y,playProgress: w,gyroResetBtn: v,gyroBtn: p,circle1: g,circle2: E,voice_bar: x,about: h}},msgBox: function(e, t, i) {var r = this.createTag("div", {style: "position:absolute;bottom:50%;width:100%;padding:0.25rem;background:rgba(0,0,0,.6);color:#fff;text-align:center;"}, {innerHTML: e});i.appendChild(r), setTimeout(function() {r.remove()}, 1e3 * t)},isMobileDevice: function(e) {var t = navigator.userAgent.toLowerCase();if (e) return t.match(/ipad/i) || t.match(/iphone os/i) || t.match(/midp/i) || t.match(/rv:1.2.3.4/i) ||t.match(/ucweb/i) || t.match(/android/i) || t.match(/windows ce/i) || t.match(/windows mobile/i);var i = "ipad" == t.match(/ipad/i),r = "iphone os" == t.match(/iphone os/i),n = "midp" == t.match(/midp/i),o = "rv:1.2.3.4" == t.match(/rv:1.2.3.4/i),a = "ucweb" == t.match(/ucweb/i),s = "android" == t.match(/android/i),c = "windows ce" == t.match(/windows ce/i),l = "windows mobile" == t.match(/windows mobile/i);return !!(i || r || n || o || a || s || c || l)},bindOrientationEnevt: function(e) {void 0 === e.controls && (e.controls = AVR.orbitControls(e.camera, e.renderer.domElement), e.controls.target = e._controlTarget.clone())},isCrossScreen: function(e) {return 180 != window.orientation && 0 != window.orientation && (90 == window.orientation || window.orientation == -90 || void 0)},initDomStyle: function(e) {function t(e) {e.preventDefault()}document.body.style.overflow = "hidden", document.body.style.margin = 0, document.body.style.padding =0, e.style.position = "absolute", e.style.width = "100%", e.style.height = "100%", e.style.left ="0px", e.style.top = "0px", e.style.overflow = "hidden";var i = document.createElement("style");document.getElementsByTagName("head")[0].appendChild(i), document.body.addEventListener("touchmove", t),document.oncontextmenu = function() {return !1}, document.onkeydown = function() {if (!this.debug && window.event && 123 == window.event.keyCode) return event.keyCode = 0, event.returnValue = !1, !1}},createTag: function(e, t, i) {var r = document.createElement(e);if (t && "object" == typeof t)for (var n in t) r.setAttribute(n, t[n]);if (i && "object" == typeof i)for (var n in i) r[n] = i[n];return r},OS: {weixin: navigator.userAgent.indexOf("MicroMessenger") > -1,android: /android/i.test(navigator.userAgent.toLowerCase()),ios: /(iphone|ipad|ipod|ios)/i.test(navigator.userAgent.toLowerCase()),googlePixel: navigator.userAgent.match(/;\sPixel\sBuild\//),MiOS: navigator.userAgent.match(/;\sMI\s\d\sBuild\//),samsungOS: navigator.userAgent.match(/;\sSM\-\w+\sBuild\//),isGooglePixel: function() {return null != this.googlePixel},isMiOS: function() {return null != this.MiOS},isSamsung: function() {return null != this.samsungOS},isMobile: function() {return this.android || this.ios},isAndroid: function() {return this.android},isiOS: function() {return this.ios},isWeixin: function() {return this.weixin}},Broswer: {win: window,nav: window.navigator,REG_APPLE: /^Apple/,ie: navigator.userAgent.match(/MSIE\s([\d.]+)/) || navigator.userAgent.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),edge: navigator.userAgent.match(/Edge\/([\d.]+)/),chrome: navigator.userAgent.match(/Chrome\/([\d.]+)/) || navigator.userAgent.match(/CriOS\/([\d.]+)/),webview: !this.chrome && navigator.userAgent.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),safari: this.webview || navigator.userAgent.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/),chromiumType: null,_getChromiumType: function() {if (null != this.chromiumType) return this.chromiumType;var e = this.win;return this.isIE() || void 0 === e.scrollMaxX || this.REG_APPLE.test(this.nav.vendor || "") ? "" :this._testExternal(/^sogou/i, 0) ? "sogou" : this._testExternal(/^liebao/i, 0) ? "liebao" : this.nav.mimeTypes[30] || !this.nav.mimeTypes.length ? "360" : e.clientInformation && e.clientInformation.permissions ? "chrome" : ""},_testExternal: function(e, t) {var i = this.win.external || {};for (var r in i)if (e.test(t ? i[r] : r)) return !0;return !1},isIE: function() {return null != this.ie},ieVersion: function() {return null != this.ie && parseInt(this.ie[1])},isEdge: function() {return null != this.edge},isSafari: function() {return null != this.safari},is360: function() {return this.chromiumType = this._getChromiumType(), "360" === this.chromiumType},isSogou: function() {return this.chromiumType = this._getChromiumType(), "sogou" === this.chromiumType},isChromium: function() {return "chrome" === this._getChromiumType()},webglAvailable: function() {try {var e = document.createElement("canvas");return !(!window.WebGLRenderingContext || !e.getContext("webgl") && !e.getContext("experimental-webgl"))} catch (t) {return !1}}}},head = document.getElementsByTagName("head")[0];head.appendChild(AVR.createTag("meta", {name: "viewport",content: "width=device-width"})), head.appendChild(AVR.createTag("meta", {name: "google",content: "notranslate"})), head.appendChild(AVR.createTag("meta", {name: "full-screen",content: "yes"})), AVR.debug && (window.onerror = function(e, t, i) {var r = "There was an error on this page.\n\n";return r += "Error: " + e + "\n", r += "URL: " + t + "\n", r += "Line: " + i + "\n\n", AVR.msgBox(r, 36,document.body), !0});