-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__game-scripts.js
3 lines (2 loc) · 47.3 KB
/
__game-scripts.js
1
2
3
var TouchInput=pc.createScript("touchInput");TouchInput.attributes.add("orbitSensitivity",{type:"number",default:.4,title:"Orbit Sensitivity",description:"How fast the camera moves around the orbit. Higher is faster"}),TouchInput.attributes.add("distanceSensitivity",{type:"number",default:.2,title:"Distance Sensitivity",description:"How fast the camera moves in and out. Higher is faster"}),TouchInput.attributes.add("cameraEntity",{type:"entity"}),TouchInput.prototype.initialize=function(){this.orbitCamera=this.cameraEntity,this.firstTouchPoint=new pc.Vec2,this.lastTouchPoint=new pc.Vec2,this.utilVec=new pc.Vec2,this.lastPinchMidPoint=new pc.Vec2,this.lastPinchDistance=0,this.orbitCamera&&this.app.touch&&(this.app.touch.on(pc.EVENT_TOUCHSTART,this.onTouchStartEndCancel,this),this.app.touch.on(pc.EVENT_TOUCHEND,this.onTouchStartEndCancel,this),this.app.touch.on(pc.EVENT_TOUCHCANCEL,this.onTouchStartEndCancel,this),this.app.touch.on(pc.EVENT_TOUCHMOVE,this.onTouchMove,this),this.on("destroy",(function(){this.app.touch.off(pc.EVENT_TOUCHSTART,this.onTouchStartEndCancel,this),this.app.touch.off(pc.EVENT_TOUCHEND,this.onTouchStartEndCancel,this),this.app.touch.off(pc.EVENT_TOUCHCANCEL,this.onTouchStartEndCancel,this),this.app.touch.off(pc.EVENT_TOUCHMOVE,this.onTouchMove,this)})))},TouchInput.prototype.getPinchDistance=function(t,i){var o=t.x-i.x,n=t.y-i.y;return Math.sqrt(o*o+n*n)},TouchInput.prototype.calcMidPoint=function(t,i,o){o.set(i.x-t.x,i.y-t.y),o.scale(.5),o.x+=t.x,o.y+=t.y},TouchInput.prototype.onTouchStartEndCancel=function(t){document.documentElement.requestFullscreen();var i=t.touches;1==i.length?(this.firstTouchPoint.set(i[0].x,i[0].y),this.lastTouchPoint.set(i[0].x,i[0].y)):2==i.length&&(this.lastPinchDistance=this.getPinchDistance(i[0],i[1]),this.calcMidPoint(i[0],i[1],this.lastPinchMidPoint))},TouchInput.fromWorldPoint=new pc.Vec3,TouchInput.toWorldPoint=new pc.Vec3,TouchInput.worldDiff=new pc.Vec3,TouchInput.prototype.pan=function(t){var i=TouchInput.fromWorldPoint,o=TouchInput.toWorldPoint,n=TouchInput.worldDiff,c=this.entity.camera,h=this.orbitCamera.distance;c.screenToWorld(t.x,t.y,h,i),c.screenToWorld(this.lastPinchMidPoint.x,this.lastPinchMidPoint.y,h,o),n.sub2(o,i)},TouchInput.pinchMidPoint=new pc.Vec2,TouchInput.prototype.onTouchMove=function(t){var i=TouchInput.pinchMidPoint,o=t.touches;if(1==o.length){var n=o[0];this.orbitCamera.pitch-=(n.y-this.lastTouchPoint.y)*this.orbitSensitivity,this.orbitCamera.yaw-=(n.x-this.lastTouchPoint.x)*this.orbitSensitivity,this.utilVec.set(n.x,n.y),this.utilVec.distance(this.lastTouchPoint)>1&&this.app.fire("touch:move",{screen:{x:n.x,y:n.y}}),this.lastTouchPoint.set(n.x,n.y)}else if(2==o.length){var c=this.getPinchDistance(o[0],o[1]),h=c-this.lastPinchDistance;this.lastPinchDistance=c,h>0?this.app.fire("cursor:wheel:global",-1,this):h<0&&this.app.fire("cursor:wheel:global",1,this),this.calcMidPoint(o[0],o[1],i),this.pan(i),this.lastPinchMidPoint.copy(i)}};var WonderingEye=pc.createScript("wonderingEye");WonderingEye.attributes.add("camera",{type:"entity"}),WonderingEye.prototype.initialize=function(){this.app.on("cursor:move:global",this.onCursorMoveGlobal,this),this.app.on("cursor:wheel:global",this.onCursorWheelGlobal,this),this.originalEulers=this.entity.getEulerAngles(),this.rotation=new pc.Quat,this.targetRotation=new pc.Quat,this.originRotation=new pc.Quat,this.lerpDuration=.5,this.lerpActive=!1},WonderingEye.prototype.postInitialize=function(){this.camera.camera.fov=80},WonderingEye.prototype.onCursorMoveGlobal=function(t){if(!this.app.inputPaused){var e=t.screen.x/window.innerWidth-.5,i=t.screen.y/window.innerHeight-.5,o=this.entity.getRotation();this.originRotation.set(o.x,o.y,o.z,o.w),this.targetRotation.setFromEulerAngles(this.originalEulers.x+(-12*i-3),this.originalEulers.y+-60*e,0),this.lerpElapsed=0,this.lerpActive=!0}},WonderingEye.prototype.onCursorWheelGlobal=function(t){this.onMouseWheel({wheelDelta:t})},WonderingEye.prototype.onMouseWheel=function(t){var e=t.wheelDelta,i=this.camera.camera.fov;e>0?i+1<=90&&(i+=1):i-1>=40&&(i-=1),this.camera.camera.fov=i},WonderingEye.prototype.update=function(t){if(this.lerpActive){this.lerpElapsed+=t;var e=this.lerpElapsed/this.lerpDuration;e>=1&&(e=1,this.lerpActive=!1),this.rotation.slerp(this.originRotation,this.targetRotation,e),this.camera.setRotation(this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)}};Object.assign(pc,function(){function computeGaussian(e,t){return 1/Math.sqrt(2*Math.PI*t)*Math.exp(-e*e/(2*t*t))}function calculateBlurValues(e,t,s,o,r){e[0]=computeGaussian(0,r),t[0]=0,t[1]=0;var i,a,l=e[0];for(i=0,a=Math.floor(7.5);i<a;i++){var u=computeGaussian(i+1,r);e[2*i]=u,e[2*i+1]=u,l+=2*u;var h=2*i+1.5;t[4*i]=s*h,t[4*i+1]=o*h,t[4*i+2]=-s*h,t[4*i+3]=-o*h}for(i=0,a=e.length;i<a;i++)e[i]/=l}var BloomEffect=function(e){pc.PostEffect.call(this,e);var t={aPosition:pc.SEMANTIC_POSITION},s=["attribute vec2 aPosition;","","varying vec2 vUv0;","","void main(void)","{"," gl_Position = vec4(aPosition, 0.0, 1.0);"," vUv0 = (aPosition + 1.0) * 0.5;","}"].join("\n"),o=["precision "+e.precision+" float;","","varying vec2 vUv0;","","uniform sampler2D uBaseTexture;","uniform float uBloomThreshold;","","void main(void)","{"," vec4 color = texture2D(uBaseTexture, vUv0);",""," gl_FragColor = clamp((color - uBloomThreshold) / (1.0 - uBloomThreshold), 0.0, 1.0);","}"].join("\n"),r=["precision "+e.precision+" float;","","#define SAMPLE_COUNT 15","","varying vec2 vUv0;","","uniform sampler2D uBloomTexture;","uniform vec2 uBlurOffsets[SAMPLE_COUNT];","uniform float uBlurWeights[SAMPLE_COUNT];","","void main(void)","{"," vec4 color = vec4(0.0);"," for (int i = 0; i < SAMPLE_COUNT; i++)"," {"," color += texture2D(uBloomTexture, vUv0 + uBlurOffsets[i]) * uBlurWeights[i];"," }",""," gl_FragColor = color;","}"].join("\n"),i=["precision "+e.precision+" float;","","varying vec2 vUv0;","","uniform float uBloomEffectIntensity;","uniform sampler2D uBaseTexture;","uniform sampler2D uBloomTexture;","","void main(void)","{"," vec4 bloom = texture2D(uBloomTexture, vUv0) * uBloomEffectIntensity;"," vec4 base = texture2D(uBaseTexture, vUv0);",""," base *= (1.0 - clamp(bloom, 0.0, 1.0));",""," gl_FragColor = base + bloom;","}"].join("\n");this.extractShader=new pc.Shader(e,{attributes:t,vshader:s,fshader:o}),this.blurShader=new pc.Shader(e,{attributes:t,vshader:s,fshader:r}),this.combineShader=new pc.Shader(e,{attributes:t,vshader:s,fshader:i});var a=e.width,l=e.height;this.targets=[];for(var u=0;u<2;u++){var h=new pc.Texture(e,{format:pc.PIXELFORMAT_R8_G8_B8_A8,width:a>>1,height:l>>1});h.minFilter=pc.FILTER_LINEAR,h.magFilter=pc.FILTER_LINEAR,h.addressU=pc.ADDRESS_CLAMP_TO_EDGE,h.addressV=pc.ADDRESS_CLAMP_TO_EDGE,h.name="pe-bloom";var n=new pc.RenderTarget(e,h,{depth:!1});this.targets.push(n)}this.bloomThreshold=.25,this.blurAmount=4,this.bloomIntensity=1.25,this.sampleWeights=new Float32Array(15),this.sampleOffsets=new Float32Array(30)};return(BloomEffect.prototype=Object.create(pc.PostEffect.prototype)).constructor=BloomEffect,Object.assign(BloomEffect.prototype,{render:function(e,t,s){var o=this.device,r=o.scope;r.resolve("uBloomThreshold").setValue(this.bloomThreshold),r.resolve("uBaseTexture").setValue(e.colorBuffer),pc.drawFullscreenQuad(o,this.targets[0],this.vertexBuffer,this.extractShader),calculateBlurValues(this.sampleWeights,this.sampleOffsets,1/this.targets[1].width,0,this.blurAmount),r.resolve("uBlurWeights[0]").setValue(this.sampleWeights),r.resolve("uBlurOffsets[0]").setValue(this.sampleOffsets),r.resolve("uBloomTexture").setValue(this.targets[0].colorBuffer),pc.drawFullscreenQuad(o,this.targets[1],this.vertexBuffer,this.blurShader),calculateBlurValues(this.sampleWeights,this.sampleOffsets,0,1/this.targets[0].height,this.blurAmount),r.resolve("uBlurWeights[0]").setValue(this.sampleWeights),r.resolve("uBlurOffsets[0]").setValue(this.sampleOffsets),r.resolve("uBloomTexture").setValue(this.targets[1].colorBuffer),pc.drawFullscreenQuad(o,this.targets[0],this.vertexBuffer,this.blurShader),r.resolve("uBloomEffectIntensity").setValue(this.bloomIntensity),r.resolve("uBloomTexture").setValue(this.targets[0].colorBuffer),r.resolve("uBaseTexture").setValue(e.colorBuffer),pc.drawFullscreenQuad(o,t,this.vertexBuffer,this.combineShader,s)}}),{BloomEffect:BloomEffect}}());var Bloom=pc.createScript("bloom");Bloom.attributes.add("bloomIntensity",{type:"number",default:1,min:0,title:"Intensity"}),Bloom.attributes.add("bloomThreshold",{type:"number",default:.25,min:0,max:1,precision:2,title:"Threshold"}),Bloom.attributes.add("blurAmount",{type:"number",default:4,min:1,title:"Blur amount"}),Bloom.prototype.initialize=function(){this.effect=new pc.BloomEffect(this.app.graphicsDevice),this.effect.bloomThreshold=this.bloomThreshold,this.effect.blurAmount=this.blurAmount,this.effect.bloomIntensity=this.bloomIntensity;var e=this.entity.camera.postEffects;e.addEffect(this.effect),this.on("attr",(function(e,t){this.effect[e]=t}),this),this.on("state",(function(t){t?e.addEffect(this.effect):e.removeEffect(this.effect)})),this.on("destroy",(function(){e.removeEffect(this.effect)}))};var Hud=pc.createScript("hud");Hud.attributes.add("css",{type:"asset",assetType:"css",title:"CSS Asset"}),Hud.attributes.add("html",{type:"asset",assetType:"html",title:"HTML Asset"}),Hud.attributes.add("buttonImage",{type:"asset",assetType:"texture"}),Hud.prototype.initialize=function(){if("low"==this.app.qualitySettings.preset)for(var e=this.app.assets.filter((function(e){return"material"==e.type})),t=0;t<e.length;t++)e[t].normalMap=null;var n=document.createElement("style");document.head.appendChild(n),n.innerHTML=this.css.resource||"",this.div=document.createElement("div"),this.div.classList.add("container"),this.div.innerHTML=this.html.resource||"",document.body.appendChild(this.div),this.app.on("trophyTweet",this.doTrophyTweet,this),this.menuTemplateHTML=this.div.querySelector(".menuTemplate").value,this.fullscreenMenuHTML=this.div.querySelector(".fullscreenMenu").value,this.menuSlate=null,this.bindEvents(),this.app.on("hud:showMenu",this.showMenu,this),this.app.on("hud:closeMenu",this.closeMenu,this),this.app.on("hud:openLink",this.openLink,this),this.app.on("controls:max",this.onControlsMax,this),this.app.on("controls:newtab",this.onControlsNewTab,this)},Hud.prototype.bindEvents=function(){var e=this,t=this.div.querySelector(".tweetButton");t.style.backgroundImage='url("'+this.buttonImage.getFileUrl()+'")',t.addEventListener("click",(function(){e.tweet()}))},Hud.prototype.openLink=function(e){var t=localStorage.getItem("linkSettings");function getLinkSetting(e){for(var n=0;n<t.length;n++)if(t[n].href==e)return t[n];return null}t=t?JSON.parse(t):[];var n=this,r=null;function launchNewTab(){e.closeTarget&&n.app.fire("controls:close",{target:e.closeTarget}),r&&r.checked&&!getLinkSetting(e.href)&&(t.push({href:e.href,method:"newtab"}),localStorage.setItem("linkSettings",JSON.stringify(t))),window.open(e.href,e.target)}function openIframe(i,s){r&&r.checked&&!getLinkSetting(e.href)&&(t.push({href:e.href,method:"iframe"}),localStorage.setItem("linkSettings",JSON.stringify(t)));var o=!1,a=n.app.root.children[0].find((function(t){return t.script&&t.script.iframePlane&&t.script.iframePlane.frameName==e.target}));if(1==a.length){var l=a[0].script.iframePlane;l.iframe?(l.lastUsedUrl=e.href,l.iframe.lastUrl=e.href):(l.activate(e.href),o=!0)}return o||window.open(e.href,e.target),o}var i=getLinkSetting(e.href);if(i){if("newtab"==i.method)return launchNewTab(),n.closeMenu(),!0;if("iframe"==i.method)return openIframe(e.target,e.href),n.closeMenu(),!0;askHow()}else if("verylow"==this.app.qualitySettings.preset||"_blank"==e.target||"_self"==e.target)askHow();else{if("_blank"!=e.target&&"_self"!=e.target)return openIframe(e.target,e.href),n.closeMenu(),!0;askHow()}function askHow(){var t=n.showMenu({name:"link"});if(t.querySelector(".menuLinkPreview").value=e.href,r=t.querySelector(".linkRememberCheckbox"),"_blank"!=e.target&&"_self"!=e.target&&"verylow"==n.app.qualitySettings.preset){var i=t.querySelector(".menuLinkIframe");i.parentNode.style.display="block",i.addEventListener("click",(function(t){n.closeMenu(),openIframe(e.target,e.href)}))}t.querySelector(".menuLinkYes").addEventListener("click",(function(e){n.closeMenu(),launchNewTab()}))}},Hud.prototype.showMenu=function(e){this.closeMenu(),this.app.inputPaused=!0,document.body.style.cursor="default",this.app.fire("pauseInput");var t=this.div.querySelector('.menuContent[name="'+e.name+'"]').value,n=document.createElement("div");n.classList.add("menuSlate"),n.innerHTML=this.menuTemplateHTML,n.querySelector(".menuContentContainer").innerHTML=t;for(var r=n.querySelector(".menuContainer"),i=this,s=n.querySelectorAll(".closeButton"),o=0;o<s.length;o++)s[o].addEventListener("click",(function(){i.app.fire("hud:closeMenu")}));document.body.appendChild(n);r.offsetWidth;return r.classList.add("menuContainerActive"),this.menuSlate=n,n},Hud.prototype.closeMenu=function(){this.menuSlate&&(this.menuSlate.remove(),this.menuSlate=null,this.app.inputPaused=!1,this.app.fire("unpauseInput"))},Hud.prototype.tweet=function(){const e="https://twitter.com/intent/tweet?url=https://m3org.com/spacebase&text="+encodeURIComponent("Chillin' in this interactive #3Dstartpage right in my web browser, built by @m3org using #webgl & #playcanvas");window.open(e,"twitterwindow","height=670, width=550, toolbar=0, location=0, menubar=0, directories=0,scrollbars=0")},Hud.prototype.doTrophyTweet=function(){const e="https://twitter.com/intent/tweet?url=https://3d.m3org.com/victory&text="+encodeURIComponent("Victory! Achievement unlocked: Collected 100% of the interactive object points in @m3org #3Dstartpage");window.open(e,"twitterwindow","height=670, width=550, toolbar=0, location=0, menubar=0, directories=0,scrollbars=0")},Hud.prototype.onControlsNewTab=function(e){var t=document.querySelector('iframe[name="'+e.target+'"]');if(t){var n=t.lastUrl;this.app.fire("hud:openLink",{target:"_blank",href:n,closeTarget:e.target})}},Hud.prototype.onControlsMax=function(e){var t=document.querySelector('iframe[name="'+e.target+'"]');if(t){var n=this;this.app.inputPaused=!0,document.body.style.cursor="default",this.app.fire("pauseInput");var r=document.createElement("div");r.classList.add("fullscreenSlate"),r.innerHTML=this.fullscreenMenuHTML,document.body.appendChild(r),t.oldParent=t.parentNode,t.parentNode.classList.add("fullscreenActive"),document.body.classList.add("fullscreenBodyMode"),t.classList.add("fullscreenIframe");var i=document.querySelector("#application-canvas");i.style.visibility="hidden",r.querySelector(".menuControlRestore").addEventListener("click",(function(e){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),i.style.visibility="visible",r.remove(),n.app.inputPaused=!1,n.app.fire("unpauseInput"),n.app.fire("controls:restore",{target:t.name})})),r.querySelector(".menuControlClose").addEventListener("click",(function(s){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),i.style.visibility="visible",r.remove(),n.app.inputPaused=!1,n.app.fire("unpauseInput"),n.app.fire("controls:close",{target:e.target})})),r.querySelector(".menuControlNewTab").addEventListener("click",(function(s){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),i.style.visibility="visible",r.remove(),n.app.inputPaused=!1,n.app.fire("unpauseInput"),n.app.fire("controls:close",{target:e.target});var o=t.lastUrl;o||(o=opt.href),window.open(o,"_blank")}))}};pc.script.createLoadingScreen((function(e){e.qualitySettings={preset:"high"},e.touch&&(e.qualitySettings.preset="low");var t,a;t=["body {"," background-color: #222;","background: #222;","background: -moz-linear-gradient(-45deg, #45484d 0%, #000000 100%);","background: -webkit-linear-gradient(-45deg, #45484d 0%,#000000 100%);","background: linear-gradient(135deg, #45484d 0%,#000000 100%);",'filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#45484d", endColorstr="#000000",GradientType=1 );',"}","#application-splash-wrapper {"," position: absolute;"," top: 0;"," left: 0;"," height: 100%;"," width: 100%;"," background-color: #222;","background: #222;","background: -moz-linear-gradient(-45deg, #45484d 0%, #000000 100%);","background: -webkit-linear-gradient(-45deg, #45484d 0%,#000000 100%);","background: linear-gradient(135deg, #45484d 0%,#000000 100%);",'filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#45484d", endColorstr="#000000",GradientType=1 );',"}","#application-splash {"," position: absolute;"," top: calc(50% - 128px);"," width: 200px;"," left: calc(50% - 100px);","}","#application-splash img {"," width: 100%;","}","#progress-bar-container {"," margin: 20px auto 0 auto;"," height: 2px;"," width: 167px;"," background-color: #1d292c;","}","#progress-bar {"," width: 0%;"," height: 100%;"," background-color: #f60;","}","@media (max-width: 480px) {"," #application-splash {"," width: 170px;"," left: calc(50% - 85px);"," }","}"].join("\n"),(a=document.createElement("style")).type="text/css",a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t)),document.head.appendChild(a),function(){var e=document.createElement("div");e.id="application-splash-wrapper",document.body.appendChild(e);var t=document.createElement("div");t.id="application-splash",e.appendChild(t),t.style.display="none";var a=document.createElement("img");a.src="https://m3org.com/logo_big.png",t.appendChild(a),a.onload=function(){t.style.display="block"};var r=document.createElement("div");r.id="progress-bar-container",t.appendChild(r);var o=document.createElement("div");o.id="progress-bar",r.appendChild(o)}(),e.on("preload:end",(function(){e.off("preload:progress")})),e.on("preload:progress",(function(e){var t=document.getElementById("progress-bar");t&&(e=Math.min(1,Math.max(0,e)),t.style.width=100*e+"%")})),e.on("start",(function(){var e=document.getElementById("application-splash-wrapper");e.parentElement.removeChild(e)}))}));var SelectionCursor=pc.createScript("selectionCursor");SelectionCursor.attributes.add("cameraEntity",{type:"entity"}),SelectionCursor.prototype.initialize=function(){this.channelManagerEntity=this.app.root.findByName("ChannelManager"),this.selectedMediaEntity=null,this.selectedMediaEntityCol=null,this.hoveredEntity=null,this.clickedEntity=null,this.app.mouse.on(pc.EVENT_MOUSEMOVE,this.onMouseMove,this),this.app.mouse.on(pc.EVENT_MOUSEDOWN,this.onMouseDown,this),this.app.mouse.on(pc.EVENT_MOUSEUP,this.onMouseUp,this),this.app.mouse.on(pc.EVENT_MOUSEWHEEL,this.onMouseWheel,this),this.app.on("touch:move",this.onTouchMove,this),this.app.on("pauseInput",this.onPauseInput,this),this.spawnModeEntity=null;var t=this;this.app.on("spawnMode:enter",(function(i){t.spawnModeEntity=i,t.hoveredEntity&&(t.hoveredEntity=null),t.clickedEntity&&(t.clickedEntity=null)})),this.app.on("spawnMode:exit",(function(){t.spawnModeEntity=null})),this.app.keyboard.on(pc.EVENT_KEYUP,this.onKeyUp,this)},SelectionCursor.prototype.onPauseInput=function(){this.hoveredEntity&&(this.unhoverEntity(this.hoveredEntity),this.hoveredEntity=null),this.clickedEntity&&(this.clickedEntity=null)},SelectionCursor.prototype.onKeyUp=function(t){if(t.key===pc.KEY_DELETE){var i=this.hoveredEntity.parent;i&&i&&i.networkId&&(this.channelManagerEntity.script.channelManager.removeMediaObject(i),this.hoveredEntity=null,this.clickedEntity=null,document.body.style.cursor="default")}},SelectionCursor.prototype.unhoverEntity=function(t){t&&t.hasEvent("cursor:exit")&&t.fire("cursor:exit")},SelectionCursor.prototype.hoverEntity=function(t){t&&t.hasEvent("cursor:enter")&&t.fire("cursor:enter")},SelectionCursor.prototype.cursorDownEntity=function(t){t&&t.hasEvent("cursor:down")&&t.fire("cursor:down")},SelectionCursor.prototype.cursorUpEntity=function(t){t&&t.hasEvent("cursor:up")&&t.fire("cursor:up")},SelectionCursor.prototype.cursorClickEntity=function(t){t&&t.hasEvent("cursor:click")&&t.fire("cursor:click")},SelectionCursor.prototype.onMouseDown=function(t){this.app.inputPaused||(this.clickedEntity&&(this.clickedEntity=null),this.hoveredEntity&&(this.cursorDownEntity(this.hoveredEntity),this.clickedEntity=this.hoveredEntity),this.app.fire("cursor:down:global",this.clickedEntity))},SelectionCursor.prototype.onMouseUp=function(t){if(!this.app.inputPaused){var i=null;this.clickedEntity&&(this.clickedEntity==this.hoveredEntity&&(i=this.clickedEntity),this.clickedEntity=null),this.hoveredEntity&&this.cursorUpEntity(this.hoveredEntity),i&&this.cursorClickEntity(i),this.app.fire("cursor:up:global",this.hoveredEntity)}},SelectionCursor.prototype.onTouchMove=function(t){this.onMouseMove(t.screen)},SelectionCursor.prototype.onMouseMove=function(t){if(!this.app.inputPaused){var i=this.doRaycast({x:t.x,y:t.y}),e=i&&i.entity?i.entity:null;e?(this.hoveredEntity?this.hoveredEntity==e||(this.unhoverEntity(this.hoveredEntity),this.hoveredEntity=null,this.hoveredEntity=e,this.hoverEntity(e)):(this.hoveredEntity=e,this.hoverEntity(e)),this.clickedEntity&&this.clickedEntity!=e&&(this.clickedEntity=null)):(this.hoveredEntity&&(this.unhoverEntity(this.hoveredEntity),this.hoveredEntity=null),this.clickedEntity&&(this.clickedEntity=null)),this.app.lastCursorMove={raycast:i,screen:{x:t.x,y:t.y}},this.app.fire("cursor:move:global",{raycast:i,screen:{x:t.x,y:t.y}})}},SelectionCursor.prototype.doRaycast=function(t){this.cameraEntity.getPosition(),this.cameraEntity.camera.screenToWorld(t.x,t.y,this.cameraEntity.camera.farClip);return this.spawnModeEntity,null},SelectionCursor.prototype.onMouseWheel=function(t){this.app.fire("cursor:wheel:global",t.wheelDelta,this)},SelectionCursor.prototype.update=function(t){};!function(){var t=new pc.Vec3;pc.RigidBodyComponentSystem.prototype.raycastFirstByTag=function(r,a,n){for(var i=Number.MAX_VALUE,s=null,e=this.app.systems.rigidbody.raycastAll(r,a),o=0;o<e.length;++o){var y=e[o];if(y.entity.tags.has(n)){t.sub2(y.point,r);var p=t.lengthSq();p<i&&(i=p,s=y)}}return s},pc.RigidBodyComponentSystem.prototype.raycastFirstWithoutTag=function(r,a,n){for(var i=Number.MAX_VALUE,s=null,e=this.app.systems.rigidbody.raycastAll(r,a),o=0;o<e.length;++o){var y=e[o];if(!y.entity.tags.has(n)){t.sub2(y.point,r);var p=t.lengthSq();p<i&&(i=p,s=y)}}return s}}();var IframePlane=pc.createScript("iframePlane");IframePlane.attributes.add("iframeUrl",{type:"string"}),IframePlane.attributes.add("controls",{type:"entity"}),IframePlane.attributes.add("iframePixelsPerUnit",{type:"number",default:640,description:"Number of canvas pixels per unit of world space. The larger the number, the higher the resolution of the iframe."}),IframePlane.attributes.add("frameName",{type:"string",description:"Leave blank usually. Only add if you have links that need to target specific iframes."}),IframePlane.prototype.initialize=function(){this.iframe=null,this.app.isFullscreened=!1;var e=new pc.StandardMaterial;e.depthWrite=!0,e.redWrite=!1,e.greenWrite=!1,e.blueWrite=!1,e.alphaWrite=!1,e.blendType=pc.BLEND_NONE,e.opacity=0,e.update(),this.entity.model.material=e,this.lastUsedUrl=null,this.app.on("controls:close",this.onControlsClose,this),this.app.on("controls:max",this.onControlsMax,this),this.app.on("controls:restore",this.onControlsRestore,this)},IframePlane.prototype.onControlsMax=function(e){var t=document.querySelector('iframe[name="'+e.target+'"]');if(t&&this.iframe==t){let e=this.iframe.dom;this.app.isFullscreened=!0,e.oldCssText=e.style.cssText,e.style.cssText="";let t=e.parentNode;e.oldParent=t,t.oldCssText=t.style.cssText,t.style.cssText=""}},IframePlane.prototype.onControlsRestore=function(e){var t=document.querySelector('iframe[name="'+e.target+'"]');if(t&&this.iframe==t){let e=this.iframe.dom;this.app.isFullscreened=!1,e.style.cssText=e.oldCssText,e.parentNode.style.cssText=e.parentNode.oldCssText}},IframePlane.prototype.onControlsClose=function(e){if(e.target==this.frameName&&this.iframe){var t=document.querySelector('iframe[name="'+e.target+'"]');if(this.app.isFullscreened&&t&&this.iframe==t){let e=this.iframe.dom;this.app.isFullscreened=!1,e.style.cssText=e.oldCssText,e.parentNode.style.cssText=e.parentNode.oldCssText}this.deactivate()}},IframePlane.prototype.deactivate=function(){this._css3Plane.destroyPlane(),this.entity.enabled=!1,this.iframe.remove(),this.iframe=null},IframePlane.prototype.activate=function(e){if(this.iframe)return console.log("WARNING: Iframe already exists."),!1;var t;!e&&this.lastUsedUrl,this.entity.enabled=!0,(t=document.createElement("iframe")).allowfullscreen=!0,t.allowusermedia=!0,t.style.cssText="width: 100%; height: 100%;",e?this.lastUsedUrl=e:e=this.lastUsedUrl?this.lastUsedUrl:this.iframeUrl,t.lastUrl=e;var s=e;if(0==s.indexOf("https://player.twitch.tv/?channel=")){var a=location.hostname,i=s.indexOf("&parent=");s=s.substring(0,i+8)+a}return t.src=s,t.style.border="0px",this.frameName&&(t.name=this.frameName),this.iframe=t,this._css3Plane=new pc.Css3Plane(t,this.entity,this.iframePixelsPerUnit,null,this.iframe),this._css3Plane.dom.style.pointerEvents="none",!0},pc.extend(pc,function(){"use strict";var epsilon=function(e){return Math.abs(e)<1e-10?0:e},getCameraCSSMatrix=function(e){var t=e.data;return"matrix3d("+epsilon(t[0])+","+epsilon(-t[1])+","+epsilon(t[2])+","+epsilon(t[3])+","+epsilon(t[4])+","+epsilon(-t[5])+","+epsilon(t[6])+","+epsilon(t[7])+","+epsilon(t[8])+","+epsilon(-t[9])+","+epsilon(t[10])+","+epsilon(t[11])+","+epsilon(t[12])+","+epsilon(-t[13])+","+epsilon(t[14])+","+epsilon(t[15])+")"},Css3Renderer=function(){if(pc.app.css3Renderer)return pc.app.css3Renderer;pc.app.css3Renderer=this,this._stageElement=null,this._cameras=[],this._cameraElements=[],this._defaultCameraElement=null,this._css3Targets=[],this._cameraInvertMat=new pc.Mat4,this._cameraHalfSize=new pc.Vec2;var e=document.createElement("div");e.style.overflow="hidden",e.style.pointerEvents="none",document.body.appendChild(e);var t=document.getElementById("application-canvas");document.body.insertBefore(e,t),this._stageElement=e,this._defaultCameraElement=this.addCamera(pc.app.root.findComponent("camera"));var s=this;function onWindowResize(){if(!pc.app.isFullscreened){s._width=window.innerWidth,s._height=window.innerHeight,s._widthHalf=s._width/2,s._heightHalf=s._height/2,s._stageElement.style.width=s._width+"px",s._stageElement.style.height=s._height+"px";for(var e=0;e<s._cameraElements.length;e++)s._cameraElements[e].style.width=s._width+"px",s._cameraElements[e].style.height=s._height+"px"}}onWindowResize(),window.addEventListener("resize",onWindowResize,!1)};Css3Renderer.prototype={render:function(){this._isRendering||(this._isRendering=!0,pc.app.on("update",this._renderElements,this))},cancelRender:function(){pc.app.off("update",this._renderElements,this),this._isRendering=!1},addCamera:function(e){if(!e)return this._defaultCameraElement;if(this._cameras.indexOf(e)>-1)return this._cameraElements[this._cameras.indexOf(e)];var t=document.createElement("div");return t.style.WebkitTransformStyle="preserve-3d",t.style.transformStyle="preserve-3d",t.style.pointerEvents="none",this._stageElement.appendChild(t),this._cameras.push(e),this._cameraElements.push(t),t},addTarget:function(e){this._css3Targets.indexOf(e)<=-1&&this._css3Targets.push(e)},blockEvents:function(e){for(var t=0;t<this._css3Targets.length;this._css3Targets[t++].blockEvents(e));},_renderElements:function(){if(!pc.app.isFullscreened){for(var e=0;e<this._cameras.length;e++){var t,s,a,i=this._cameras[e],r=this._cameraElements[e],n=i.projectionMatrix.data[5]*this._heightHalf;i.projection==pc.PROJECTION_PERSPECTIVE?(this._stageElement.style.WebkitPerspective=n+"px",this._stageElement.style.perspective=n+"px"):(this._stageElement.style.WebkitPerspective="",this._stageElement.style.perspective=""),i.projection==pc.PROJECTION_ORTHOGRAPHIC&&(pc.Mat4._getPerspectiveHalfSize(this._cameraHalfSize,i.fov,i.aspectRatio,i.nearClip,i.horizontalFov),t=-(this._cameraHalfSize.x-this._cameraHalfSize.x)/2,s=(this._cameraHalfSize.y-this._cameraHalfSize.y)/2),this._cameraInvertMat.copy(i.entity.getWorldTransform()).invert(),a=(i.projection==pc.PROJECTION_ORTHOGRAPHIC?"scale("+n+")translate("+epsilon(t)+"px,"+epsilon(s)+"px)"+getCameraCSSMatrix(this._cameraInvertMat):"translateZ("+n+"px)"+getCameraCSSMatrix(this._cameraInvertMat))+"translate("+this._widthHalf+"px,"+this._heightHalf+"px)",r.style.WebkitTransform=a,r.style.transform=a}for(var l=0;l<this._css3Targets.length;this._css3Targets[l++].updateTransform());}}};var Css3Plane=function(e,t,s,a,i){pc.app.css3Renderer||(pc.app.css3Renderer=new pc.Css3Renderer),this._renderer=pc.app.css3Renderer,(e=document.createElement("div")).appendChild(i),e.iframe=i,i.dom=e,e.style.position="absolute",e.style.pointerEvents="auto",this.dom=e,t||(t=new pc.Entity,pc.app.root.addChild(t)),this.entity=t,this._renderer.addCamera(a).appendChild(e),this._maxWidth=1920,this._maxHeight=1080,s=s||this._maxWidth,this.pixelsPerWorldUnit=new pc.Vec2(s,s),this._renderer.addTarget(this),this._renderer.render()};return Css3Plane.prototype={updateTransform:function(){if(!pc.app.isFullscreened){var e,t,s,a=this.entity.getWorldTransform(),i=a.getScale(),r=Math.min(i.x*this.pixelsPerWorldUnit.x,this._maxWidth),n=Math.min(i.z*this.pixelsPerWorldUnit.y,this._maxHeight),l=(e=r,t=n,s=a.data,"translate(-50%,-50%)matrix3d("+epsilon(s[0]/e)+","+epsilon(s[1]/e)+","+epsilon(s[2]/e)+","+epsilon(s[3]/e)+","+epsilon(s[8]/t)+","+epsilon(s[9]/t)+","+epsilon(s[10]/t)+","+epsilon(s[11]/t)+","+epsilon(s[4])+","+epsilon(s[5])+","+epsilon(s[6])+","+epsilon(s[7])+","+epsilon(s[12])+","+epsilon(s[13])+","+epsilon(s[14])+","+epsilon(s[15])+")");this.dom.style.width=Math.round(r)+"px",this.dom.style.height=Math.round(n)+"px",this.dom.style.lineHeight=this.dom.style.height,this.dom.style.WebkitTransform=l,this.dom.style.transform=l}},blockEvents:function(e){this.dom.style.pointerEvents=e?"none":"auto"},attachPlane:function(e){this.entity=e},destroyPlane:function(){}},{Css3Renderer:Css3Renderer,Css3Plane:Css3Plane}}());var ControlsButton=pc.createScript("controlsButton");ControlsButton.attributes.add("action",{type:"number",default:0}),ControlsButton.attributes.add("target",{type:"string"}),ControlsButton.prototype.initialize=function(){this.entity.on("cursor:enter",this.onCursorEnter,this),this.entity.on("cursor:exit",this.onCursorExit,this),this.entity.on("cursor:down",this.onCursorDown,this),this.highlightEntity=this.entity.findByName("Glow")},ControlsButton.prototype.onCursorDown=function(t){0==this.action?this.app.fire("controls:close",{target:this.target}):1==this.action?this.app.fire("controls:max",{target:this.target}):3==this.action&&this.app.fire("controls:newtab",{target:this.target})},ControlsButton.prototype.onCursorEnter=function(t){document.body.style.cursor="pointer",this.highlightEntity.enabled=!0},ControlsButton.prototype.onCursorExit=function(){document.body.style.cursor="default",this.highlightEntity.enabled=!1};var SelectableMedia=pc.createScript("selectableMedia");SelectableMedia.attributes.add("mediaEntity",{type:"entity"}),SelectableMedia.prototype.initialize=function(){this.selectionCursor=this.app.root.children[0].script.selectionCursor,this.hasBeenInteracted=!1,this.app.on("media:select",this.onMediaSelect,this),this.app.on("media:deselect",this.onMediaDeselect,this),this.app.on("cursor:down:global",this.onCursorDownGlobal,this),this.entity.on("cursor:click",this.onCursorClick,this)},SelectableMedia.prototype.onCursorDownGlobal=function(e){if(e!=this.entity){var t=this.selectionCursor.selectedMediaEntity,i=this.selectionCursor.selectedMediaEntityCol;t==this.mediaEntity&&i==this.entity&&(this.selectionCursor.selectedMediaEntity=null,this.selectionCursor.selectedMediaEntityCol=null,this.app.fire("media:deselect",t,this.entity))}},SelectableMedia.prototype.onCursorClick=function(){var e=this.selectionCursor.selectedMediaEntity,t=this.selectionCursor.selectedMediaEntityCol;e&&t&&(e==this.mediaEntity&&t==this.entity||(this.selectionCursor.selectedMediaEntity=null,this.selectionCursor.selectedMediaEntityCol=null,this.app.fire("media:deselect",e,this.entity))),e==this.mediaEntity&&t==this.entity||(this.mediaEntity.script.iframePlane.iframe?(this.selectionCursor.selectedMediaEntity=this.mediaEntity,this.selectionCursor.selectedMediaEntityCol=this.entity,this.app.fire("media:select",this.mediaEntity,this.entity)):this.mediaEntity.script.iframePlane.activate()&&(this.selectionCursor.selectedMediaEntity=this.mediaEntity,this.selectionCursor.selectedMediaEntityCol=this.entity,this.app.fire("media:select",this.mediaEntity,this.entity),console.log("select")))},SelectableMedia.prototype.onMediaDeselect=function(e){e==this.mediaEntity&&(this.entity.enabled=!0,e.script.iframePlane._css3Plane.dom.style.pointerEvents="none",document.getElementById("application-canvas").style.pointerEvents="auto",e.script.iframePlane.controls.enabled=!1)},SelectableMedia.prototype.onMediaSelect=function(e,t){e==this.mediaEntity&&(this.hasBeenInteracted=!0,t==this.entity&&(this.entity.enabled=!1,this.entity.parent.findByName("LabelSlate").enabled=!1,e.script.iframePlane.iframe||e.script.iframePlane.activate(),e.script.iframePlane._css3Plane.dom.style.pointerEvents="auto",e.script.iframePlane.controls.enabled=!0,document.getElementById("application-canvas").style.pointerEvents="none"))};var HoverLabel=pc.createScript("hoverLabel");HoverLabel.prototype.initialize=function(){this.labelEntity=this.entity.parent.findByName("LabelSlate"),this.entity.on("cursor:enter",this.onCursorEnter,this),this.entity.on("cursor:exit",this.onCursorExit,this)},HoverLabel.prototype.onCursorEnter=function(){this.labelEntity&&(this.labelEntity.enabled=!0),document.body.style.cursor="pointer"},HoverLabel.prototype.onCursorExit=function(){this.labelEntity&&(this.labelEntity.enabled=!1),document.body.style.cursor="default"};var MediaObject=pc.createScript("mediaObject");MediaObject.attributes.add("dynamicMaterialName",{type:"string",title:"Dynamic Material Name",default:"DynamicImage"}),MediaObject.attributes.add("dynamicMaterial",{type:"asset",assetType:"material",title:"Dynamic Material"}),MediaObject.attributes.add("mediaObjectEntity",{type:"entity"}),MediaObject.prototype.initialize=function(){this.youTubeId=null,this.modelEntity=this.entity.findByName("Model"),this.selectableMediaEntity=this.entity.findByName("Col"),this.selectableMediaEntity.on("cursor:click",this.onCursorClick,this);this.clonedDynamicMaterial=this.dynamicMaterial.resource.clone();var e=this.modelEntity.model.material;if(e.name==this.dynamicMaterialName)e=this.clonedDynamicMaterial,this.modelEntity.model.material=e;else for(var t,i=0;i<this.modelEntity.model.meshInstances.length;i++)(e=(t=this.modelEntity.model.meshInstances[i]).material)&&e.name==this.dynamicMaterialName&&(e=this.clonedDynamicMaterial,t.material=e)},MediaObject.prototype.stop=function(){this.mediaObjectEntity.script.iframePlane._css3Plane?this.mediaObjectEntity.script.iframePlane._css3Plane.dom.src="":this.mediaObjectEntity.script.iframePlane.iframeUrl="",this.mediaObjectEntity.enabled=!1},MediaObject.prototype.assignMedia=function(e){var t="https://i.ytimg.com/vi/"+e+"/default.jpg";this.assignTextureImage(t),this.youTubeId=e},MediaObject.prototype.onCursorClick=function(){var e="https://www.youtube.com/embed/"+this.youTubeId+"?autoplay=1";this.mediaObjectEntity.script.iframePlane._css3Plane?this.mediaObjectEntity.script.iframePlane._css3Plane.dom.src=e:this.mediaObjectEntity.script.iframePlane.iframeUrl=e;var t=this.entity.findByName("MediaPlanePoint"),i=t.getPosition(),a=t.getRotation();this.mediaObjectEntity.setPosition(i.x,i.y,i.z),this.mediaObjectEntity.setRotation(a.x,a.y,a.z,a.w),this.mediaObjectEntity.enabled=!0},MediaObject.prototype.assignTextureImage=function(e){var t=this;var i=e;this.modelEntity.script.dynamicImage.loadTextureUrl(i).then((function onTextureLoad(e){var i=t.modelEntity.model.material;if(i.name==t.dynamicMaterialName)i.diffuseMap=e.resource,i.emissiveMap=e.resource,i.update();else for(var a=0;a<t.modelEntity.model.meshInstances.length;a++)(i=t.modelEntity.model.meshInstances[a].material)&&i.name==t.dynamicMaterialName&&(i.diffuseMap=e.resource,i.emissiveMap=e.resource,i.update())})).catch((function onTextureError(e){console.log(e)}))};var ShortcutObject=pc.createScript("shortcutObject");ShortcutObject.attributes.add("href",{type:"string"}),ShortcutObject.attributes.add("target",{type:"string",default:"_blank"}),ShortcutObject.prototype.initialize=function(){if(this.entity.on("cursor:enter",this.onCursorEnter,this),this.entity.on("cursor:exit",this.onCursorExit,this),this.entity.on("cursor:click",this.onCursorClick,this),this.highlightEntity=this.entity.parent.findByName("Highlight"),this.newIconEntity=this.entity.parent.findByName("NewIcon"),this.notHighlightEntity=this.entity.parent.findByName("NotHighlight"),this.app.on("hotspot:report",(function(){this.app.fire("hotspot:reporting",this.entity)}),this),this.worldDynamicLight=this.app.root.children[0].findByName("_dynamic_light"),!this.worldDynamicLight.hasOwnProperty("originalProperties")){var t={color:this.worldDynamicLight.light.color.clone(),intensity:this.worldDynamicLight.light.intensity,range:this.worldDynamicLight.light.range,innerConeAngle:this.worldDynamicLight.light.innerConeAngle,outerConeAngle:this.worldDynamicLight.light.outerConeAngle,position:this.worldDynamicLight.getPosition().clone(),rotation:this.worldDynamicLight.getRotation().clone()};this.worldDynamicLight.originalProperties=t}},ShortcutObject.prototype.postInitialize=function(){this.highlightEntity.enabled=!1,this.newIconEntity.enabled=!1,this.worldDynamicLight.enabled=!1},ShortcutObject.prototype.onCursorClick=function(t){this.app.fire("interaction",{entity:this.entity,href:this.href,target:this.target}),this.app.fire("hud:openLink",{entity:this.entity,href:this.href,target:this.target}),this.onCursorExit()},ShortcutObject.prototype.onCursorEnter=function(){document.body.style.cursor="pointer",this.notHighlightEntity&&(this.notHighlightEntity.enabled=!1),this.highlightEntity.enabled=!0;var t=localStorage.getItem("startpagescore");(t=t?JSON.parse(t):{usedUrls:[]}).usedUrls.indexOf(this.href)<0?this.newIconEntity.enabled=!0:this.newIconEntity.enabled=!1;var i=this.highlightEntity.findByName("_dynamic_light");if(i)for(var n in this.worldDynamicLight.enabled=!0,this.worldDynamicLight.originalProperties)if("position"==n){var o=i.getPosition();this.worldDynamicLight.setPosition(o.x,o.y,o.z)}else if("rotation"==n){var r=i.getRotation();this.worldDynamicLight.setRotation(r.x,r.y,r.z,r.w)}else this.worldDynamicLight.light[n]=i.light[n]},ShortcutObject.prototype.onCursorExit=function(){if(document.body.style.cursor="default",this.highlightEntity.enabled=!1,this.notHighlightEntity&&(this.notHighlightEntity.enabled=!0),this.highlightEntity.findByName("_dynamic_light"))for(var t in this.worldDynamicLight.enabled=!1,this.worldDynamicLight.originalProperties)"position"==t?this.worldDynamicLight.setPosition(this.worldDynamicLight.originalProperties[t].x,this.worldDynamicLight.originalProperties[t].y,this.worldDynamicLight.originalProperties[t].z):"rotation"==t?this.worldDynamicLight.setRotation(this.worldDynamicLight.originalProperties[t].x,this.worldDynamicLight.originalProperties[t].y,this.worldDynamicLight.originalProperties[t].z,this.worldDynamicLight.originalProperties[t].w):this.worldDynamicLight.light[t]=this.worldDynamicLight.originalProperties[t]};var ShortcutButton=pc.createScript("shortcutButton");ShortcutButton.attributes.add("href",{type:"string"}),ShortcutButton.attributes.add("target",{type:"string",default:"_blank"}),ShortcutButton.prototype.initialize=function(){this.entity.on("cursor:enter",this.onCursorEnter,this),this.entity.on("cursor:exit",this.onCursorExit,this),this.entity.on("cursor:click",this.onCursorClick,this),this.labelSlate=this.entity.parent.findByName("LabelSlate"),this.newIconEntity=this.entity.parent.findByName("NewIcon"),this.model=this.entity.parent.findByName("Icon").model,this.model.material=this.model.material.clone(),this.originalColor=this.model.material.emissive.clone(),this.app.on("hotspot:report",(function(){this.app.fire("hotspot:reporting",this.entity)}),this)},ShortcutButton.prototype.postInitialize=function(){this.labelSlate.enabled=!1,this.newIconEntity.enabled=!1},ShortcutButton.prototype.onCursorClick=function(){this.app.fire("interaction",{entity:this.entity,href:this.href,target:this.target}),this.app.fire("hud:openLink",{entity:this.entity,href:this.href,target:this.target}),this.onCursorExit()},ShortcutButton.prototype.onCursorEnter=function(t){document.body.style.cursor="pointer",this.labelSlate.enabled=!0,this.model.material.emissive=new pc.Color(255,255,255),this.model.material.update();var i=localStorage.getItem("startpagescore");(i=i?JSON.parse(i):{usedUrls:[]}).usedUrls.indexOf(this.href)<0?this.newIconEntity.enabled=!0:this.newIconEntity.enabled=!1;var o=this.labelSlate.findByName("_dynamic_light");if(o)for(var e in this.worldDynamicLight.enabled=!0,this.worldDynamicLight.originalProperties)if("position"==e){var r=o.getPosition();this.worldDynamicLight.setPosition(r.x,r.y,r.z)}else if("rotation"==e){var n=o.getRotation();this.worldDynamicLight.setRotation(n.x,n.y,n.z,n.w)}else this.worldDynamicLight.light[e]=o.light[e]},ShortcutButton.prototype.onCursorExit=function(t){if(document.body.style.cursor="default",this.labelSlate.enabled=!1,this.model.material.emissive=new pc.Color(this.originalColor.r,this.originalColor.g,this.originalColor.b),this.model.material.update(),this.labelSlate.findByName("_dynamic_light"))for(var i in this.worldDynamicLight.enabled=!1,this.worldDynamicLight.originalProperties)"position"==i?this.worldDynamicLight.setPosition(this.worldDynamicLight.originalProperties[i].x,this.worldDynamicLight.originalProperties[i].y,this.worldDynamicLight.originalProperties[i].z):"rotation"==i?this.worldDynamicLight.setRotation(this.worldDynamicLight.originalProperties[i].x,this.worldDynamicLight.originalProperties[i].y,this.worldDynamicLight.originalProperties[i].z,this.worldDynamicLight.originalProperties[i].w):this.worldDynamicLight.light[i]=this.worldDynamicLight.originalProperties[i]};var ChannelManager=pc.createScript("channelManager");ChannelManager.attributes.add("cameraEntity",{type:"entity"}),ChannelManager.prototype.initialize=function(){this.mediaObjects={},this.lastSpawnPoint=null,this.vec3=new pc.Vec3,this.spawnModeEntity=null,this.app.on("cursor:up:global",this.onCursorUpGlobal,this),this.app.on("cursor:move:global",this.onCursorMoveGlobal,this),this.mediaCabinets=this.app.root.findByName("MediaCabinets"),this.selectionCursor=this.app.root.children[0].script.selectionCursor,this.firebaseConfig={},this.channelRootRef=null},ChannelManager.prototype.onRemoteMediaObjectAdded=function(t,e){var i="MediaObject_"+t.key;if(!this.app.root.findByName(i)){var n=t.val();this.mediaObjects[t.key]=n;var a=this.mediaCabinets.findByName("flatscreen_tv").clone();a.name=i,a.networkId=t.key,this.app.root.addChild(a),a.setPosition(n.position.x,n.position.y,n.position.z),a.setEulerAngles(n.rotation.x,n.rotation.y,n.rotation.z),a.enabled=!0,a.script.mediaObject.assignMedia(n.youTubeId)}},ChannelManager.prototype.onRemoteMediaObjectRemoved=function(t){var e="MediaObject_"+t.key,i=this.app.root.findByName(e);if(i){i.findByName("MediaPlanePoint").getPosition().distance(i.script.mediaObject.mediaObjectEntity.getPosition())<.01&&i.script.mediaObject.stop(),i.destroy()}},ChannelManager.prototype.onRemoteMediaObjectChanged=function(t){var e=t.val();console.log("changed: ",e)},ChannelManager.prototype.syncMediaObject=function(t){var e;t.networkId||(e=this.channelRootRef.child("objects").push().key,t.networkId=e,t.name="MediaObject_"+e);var i=t.getPosition(),n=t.getEulerAngles(),a={youTubeId:t.script.mediaObject.youTubeId,position:{x:i.x,y:i.y,z:i.z},rotation:{x:n.x,y:n.y,z:n.z}};this.channelRootRef.child("objects").child(e).update(a)},ChannelManager.prototype.removeMediaObject=function(t){var e=t.networkId;this.selectionCursor.selectedMediaEntityCol==t.findByName("Col")&&t.script.mediaObject.stop(),t.destroy(),this.channelRootRef.child("objects").child(e).remove()},ChannelManager.prototype.enterSpawnMode=function(t){var e=this.mediaCabinets.findByName(t.cabinet);if(e){var i=e.clone();this.app.root.addChild(i),i.enabled=!0,i.script.mediaObject.assignMedia(t.youTubeId),this.spawnModeEntity=i,this.app.fire("spawnMode:enter",this.spawnModeEntity),document.body.style.cursor="grabbing"}},ChannelManager.prototype.onCursorUpGlobal=function(t){if(this.spawnModeEntity&&this.lastSpawnPoint){var e=this.spawnModeEntity;this.spawnModeEntity=null,this.lastSpawnPoint=null,document.body.style.cursor="default",this.app.fire("spawnMode:exit"),this.syncMediaObject(e)}},ChannelManager.prototype.onCursorMoveGlobal=function(t){if(this.spawnModeEntity){var e=t.raycast&&t.raycast.point?t.raycast.point:null;if(e){this.spawnModeEntity.setPosition(e.x,e.y,e.z);var i=this.cameraEntity.getPosition();this.vec3.set(i.x,e.y,i.z),this.spawnModeEntity.lookAt(this.vec3.x,this.vec3.y,this.vec3.z),this.spawnModeEntity.rotateLocal(0,180,0),this.lastSpawnPoint=e}}};var VideoTexture=pc.createScript("videoTexture");VideoTexture.attributes.add("video",{title:"Video",description:"MP4 video asset to play back on this video texture.",type:"asset"}),VideoTexture.attributes.add("playEvent",{title:"Play Event",description:"Event that is fired as soon as the video texture is ready to play.",type:"string",default:""}),VideoTexture.prototype.initialize=function(){var e=this.app,t=document.createElement("video");t.loop=!0,t.muted=!0,t.playsInline=!0,t.crossOrigin="anonymous",t.autoplay=!0;var i=t.style;i.width="1px",i.height="1px",i.position="absolute",i.opacity="0",i.zIndex="-1000",i.pointerEvents="none",document.body.appendChild(t),this.videoTexture=new pc.Texture(e.graphicsDevice,{format:pc.PIXELFORMAT_R8_G8_B8,minFilter:pc.FILTER_LINEAR_MIPMAP_LINEAR,magFilter:pc.FILTER_LINEAR,addressU:pc.ADDRESS_REPEAT,addressV:pc.ADDRESS_REPEAT,mipmaps:!0}),this.videoTexture.setSource(t),t.addEventListener("canplaythrough",function(i){e.fire(this.playEvent,this.videoTexture);try{t.play()}catch(i){}}.bind(this)),t.src=this.video?this.video.getFileUrl():this.videoUrl,document.body.appendChild(t),t.load()},VideoTexture.prototype.update=function(e){this.videoTexture.upload()};var TvScreen=pc.createScript("tvScreen");TvScreen.attributes.add("screenMaterials",{title:"Screen Material",description:"The screen material of the TV that displays the video texture.",type:"asset",assetType:"material",array:!0}),TvScreen.attributes.add("playEvent",{title:"Play Event",description:"Set the TV screen material emissive map on this event.",type:"string",default:""}),TvScreen.prototype.initialize=function(){this.app.on(this.playEvent,(function(e){for(var t=0;t<this.screenMaterials.length;t++){var a=this.screenMaterials[t].resource;a.emissiveMap=e,a.update()}}),this)};var LazyClock=pc.createScript("lazyClock");LazyClock.attributes.add("dateEntity",{type:"entity"}),LazyClock.attributes.add("timeEntity",{type:"entity"}),LazyClock.prototype.initialize=function(){this.lastMinutes=-1,this.lastDateString="",this.lastTimeString=""},LazyClock.prototype.update=function(t){var i=new Date,e=i.getMinutes();if(this.lastMinutes!=e){this.lastMinutes=e;var a=i.toDateString(),n=i.toLocaleTimeString(),s=n.lastIndexOf(":"),r=n.substring(s+1);n=n.substring(0,s),s=r.indexOf(" "),n+=r=r.substring(s),this.updateDateString(a),this.updateTimeString(n)}},LazyClock.prototype.updateDateString=function(t){this.lastDateString!=t&&(this.dateEntity.element.text=t,this.lastDateString=t)},LazyClock.prototype.updateTimeString=function(t){this.lastTimeString!=t&&(this.timeEntity.element.text=t,this.lastTimeString=t)};var Spin=pc.createScript("spin");Spin.attributes.add("speed",{type:"number",default:10,title:"Spin Speed"}),Spin.prototype.postUpdate=function(t){this.entity.rotateLocal(0,this.speed*t,0)};
//# sourceMappingURL=__game-scripts.js.map