-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__game-scripts.js
1 lines (1 loc) · 49 KB
/
__game-scripts.js
1
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 WonderingEye=pc.createScript("wonderingEye");WonderingEye.attributes.add("camera",{type:"entity"}),WonderingEye.attributes.add("cameraRig",{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.app.on("moveWonderingEye",this.onMoveWonderingEye,this),this.app.on("resetWonderingEye",this.onResetWonderingEye,this),this.originalRotation=this.camera.getRotation().clone(),this.originalPosition=this.camera.getPosition().clone(),this.originalLocalCameraRotation=this.camera.getLocalRotation().clone(),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.onMoveWonderingEye=function(t){this.camera.setPosition(t.getPosition().clone()),this.camera.setRotation(t.getRotation().clone()),this.camera.setLocalRotation(this.originalLocalCameraRotation),this.originalEulers=this.camera.getEulerAngles(),this.rotation=new pc.Quat,this.targetRotation=new pc.Quat,this.originRotation=new pc.Quat,this.lerpDuration=.5,this.lerpActive=!1},WonderingEye.prototype.onResetWonderingEye=function(){this.camera.setPosition(this.originalPosition),this.camera.setRotation(this.originRotation),this.camera.setLocalRotation(this.originalLocalCameraRotation),this.originalEulers=this.camera.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(){"low"==this.app.qualitySettings.preset&&(this.camera.camera.fov=80)},WonderingEye.prototype.onCursorMoveGlobal=function(t){var i=t.screen.x/window.innerWidth-.5,e=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*e-3),this.originalEulers.y+-60*i,0),this.lerpElapsed=0,this.lerpActive=!0},WonderingEye.prototype.onCursorWheelGlobal=function(t){this.onMouseWheel({wheelDelta:t})},WonderingEye.prototype.onMouseWheel=function(t){if(!this.app.inputPaused){var i=t.wheelDelta,e=this.camera.camera.fov;i>0?e+1<=90&&(e+=1):e-1>=40&&(e-=1),this.camera.camera.fov=e}},WonderingEye.prototype.update=function(t){if(this.lerpActive){this.lerpElapsed+=t;var i=this.lerpElapsed/this.lerpDuration;i>=1&&(i=1,this.lerpActive=!1),this.rotation.slerp(this.originRotation,this.targetRotation,i),this.camera.setRotation(this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)}};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.inputPaused=!1,this.app.on("pauseInput",this.onPauseInput,this),this.app.on("unpauseInput",this.onUnpauseInput,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.app.inputPaused=!0,this.hoveredEntity&&(this.unhoverEntity(this.hoveredEntity),this.hoveredEntity=null),this.clickedEntity&&(this.clickedEntity=null)},SelectionCursor.prototype.onUnpauseInput=function(){this.app.inputPaused=!1},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){var i=this.doRaycast({x:t.x,y:t.y}),e=i&&i.entity?i.entity:null;this.app.inputPaused||(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){var i=this.cameraEntity.getPosition(),e=this.cameraEntity.camera.screenToWorld(t.x,t.y,this.cameraEntity.camera.farClip);return(this.spawnModeEntity?this.app.systems.rigidbody.raycastFirstWithoutTag(i,e,"ui"):this.app.systems.rigidbody.raycastFirst(i,e))||null},SelectionCursor.prototype.onMouseWheel=function(t){this.app.fire("cursor:wheel:global",t.wheelDelta,this)},SelectionCursor.prototype.update=function(t){};var ShortcutButton=pc.createScript("shortcutButton");ShortcutButton.attributes.add("href",{type:"string"}),ShortcutButton.attributes.add("target",{type:"string",default:"_blank"}),ShortcutButton.attributes.add("trackNew",{type:"boolean",default:!1}),ShortcutButton.attributes.add("trackHotspot",{type:"boolean",default:!0}),ShortcutButton.attributes.add("trackOpenNewTab",{type:"boolean",default:!1}),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.newTabIcon=this.entity.parent.findByName("NewTabIcon"),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.trackHotspot&&this.app.on("hotspot:report",(function(){this.app.fire("hotspot:reporting",this.entity)}),this)},ShortcutButton.prototype.postInitialize=function(){this.labelSlate.enabled=!1,this.newIconEntity&&(this.newIconEntity.enabled=!1),this.newTabIcon&&(this.trackOpenNewTab?this.newTabIcon.enabled="_blank"==this.target:this.newTabIcon.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:[]},this.trackNew&&this.newIconEntity&&(i.usedUrls.indexOf(this.href)<0?this.newIconEntity.enabled=!0:this.newIconEntity.enabled=!1);var e=this.labelSlate.findByName("_dynamic_light");if(e)for(var o in this.worldDynamicLight.enabled=!0,this.worldDynamicLight.originalProperties)if("position"==o){var n=e.getPosition();this.worldDynamicLight.setPosition(n.x,n.y,n.z)}else if("rotation"==o){var r=e.getRotation();this.worldDynamicLight.setRotation(r.x,r.y,r.z,r.w)}else this.worldDynamicLight.light[o]=e.light[o]},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]};!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 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 ShortcutObject=pc.createScript("shortcutObject");ShortcutObject.attributes.add("href",{type:"string"}),ShortcutObject.attributes.add("target",{type:"string",default:"_blank"}),ShortcutObject.attributes.add("title",{type:"string",default:"Untitled Shortcut"}),ShortcutObject.attributes.add("description",{type:"string",default:"Shortcut description."}),ShortcutObject.attributes.add("screen",{type:"string",default:""}),ShortcutObject.attributes.add("screenAsset",{type:"asset",assetType:"texture"}),ShortcutObject.attributes.add("trackNew",{type:"boolean",default:!1}),ShortcutObject.attributes.add("trackHotspot",{type:"boolean",default:!0}),ShortcutObject.attributes.add("trackOpenNewTab",{type:"boolean",default:!1}),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.newTabIcon=this.entity.parent.findByName("NewTabIcon"),this.highlightEntity=this.entity.parent.findByName("Highlight"),this.newIconEntity=this.entity.parent.findByName("NewIcon"),this.notHighlightEntity=this.entity.parent.findByName("NotHighlight"),this.trackHotspot&&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&&(this.highlightEntity.enabled=!1),this.newIconEntity&&(this.newIconEntity.enabled=!1),this.newTabIcon&&(this.trackOpenNewTab?this.newTabIcon.enabled="_blank"==this.target:this.newTabIcon.enabled=!1),this.worldDynamicLight.enabled=!1},ShortcutObject.prototype.onCursorClick=function(t){this.app.fire("interaction",{entity:this.entity,href:this.href,target:this.target});var i=this.screen;!i&&this.screenAsset&&(i=this.screenAsset.getFileUrl()),this.app.fire("hud:openLink",{entity:this.entity,href:this.href,target:this.target,template:"moreinfo",screen:i,description:this.description,title:this.title}),this.onCursorExit()},ShortcutObject.prototype.onCursorEnter=function(){document.body.style.cursor="pointer",this.notHighlightEntity&&(this.notHighlightEntity.enabled=!1),this.highlightEntity&&(this.highlightEntity.enabled=!0);var t=localStorage.getItem("startpagescore");t=t?JSON.parse(t):{usedUrls:[]},this.trackNew&&this.newIconEntity&&(t.usedUrls.indexOf(this.href)<0?this.newIconEntity.enabled=!0:this.newIconEntity.enabled=!1);var i=this.highlightEntity?this.highlightEntity.findByName("_dynamic_light"):null;if(i)for(var e in this.worldDynamicLight.enabled=!0,this.worldDynamicLight.originalProperties)if("position"==e){var n=i.getPosition();this.worldDynamicLight.setPosition(n.x,n.y,n.z)}else if("rotation"==e){var h=i.getRotation();this.worldDynamicLight.setRotation(h.x,h.y,h.z,h.w)}else this.worldDynamicLight.light[e]=i.light[e]},ShortcutObject.prototype.onCursorExit=function(){if(document.body.style.cursor="default",this.highlightEntity&&(this.highlightEntity.enabled=!1),this.notHighlightEntity&&(this.notHighlightEntity.enabled=!0),this.highlightEntity?this.highlightEntity.findByName("_dynamic_light"):null)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 PosterImage=pc.createScript("posterImage");PosterImage.attributes.add("imageAsset",{type:"asset",assetType:"texture"}),PosterImage.attributes.add("dynamicAspectRatio",{type:"boolean",default:!0}),PosterImage.attributes.add("fixedWidth",{type:"boolean",default:!0}),PosterImage.attributes.add("fixedHeight",{type:"boolean",default:!0}),PosterImage.attributes.add("mouseHoverEntity",{type:"entity"}),PosterImage.prototype.initialize=function(){var t=this.entity.render.material.clone();if(this.entity.render.material=t,t.diffuseMap=this.imageAsset.resource,t.update(),this.mouseHoverEntity&&(this.mouseHoverEntity.on("cursor:enter",this.onCursorEnter,this),this.mouseHoverEntity.on("cursor:exit",this.onCursorExit,this)),this.dynamicAspectRatio){var e=this.entity.getLocalScale().clone();this.originalScale=e;var i=this.imageAsset.resource.width,s=this.imageAsset.resource.height,a=i/s,r=new pc.Vec3;this.fixedWidth&&this.fixedHeight?i>s?(r.x=e.x,r.y=e.y,r.z=e.z/a):i<s?(r.x=e.x*a,r.y=e.y,r.z=e.z):(r.x=e.x,r.y=e.y,r.z=e.z):this.fixedWidth&&!this.fixedHeight?(r.x=e.x,r.y=e.y,r.z=e.z/a):this.fixedHeight&&!this.fixedWidth&&(r.x=e.x*a,r.y=e.y,r.z=e.z),this.entity.setLocalScale(r.x,r.y,r.z)}},PosterImage.prototype.onCursorEnter=function(t){var e=this.entity.render.material;e.emissiveMap=e.diffuseMap,e.update()},PosterImage.prototype.onCursorExit=function(t){var e=this.entity.render.material;e.emissiveMap=null,e.update()};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(WebFont.load({google:{families:["Roboto:300,400,700"]}}),"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("htmlcontainer"),this.div.innerHTML=this.html.resource||"",document.body.appendChild(this.div);var r=this.div;r.addEventListener("mousemove",(function(e){e.preventDefault(),e.stopPropagation()})),r.addEventListener("mousedown",(function(e){e.preventDefault(),e.stopPropagation()})),r.addEventListener("mouseup",(function(e){e.preventDefault(),e.stopPropagation()})),r.addEventListener("click",(function(e){e.preventDefault(),e.stopPropagation()})),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(o,i){r&&r.checked&&!getLinkSetting(e.href)&&(t.push({href:e.href,method:"iframe"}),localStorage.setItem("linkSettings",JSON.stringify(t)));var a=!1,s=n.app.root.children[0].find((function(t){return t.script&&t.script.iframePlane&&t.script.iframePlane.frameName==e.target}));if(1==s.length){var l=s[0].script.iframePlane;l.iframe?(l.lastUsedUrl=e.href,l.iframe.lastUrl=e.href):(l.activate(e.href),a=!0)}return a||window.open(e.href,e.target),a}var o=getLinkSetting(e.href);if(o){if("newtab"==o.method)return launchNewTab(),n.closeMenu(),!0;if("iframe"==o.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="link";e.hasOwnProperty("template")&&e.template&&(t=e.template);var o=n.showMenu({name:t}),i=o.querySelector(".menuLinkPreview");if(i&&(i.value=e.href),r=o.querySelector(".linkRememberCheckbox"),"_blank"!=e.target&&"_self"!=e.target&&"verylow"==n.app.qualitySettings.preset){var a=o.querySelector(".menuLinkIframe");a.parentNode.style.display="block",a.addEventListener("click",(function(t){n.closeMenu(),openIframe(e.target,e.href)}))}if(o.querySelector(".menuLinkYes").addEventListener("click",(function(e){n.closeMenu(),launchNewTab()})),e.hasOwnProperty("screen")&&e.screen){e[u="screen"];for(var s=o.querySelectorAll('.menuLinkField[field="'+u+'"]'),l=0;l<s.length;l++)"innerText"==(d=(c=s[l]).getAttribute("attribute"))?(c.innerHTML="",c.appendChild(document.createTextNode(e[u]))):c.setAttribute(d,e[u])}if(e.hasOwnProperty("description")&&e.description)for(e[u="description"],s=o.querySelectorAll('.menuLinkField[field="'+u+'"]'),l=0;l<s.length;l++)"innerText"==(d=(c=s[l]).getAttribute("attribute"))?(c.innerHTML="",c.appendChild(document.createTextNode(e[u]))):c.setAttribute(d,e[u]);if(e.hasOwnProperty("title")&&e.title){var u,c,d;for(e[u="title"],s=o.querySelectorAll('.menuLinkField[field="'+u+'"]'),l=0;l<s.length;l++)"innerText"==(d=(c=s[l]).getAttribute("attribute"))?(c.innerHTML="",c.appendChild(document.createTextNode(e[u]))):c.setAttribute(d,e[u])}}},Hud.prototype.showMenu=function(e){this.closeMenu(),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"),o=this,i=n.querySelectorAll(".closeButton"),a=0;a<i.length;a++)i[a].addEventListener("click",(function(){o.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.fire("unpauseInput"))},Hud.prototype.tweet=function(){const e="https://twitter.com/intent/tweet?url=https://m3org.com/mfshop&text="+encodeURIComponent("Checkin' out this #3dstorefront by @TheMetaFactory & talking with the robot clerk about #NFTNYC & how to look good while metaverse hopping.");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;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 o=document.querySelector("#application-canvas");o.style.display="none",r.querySelector(".menuControlRestore").addEventListener("click",(function(e){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),o.style.display="block",r.remove(),n.app.fire("unpauseInput")})),r.querySelector(".menuControlClose").addEventListener("click",(function(i){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),o.style.display="block",r.remove(),n.app.fire("unpauseInput"),n.app.fire("controls:close",{target:e.target})})),r.querySelector(".menuControlNewTab").addEventListener("click",(function(i){t.classList.remove("fullscreenIframe"),t.oldParent.classList.remove("fullscreenActive"),document.body.classList.remove("fullscreenBodyMode"),o.style.display="block",r.remove(),n.app.fire("unpauseInput"),n.app.fire("controls:close",{target:e.target});var a=t.lastUrl;a||(a=opt.href),window.open(a,"_blank")}))}};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)}};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://cdn.discordapp.com/attachments/503271871328813260/971128354679951430/mflogo.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 Ufo=pc.createScript("ufo");Ufo.attributes.add("target",{type:"entity"}),Ufo.attributes.add("duration",{type:"number",default:7}),Ufo.attributes.add("minWait",{type:"number",default:12}),Ufo.attributes.add("maxWait",{type:"number",default:60}),Ufo.prototype.initialize=function(){this.elapsed=0,this.startPos=this.entity.getPosition().clone(),this.targetPos=this.target.getPosition().clone(),this.state=0,this.testElapsed=0,this.lerpVal=new pc.Vec3;var t=Math.random()*(this.maxWait-this.minWait);this.testElapsed=this.minWait+t},Ufo.prototype.fly=function(){this.state=1,this.elapsed=0;var t=Math.random()*(this.maxWait-this.minWait);this.testElapsed=this.minWait+t,this.entity.sound.play("fly")},Ufo.prototype.update=function(t){if(1!=this.state)return this.testElapsed-=t,void(this.testElapsed<=0&&this.fly());this.elapsed+=t;var i=!1;if(this.elapsed>=this.duration&&(this.elapsed=this.duration,i=!0),i)this.entity.setPosition(this.startPos),this.state=0;else{var s=this.elapsed/this.duration;this.lerpVal.lerp(this.startPos,this.targetPos,s),this.entity.setPosition(this.lerpVal)}};var Clerk=pc.createScript("clerk");Clerk.attributes.add("cameraDummy",{type:"entity"}),Clerk.attributes.add("roboFace",{type:"entity"}),Clerk.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)},Clerk.prototype.onCursorClick=function(t){this.app.fire("moveWonderingEye",this.cameraDummy),this.app.fire("quest:clue")},Clerk.prototype.onCursorEnter=function(){document.body.style.cursor="pointer",this.roboFace.enabled=!0},Clerk.prototype.onCursorExit=function(){document.body.style.cursor="default",this.roboFace.enabled=!1};var Ezquest=pc.createScript("ezquest");function loadAJavaScript(e){return console.log("loading javascript: "+e),new Promise((function(t,n){var s=document.createElement("script");s.type="text/javascript",s.src=e,s.addEventListener("load",t),document.getElementsByTagName("head")[0].appendChild(s)}))}Ezquest.attributes.add("cluecornerasset",{type:"asset",assetType:"texture"}),Ezquest.attributes.add("dialogueiconasset",{type:"asset",assetType:"texture"}),Ezquest.prototype.initialize=function(){this.div=null,this.app.on("quest:clue",this.onQuestClue,this)},Ezquest.prototype.onQuestClue=function(){this.createQuestDialogue()},Ezquest.prototype.destroyQuestDialogue=function(){this.div.remove(),this.div=null,this.app.fire("unpauseInput")},Ezquest.prototype.createQuestDialogue=function(){this.app.fire("pauseInput");var e=this,t=document.body.querySelector(".ezquestContainerHTML").value,n=this.cluecornerasset.getFileUrl();t=t.replace(/ASSETURL_cluecorner/g,n),this.div=document.createElement("div"),this.div.className="ezquestContainer",this.div.innerHTML=t,document.body.appendChild(this.div);var arcadeHud_generateIconHTML=function(e,t,n,s){return'<img src="'+e+'" style="width: '+t+"px; height: "+n+'px;" />'},s={id:"testQuestId",_template:"gossip",title:"Test Quest Title",objective:"Talk to the clerk.",dialogue:"",spin:"0",type:1,interact:"useRepeatable",presence:"always",visibility:"untilSuccess",initial:"active"};s.dialogue=document.querySelector("#testQuestText").value;var a,i,r="Hello World.",o=s,u=o.dialogue,l=this.div.querySelector("#comicCorner");1==o.type&&(l.style.display="block");var p=document.querySelector("#questDialogue"),d=document.querySelector("#interactIcon"),c=document.querySelector("#interactButton"),g=document.querySelector("#questResponsesLeft"),h=document.querySelector("#questResponsesRight");function doDialogueSuccess(){console.log("win event!")}function doDialogueFailure(){console.log("fail event. :("),aaapi.cmd("questDialogueEvent","testQuestId","testClueId","failure")}function exitDialogue(){e.destroyQuestDialogue(),e.app.fire("resetWonderingEye")}function addQuestResponse(e,t){var n=document.createElement("div");n.className="questResponse",n.dialogue=t,n.addEventListener("click",function(){if(this.dialogue.hasOwnProperty("response_action"))if(this.dialogue.response_action.indexOf("success")>=0)doDialogueSuccess();else if(this.dialogue.response_action.indexOf("failure")>=0)doDialogueFailure();else if(this.dialogue.response_action.indexOf("jump")>=0)showQuestDialogue(this.dialogue.branch_parent,0);else if(this.dialogue.response_action.indexOf("jump2")>=0)showQuestDialogue(this.dialogue.branch_grandparent,0);else if(this.dialogue.response_action.indexOf("jump3")>=0)showQuestDialogue(this.dialogue.branch_greatgrandparent,0);else if(this.dialogue.response_action.indexOf("jumplite")>=0){var e=this.dialogue.branch_grandparent.quest_text.length>0?this.dialogue.branch_grandparent.quest_text.length-1:0;showQuestDialogue(this.dialogue.branch_grandparent,e)}else if(this.dialogue.response_action.indexOf("jumplite2")>=0){e=this.dialogue.branch_greatgrandparent.quest_text.length>0?this.dialogue.branch_greatgrandparent.quest_text.length-1:0;showQuestDialogue(this.dialogue.branch_greatgrandparent,e)}else if(this.dialogue.response_action.indexOf("jumplite3")>=0){e=this.dialogue.branch_greatgreatgrandparent.quest_text.length>0?this.dialogue.branch_greatgreatgrandparent.quest_text.length-1:0;showQuestDialogue(this.dialogue.branch_greatgreatgrandparent,e)}else if(this.dialogue.response_action.indexOf("menu3")>=0){if(this.dialogue.branch_greatgrandparent.hasOwnProperty("responses")&&this.dialogue.branch_greatgrandparent.responses.length>0){var t=this.dialogue.branch_greatgrandparent.quest_text.length-1;updateResponses(this.dialogue.branch_greatgrandparent,t),a=this.dialogue.branch_greatgrandparent,i=t}}else if(this.dialogue.response_action.indexOf("menu2")>=0){if(this.dialogue.branch_grandparent.hasOwnProperty("responses")&&this.dialogue.branch_grandparent.responses.length>0){t=this.dialogue.branch_grandparent.quest_text.length-1;updateResponses(this.dialogue.branch_grandparent,t),a=this.dialogue.branch_grandparent,i=t}}else if(this.dialogue.response_action.indexOf("menu")>=0){if(this.dialogue.branch_parent.hasOwnProperty("responses")&&this.dialogue.branch_parent.responses.length>0){t=this.dialogue.branch_parent.quest_text.length-1;updateResponses(this.dialogue.branch_parent,t),a=this.dialogue.branch_parent,i=t}}else this.dialogue.response_action.indexOf("exit")>=0&&exitDialogue();this.dialogue&&this.dialogue.hasOwnProperty("quest_text")?showQuestDialogue(this.dialogue,0):(!this.dialogue.hasOwnProperty("response_action")||this.dialogue.response_action.indexOf("exit")<0&&this.dialogue.response_action.indexOf("jump")<0&&this.dialogue.response_action.indexOf("jump2")<0&&this.dialogue.response_action.indexOf("jump3")<0&&this.dialogue.response_action.indexOf("jumplite")&&this.dialogue.response_action.indexOf("jumplite2")<0&&this.dialogue.response_action.indexOf("jumplite3")<0&&this.dialogue.response_action.indexOf("menu")<0&&this.dialogue.response_action.indexOf("menu2")<0&&this.dialogue.response_action.indexOf("menu3")<0)&&exitDialogue()}.bind(n)),n.appendChild(document.createTextNode(t.response_text)),e.appendChild(n)}function updateResponses(t,n){if(delete c.action,t.quest_text.length==n+1&&t.hasOwnProperty("quest_action")&&t.quest_action.indexOf("menu")>=0&&t.branch_parent&&t.branch_parent.responses.length>0&&t.branch_parent.quest_text&&t.branch_parent.quest_text.length>0){var s=t.branch_parent.quest_text.length-1;updateResponses(t.branch_parent,s)}else if(t.quest_text.length==n+1&&t.hasOwnProperty("quest_action")&&t.quest_action.indexOf("menu2")>=0&&t.branch_grandparent&&t.branch_grandparent.responses.length>0&&t.branch_grandparent.quest_text&&t.branch_grandparent.quest_text.length>0){s=t.branch_grandparent.quest_text.length-1;updateResponses(t.branch_grandparent,s)}else if(t.quest_text.length==n+1&&t.hasOwnProperty("quest_action")&&t.quest_action.indexOf("menu3")>=0&&t.branch_greatgrandparent&&t.branch_greatgrandparent.responses.length>0&&t.branch_greatgrandparent.quest_text&&t.branch_greatgrandparent.quest_text.length>0){s=t.branch_greatgrandparent.quest_text.length-1;updateResponses(t.branch_greatgrandparent,s)}else{var a=!1;if(t.quest_text.length>1&&t.quest_text.length-1>n)d.innerHTML="<div style='font-size: 24px; display: inline; font-family: Arial; pointer-events: none;'>Next</div>";else if(t.hasOwnProperty("responses")&&t.responses.length>0){a=!0;var i=arcadeHud_generateIconHTML(e.dialogueiconasset.getFileUrl(),64,64,"aaTextColorTwoColor");d.innerHTML=i}else t.hasOwnProperty("quest_action")?t.quest_action.indexOf("exit")>=0||t.quest_action.indexOf("success")>=0||t.quest_action.indexOf("failure")>=0?(c.action=t.quest_action,d.innerHTML="<div style='font-size: 24px; display: inline; font-family: Arial; pointer-events: none;'>Done</div>"):(t.quest_action.indexOf("jump")>=0||t.quest_action.indexOf("jump2")>=0||t.quest_action.indexOf("jump3")>=0||t.quest_action.indexOf("jumplite")>=0||t.quest_action.indexOf("jumplite2")>=0||t.quest_action.indexOf("jumplite3")>=0||t.quest_action.indexOf("menu")>=0||t.quest_action.indexOf("menu2")>=0||t.quest_action.indexOf("menu3")>=0)&&(c.action=t.quest_action,d.innerHTML="<div style='font-size: 24px; display: inline; font-family: Arial; pointer-events: none;'>OK</div>"):d.innerHTML="<div style='font-size: 24px; display: inline; font-family: Arial; pointer-events: none;'>OK</div>";if(c.style.pointerEvents=a?"none":"all",g.innerHTML="",h.innerHTML="",a&&t.hasOwnProperty("responses")){for(var r=0;r<Math.round(t.responses.length/2);r++)addQuestResponse(g,t.responses[r]);for(r=Math.round(t.responses.length/2);r<t.responses.length;r++)addQuestResponse(h,t.responses[r])}}}function showQuestDialogue(e,t){var n=void 0===t?0:t;p.innerHTML="",p.appendChild(document.createTextNode(e.quest_text[n]));if("["!=e.quest_text[n][0]||"]"!=e.quest_text[n][e.quest_text[n].length-1]){r=e.quest_text[n],window.speechSynthesis.cancel();var s=r;s=s.replace(/d00dz/g,"dudes"),window.speechSynthesis.speak(new SpeechSynthesisUtterance(s))}updateResponses(e,n),a=e,i=n}c.addEventListener("click",(function(){if(a.quest_text.length>i+1)i++,showQuestDialogue(a,i);else if(this.hasOwnProperty("action"))if(this.action.indexOf("success")>=0)doDialogueSuccess(),exitDialogue();else if(this.action.indexOf("failure")>=0)doDialogueFailure(),exitDialogue();else if(this.action.indexOf("jump")>=0)showQuestDialogue(a.branch_parent,0);else if(this.action.indexOf("jump2")>=0)showQuestDialogue(a.branch_grandparent,0);else if(this.action.indexOf("jump3")>=0)showQuestDialogue(a.branch_greatgrandparent,0);else if(this.action.indexOf("jumplite")>=0){var e=a.branch_parent.quest_text.length>0?a.branch_parent.quest_text.length-1:0;showQuestDialogue(a.branch_parent,e)}else if(this.action.indexOf("jumplite2")>=0){e=a.branch_grandparent.quest_text.length>0?a.branch_grandparent.quest_text.length-1:0;showQuestDialogue(a.branch_grandparent,e)}else if(this.action.indexOf("jumplite3")>=0){e=a.branch_greatgrandparent.quest_text.length>0?a.branch_greatgrandparent.quest_text.length-1:0;showQuestDialogue(a.branch_greatgrandparent,e)}else if(this.action.indexOf("menu3")>=0){if(a.branch_greatgrandparent.hasOwnProperty("responses")&&a.branch_greatgrandparent.responses.length>0){var t=a.branch_greatgrandparent.quest_text.length-1;updateResponses(a.branch_greatgrandparent,t),a=a.branch_greatgrandparent,i=t}}else if(this.action.indexOf("menu2")>=0){if(a.branch_grandparent.hasOwnProperty("responses")&&a.branch_grandparent.responses.length>0){t=a.branch_grandparent.quest_text.length-1;updateResponses(a.branch_grandparent,t),a=a.branch_grandparent,i=t}}else if(this.action.indexOf("menu")>=0){if(a.branch_parent.hasOwnProperty("responses")&&a.branch_parent.responses.length>0){t=a.branch_parent.quest_text.length-1;updateResponses(a.branch_parent,t),a=a.branch_parent,i=t}}else this.action.indexOf("exit")>=0&&exitDialogue();else console.log("Unhandled quest response."),exitDialogue()}));var _=function parseRawDialogue(e){function findFirstNotOf(e,t){for(var n=0;n<e.length;n++)if(e[n]!=t)return n;return-1}function getTextActions(e){var t=e.match(/(\[[^\]]+\])+\r?$/g);if(t){if(Array.isArray(t)&&t.length>0){t=t[0].split(/[\[\]]+/).filter((function(e){return e}))}}else t=[];var n=["exit","success","failure","jump","jump2","jump3","jumplite","jumplite2","jumplite3","menu","menu2","menu3"];t.reverse();for(var s=0;s<t.length;s++)if(n.indexOf(t[s])<0){t.splice(s);break}return t.reverse(),t}function composeResult(e,t,n,s,a){var i={};return t.length>0&&(i.quest_text=t),n.length>0&&(i.quest_action=n),""!=s&&(i.response_text=s),a.length>0&&(i.responses=a),{numLines:e,dialogue:i}}if(""!=e){var t=e.match(/[^\r\n]+/g);if(0!=t.length){if("\t"!=t[0][0]){var n=function parseDialogueBlock(e){if(e>=t.length)return{numLines:0,dialogue:{}};var n,s=findFirstNotOf(t[e],"\t"),a=[],i=[],r=[];for(n=e;n<t.length;n++){var o="",u=t[n],l=findFirstNotOf(u,"\t"),p=l-s,d=l%2==1,c=!d,g=h,h=getTextActions(u);if(h.length>0){for(var _=u.length,f=0;f<h.length;f++)_-=h[f].length+2;u=u.substring(0,_)}if(0==p){if(d)return x=composeResult(n-e,a,i,o,r);c&&a.push(u.trim())}else if(p>0){n+=(x=parseDialogueBlock(n+1)).numLines,d&&(x.dialogue.response_text=u.trim(),h.length>0&&(x.dialogue.response_action=h),r.push(x.dialogue),h=[])}else if(p<0){var x;return x=composeResult(n-e,a,g,o,r)}}return x=composeResult(n-e,a,h,o,r)}(0),s=n.dialogue;return console.log(s),s}console.log("Parsing Error: Dialogue cannot start with a TAB character.")}else console.log("Parsing Error: Dialogue cannot be empty.")}else console.log("Parsing Error: Dialogue cannot be empty.")}(u);!function processDialogueTree(e,t,n,s,a){e.branch_parent=t,e.branch_grandparent=n,e.branch_greatgrandparent=s,e.branch_greatgreatgrandparent=a;var i=t,r=n,o=s,u=a;if(e.hasOwnProperty("responses")){e.responses.length>1&&(u=o,o=r,r=i,i=e);for(var l=0;l<e.responses.length;l++)processDialogueTree(e.responses[l],i,r,o,u)}}(_),showQuestDialogue(_,0)},Ezquest.prototype.postInitializex=function(){document.body.innerHTML="";var e=document.createElement("script");e.src="https://code.responsivevoice.org/responsivevoice.js?key=lsbSYU7R",document.body.appendChild(e)};