@playcanvas/web-components 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pwc.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("playcanvas")):"function"==typeof define&&define.amd?define(["exports","playcanvas"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pd={},t.pc)}(this,(function(t,e){"use strict";class s extends HTMLElement{constructor(){super(),this._readyPromise=new Promise((t=>{this._readyResolve=t}))}get closestApp(){var t;return null===(t=this.parentElement)||void 0===t?void 0:t.closest("pc-app")}get closestEntity(){var t;return null===(t=this.parentElement)||void 0===t?void 0:t.closest("pc-entity")}_onReady(){this._readyResolve(),this.dispatchEvent(new CustomEvent("ready"))}ready(){return this._readyPromise.then((()=>this))}}class i extends HTMLElement{constructor(){super(),this.loadPromise=this.loadModule()}async loadModule(){const t=this.getAttribute("name"),s=this.getAttribute("glue"),i=this.getAttribute("wasm"),n=this.getAttribute("fallback");"Basis"===t?e.basisInitialize({glueUrl:s,wasmUrl:i,fallbackUrl:n}):(e.WasmModule.setConfig(t,{glueUrl:s,wasmUrl:i,fallbackUrl:n}),await new Promise((s=>{e.WasmModule.getInstance(t,(()=>s()))})))}getLoadPromise(){return this.loadPromise}}customElements.define("pc-module",i);class n extends s{constructor(){super(),this._canvas=null,this._alpha=!0,this._antialias=!0,this._depth=!0,this._stencil=!0,this._highResolution=!0,this._hierarchyReady=!1,this._picker=null,this._hasPointerListeners={pointerenter:!1,pointerleave:!1,pointerdown:!1,pointerup:!1,pointermove:!1},this._hoveredEntity=null,this._pointerHandlers={pointermove:null,pointerdown:null,pointerup:null},this.app=null,this._onWindowResize=this._onWindowResize.bind(this)}async connectedCallback(){const t=this.querySelectorAll(":scope > pc-module");await Promise.all(Array.from(t).map((t=>t.getLoadPromise()))),this._canvas=document.createElement("canvas"),this.appendChild(this._canvas),this.app=new e.Application(this._canvas,{graphicsDeviceOptions:{alpha:this._alpha,antialias:this._antialias,depth:this._depth,stencil:this._stencil},keyboard:new e.Keyboard(window),mouse:new e.Mouse(this._canvas)}),this.app.graphicsDevice.maxPixelRatio=this._highResolution?window.devicePixelRatio:1,this.app.setCanvasFillMode(e.FILLMODE_FILL_WINDOW),this.app.setCanvasResolution(e.RESOLUTION_AUTO),this._pickerCreate();const s=this.querySelectorAll(":scope > pc-asset");Array.from(s).forEach((t=>{t.createAsset();const e=t.asset;e&&this.app.assets.add(e)}));const i=this.querySelectorAll(":scope > pc-material");Array.from(i).forEach((t=>{t.createMaterial()}));const n=this.querySelectorAll("pc-entity");Array.from(n).forEach((t=>{t.createEntity(this.app)})),n.forEach((t=>{t.buildHierarchy(this.app)})),this._hierarchyReady=!0,this.app.preload((()=>{this.app.start(),window.addEventListener("resize",this._onWindowResize),this._onReady()}))}disconnectedCallback(){this._pickerDestroy(),this.app&&(this.app.destroy(),this.app=null),window.removeEventListener("resize",this._onWindowResize),this._canvas&&this.contains(this._canvas)&&(this.removeChild(this._canvas),this._canvas=null)}_onWindowResize(){this.app&&this.app.resizeCanvas()}_pickerCreate(){const{width:t,height:s}=this.app.graphicsDevice;this._picker=new e.Picker(this.app,t,s),this._pointerHandlers.pointermove=this._onPointerMove.bind(this),this._pointerHandlers.pointerdown=this._onPointerDown.bind(this),this._pointerHandlers.pointerup=this._onPointerUp.bind(this),["pointermove","pointerdown","pointerup","pointerenter","pointerleave"].forEach((t=>{this.addEventListener(`${t}:connect`,(()=>this._onPointerListenerAdded(t))),this.addEventListener(`${t}:disconnect`,(()=>this._onPointerListenerRemoved(t)))}))}_pickerDestroy(){this._canvas&&Object.entries(this._pointerHandlers).forEach((([t,e])=>{e&&this._canvas.removeEventListener(t,e)})),this._picker=null,this._pointerHandlers={pointermove:null,pointerdown:null,pointerup:null}}_getPickerCoordinates(t){const e=this._canvas.getBoundingClientRect(),s=this._canvas.width/e.width,i=this._canvas.height/e.height;return{x:(t.clientX-e.left)*s,y:(t.clientY-e.top)*i}}_onPointerMove(t){if(!this._picker||!this.app)return;const e=this.app.root.findComponent("camera");if(!e)return;const{x:s,y:i}=this._getPickerCoordinates(t);this._picker.prepare(e,this.app.scene);const n=this._picker.getSelection(s,i);let a=null;if(n.length>0){let t=n[0].node;for(;null!==t;){const e=this.querySelector(`pc-entity[name="${t.name}"]`);if(e){a=e;break}t=t.parent}}this._hoveredEntity!==a&&(this._hoveredEntity&&this._hoveredEntity.hasListeners("pointerleave")&&this._hoveredEntity.dispatchEvent(new PointerEvent("pointerleave",t)),a&&a.hasListeners("pointerenter")&&a.dispatchEvent(new PointerEvent("pointerenter",t))),this._hoveredEntity=a,a&&a.hasListeners("pointermove")&&a.dispatchEvent(new PointerEvent("pointermove",t))}_onPointerDown(t){if(!this._picker||!this.app)return;const e=this.app.root.findComponent("camera");if(!e)return;const{x:s,y:i}=this._getPickerCoordinates(t);this._picker.prepare(e,this.app.scene);const n=this._picker.getSelection(s,i);if(n.length>0){let e=n[0].node;for(;null!==e;){const s=this.querySelector(`pc-entity[name="${e.name}"]`);if(s&&s.hasListeners("pointerdown")){s.dispatchEvent(new PointerEvent("pointerdown",t));break}e=e.parent}}}_onPointerUp(t){if(!this._picker||!this.app)return;const e=this.app.root.findComponent("camera");if(!e)return;const{x:s,y:i}=this._getPickerCoordinates(t);this._picker.prepare(e,this.app.scene);const n=this._picker.getSelection(s,i);if(n.length>0){const e=this.querySelector(`pc-entity[name="${n[0].node.name}"]`);e&&e.hasListeners("pointerup")&&e.dispatchEvent(new PointerEvent("pointerup",t))}}_onPointerListenerAdded(t){if(!this._hasPointerListeners[t]&&this._canvas){this._hasPointerListeners[t]=!0;const e="pointerenter"===t||"pointerleave"===t?this._pointerHandlers.pointermove:this._pointerHandlers[t];e&&this._canvas.addEventListener("pointerenter"===t||"pointerleave"===t?"pointermove":t,e)}}_onPointerListenerRemoved(t){if(!Array.from(this.querySelectorAll("pc-entity")).some((e=>e.hasListeners(t)))&&this._canvas){this._hasPointerListeners[t]=!1;const e="pointerenter"===t||"pointerleave"===t?this._pointerHandlers.pointermove:this._pointerHandlers[t];e&&this._canvas.removeEventListener("pointerenter"===t||"pointerleave"===t?"pointermove":t,e)}}set alpha(t){this._alpha=t}get alpha(){return this._alpha}set antialias(t){this._antialias=t}get antialias(){return this._antialias}set depth(t){this._depth=t}get depth(){return this._depth}get hierarchyReady(){return this._hierarchyReady}set highResolution(t){this._highResolution=t,this.app&&(this.app.graphicsDevice.maxPixelRatio=t?window.devicePixelRatio:1)}get highResolution(){return this._highResolution}set stencil(t){this._stencil=t}get stencil(){return this._stencil}static get observedAttributes(){return["alpha","antialias","depth","stencil","high-resolution"]}attributeChangedCallback(t,e,s){switch(t){case"alpha":this.alpha="false"!==s;break;case"antialias":this.antialias="false"!==s;break;case"depth":this.depth="false"!==s;break;case"high-resolution":this.highResolution="false"!==s;break;case"stencil":this.stencil="false"!==s}}}customElements.define("pc-app",n);const a={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},o=t=>{const s=a[t.toLowerCase()];if(s)return(new e.Color).fromString(s);if(t.startsWith("#"))return(new e.Color).fromString(t);const i=t.split(" ").map(Number);return new e.Color(i)},r=t=>{const s=t.split(" ").map(Number);return new e.Vec2(s)},h=t=>{const s=t.split(" ").map(Number);return new e.Vec3(s)},c=t=>{const s=t.split(" ").map(Number);return new e.Vec4(s)};class l extends s{constructor(){super(...arguments),this._enabled=!0,this._name="Untitled",this._position=new e.Vec3,this._rotation=new e.Vec3,this._scale=new e.Vec3(1,1,1),this._tags=[],this._listeners={},this.entity=null}createEntity(t){this.entity=new e.Entity(this.getAttribute("name")||this._name,t);const s=this.getAttribute("enabled");s&&(this.entity.enabled="false"!==s);const i=this.getAttribute("position");i&&this.entity.setLocalPosition(h(i));const n=this.getAttribute("rotation");n&&this.entity.setLocalEulerAngles(h(n));const a=this.getAttribute("scale");a&&this.entity.setLocalScale(h(a));const o=this.getAttribute("tags");o&&this.entity.tags.add(o.split(",").map((t=>t.trim())));["onpointerenter","onpointerleave","onpointerdown","onpointerup","onpointermove"].forEach((t=>{const e=this.getAttribute(t);if(e){const s=t.substring(2),i=t=>{try{new Function("event",e).call(this,t)}catch(t){console.error("Error in event handler:",t)}};this.addEventListener(s,i)}}))}buildHierarchy(t){if(!this.entity)return;const e=this.closestEntity;(null==e?void 0:e.entity)?e.entity.addChild(this.entity):t.root.addChild(this.entity),this._onReady()}connectedCallback(){const t=this.closestApp;if(t&&t.hierarchyReady){const e=t.app;this.createEntity(e),this.buildHierarchy(e);const s=this.querySelectorAll("pc-entity");s.forEach((t=>{t.createEntity(e)})),s.forEach((t=>{t.buildHierarchy(e)}))}}disconnectedCallback(){if(this.entity){this.querySelectorAll("pc-entity").forEach((t=>{t.entity=null})),this.entity.destroy(),this.entity=null}}set enabled(t){this._enabled=t,this.entity&&(this.entity.enabled=t)}get enabled(){return this._enabled}set name(t){this._name=t,this.entity&&(this.entity.name=t)}get name(){return this._name}set position(t){this._position=t,this.entity&&this.entity.setLocalPosition(this._position)}get position(){return this._position}set rotation(t){this._rotation=t,this.entity&&this.entity.setLocalEulerAngles(this._rotation)}get rotation(){return this._rotation}set scale(t){this._scale=t,this.entity&&this.entity.setLocalScale(this._scale)}get scale(){return this._scale}set tags(t){this._tags=t,this.entity&&(this.entity.tags.clear(),this.entity.tags.add(this._tags))}get tags(){return this._tags}static get observedAttributes(){return["enabled","name","position","rotation","scale","tags","onpointerenter","onpointerleave","onpointerdown","onpointerup","onpointermove"]}attributeChangedCallback(t,e,s){switch(t){case"enabled":this.enabled="false"!==s;break;case"name":this.name=s;break;case"position":this.position=h(s);break;case"rotation":this.rotation=h(s);break;case"scale":this.scale=h(s);break;case"tags":this.tags=s.split(",").map((t=>t.trim()));break;case"onpointerenter":case"onpointerleave":case"onpointerdown":case"onpointerup":case"onpointermove":if(s){const e=t.substring(2),s=t=>{try{const s=this.getAttribute(e)||"";new Function("event",s).call(this,t)}catch(t){console.error("Error in event handler:",t)}};this.addEventListener(e,s)}}}addEventListener(t,e,s){this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),super.addEventListener(t,e,s),t.startsWith("pointer")&&this.dispatchEvent(new CustomEvent(`${t}:connect`,{bubbles:!0}))}removeEventListener(t,e,s){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter((t=>t!==e))),super.removeEventListener(t,e,s),t.startsWith("pointer")&&this.dispatchEvent(new CustomEvent(`${t}:disconnect`,{bubbles:!0}))}hasListeners(t){var e;return Boolean(null===(e=this._listeners[t])||void 0===e?void 0:e.length)}}customElements.define("pc-entity",l);const p=new Map([["bin","binary"],["css","css"],["frag","shader"],["glb","container"],["glsl","shader"],["hdr","texture"],["html","html"],["jpg","texture"],["js","script"],["json","json"],["mp3","audio"],["mjs","script"],["ply","gsplat"],["png","texture"],["txt","text"],["vert","shader"],["webp","texture"]]);class u extends HTMLElement{constructor(){super(...arguments),this._lazy=!1,this.asset=null}disconnectedCallback(){this.destroyAsset()}createAsset(){var t;const s=this.getAttribute("id")||"",i=this.getAttribute("src")||"";let n=this.getAttribute("type");if(!n){const e=i.split(".").pop();n=null!==(t=p.get(e||""))&&void 0!==t?t:null}n?(this.asset=new e.Asset(s,n,{url:i}),this.asset.preload=!this._lazy):console.warn(`Unsupported asset type: ${i}`)}destroyAsset(){this.asset&&(this.asset.unload(),this.asset=null)}set lazy(t){this._lazy=t,this.asset&&(this.asset.preload=!t)}get lazy(){return this._lazy}static get(t){const e=document.querySelector(`pc-asset[id="${t}"]`);return null==e?void 0:e.asset}static get observedAttributes(){return["lazy"]}attributeChangedCallback(t,e,s){"lazy"===t&&(this.lazy=this.hasAttribute("lazy"))}}customElements.define("pc-asset",u);class d extends s{constructor(t){super(),this._enabled=!0,this._component=null,this._componentName=t}getInitialComponentData(){return{}}async addComponent(){const t=this.closestEntity;if(t){await t.ready();const e=this.getInitialComponentData();this._component=t.entity.addComponent(this._componentName,e)}}initComponent(){}async connectedCallback(){var t;await(null===(t=this.closestApp)||void 0===t?void 0:t.ready()),await this.addComponent(),this.initComponent(),this._onReady()}disconnectedCallback(){this.component&&this.component.entity&&(this._component.entity.removeComponent(this._componentName),this._component=null)}get component(){return this._component}set enabled(t){this._enabled=t,this.component&&(this.component.enabled=t)}get enabled(){return this._enabled}static get observedAttributes(){return["enabled"]}attributeChangedCallback(t,e,s){if("enabled"===t)this.enabled="false"!==s}}class m extends d{constructor(){super("audiolistener")}get component(){return super.component}}customElements.define("pc-listener",m);const f=new Map([["none",e.TONEMAP_NONE],["linear",e.TONEMAP_LINEAR],["filmic",e.TONEMAP_FILMIC],["hejl",e.TONEMAP_HEJL],["aces",e.TONEMAP_ACES],["aces2",e.TONEMAP_ACES2],["neutral",e.TONEMAP_NEUTRAL]]);class _ extends d{constructor(){super("camera"),this._clearColor=new e.Color(.75,.75,.75,1),this._clearColorBuffer=!0,this._clearDepthBuffer=!0,this._clearStencilBuffer=!1,this._cullFaces=!0,this._farClip=1e3,this._flipFaces=!1,this._fov=45,this._frustumCulling=!0,this._gamma="srgb",this._horizontalFov=!1,this._nearClip=.1,this._orthographic=!1,this._orthoHeight=10,this._priority=0,this._rect=new e.Vec4(0,0,1,1),this._scissorRect=new e.Vec4(0,0,1,1),this._tonemap="none"}getInitialComponentData(){return{clearColor:this._clearColor,clearColorBuffer:this._clearColorBuffer,clearDepthBuffer:this._clearDepthBuffer,clearStencilBuffer:this._clearStencilBuffer,cullFaces:this._cullFaces,farClip:this._farClip,flipFaces:this._flipFaces,fov:this._fov,frustumCulling:this._frustumCulling,gammaCorrection:"srgb"===this._gamma?e.GAMMA_SRGB:e.GAMMA_NONE,horizontalFov:this._horizontalFov,nearClip:this._nearClip,orthographic:this._orthographic,orthoHeight:this._orthoHeight,priority:this._priority,rect:this._rect,scissorRect:this._scissorRect,toneMapping:f.get(this._tonemap)}}get xrAvailable(){var t;const s=null===(t=this.component)||void 0===t?void 0:t.system.app.xr;return s&&s.supported&&s.isAvailable(e.XRTYPE_VR)}startXr(t,e){this.component&&this.xrAvailable&&this.component.startXr(t,e,{callback:t=>{t&&console.error(`WebXR Immersive VR failed to start: ${t.message}`)}})}endXr(){this.component&&this.component.endXr()}get component(){return super.component}set clearColor(t){this._clearColor=t,this.component&&(this.component.clearColor=t)}get clearColor(){return this._clearColor}set clearColorBuffer(t){this._clearColorBuffer=t,this.component&&(this.component.clearColorBuffer=t)}get clearColorBuffer(){return this._clearColorBuffer}set clearDepthBuffer(t){this._clearDepthBuffer=t,this.component&&(this.component.clearDepthBuffer=t)}get clearDepthBuffer(){return this._clearDepthBuffer}set clearStencilBuffer(t){this._clearStencilBuffer=t,this.component&&(this.component.clearStencilBuffer=t)}get clearStencilBuffer(){return this._clearStencilBuffer}set cullFaces(t){this._cullFaces=t,this.component&&(this.component.cullFaces=t)}get cullFaces(){return this._cullFaces}set farClip(t){this._farClip=t,this.component&&(this.component.farClip=t)}get farClip(){return this._farClip}set flipFaces(t){this._flipFaces=t,this.component&&(this.component.flipFaces=t)}get flipFaces(){return this._flipFaces}set fov(t){this._fov=t,this.component&&(this.component.fov=t)}get fov(){return this._fov}set frustumCulling(t){this._frustumCulling=t,this.component&&(this.component.frustumCulling=t)}get frustumCulling(){return this._frustumCulling}set gamma(t){this._gamma=t,this.component&&(this.component.gammaCorrection="srgb"===t?e.GAMMA_SRGB:e.GAMMA_NONE)}get gamma(){return this._gamma}set horizontalFov(t){this._horizontalFov=t,this.component&&(this.component.horizontalFov=t)}get horizontalFov(){return this._horizontalFov}set nearClip(t){this._nearClip=t,this.component&&(this.component.nearClip=t)}get nearClip(){return this._nearClip}set orthographic(t){this._orthographic=t,this.component&&(this.component.projection=t?e.PROJECTION_ORTHOGRAPHIC:e.PROJECTION_PERSPECTIVE)}get orthographic(){return this._orthographic}set orthoHeight(t){this._orthoHeight=t,this.component&&(this.component.orthoHeight=t)}get orthoHeight(){return this._orthoHeight}set priority(t){this._priority=t,this.component&&(this.component.priority=t)}get priority(){return this._priority}set rect(t){this._rect=t,this.component&&(this.component.rect=t)}get rect(){return this._rect}set scissorRect(t){this._scissorRect=t,this.component&&(this.component.scissorRect=t)}get scissorRect(){return this._scissorRect}set tonemap(t){var s;this._tonemap=t,this.component&&(this.component.toneMapping=null!==(s=f.get(t))&&void 0!==s?s:e.TONEMAP_NONE)}get tonemap(){return this._tonemap}static get observedAttributes(){return[...super.observedAttributes,"clear-color","clear-color-buffer","clear-depth-buffer","clear-stencil-buffer","cull-faces","far-clip","flip-faces","fov","frustum-culling","gamma","horizontal-fov","near-clip","orthographic","ortho-height","priority","rect","scissor-rect","tonemap"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"clear-color":this.clearColor=o(s);break;case"clear-color-buffer":this.clearColorBuffer="false"!==s;break;case"clear-depth-buffer":this.clearDepthBuffer="false"!==s;break;case"clear-stencil-buffer":this.clearStencilBuffer="false"!==s;break;case"cull-faces":this.cullFaces="false"!==s;break;case"far-clip":this.farClip=parseFloat(s);break;case"flip-faces":this.flipFaces="true"!==s;break;case"fov":this.fov=parseFloat(s);break;case"frustum-culling":this.frustumCulling="false"!==s;break;case"gamma":this.gamma=s;break;case"horizontal-fov":this.horizontalFov=this.hasAttribute("horizontal-fov");break;case"near-clip":this.nearClip=parseFloat(s);break;case"orthographic":this.orthographic=this.hasAttribute("orthographic");break;case"ortho-height":this.orthoHeight=parseFloat(s);break;case"priority":this.priority=parseFloat(s);break;case"rect":this.rect=c(s);break;case"scissor-rect":this.scissorRect=c(s);break;case"tonemap":this.tonemap=s}}}customElements.define("pc-camera",_);class g extends d{constructor(){super("collision"),this._angularOffset=new e.Quat,this._axis=1,this._convexHull=!1,this._halfExtents=new e.Vec3(.5,.5,.5),this._height=2,this._linearOffset=new e.Vec3,this._radius=.5,this._type="box"}getInitialComponentData(){return{axis:this._axis,angularOffset:this._angularOffset,convexHull:this._convexHull,halfExtents:this._halfExtents,height:this._height,linearOffset:this._linearOffset,radius:this._radius,type:this._type}}get component(){return super.component}set angularOffset(t){this._angularOffset=t,this.component&&(this.component.angularOffset=t)}get angularOffset(){return this._angularOffset}set axis(t){this._axis=t,this.component&&(this.component.axis=t)}get axis(){return this._axis}set convexHull(t){this._convexHull=t,this.component&&(this.component.convexHull=t)}get convexHull(){return this._convexHull}set halfExtents(t){this._halfExtents=t,this.component&&(this.component.halfExtents=t)}get halfExtents(){return this._halfExtents}set height(t){this._height=t,this.component&&(this.component.height=t)}get height(){return this._height}set linearOffset(t){this._linearOffset=t,this.component&&(this.component.linearOffset=t)}get linearOffset(){return this._linearOffset}set radius(t){this._radius=t,this.component&&(this.component.radius=t)}get radius(){return this._radius}set type(t){this._type=t,this.component&&(this.component.type=t)}get type(){return this._type}static get observedAttributes(){return[...super.observedAttributes,"angular-offset","axis","convex-hull","half-extents","height","linear-offset","radius","type"]}attributeChangedCallback(t,s,i){switch(super.attributeChangedCallback(t,s,i),t){case"angular-offset":this.angularOffset=(t=>{const[s,i,n]=t.split(" ").map(Number),a=new e.Quat;return a.setFromEulerAngles(s,i,n),a})(i);break;case"axis":this.axis=parseInt(i,10);break;case"convex-hull":this.convexHull=this.hasAttribute("convex-hull");break;case"half-extents":this.halfExtents=h(i);break;case"height":this.height=parseFloat(i);break;case"linear-offset":this.linearOffset=h(i);break;case"radius":this.radius=parseFloat(i);break;case"type":this.type=i}}}customElements.define("pc-collision",g);class b extends d{constructor(){super("element"),this._anchor=new e.Vec4(.5,.5,.5,.5),this._asset="",this._autoWidth=!0,this._color=new e.Color(1,1,1,1),this._fontSize=32,this._lineHeight=32,this._pivot=new e.Vec2(.5,.5),this._text="",this._type="group",this._width=0,this._wrapLines=!1}initComponent(){this.component._text._material.useFog=!0}getInitialComponentData(){return{anchor:this._anchor,autoWidth:this._autoWidth,color:this._color,fontAsset:u.get(this._asset).id,fontSize:this._fontSize,lineHeight:this._lineHeight,pivot:this._pivot,type:this._type,text:this._text,width:this._width,wrapLines:this._wrapLines}}get component(){return super.component}set anchor(t){this._anchor=t,this.component&&(this.component.anchor=t)}get anchor(){return this._anchor}set asset(t){this._asset=t;const e=u.get(t);this.component&&e&&(this.component.fontAsset=e.id)}get asset(){return this._asset}set autoWidth(t){this._autoWidth=t,this.component&&(this.component.autoWidth=t)}get autoWidth(){return this._autoWidth}set color(t){this._color=t,this.component&&(this.component.color=t)}get color(){return this._color}set fontSize(t){this._fontSize=t,this.component&&(this.component.fontSize=t)}get fontSize(){return this._fontSize}set lineHeight(t){this._lineHeight=t,this.component&&(this.component.lineHeight=t)}get lineHeight(){return this._lineHeight}set pivot(t){this._pivot=t,this.component&&(this.component.pivot=t)}get pivot(){return this._pivot}set text(t){this._text=t,this.component&&(this.component.text=t)}get text(){return this._text}set type(t){this._type=t,this.component&&(this.component.type=t)}get type(){return this._type}set width(t){this._width=t,this.component&&(this.component.width=t)}get width(){return this._width}set wrapLines(t){this._wrapLines=t,this.component&&(this.component.wrapLines=t)}get wrapLines(){return this._wrapLines}static get observedAttributes(){return[...super.observedAttributes,"anchor","asset","auto-width","color","font-size","line-height","pivot","text","type","width","wrap-lines"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"anchor":this.anchor=c(s);break;case"asset":this.asset=s;break;case"auto-width":this.autoWidth="false"!==s;break;case"color":this.color=o(s);break;case"font-size":this.fontSize=Number(s);break;case"line-height":this.lineHeight=Number(s);break;case"pivot":this.pivot=r(s);break;case"text":this.text=s;break;case"type":this.type=s;break;case"width":this.width=Number(s);break;case"wrap-lines":this.wrapLines=this.hasAttribute(t)}}}customElements.define("pc-element",b);class y extends d{constructor(){super("gsplat"),this._asset=""}getInitialComponentData(){return{asset:u.get(this._asset)}}get component(){return super.component}set asset(t){this._asset=t;const e=u.get(t);this.component&&e&&(this.component.asset=e)}get asset(){return this._asset}static get observedAttributes(){return[...super.observedAttributes,"asset"]}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),"asset"===t)this.asset=s}}customElements.define("pc-splat",y);const v=new Map([["pcf1-16f",e.SHADOW_PCF1_16F],["pcf1-32f",e.SHADOW_PCF1_32F],["pcf3-16f",e.SHADOW_PCF3_16F],["pcf3-32f",e.SHADOW_PCF3_32F],["pcf5-16f",e.SHADOW_PCF5_16F],["pcf5-32f",e.SHADOW_PCF5_32F],["vsm-16f",e.SHADOW_VSM_16F],["vsm-32f",e.SHADOW_VSM_32F],["pcss-32f",e.SHADOW_PCSS_32F]]);class w extends d{constructor(){super("light"),this._castShadows=!1,this._color=new e.Color(1,1,1),this._innerConeAngle=40,this._intensity=1,this._normalOffsetBias=.05,this._outerConeAngle=45,this._range=10,this._shadowBias=.2,this._shadowDistance=16,this._shadowIntensity=1,this._shadowResolution=1024,this._shadowType="pcf3-32f",this._type="directional",this._vsmBias=.01}getInitialComponentData(){return{castShadows:this._castShadows,color:this._color,innerConeAngle:this._innerConeAngle,intensity:this._intensity,normalOffsetBias:this._normalOffsetBias,outerConeAngle:this._outerConeAngle,range:this._range,shadowBias:this._shadowBias,shadowDistance:this._shadowDistance,shadowIntensity:this._shadowIntensity,shadowResolution:this._shadowResolution,shadowType:v.get(this._shadowType),type:this._type,vsmBias:this._vsmBias}}get component(){return super.component}set castShadows(t){this._castShadows=t,this.component&&(this.component.castShadows=t)}get castShadows(){return this._castShadows}set color(t){this._color=t,this.component&&(this.component.color=t)}get color(){return this._color}set innerConeAngle(t){this._innerConeAngle=t,this.component&&(this.component.innerConeAngle=t)}get innerConeAngle(){return this._innerConeAngle}set intensity(t){this._intensity=t,this.component&&(this.component.intensity=t)}get intensity(){return this._intensity}set normalOffsetBias(t){this._normalOffsetBias=t,this.component&&(this.component.normalOffsetBias=t)}get normalOffsetBias(){return this._normalOffsetBias}set outerConeAngle(t){this._outerConeAngle=t,this.component&&(this.component.outerConeAngle=t)}get outerConeAngle(){return this._outerConeAngle}set range(t){this._range=t,this.component&&(this.component.range=t)}get range(){return this._range}set shadowBias(t){this._shadowBias=t,this.component&&(this.component.shadowBias=t)}get shadowBias(){return this._shadowBias}set shadowDistance(t){this._shadowDistance=t,this.component&&(this.component.shadowDistance=t)}get shadowDistance(){return this._shadowDistance}set shadowIntensity(t){this._shadowIntensity=t,this.component&&(this.component.shadowIntensity=t)}get shadowIntensity(){return this._shadowIntensity}set shadowResolution(t){this._shadowResolution=t,this.component&&(this.component.shadowResolution=t)}get shadowResolution(){return this._shadowResolution}set shadowType(t){var s;this._shadowType=t,this.component&&(this.component.shadowType=null!==(s=v.get(t))&&void 0!==s?s:e.SHADOW_PCF3_32F)}get shadowType(){return this._shadowType}set type(t){["directional","omni","spot"].includes(t)?(this._type=t,this.component&&(this.component.type=t)):console.warn(`Invalid light type '${t}', using default type '${this._type}'.`)}get type(){return this._type}set vsmBias(t){this._vsmBias=t,this.component&&(this.component.vsmBias=t)}get vsmBias(){return this._vsmBias}static get observedAttributes(){return[...super.observedAttributes,"color","cast-shadows","intensity","inner-cone-angle","normal-offset-bias","outer-cone-angle","range","shadow-bias","shadow-distance","shadow-intensity","shadow-resolution","shadow-type","type","vsm-bias"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"color":this.color=o(s);break;case"cast-shadows":this.castShadows=this.hasAttribute("cast-shadows");break;case"inner-cone-angle":this.innerConeAngle=Number(s);break;case"intensity":this.intensity=Number(s);break;case"normal-offset-bias":this.normalOffsetBias=Number(s);break;case"outer-cone-angle":this.outerConeAngle=Number(s);break;case"range":this.range=Number(s);break;case"shadow-bias":this.shadowBias=Number(s);break;case"shadow-distance":this.shadowDistance=Number(s);break;case"shadow-resolution":this.shadowResolution=Number(s);break;case"shadow-intensity":this.shadowIntensity=Number(s);break;case"shadow-type":this.shadowType=s;break;case"type":this.type=s;break;case"vsm-bias":this.vsmBias=Number(s)}}}customElements.define("pc-light",w);class C extends HTMLElement{constructor(){super(...arguments),this._diffuse=new e.Color(1,1,1),this._diffuseMap="",this._metalnessMap="",this._normalMap="",this._roughnessMap="",this.material=null}createMaterial(){this.material=new e.StandardMaterial,this.material.glossInvert=!1,this.material.useMetalness=!1,this.material.diffuse=this._diffuse,this.diffuseMap=this._diffuseMap,this.metalnessMap=this._metalnessMap,this.normalMap=this._normalMap,this.roughnessMap=this._roughnessMap,this.material.update()}disconnectedCallback(){this.material&&(this.material.destroy(),this.material=null)}setMap(t,e){if(this.material){const s=u.get(t);s&&(s.loaded?(this.material[e]=s.resource,this.material[e].anisotropy=4):s.once("load",(()=>{this.material[e]=s.resource,this.material[e].anisotropy=4,this.material.update()})))}}set diffuse(t){this._diffuse=t,this.material&&(this.material.diffuse=t)}get diffuse(){return this._diffuse}set diffuseMap(t){this._diffuseMap=t,this.setMap(t,"diffuseMap")}get diffuseMap(){return this._diffuseMap}set metalnessMap(t){this._metalnessMap=t,this.setMap(t,"metalnessMap")}get metalnessMap(){return this._metalnessMap}set normalMap(t){this._normalMap=t,this.setMap(t,"normalMap")}get normalMap(){return this._normalMap}set roughnessMap(t){this._roughnessMap=t,this.setMap(t,"glossMap")}get roughnessMap(){return this._roughnessMap}static get(t){const e=document.querySelector(`pc-material[id="${t}"]`);return null==e?void 0:e.material}static get observedAttributes(){return["diffuse","diffuse-map","metalness-map","normal-map","roughness-map"]}attributeChangedCallback(t,e,s){switch(t){case"diffuse":this.diffuse=o(s);break;case"diffuse-map":this.diffuseMap=s;break;case"metalness-map":this.metalnessMap=s;break;case"normal-map":this.normalMap=s;break;case"roughness-map":this.roughnessMap=s}}}customElements.define("pc-material",C);class k extends d{constructor(){super("render"),this._castShadows=!0,this._material="",this._receiveShadows=!0,this._type="asset"}getInitialComponentData(){return{type:this._type,castShadows:this._castShadows,material:C.get(this._material),receiveShadows:this._receiveShadows}}get component(){return super.component}set type(t){this._type=t,this.component&&(this.component.type=t)}get type(){return this._type}set castShadows(t){this._castShadows=t,this.component&&(this.component.castShadows=t)}get castShadows(){return this._castShadows}set material(t){this._material=t,this.component&&(this.component.material=C.get(t))}get material(){return this._material}set receiveShadows(t){this._receiveShadows=t,this.component&&(this.component.receiveShadows=t)}get receiveShadows(){return this._receiveShadows}static get observedAttributes(){return[...super.observedAttributes,"cast-shadows","material","receive-shadows","type"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"cast-shadows":this.castShadows="false"!==s;break;case"material":this.material=s;break;case"receive-shadows":this.receiveShadows="false"!==s;break;case"type":this.type=s}}}customElements.define("pc-render",k);class E extends d{constructor(){super("rigidbody"),this._angularDamping=0,this._angularFactor=new e.Vec3(1,1,1),this._friction=.5,this._linearDamping=0,this._linearFactor=new e.Vec3(1,1,1),this._mass=1,this._restitution=0,this._rollingFriction=0,this._type="static"}getInitialComponentData(){return{angularDamping:this._angularDamping,angularFactor:this._angularFactor,friction:this._friction,linearDamping:this._linearDamping,linearFactor:this._linearFactor,mass:this._mass,restitution:this._restitution,rollingFriction:this._rollingFriction,type:this._type}}get component(){return super.component}set angularDamping(t){this._angularDamping=t,this.component&&(this.component.angularDamping=t)}get angularDamping(){return this._angularDamping}set angularFactor(t){this._angularFactor=t,this.component&&(this.component.angularFactor=t)}get angularFactor(){return this._angularFactor}set friction(t){this._friction=t,this.component&&(this.component.friction=t)}get friction(){return this._friction}set linearDamping(t){this._linearDamping=t,this.component&&(this.component.linearDamping=t)}get linearDamping(){return this._linearDamping}set linearFactor(t){this._linearFactor=t,this.component&&(this.component.linearFactor=t)}get linearFactor(){return this._linearFactor}set mass(t){this._mass=t,this.component&&(this.component.mass=t)}get mass(){return this._mass}set restitution(t){this._restitution=t,this.component&&(this.component.restitution=t)}get restitution(){return this._restitution}set rollingFriction(t){this._rollingFriction=t,this.component&&(this.component.rollingFriction=t)}get rollingFriction(){return this._rollingFriction}set type(t){this._type=t,this.component&&(this.component.type=t)}get type(){return this._type}static get observedAttributes(){return[...super.observedAttributes,"angular-damping","angular-factor","friction","linear-damping","linear-factor","mass","restitution","rolling-friction","type"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"angular-damping":this.angularDamping=parseFloat(s);break;case"angular-factor":this.angularFactor=h(s);break;case"friction":this.friction=parseFloat(s);break;case"linear-damping":this.linearDamping=parseFloat(s);break;case"linear-factor":this.linearFactor=h(s);break;case"mass":this.mass=parseFloat(s);break;case"restitution":this.restitution=parseFloat(s);break;case"rolling-friction":this.rollingFriction=parseFloat(s);break;case"type":this.type=s}}}customElements.define("pc-rigidbody",E);class A extends d{constructor(){super("screen"),this._screenSpace=!1,this._resolution=new e.Vec2(640,320),this._referenceResolution=new e.Vec2(640,320),this._priority=0,this._blend=!1,this._scaleBlend=.5}getInitialComponentData(){return{priority:this._priority,referenceResolution:this._referenceResolution,resolution:this._resolution,scaleBlend:this._scaleBlend,scaleMode:this._blend?e.SCALEMODE_BLEND:e.SCALEMODE_NONE,screenSpace:this._screenSpace}}get component(){return super.component}set priority(t){this._priority=t,this.component&&(this.component.priority=this._priority)}get priority(){return this._priority}set referenceResolution(t){this._referenceResolution=t,this.component&&(this.component.referenceResolution=this._referenceResolution)}get referenceResolution(){return this._referenceResolution}set resolution(t){this._resolution=t,this.component&&(this.component.resolution=this._resolution)}get resolution(){return this._resolution}set scaleBlend(t){this._scaleBlend=t,this.component&&(this.component.scaleBlend=this._scaleBlend)}get scaleBlend(){return this._scaleBlend}set blend(t){this._blend=t,this.component&&(this.component.scaleMode=this._blend?e.SCALEMODE_BLEND:e.SCALEMODE_NONE)}get blend(){return this._blend}set screenSpace(t){this._screenSpace=t,this.component&&(this.component.screenSpace=this._screenSpace)}get screenSpace(){return this._screenSpace}static get observedAttributes(){return[...super.observedAttributes,"blend","screen-space","resolution","reference-resolution","priority","scale-blend"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"priority":this.priority=parseInt(s,10);break;case"reference-resolution":this.referenceResolution=r(s);break;case"resolution":this.resolution=r(s);break;case"scale-blend":this.scaleBlend=parseFloat(s);break;case"blend":this.blend=this.hasAttribute("blend");break;case"screen-space":this.screenSpace=this.hasAttribute("screen-space")}}}customElements.define("pc-screen",A);class S extends d{constructor(){super("script"),this.observer=new MutationObserver(this.handleMutations.bind(this)),this.observer.observe(this,{childList:!0}),this.addEventListener("scriptattributeschange",this.handleScriptAttributesChange.bind(this)),this.addEventListener("scriptenablechange",this.handleScriptEnableChange.bind(this))}initComponent(){this.querySelectorAll(":scope > pc-script").forEach((t=>{const e=t.getAttribute("name"),s=t.getAttribute("attributes");e&&this.createScript(e,s)}))}convertAttributes(t){if("string"==typeof t){if(t.startsWith("asset:")){const e=t.slice(6),s=document.querySelector(`pc-asset#${e}`);if(s)return s.asset}if(t.startsWith("entity:")){const e=t.slice(7),s=document.querySelector(`pc-entity[name="${e}"]`);if(s)return s.entity}if(t.startsWith("vec2:")){const s=t.slice(5).split(",").map(Number);if(2===s.length&&s.every((t=>!isNaN(t))))return new e.Vec2(s[0],s[1])}if(t.startsWith("vec3:")){const s=t.slice(5).split(",").map(Number);if(3===s.length&&s.every((t=>!isNaN(t))))return new e.Vec3(s[0],s[1],s[2])}if(t.startsWith("vec4:")){const s=t.slice(5).split(",").map(Number);if(4===s.length&&s.every((t=>!isNaN(t))))return new e.Vec4(s[0],s[1],s[2],s[3])}if(t.startsWith("color:")){const s=t.slice(6).split(",").map(Number);if(4===s.length&&s.every((t=>!isNaN(t))))return new e.Color(s[0],s[1],s[2],s[3])}return t}if(Array.isArray(t))return t.length>0&&t[0],t.map((t=>this.convertAttributes(t)));if(t&&"object"==typeof t){const e={};for(const s in t)e[s]=this.convertAttributes(t[s]);return e}return t}preprocessAttributes(t){return this.convertAttributes(t)}mergeDeep(t,e){for(const s in e)e[s]&&"object"==typeof e[s]&&!Array.isArray(e[s])?(t[s]&&"object"==typeof t[s]||(t[s]={}),this.mergeDeep(t[s],e[s])):t[s]=e[s];return t}applyAttributes(t,e){try{const s=e?JSON.parse(e):{},i=this.convertAttributes(s);this.mergeDeep(t,i)}catch(t){console.error(`Error parsing attributes JSON string ${e}:`,t)}}handleScriptAttributesChange(t){const e=t.target.getAttribute("name");if(!e||!this.component)return;const s=this.component.get(e);s&&this.applyAttributes(s,t.detail.attributes)}handleScriptEnableChange(t){const e=t.target.getAttribute("name");if(!e||!this.component)return;const s=this.component.get(e);s&&(s.enabled=t.detail.enabled)}createScript(t,e){if(!this.component)return null;let s={};if(e)try{s=JSON.parse(e),s=this.preprocessAttributes(s)}catch(t){console.error(`Error parsing attributes JSON string ${e}:`,t)}return this.component.create(t,{properties:s})}destroyScript(t){this.component&&this.component.destroy(t)}handleMutations(t){for(const e of t)e.addedNodes.forEach((t=>{if(t instanceof HTMLElement&&"pc-script"===t.tagName.toLowerCase()){const e=t.getAttribute("name"),s=t.getAttribute("attributes");e&&this.createScript(e,s)}})),e.removedNodes.forEach((t=>{if(t instanceof HTMLElement&&"pc-script"===t.tagName.toLowerCase()){const e=t.getAttribute("name");e&&this.destroyScript(e)}}))}disconnectedCallback(){var t;this.observer.disconnect(),null===(t=super.disconnectedCallback)||void 0===t||t.call(this)}get component(){return super.component}}customElements.define("pc-scripts",S);class x extends HTMLElement{constructor(){super(...arguments),this._attributes="{}",this._enabled=!0,this._name=""}set scriptAttributes(t){this._attributes=t,this.dispatchEvent(new CustomEvent("scriptattributeschange",{detail:{attributes:t},bubbles:!0}))}get scriptAttributes(){return this._attributes}set enabled(t){this._enabled=t,this.dispatchEvent(new CustomEvent("scriptenablechange",{detail:{enabled:t},bubbles:!0}))}get enabled(){return this._enabled}set name(t){this._name=t}get name(){return this._name}static get observedAttributes(){return["attributes","enabled","name"]}attributeChangedCallback(t,e,s){switch(t){case"attributes":this.scriptAttributes=s;break;case"enabled":this.enabled="false"!==s;break;case"name":this.name=s}}}customElements.define("pc-script",x);class F extends d{constructor(){super("sound"),this._distanceModel="linear",this._maxDistance=1e4,this._pitch=1,this._positional=!1,this._refDistance=1,this._rollOffFactor=1,this._volume=1}getInitialComponentData(){return{distanceModel:this._distanceModel,maxDistance:this._maxDistance,pitch:this._pitch,positional:this._positional,refDistance:this._refDistance,rollOffFactor:this._rollOffFactor,volume:this._volume}}get component(){return super.component}set distanceModel(t){this._distanceModel=t,this.component&&(this.component.distanceModel=t)}get distanceModel(){return this._distanceModel}set maxDistance(t){this._maxDistance=t,this.component&&(this.component.maxDistance=t)}get maxDistance(){return this._maxDistance}set pitch(t){this._pitch=t,this.component&&(this.component.pitch=t)}get pitch(){return this._pitch}set positional(t){this._positional=t,this.component&&(this.component.positional=t)}get positional(){return this._positional}set refDistance(t){this._refDistance=t,this.component&&(this.component.refDistance=t)}get refDistance(){return this._refDistance}set rollOffFactor(t){this._rollOffFactor=t,this.component&&(this.component.rollOffFactor=t)}get rollOffFactor(){return this._rollOffFactor}set volume(t){this._volume=t,this.component&&(this.component.volume=t)}get volume(){return this._volume}static get observedAttributes(){return[...super.observedAttributes,"distance-model","max-distance","pitch","positional","ref-distance","roll-off-factor","volume"]}attributeChangedCallback(t,e,s){switch(super.attributeChangedCallback(t,e,s),t){case"distance-model":this.distanceModel=s;break;case"max-distance":this.maxDistance=parseFloat(s);break;case"pitch":this.pitch=parseFloat(s);break;case"positional":this.positional=this.hasAttribute("positional");break;case"ref-distance":this.refDistance=parseFloat(s);break;case"roll-off-factor":this.rollOffFactor=parseFloat(s);break;case"volume":this.volume=parseFloat(s)}}}customElements.define("pc-sounds",F);class M extends s{constructor(){super(...arguments),this._asset="",this._autoPlay=!1,this._duration=null,this._loop=!1,this._name="",this._overlap=!1,this._pitch=1,this._startTime=0,this._volume=1,this.soundSlot=null}async connectedCallback(){var t;await(null===(t=this.soundElement)||void 0===t?void 0:t.ready());const e={autoPlay:this._autoPlay,loop:this._loop,overlap:this._overlap,pitch:this._pitch,startTime:this._startTime,volume:this._volume};this._duration&&(e.duration=this._duration),this.soundSlot=this.soundElement.component.addSlot(this._name,e),this.asset=this._asset,this.soundSlot.play(),this._onReady()}disconnectedCallback(){this.soundElement.component.removeSlot(this._name)}get soundElement(){const t=this.parentElement;return t instanceof F?t:(console.warn("pc-sound-slot must be a direct child of a pc-sound element"),null)}set asset(t){var e;if(this._asset=t,this.soundSlot){const s=null===(e=u.get(t))||void 0===e?void 0:e.id;s&&(this.soundSlot.asset=s)}}get asset(){return this._asset}set autoPlay(t){this._autoPlay=t,this.soundSlot&&(this.soundSlot.autoPlay=t)}get autoPlay(){return this._autoPlay}set duration(t){this._duration=t,this.soundSlot&&(this.soundSlot.duration=t)}get duration(){return this._duration}set loop(t){this._loop=t,this.soundSlot&&(this.soundSlot.loop=t)}get loop(){return this._loop}set name(t){this._name=t,this.soundSlot&&(this.soundSlot.name=t)}get name(){return this._name}set overlap(t){this._overlap=t,this.soundSlot&&(this.soundSlot.overlap=t)}get overlap(){return this._overlap}set pitch(t){this._pitch=t,this.soundSlot&&(this.soundSlot.pitch=t)}get pitch(){return this._pitch}set startTime(t){this._startTime=t,this.soundSlot&&(this.soundSlot.startTime=t)}get startTime(){return this._startTime}set volume(t){this._volume=t,this.soundSlot&&(this.soundSlot.volume=t)}get volume(){return this._volume}static get observedAttributes(){return["asset","autoPlay","duration","loop","name","overlap","pitch","startTime","volume"]}attributeChangedCallback(t,e,s){switch(t){case"asset":this.asset=s;break;case"duration":this.duration=parseFloat(s);break;case"loop":this.loop=this.hasAttribute("loop");break;case"name":this.name=s;break;case"overlap":this.overlap=this.hasAttribute("overlap");break;case"pitch":this.pitch=parseFloat(s);break;case"startTime":this.startTime=parseFloat(s);break;case"volume":this.volume=parseFloat(s)}}}customElements.define("pc-sound",M);class D extends s{constructor(){super(...arguments),this._asset="",this._entity=null}connectedCallback(){this._loadModel(),this._onReady()}disconnectedCallback(){this._unloadModel()}_instantiate(t){this._entity=t.instantiateRenderEntity(),t.animations.length>0&&(this._entity.addComponent("anim"),this._entity.anim.assignAnimation("animation",t.animations[0].resource));const e=this.closestEntity;if(e)e.ready().then((()=>{e.entity.addChild(this._entity)}));else{const t=this.closestApp;t&&t.ready().then((()=>{t.app.root.addChild(this._entity)}))}}async _loadModel(){var t;this._unloadModel();const e=await(null===(t=this.closestApp)||void 0===t?void 0:t.ready()),s=null==e?void 0:e.app,i=u.get(this._asset);i&&(i.loaded?this._instantiate(i.resource):(i.once("load",(()=>{this._instantiate(i.resource)})),s.assets.load(i)))}_unloadModel(){var t;null===(t=this._entity)||void 0===t||t.destroy(),this._entity=null}set asset(t){this._asset=t,this.isConnected&&this._loadModel()}get asset(){return this._asset}static get observedAttributes(){return["asset"]}attributeChangedCallback(t,e,s){if("asset"===t)this.asset=s}}customElements.define("pc-model",D);class L extends s{constructor(){super(...arguments),this._fog="none",this._fogColor=new e.Color(1,1,1),this._fogDensity=0,this._fogStart=0,this._fogEnd=1e3,this._gravity=new e.Vec3(0,-9.81,0),this.scene=null}async connectedCallback(){var t;await(null===(t=this.closestApp)||void 0===t?void 0:t.ready()),this.scene=this.closestApp.app.scene,this.updateSceneSettings(),this._onReady()}updateSceneSettings(){if(this.scene){this.scene.fog.type=this._fog,this.scene.fog.color=this._fogColor,this.scene.fog.density=this._fogDensity,this.scene.fog.start=this._fogStart,this.scene.fog.end=this._fogEnd;this.parentElement.app.systems.rigidbody.gravity.copy(this._gravity)}}set fog(t){this._fog=t,this.scene&&(this.scene.fog.type=t)}get fog(){return this._fog}set fogColor(t){this._fogColor=t,this.scene&&(this.scene.fog.color=t)}get fogColor(){return this._fogColor}set fogDensity(t){this._fogDensity=t,this.scene&&(this.scene.fog.density=t)}get fogDensity(){return this._fogDensity}set fogStart(t){this._fogStart=t,this.scene&&(this.scene.fog.start=t)}get fogStart(){return this._fogStart}set fogEnd(t){this._fogEnd=t,this.scene&&(this.scene.fog.end=t)}get fogEnd(){return this._fogEnd}set gravity(t){if(this._gravity=t,this.scene){this.parentElement.app.systems.rigidbody.gravity.copy(t)}}get gravity(){return this._gravity}static get observedAttributes(){return["fog","fog-color","fog-density","fog-start","fog-end","gravity"]}attributeChangedCallback(t,e,s){switch(t){case"fog":this.fog=s;break;case"fog-color":this.fogColor=o(s);break;case"fog-density":this.fogDensity=parseFloat(s);break;case"fog-start":this.fogStart=parseFloat(s);break;case"fog-end":this.fogEnd=parseFloat(s);break;case"gravity":this.gravity=h(s)}}}customElements.define("pc-scene",L);class O extends s{constructor(){super(...arguments),this._asset="",this._center=new e.Vec3(0,.01,0),this._intensity=1,this._rotation=new e.Vec3,this._level=0,this._lighting=!1,this._scale=new e.Vec3(100,100,100),this._type="infinite",this._scene=null}connectedCallback(){this._loadSkybox(),this._onReady()}disconnectedCallback(){this._unloadSkybox()}_generateSkybox(t){if(!this._scene)return;const s=t.resource,i=e.EnvLighting.generateSkyboxCubemap(s);if(i.anisotropy=4,this._scene.skybox=i,this._lighting){const t=e.EnvLighting.generateLightingSource(s),i=e.EnvLighting.generateAtlas(t);this._scene.envAtlas=i}const n=this._scene.layers.getLayerById(e.LAYERID_SKYBOX);n&&(n.enabled="none"!==this._type),this._scene.sky.type=this._type,this._scene.sky.node.setLocalScale(this._scale),this._scene.sky.center=this._center,this._scene.skyboxIntensity=this._intensity}async _loadSkybox(){var t;const e=await(null===(t=this.closestApp)||void 0===t?void 0:t.ready()),s=null==e?void 0:e.app;if(!s)return;const i=u.get(this._asset);i&&(this._scene=s.scene,i.loaded?this._generateSkybox(i):(i.once("load",(()=>{this._generateSkybox(i)})),s.assets.load(i)))}_unloadSkybox(){var t,e;this._scene&&(null===(t=this._scene.skybox)||void 0===t||t.destroy(),this._scene.skybox=null,null===(e=this._scene.envAtlas)||void 0===e||e.destroy(),this._scene.envAtlas=null,this._scene=null)}set asset(t){this._asset=t,this.isConnected&&this._loadSkybox()}get asset(){return this._asset}set center(t){this._center=t,this._scene&&(this._scene.sky.center=this._center)}get center(){return this._center}set intensity(t){this._intensity=t,this._scene&&(this._scene.skyboxIntensity=this._intensity)}get intensity(){return this._intensity}set level(t){this._level=t,this._scene&&(this._scene.skyboxMip=this._level)}get level(){return this._level}set lighting(t){this._lighting=t}get lighting(){return this._lighting}set rotation(t){this._rotation=t,this._scene&&(this._scene.skyboxRotation=(new e.Quat).setFromEulerAngles(t))}get rotation(){return this._rotation}set scale(t){this._scale=t,this._scene&&this._scene.sky.node.setLocalScale(this._scale)}get scale(){return this._scale}set type(t){if(this._type=t,this._scene){this._scene.sky.type=this._type;const t=this._scene.layers.getLayerById(e.LAYERID_SKYBOX);t&&(t.enabled="none"!==this._type)}}get type(){return this._type}static get observedAttributes(){return["asset","center","intensity","level","lighting","rotation","scale","type"]}attributeChangedCallback(t,e,s){switch(t){case"asset":this.asset=s;break;case"center":this.center=h(s);break;case"intensity":this.intensity=parseFloat(s);break;case"level":this.level=parseInt(s,10);break;case"lighting":this.lighting=this.hasAttribute(t);break;case"rotation":this.rotation=h(s);break;case"scale":this.scale=h(s);break;case"type":this.type=s}}}customElements.define("pc-sky",O),t.AppElement=n,t.AssetElement=u,t.AsyncElement=s,t.CameraComponentElement=_,t.CollisionComponentElement=g,t.ComponentElement=d,t.ElementComponentElement=b,t.EntityElement=l,t.LightComponentElement=w,t.ListenerComponentElement=m,t.MaterialElement=C,t.ModelElement=D,t.ModuleElement=i,t.RenderComponentElement=k,t.RigidBodyComponentElement=E,t.SceneElement=L,t.ScreenComponentElement=A,t.ScriptComponentElement=S,t.ScriptElement=x,t.SkyElement=O,t.SoundComponentElement=F,t.SoundSlotElement=M,t.SplatComponentElement=y}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("playcanvas")):"function"==typeof define&&define.amd?define(["exports","playcanvas"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).pd={},e.pc)}(this,(function(e,t){"use strict";class a extends HTMLElement{constructor(){super(),this._readyPromise=new Promise((e=>{this._readyResolve=e}))}get closestApp(){var e;return null===(e=this.parentElement)||void 0===e?void 0:e.closest("pc-app")}get closestEntity(){var e;return null===(e=this.parentElement)||void 0===e?void 0:e.closest("pc-entity")}_onReady(){this._readyResolve(),this.dispatchEvent(new CustomEvent("ready"))}ready(){return this._readyPromise.then((()=>this))}}class s extends HTMLElement{constructor(){super(),this.loadPromise=this.loadModule()}async loadModule(){const e=this.getAttribute("name"),a=this.getAttribute("glue"),s=this.getAttribute("wasm"),i=this.getAttribute("fallback");"Basis"===e?t.basisInitialize({glueUrl:a,wasmUrl:s,fallbackUrl:i}):(t.WasmModule.setConfig(e,{glueUrl:a,wasmUrl:s,fallbackUrl:i}),await new Promise((a=>{t.WasmModule.getInstance(e,(()=>a()))})))}getLoadPromise(){return this.loadPromise}}customElements.define("pc-module",s);class i extends a{constructor(){super(),this._canvas=null,this._alpha=!0,this._antialias=!0,this._depth=!0,this._stencil=!0,this._highResolution=!0,this._hierarchyReady=!1,this._picker=null,this._hasPointerListeners={pointerenter:!1,pointerleave:!1,pointerdown:!1,pointerup:!1,pointermove:!1},this._hoveredEntity=null,this._pointerHandlers={pointermove:null,pointerdown:null,pointerup:null},this.app=null,this._onWindowResize=this._onWindowResize.bind(this)}async connectedCallback(){const e=this.querySelectorAll(":scope > pc-module");await Promise.all(Array.from(e).map((e=>e.getLoadPromise()))),this._canvas=document.createElement("canvas"),this.appendChild(this._canvas),this.app=new t.Application(this._canvas,{graphicsDeviceOptions:{alpha:this._alpha,antialias:this._antialias,depth:this._depth,stencil:this._stencil},keyboard:new t.Keyboard(window),mouse:new t.Mouse(this._canvas)}),this.app.graphicsDevice.maxPixelRatio=this._highResolution?window.devicePixelRatio:1,this.app.setCanvasFillMode(t.FILLMODE_FILL_WINDOW),this.app.setCanvasResolution(t.RESOLUTION_AUTO),this._pickerCreate();const a=this.querySelectorAll(":scope > pc-asset");Array.from(a).forEach((e=>{e.createAsset();const t=e.asset;t&&this.app.assets.add(t)}));const s=this.querySelectorAll(":scope > pc-material");Array.from(s).forEach((e=>{e.createMaterial()}));const i=this.querySelectorAll("pc-entity");Array.from(i).forEach((e=>{e.createEntity(this.app)})),i.forEach((e=>{e.buildHierarchy(this.app)})),this._hierarchyReady=!0,this.app.preload((()=>{this.app.start(),window.addEventListener("resize",this._onWindowResize),this._onReady()}))}disconnectedCallback(){this._pickerDestroy(),this.app&&(this.app.destroy(),this.app=null),window.removeEventListener("resize",this._onWindowResize),this._canvas&&this.contains(this._canvas)&&(this.removeChild(this._canvas),this._canvas=null)}_onWindowResize(){this.app&&this.app.resizeCanvas()}_pickerCreate(){const{width:e,height:a}=this.app.graphicsDevice;this._picker=new t.Picker(this.app,e,a),this._pointerHandlers.pointermove=this._onPointerMove.bind(this),this._pointerHandlers.pointerdown=this._onPointerDown.bind(this),this._pointerHandlers.pointerup=this._onPointerUp.bind(this),["pointermove","pointerdown","pointerup","pointerenter","pointerleave"].forEach((e=>{this.addEventListener(`${e}:connect`,(()=>this._onPointerListenerAdded(e))),this.addEventListener(`${e}:disconnect`,(()=>this._onPointerListenerRemoved(e)))}))}_pickerDestroy(){this._canvas&&Object.entries(this._pointerHandlers).forEach((([e,t])=>{t&&this._canvas.removeEventListener(e,t)})),this._picker=null,this._pointerHandlers={pointermove:null,pointerdown:null,pointerup:null}}_getPickerCoordinates(e){const t=this._canvas.getBoundingClientRect(),a=this._canvas.width/t.width,s=this._canvas.height/t.height;return{x:(e.clientX-t.left)*a,y:(e.clientY-t.top)*s}}_onPointerMove(e){if(!this._picker||!this.app)return;const t=this.app.root.findComponent("camera");if(!t)return;const{x:a,y:s}=this._getPickerCoordinates(e);this._picker.prepare(t,this.app.scene);const i=this._picker.getSelection(a,s);let n=null;if(i.length>0){let e=i[0].node;for(;null!==e;){const t=this.querySelector(`pc-entity[name="${e.name}"]`);if(t){n=t;break}e=e.parent}}this._hoveredEntity!==n&&(this._hoveredEntity&&this._hoveredEntity.hasListeners("pointerleave")&&this._hoveredEntity.dispatchEvent(new PointerEvent("pointerleave",e)),n&&n.hasListeners("pointerenter")&&n.dispatchEvent(new PointerEvent("pointerenter",e))),this._hoveredEntity=n,n&&n.hasListeners("pointermove")&&n.dispatchEvent(new PointerEvent("pointermove",e))}_onPointerDown(e){if(!this._picker||!this.app)return;const t=this.app.root.findComponent("camera");if(!t)return;const{x:a,y:s}=this._getPickerCoordinates(e);this._picker.prepare(t,this.app.scene);const i=this._picker.getSelection(a,s);if(i.length>0){let t=i[0].node;for(;null!==t;){const a=this.querySelector(`pc-entity[name="${t.name}"]`);if(a&&a.hasListeners("pointerdown")){a.dispatchEvent(new PointerEvent("pointerdown",e));break}t=t.parent}}}_onPointerUp(e){if(!this._picker||!this.app)return;const t=this.app.root.findComponent("camera");if(!t)return;const{x:a,y:s}=this._getPickerCoordinates(e);this._picker.prepare(t,this.app.scene);const i=this._picker.getSelection(a,s);if(i.length>0){const t=this.querySelector(`pc-entity[name="${i[0].node.name}"]`);t&&t.hasListeners("pointerup")&&t.dispatchEvent(new PointerEvent("pointerup",e))}}_onPointerListenerAdded(e){if(!this._hasPointerListeners[e]&&this._canvas){this._hasPointerListeners[e]=!0;const t="pointerenter"===e||"pointerleave"===e?this._pointerHandlers.pointermove:this._pointerHandlers[e];t&&this._canvas.addEventListener("pointerenter"===e||"pointerleave"===e?"pointermove":e,t)}}_onPointerListenerRemoved(e){if(!Array.from(this.querySelectorAll("pc-entity")).some((t=>t.hasListeners(e)))&&this._canvas){this._hasPointerListeners[e]=!1;const t="pointerenter"===e||"pointerleave"===e?this._pointerHandlers.pointermove:this._pointerHandlers[e];t&&this._canvas.removeEventListener("pointerenter"===e||"pointerleave"===e?"pointermove":e,t)}}set alpha(e){this._alpha=e}get alpha(){return this._alpha}set antialias(e){this._antialias=e}get antialias(){return this._antialias}set depth(e){this._depth=e}get depth(){return this._depth}get hierarchyReady(){return this._hierarchyReady}set highResolution(e){this._highResolution=e,this.app&&(this.app.graphicsDevice.maxPixelRatio=e?window.devicePixelRatio:1)}get highResolution(){return this._highResolution}set stencil(e){this._stencil=e}get stencil(){return this._stencil}static get observedAttributes(){return["alpha","antialias","depth","stencil","high-resolution"]}attributeChangedCallback(e,t,a){switch(e){case"alpha":this.alpha="false"!==a;break;case"antialias":this.antialias="false"!==a;break;case"depth":this.depth="false"!==a;break;case"high-resolution":this.highResolution="false"!==a;break;case"stencil":this.stencil="false"!==a}}}customElements.define("pc-app",i);const n={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},o=e=>{const a=n[e.toLowerCase()];if(a)return(new t.Color).fromString(a);if(e.startsWith("#"))return(new t.Color).fromString(e);const s=e.split(" ").map(Number);return new t.Color(s)},c=e=>{const a=e.split(" ").map(Number);return new t.Vec2(a)},r=e=>{const a=e.split(" ").map(Number);return new t.Vec3(a)},b=e=>{const a=e.split(" ").map(Number);return new t.Vec4(a)};class h extends a{constructor(){super(...arguments),this._enabled=!0,this._name="Untitled",this._position=new t.Vec3,this._rotation=new t.Vec3,this._scale=new t.Vec3(1,1,1),this._tags=[],this._listeners={},this.entity=null}createEntity(e){this.entity=new t.Entity(this.getAttribute("name")||this._name,e);const a=this.getAttribute("enabled");a&&(this.entity.enabled="false"!==a);const s=this.getAttribute("position");s&&this.entity.setLocalPosition(r(s));const i=this.getAttribute("rotation");i&&this.entity.setLocalEulerAngles(r(i));const n=this.getAttribute("scale");n&&this.entity.setLocalScale(r(n));const o=this.getAttribute("tags");o&&this.entity.tags.add(o.split(",").map((e=>e.trim())));["onpointerenter","onpointerleave","onpointerdown","onpointerup","onpointermove"].forEach((e=>{const t=this.getAttribute(e);if(t){const a=e.substring(2),s=e=>{try{new Function("event",t).call(this,e)}catch(e){console.error("Error in event handler:",e)}};this.addEventListener(a,s)}}))}buildHierarchy(e){if(!this.entity)return;const t=this.closestEntity;(null==t?void 0:t.entity)?t.entity.addChild(this.entity):e.root.addChild(this.entity),this._onReady()}connectedCallback(){const e=this.closestApp;if(e&&e.hierarchyReady){const t=e.app;this.createEntity(t),this.buildHierarchy(t);const a=this.querySelectorAll("pc-entity");a.forEach((e=>{e.createEntity(t)})),a.forEach((e=>{e.buildHierarchy(t)}))}}disconnectedCallback(){if(this.entity){this.querySelectorAll("pc-entity").forEach((e=>{e.entity=null})),this.entity.destroy(),this.entity=null}}set enabled(e){this._enabled=e,this.entity&&(this.entity.enabled=e)}get enabled(){return this._enabled}set name(e){this._name=e,this.entity&&(this.entity.name=e)}get name(){return this._name}set position(e){this._position=e,this.entity&&this.entity.setLocalPosition(this._position)}get position(){return this._position}set rotation(e){this._rotation=e,this.entity&&this.entity.setLocalEulerAngles(this._rotation)}get rotation(){return this._rotation}set scale(e){this._scale=e,this.entity&&this.entity.setLocalScale(this._scale)}get scale(){return this._scale}set tags(e){this._tags=e,this.entity&&(this.entity.tags.clear(),this.entity.tags.add(this._tags))}get tags(){return this._tags}static get observedAttributes(){return["enabled","name","position","rotation","scale","tags","onpointerenter","onpointerleave","onpointerdown","onpointerup","onpointermove"]}attributeChangedCallback(e,t,a){switch(e){case"enabled":this.enabled="false"!==a;break;case"name":this.name=a;break;case"position":this.position=r(a);break;case"rotation":this.rotation=r(a);break;case"scale":this.scale=r(a);break;case"tags":this.tags=a.split(",").map((e=>e.trim()));break;case"onpointerenter":case"onpointerleave":case"onpointerdown":case"onpointerup":case"onpointermove":if(a){const t=e.substring(2),a=e=>{try{const a=this.getAttribute(t)||"";new Function("event",a).call(this,e)}catch(e){console.error("Error in event handler:",e)}};this.addEventListener(t,a)}}}addEventListener(e,t,a){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),super.addEventListener(e,t,a),e.startsWith("pointer")&&this.dispatchEvent(new CustomEvent(`${e}:connect`,{bubbles:!0}))}removeEventListener(e,t,a){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((e=>e!==t))),super.removeEventListener(e,t,a),e.startsWith("pointer")&&this.dispatchEvent(new CustomEvent(`${e}:disconnect`,{bubbles:!0}))}hasListeners(e){var t;return Boolean(null===(t=this._listeners[e])||void 0===t?void 0:t.length)}}customElements.define("pc-entity",h);var l=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var a,s=WebAssembly.validate(e)?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",i=WebAssembly.instantiate(n(s),{}).then((function(e){(a=e.instance).exports.__wasm_call_ctors()}));function n(e){for(var a=new Uint8Array(e.length),s=0;s<e.length;++s){var i=e.charCodeAt(s);a[s]=i>96?i-97:i>64?i-39:i+4}var n=0;for(s=0;s<e.length;++s)a[n++]=a[s]<60?t[a[s]]:64*(a[s]-60)+a[++s];return a.buffer.slice(0,n)}function o(e,t,s,i,n,o){var c=a.exports.sbrk,r=s+3&-4,b=c(r*i),h=c(n.length),l=new Uint8Array(a.exports.memory.buffer);l.set(n,h);var p=e(b,s,i,h,n.length);if(0==p&&o&&o(b,r,i),t.set(l.subarray(b,b+s*i)),c(b-c(0)),0!=p)throw new Error("Malformed buffer data: "+p)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},b=[],h=0;function l(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var a=e.data;t.pending-=a.count,t.requests[a.id][a.action](a.value),delete t.requests[a.id]},t}function p(e){for(var t="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(n(s))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+o.toString()+d.toString(),a=new Blob([t],{type:"text/javascript"}),i=URL.createObjectURL(a),c=0;c<e;++c)b[c]=l(i);URL.revokeObjectURL(i)}function d(e){i.then((function(){var t=e.data;try{var s=new Uint8Array(t.count*t.size);o(a.exports[t.mode],s,t.count,t.size,t.source,a.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:s},[s.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}}))}return{ready:i,supported:!0,useWorkers:function(e){p(e)},decodeVertexBuffer:function(e,t,s,i,n){o(a.exports.meshopt_decodeVertexBuffer,e,t,s,i,a.exports[c[n]])},decodeIndexBuffer:function(e,t,s,i){o(a.exports.meshopt_decodeIndexBuffer,e,t,s,i)},decodeIndexSequence:function(e,t,s,i){o(a.exports.meshopt_decodeIndexSequence,e,t,s,i)},decodeGltfBuffer:function(e,t,s,i,n,b){o(a.exports[r[n]],e,t,s,i,a.exports[c[b]])},decodeGltfBufferAsync:function(e,t,s,n,l){return b.length>0?function(e,t,a,s,i){for(var n=b[0],o=1;o<b.length;++o)b[o].pending<n.pending&&(n=b[o]);return new Promise((function(o,c){var r=new Uint8Array(a),b=h++;n.pending+=e,n.requests[b]={resolve:o,reject:c},n.object.postMessage({id:b,count:e,size:t,source:r,mode:s,filter:i},[r.buffer])}))}(e,t,s,r[n],c[l]):i.then((function(){var i=new Uint8Array(e*t);return o(a.exports[r[n]],i,e,t,s,a.exports[c[l]]),i}))}}}();const p=new Map([["bin","binary"],["css","css"],["frag","shader"],["glb","container"],["glsl","shader"],["hdr","texture"],["html","html"],["jpg","texture"],["js","script"],["json","json"],["mp3","audio"],["mjs","script"],["ply","gsplat"],["png","texture"],["txt","text"],["vert","shader"],["webp","texture"]]),d=(e,t,a)=>{if(e.extensions&&e.extensions.EXT_meshopt_compression){const s=e.extensions.EXT_meshopt_compression;Promise.all([l.ready,t[s.buffer]]).then((e=>{const t=e[1],i=s.byteOffset||0,n=s.byteLength||0,o=s.count,c=s.byteStride,r=new Uint8Array(o*c),b=new Uint8Array(t.buffer,t.byteOffset+i,n);l.decodeGltfBuffer(r,o,c,b,s.mode,s.filter),a(null,r)}))}else a(null,null)};class f extends HTMLElement{constructor(){super(...arguments),this._lazy=!1,this.asset=null}disconnectedCallback(){this.destroyAsset()}createAsset(){var e;const a=this.getAttribute("id")||"",s=this.getAttribute("src")||"";let i=this.getAttribute("type");if(!i){const t=s.split(".").pop();i=null!==(e=p.get(t||""))&&void 0!==e?e:null}i?(this.asset="container"===i?new t.Asset(a,i,{url:s},void 0,{bufferView:{processAsync:d.bind(this)}}):new t.Asset(a,i,{url:s}),this.asset.preload=!this._lazy):console.warn(`Unsupported asset type: ${s}`)}destroyAsset(){this.asset&&(this.asset.unload(),this.asset=null)}set lazy(e){this._lazy=e,this.asset&&(this.asset.preload=!e)}get lazy(){return this._lazy}static get(e){const t=document.querySelector(`pc-asset[id="${e}"]`);return null==t?void 0:t.asset}static get observedAttributes(){return["lazy"]}attributeChangedCallback(e,t,a){"lazy"===e&&(this.lazy=this.hasAttribute("lazy"))}}customElements.define("pc-asset",f);class g extends a{constructor(e){super(),this._enabled=!0,this._component=null,this._componentName=e}getInitialComponentData(){return{}}async addComponent(){const e=this.closestEntity;if(e){await e.ready();const t=this.getInitialComponentData();this._component=e.entity.addComponent(this._componentName,t)}}initComponent(){}async connectedCallback(){var e;await(null===(e=this.closestApp)||void 0===e?void 0:e.ready()),await this.addComponent(),this.initComponent(),this._onReady()}disconnectedCallback(){this.component&&this.component.entity&&(this._component.entity.removeComponent(this._componentName),this._component=null)}get component(){return this._component}set enabled(e){this._enabled=e,this.component&&(this.component.enabled=e)}get enabled(){return this._enabled}static get observedAttributes(){return["enabled"]}attributeChangedCallback(e,t,a){if("enabled"===e)this.enabled="false"!==a}}class u extends g{constructor(){super("audiolistener")}get component(){return super.component}}customElements.define("pc-listener",u);const m=new Map([["none",t.TONEMAP_NONE],["linear",t.TONEMAP_LINEAR],["filmic",t.TONEMAP_FILMIC],["hejl",t.TONEMAP_HEJL],["aces",t.TONEMAP_ACES],["aces2",t.TONEMAP_ACES2],["neutral",t.TONEMAP_NEUTRAL]]);class _ extends g{constructor(){super("camera"),this._clearColor=new t.Color(.75,.75,.75,1),this._clearColorBuffer=!0,this._clearDepthBuffer=!0,this._clearStencilBuffer=!1,this._cullFaces=!0,this._farClip=1e3,this._flipFaces=!1,this._fov=45,this._frustumCulling=!0,this._gamma="srgb",this._horizontalFov=!1,this._nearClip=.1,this._orthographic=!1,this._orthoHeight=10,this._priority=0,this._rect=new t.Vec4(0,0,1,1),this._scissorRect=new t.Vec4(0,0,1,1),this._tonemap="none"}getInitialComponentData(){return{clearColor:this._clearColor,clearColorBuffer:this._clearColorBuffer,clearDepthBuffer:this._clearDepthBuffer,clearStencilBuffer:this._clearStencilBuffer,cullFaces:this._cullFaces,farClip:this._farClip,flipFaces:this._flipFaces,fov:this._fov,frustumCulling:this._frustumCulling,gammaCorrection:"srgb"===this._gamma?t.GAMMA_SRGB:t.GAMMA_NONE,horizontalFov:this._horizontalFov,nearClip:this._nearClip,orthographic:this._orthographic,orthoHeight:this._orthoHeight,priority:this._priority,rect:this._rect,scissorRect:this._scissorRect,toneMapping:m.get(this._tonemap)}}get xrAvailable(){var e;const a=null===(e=this.component)||void 0===e?void 0:e.system.app.xr;return a&&a.supported&&a.isAvailable(t.XRTYPE_VR)}startXr(e,t){this.component&&this.xrAvailable&&this.component.startXr(e,t,{callback:e=>{e&&console.error(`WebXR Immersive VR failed to start: ${e.message}`)}})}endXr(){this.component&&this.component.endXr()}get component(){return super.component}set clearColor(e){this._clearColor=e,this.component&&(this.component.clearColor=e)}get clearColor(){return this._clearColor}set clearColorBuffer(e){this._clearColorBuffer=e,this.component&&(this.component.clearColorBuffer=e)}get clearColorBuffer(){return this._clearColorBuffer}set clearDepthBuffer(e){this._clearDepthBuffer=e,this.component&&(this.component.clearDepthBuffer=e)}get clearDepthBuffer(){return this._clearDepthBuffer}set clearStencilBuffer(e){this._clearStencilBuffer=e,this.component&&(this.component.clearStencilBuffer=e)}get clearStencilBuffer(){return this._clearStencilBuffer}set cullFaces(e){this._cullFaces=e,this.component&&(this.component.cullFaces=e)}get cullFaces(){return this._cullFaces}set farClip(e){this._farClip=e,this.component&&(this.component.farClip=e)}get farClip(){return this._farClip}set flipFaces(e){this._flipFaces=e,this.component&&(this.component.flipFaces=e)}get flipFaces(){return this._flipFaces}set fov(e){this._fov=e,this.component&&(this.component.fov=e)}get fov(){return this._fov}set frustumCulling(e){this._frustumCulling=e,this.component&&(this.component.frustumCulling=e)}get frustumCulling(){return this._frustumCulling}set gamma(e){this._gamma=e,this.component&&(this.component.gammaCorrection="srgb"===e?t.GAMMA_SRGB:t.GAMMA_NONE)}get gamma(){return this._gamma}set horizontalFov(e){this._horizontalFov=e,this.component&&(this.component.horizontalFov=e)}get horizontalFov(){return this._horizontalFov}set nearClip(e){this._nearClip=e,this.component&&(this.component.nearClip=e)}get nearClip(){return this._nearClip}set orthographic(e){this._orthographic=e,this.component&&(this.component.projection=e?t.PROJECTION_ORTHOGRAPHIC:t.PROJECTION_PERSPECTIVE)}get orthographic(){return this._orthographic}set orthoHeight(e){this._orthoHeight=e,this.component&&(this.component.orthoHeight=e)}get orthoHeight(){return this._orthoHeight}set priority(e){this._priority=e,this.component&&(this.component.priority=e)}get priority(){return this._priority}set rect(e){this._rect=e,this.component&&(this.component.rect=e)}get rect(){return this._rect}set scissorRect(e){this._scissorRect=e,this.component&&(this.component.scissorRect=e)}get scissorRect(){return this._scissorRect}set tonemap(e){var a;this._tonemap=e,this.component&&(this.component.toneMapping=null!==(a=m.get(e))&&void 0!==a?a:t.TONEMAP_NONE)}get tonemap(){return this._tonemap}static get observedAttributes(){return[...super.observedAttributes,"clear-color","clear-color-buffer","clear-depth-buffer","clear-stencil-buffer","cull-faces","far-clip","flip-faces","fov","frustum-culling","gamma","horizontal-fov","near-clip","orthographic","ortho-height","priority","rect","scissor-rect","tonemap"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"clear-color":this.clearColor=o(a);break;case"clear-color-buffer":this.clearColorBuffer="false"!==a;break;case"clear-depth-buffer":this.clearDepthBuffer="false"!==a;break;case"clear-stencil-buffer":this.clearStencilBuffer="false"!==a;break;case"cull-faces":this.cullFaces="false"!==a;break;case"far-clip":this.farClip=parseFloat(a);break;case"flip-faces":this.flipFaces="true"!==a;break;case"fov":this.fov=parseFloat(a);break;case"frustum-culling":this.frustumCulling="false"!==a;break;case"gamma":this.gamma=a;break;case"horizontal-fov":this.horizontalFov=this.hasAttribute("horizontal-fov");break;case"near-clip":this.nearClip=parseFloat(a);break;case"orthographic":this.orthographic=this.hasAttribute("orthographic");break;case"ortho-height":this.orthoHeight=parseFloat(a);break;case"priority":this.priority=parseFloat(a);break;case"rect":this.rect=b(a);break;case"scissor-rect":this.scissorRect=b(a);break;case"tonemap":this.tonemap=a}}}customElements.define("pc-camera",_);class k extends g{constructor(){super("collision"),this._angularOffset=new t.Quat,this._axis=1,this._convexHull=!1,this._halfExtents=new t.Vec3(.5,.5,.5),this._height=2,this._linearOffset=new t.Vec3,this._radius=.5,this._type="box"}getInitialComponentData(){return{axis:this._axis,angularOffset:this._angularOffset,convexHull:this._convexHull,halfExtents:this._halfExtents,height:this._height,linearOffset:this._linearOffset,radius:this._radius,type:this._type}}get component(){return super.component}set angularOffset(e){this._angularOffset=e,this.component&&(this.component.angularOffset=e)}get angularOffset(){return this._angularOffset}set axis(e){this._axis=e,this.component&&(this.component.axis=e)}get axis(){return this._axis}set convexHull(e){this._convexHull=e,this.component&&(this.component.convexHull=e)}get convexHull(){return this._convexHull}set halfExtents(e){this._halfExtents=e,this.component&&(this.component.halfExtents=e)}get halfExtents(){return this._halfExtents}set height(e){this._height=e,this.component&&(this.component.height=e)}get height(){return this._height}set linearOffset(e){this._linearOffset=e,this.component&&(this.component.linearOffset=e)}get linearOffset(){return this._linearOffset}set radius(e){this._radius=e,this.component&&(this.component.radius=e)}get radius(){return this._radius}set type(e){this._type=e,this.component&&(this.component.type=e)}get type(){return this._type}static get observedAttributes(){return[...super.observedAttributes,"angular-offset","axis","convex-hull","half-extents","height","linear-offset","radius","type"]}attributeChangedCallback(e,a,s){switch(super.attributeChangedCallback(e,a,s),e){case"angular-offset":this.angularOffset=(e=>{const[a,s,i]=e.split(" ").map(Number),n=new t.Quat;return n.setFromEulerAngles(a,s,i),n})(s);break;case"axis":this.axis=parseInt(s,10);break;case"convex-hull":this.convexHull=this.hasAttribute("convex-hull");break;case"half-extents":this.halfExtents=r(s);break;case"height":this.height=parseFloat(s);break;case"linear-offset":this.linearOffset=r(s);break;case"radius":this.radius=parseFloat(s);break;case"type":this.type=s}}}customElements.define("pc-collision",k);class v extends g{constructor(){super("element"),this._anchor=new t.Vec4(.5,.5,.5,.5),this._asset="",this._autoWidth=!0,this._color=new t.Color(1,1,1,1),this._fontSize=32,this._lineHeight=32,this._pivot=new t.Vec2(.5,.5),this._text="",this._type="group",this._width=0,this._wrapLines=!1}initComponent(){this.component._text._material.useFog=!0}getInitialComponentData(){return{anchor:this._anchor,autoWidth:this._autoWidth,color:this._color,fontAsset:f.get(this._asset).id,fontSize:this._fontSize,lineHeight:this._lineHeight,pivot:this._pivot,type:this._type,text:this._text,width:this._width,wrapLines:this._wrapLines}}get component(){return super.component}set anchor(e){this._anchor=e,this.component&&(this.component.anchor=e)}get anchor(){return this._anchor}set asset(e){this._asset=e;const t=f.get(e);this.component&&t&&(this.component.fontAsset=t.id)}get asset(){return this._asset}set autoWidth(e){this._autoWidth=e,this.component&&(this.component.autoWidth=e)}get autoWidth(){return this._autoWidth}set color(e){this._color=e,this.component&&(this.component.color=e)}get color(){return this._color}set fontSize(e){this._fontSize=e,this.component&&(this.component.fontSize=e)}get fontSize(){return this._fontSize}set lineHeight(e){this._lineHeight=e,this.component&&(this.component.lineHeight=e)}get lineHeight(){return this._lineHeight}set pivot(e){this._pivot=e,this.component&&(this.component.pivot=e)}get pivot(){return this._pivot}set text(e){this._text=e,this.component&&(this.component.text=e)}get text(){return this._text}set type(e){this._type=e,this.component&&(this.component.type=e)}get type(){return this._type}set width(e){this._width=e,this.component&&(this.component.width=e)}get width(){return this._width}set wrapLines(e){this._wrapLines=e,this.component&&(this.component.wrapLines=e)}get wrapLines(){return this._wrapLines}static get observedAttributes(){return[...super.observedAttributes,"anchor","asset","auto-width","color","font-size","line-height","pivot","text","type","width","wrap-lines"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"anchor":this.anchor=b(a);break;case"asset":this.asset=a;break;case"auto-width":this.autoWidth="false"!==a;break;case"color":this.color=o(a);break;case"font-size":this.fontSize=Number(a);break;case"line-height":this.lineHeight=Number(a);break;case"pivot":this.pivot=c(a);break;case"text":this.text=a;break;case"type":this.type=a;break;case"width":this.width=Number(a);break;case"wrap-lines":this.wrapLines=this.hasAttribute(e)}}}customElements.define("pc-element",v);const y=new Map([["pcf1-16f",t.SHADOW_PCF1_16F],["pcf1-32f",t.SHADOW_PCF1_32F],["pcf3-16f",t.SHADOW_PCF3_16F],["pcf3-32f",t.SHADOW_PCF3_32F],["pcf5-16f",t.SHADOW_PCF5_16F],["pcf5-32f",t.SHADOW_PCF5_32F],["vsm-16f",t.SHADOW_VSM_16F],["vsm-32f",t.SHADOW_VSM_32F],["pcss-32f",t.SHADOW_PCSS_32F]]);class w extends g{constructor(){super("light"),this._castShadows=!1,this._color=new t.Color(1,1,1),this._innerConeAngle=40,this._intensity=1,this._normalOffsetBias=.05,this._outerConeAngle=45,this._range=10,this._shadowBias=.2,this._shadowDistance=16,this._shadowIntensity=1,this._shadowResolution=1024,this._shadowType="pcf3-32f",this._type="directional",this._vsmBias=.01}getInitialComponentData(){return{castShadows:this._castShadows,color:this._color,innerConeAngle:this._innerConeAngle,intensity:this._intensity,normalOffsetBias:this._normalOffsetBias,outerConeAngle:this._outerConeAngle,range:this._range,shadowBias:this._shadowBias,shadowDistance:this._shadowDistance,shadowIntensity:this._shadowIntensity,shadowResolution:this._shadowResolution,shadowType:y.get(this._shadowType),type:this._type,vsmBias:this._vsmBias}}get component(){return super.component}set castShadows(e){this._castShadows=e,this.component&&(this.component.castShadows=e)}get castShadows(){return this._castShadows}set color(e){this._color=e,this.component&&(this.component.color=e)}get color(){return this._color}set innerConeAngle(e){this._innerConeAngle=e,this.component&&(this.component.innerConeAngle=e)}get innerConeAngle(){return this._innerConeAngle}set intensity(e){this._intensity=e,this.component&&(this.component.intensity=e)}get intensity(){return this._intensity}set normalOffsetBias(e){this._normalOffsetBias=e,this.component&&(this.component.normalOffsetBias=e)}get normalOffsetBias(){return this._normalOffsetBias}set outerConeAngle(e){this._outerConeAngle=e,this.component&&(this.component.outerConeAngle=e)}get outerConeAngle(){return this._outerConeAngle}set range(e){this._range=e,this.component&&(this.component.range=e)}get range(){return this._range}set shadowBias(e){this._shadowBias=e,this.component&&(this.component.shadowBias=e)}get shadowBias(){return this._shadowBias}set shadowDistance(e){this._shadowDistance=e,this.component&&(this.component.shadowDistance=e)}get shadowDistance(){return this._shadowDistance}set shadowIntensity(e){this._shadowIntensity=e,this.component&&(this.component.shadowIntensity=e)}get shadowIntensity(){return this._shadowIntensity}set shadowResolution(e){this._shadowResolution=e,this.component&&(this.component.shadowResolution=e)}get shadowResolution(){return this._shadowResolution}set shadowType(e){var a;this._shadowType=e,this.component&&(this.component.shadowType=null!==(a=y.get(e))&&void 0!==a?a:t.SHADOW_PCF3_32F)}get shadowType(){return this._shadowType}set type(e){["directional","omni","spot"].includes(e)?(this._type=e,this.component&&(this.component.type=e)):console.warn(`Invalid light type '${e}', using default type '${this._type}'.`)}get type(){return this._type}set vsmBias(e){this._vsmBias=e,this.component&&(this.component.vsmBias=e)}get vsmBias(){return this._vsmBias}static get observedAttributes(){return[...super.observedAttributes,"color","cast-shadows","intensity","inner-cone-angle","normal-offset-bias","outer-cone-angle","range","shadow-bias","shadow-distance","shadow-intensity","shadow-resolution","shadow-type","type","vsm-bias"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"color":this.color=o(a);break;case"cast-shadows":this.castShadows=this.hasAttribute("cast-shadows");break;case"inner-cone-angle":this.innerConeAngle=Number(a);break;case"intensity":this.intensity=Number(a);break;case"normal-offset-bias":this.normalOffsetBias=Number(a);break;case"outer-cone-angle":this.outerConeAngle=Number(a);break;case"range":this.range=Number(a);break;case"shadow-bias":this.shadowBias=Number(a);break;case"shadow-distance":this.shadowDistance=Number(a);break;case"shadow-resolution":this.shadowResolution=Number(a);break;case"shadow-intensity":this.shadowIntensity=Number(a);break;case"shadow-type":this.shadowType=a;break;case"type":this.type=a;break;case"vsm-bias":this.vsmBias=Number(a)}}}customElements.define("pc-light",w);class A extends g{constructor(){super("particlesystem"),this._asset=""}getInitialComponentData(){var e;const t=f.get(this._asset);if(!t)return{};if(t.resource.colorMapAsset){const a=t.resource.colorMapAsset,s=null===(e=f.get(a))||void 0===e?void 0:e.id;s&&(t.resource.colorMapAsset=s)}return t.resource}get component(){return super.component}applyConfig(e){if(this.component)for(const t in e)e.hasOwnProperty(t)&&(this.component[t]=e[t])}async _loadAsset(){var e;const t=await(null===(e=this.closestApp)||void 0===e?void 0:e.ready()),a=null==t?void 0:t.app,s=f.get(this._asset);s&&(s.loaded?this.applyConfig(s.resource):(s.once("load",(()=>{this.applyConfig(s.resource)})),a.assets.load(s)))}set asset(e){this._asset=e,this.isConnected&&this._loadAsset()}get asset(){return this._asset}play(){this.component&&this.component.play()}pause(){this.component&&this.component.pause()}reset(){this.component&&this.component.reset()}stop(){this.component&&this.component.stop()}static get observedAttributes(){return[...super.observedAttributes,"asset"]}attributeChangedCallback(e,t,a){if(super.attributeChangedCallback(e,t,a),"asset"===e)this.asset=a}}customElements.define("pc-particles",A);class x extends HTMLElement{constructor(){super(...arguments),this._diffuse=new t.Color(1,1,1),this._diffuseMap="",this._metalnessMap="",this._normalMap="",this._roughnessMap="",this.material=null}createMaterial(){this.material=new t.StandardMaterial,this.material.glossInvert=!1,this.material.useMetalness=!1,this.material.diffuse=this._diffuse,this.diffuseMap=this._diffuseMap,this.metalnessMap=this._metalnessMap,this.normalMap=this._normalMap,this.roughnessMap=this._roughnessMap,this.material.update()}disconnectedCallback(){this.material&&(this.material.destroy(),this.material=null)}setMap(e,t){if(this.material){const a=f.get(e);a&&(a.loaded?(this.material[t]=a.resource,this.material[t].anisotropy=4):a.once("load",(()=>{this.material[t]=a.resource,this.material[t].anisotropy=4,this.material.update()})))}}set diffuse(e){this._diffuse=e,this.material&&(this.material.diffuse=e)}get diffuse(){return this._diffuse}set diffuseMap(e){this._diffuseMap=e,this.setMap(e,"diffuseMap")}get diffuseMap(){return this._diffuseMap}set metalnessMap(e){this._metalnessMap=e,this.setMap(e,"metalnessMap")}get metalnessMap(){return this._metalnessMap}set normalMap(e){this._normalMap=e,this.setMap(e,"normalMap")}get normalMap(){return this._normalMap}set roughnessMap(e){this._roughnessMap=e,this.setMap(e,"glossMap")}get roughnessMap(){return this._roughnessMap}static get(e){const t=document.querySelector(`pc-material[id="${e}"]`);return null==t?void 0:t.material}static get observedAttributes(){return["diffuse","diffuse-map","metalness-map","normal-map","roughness-map"]}attributeChangedCallback(e,t,a){switch(e){case"diffuse":this.diffuse=o(a);break;case"diffuse-map":this.diffuseMap=a;break;case"metalness-map":this.metalnessMap=a;break;case"normal-map":this.normalMap=a;break;case"roughness-map":this.roughnessMap=a}}}customElements.define("pc-material",x);class C extends g{constructor(){super("render"),this._castShadows=!0,this._material="",this._receiveShadows=!0,this._type="asset"}getInitialComponentData(){return{type:this._type,castShadows:this._castShadows,material:x.get(this._material),receiveShadows:this._receiveShadows}}get component(){return super.component}set type(e){this._type=e,this.component&&(this.component.type=e)}get type(){return this._type}set castShadows(e){this._castShadows=e,this.component&&(this.component.castShadows=e)}get castShadows(){return this._castShadows}set material(e){this._material=e,this.component&&(this.component.material=x.get(e))}get material(){return this._material}set receiveShadows(e){this._receiveShadows=e,this.component&&(this.component.receiveShadows=e)}get receiveShadows(){return this._receiveShadows}static get observedAttributes(){return[...super.observedAttributes,"cast-shadows","material","receive-shadows","type"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"cast-shadows":this.castShadows="false"!==a;break;case"material":this.material=a;break;case"receive-shadows":this.receiveShadows="false"!==a;break;case"type":this.type=a}}}customElements.define("pc-render",C);class j extends g{constructor(){super("rigidbody"),this._angularDamping=0,this._angularFactor=new t.Vec3(1,1,1),this._friction=.5,this._linearDamping=0,this._linearFactor=new t.Vec3(1,1,1),this._mass=1,this._restitution=0,this._rollingFriction=0,this._type="static"}getInitialComponentData(){return{angularDamping:this._angularDamping,angularFactor:this._angularFactor,friction:this._friction,linearDamping:this._linearDamping,linearFactor:this._linearFactor,mass:this._mass,restitution:this._restitution,rollingFriction:this._rollingFriction,type:this._type}}get component(){return super.component}set angularDamping(e){this._angularDamping=e,this.component&&(this.component.angularDamping=e)}get angularDamping(){return this._angularDamping}set angularFactor(e){this._angularFactor=e,this.component&&(this.component.angularFactor=e)}get angularFactor(){return this._angularFactor}set friction(e){this._friction=e,this.component&&(this.component.friction=e)}get friction(){return this._friction}set linearDamping(e){this._linearDamping=e,this.component&&(this.component.linearDamping=e)}get linearDamping(){return this._linearDamping}set linearFactor(e){this._linearFactor=e,this.component&&(this.component.linearFactor=e)}get linearFactor(){return this._linearFactor}set mass(e){this._mass=e,this.component&&(this.component.mass=e)}get mass(){return this._mass}set restitution(e){this._restitution=e,this.component&&(this.component.restitution=e)}get restitution(){return this._restitution}set rollingFriction(e){this._rollingFriction=e,this.component&&(this.component.rollingFriction=e)}get rollingFriction(){return this._rollingFriction}set type(e){this._type=e,this.component&&(this.component.type=e)}get type(){return this._type}static get observedAttributes(){return[...super.observedAttributes,"angular-damping","angular-factor","friction","linear-damping","linear-factor","mass","restitution","rolling-friction","type"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"angular-damping":this.angularDamping=parseFloat(a);break;case"angular-factor":this.angularFactor=r(a);break;case"friction":this.friction=parseFloat(a);break;case"linear-damping":this.linearDamping=parseFloat(a);break;case"linear-factor":this.linearFactor=r(a);break;case"mass":this.mass=parseFloat(a);break;case"restitution":this.restitution=parseFloat(a);break;case"rolling-friction":this.rollingFriction=parseFloat(a);break;case"type":this.type=a}}}customElements.define("pc-rigidbody",j);class F extends g{constructor(){super("screen"),this._screenSpace=!1,this._resolution=new t.Vec2(640,320),this._referenceResolution=new t.Vec2(640,320),this._priority=0,this._blend=!1,this._scaleBlend=.5}getInitialComponentData(){return{priority:this._priority,referenceResolution:this._referenceResolution,resolution:this._resolution,scaleBlend:this._scaleBlend,scaleMode:this._blend?t.SCALEMODE_BLEND:t.SCALEMODE_NONE,screenSpace:this._screenSpace}}get component(){return super.component}set priority(e){this._priority=e,this.component&&(this.component.priority=this._priority)}get priority(){return this._priority}set referenceResolution(e){this._referenceResolution=e,this.component&&(this.component.referenceResolution=this._referenceResolution)}get referenceResolution(){return this._referenceResolution}set resolution(e){this._resolution=e,this.component&&(this.component.resolution=this._resolution)}get resolution(){return this._resolution}set scaleBlend(e){this._scaleBlend=e,this.component&&(this.component.scaleBlend=this._scaleBlend)}get scaleBlend(){return this._scaleBlend}set blend(e){this._blend=e,this.component&&(this.component.scaleMode=this._blend?t.SCALEMODE_BLEND:t.SCALEMODE_NONE)}get blend(){return this._blend}set screenSpace(e){this._screenSpace=e,this.component&&(this.component.screenSpace=this._screenSpace)}get screenSpace(){return this._screenSpace}static get observedAttributes(){return[...super.observedAttributes,"blend","screen-space","resolution","reference-resolution","priority","scale-blend"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"priority":this.priority=parseInt(a,10);break;case"reference-resolution":this.referenceResolution=c(a);break;case"resolution":this.resolution=c(a);break;case"scale-blend":this.scaleBlend=parseFloat(a);break;case"blend":this.blend=this.hasAttribute("blend");break;case"screen-space":this.screenSpace=this.hasAttribute("screen-space")}}}customElements.define("pc-screen",F);class E extends g{constructor(){super("script"),this.observer=new MutationObserver(this.handleMutations.bind(this)),this.observer.observe(this,{childList:!0}),this.addEventListener("scriptattributeschange",this.handleScriptAttributesChange.bind(this)),this.addEventListener("scriptenablechange",this.handleScriptEnableChange.bind(this))}initComponent(){this.querySelectorAll(":scope > pc-script").forEach((e=>{const t=e.getAttribute("name"),a=e.getAttribute("attributes");t&&this.createScript(t,a)}))}convertAttributes(e){if("string"==typeof e){if(e.startsWith("asset:")){const t=e.slice(6),a=document.querySelector(`pc-asset#${t}`);if(a)return a.asset}if(e.startsWith("entity:")){const t=e.slice(7),a=document.querySelector(`pc-entity[name="${t}"]`);if(a)return a.entity}if(e.startsWith("vec2:")){const a=e.slice(5).split(",").map(Number);if(2===a.length&&a.every((e=>!isNaN(e))))return new t.Vec2(a[0],a[1])}if(e.startsWith("vec3:")){const a=e.slice(5).split(",").map(Number);if(3===a.length&&a.every((e=>!isNaN(e))))return new t.Vec3(a[0],a[1],a[2])}if(e.startsWith("vec4:")){const a=e.slice(5).split(",").map(Number);if(4===a.length&&a.every((e=>!isNaN(e))))return new t.Vec4(a[0],a[1],a[2],a[3])}if(e.startsWith("color:")){const a=e.slice(6).split(",").map(Number);if(4===a.length&&a.every((e=>!isNaN(e))))return new t.Color(a[0],a[1],a[2],a[3])}return e}if(Array.isArray(e))return e.length>0&&e[0],e.map((e=>this.convertAttributes(e)));if(e&&"object"==typeof e){const t={};for(const a in e)t[a]=this.convertAttributes(e[a]);return t}return e}preprocessAttributes(e){return this.convertAttributes(e)}mergeDeep(e,t){for(const a in t)t[a]&&"object"==typeof t[a]&&!Array.isArray(t[a])?(e[a]&&"object"==typeof e[a]||(e[a]={}),this.mergeDeep(e[a],t[a])):e[a]=t[a];return e}applyAttributes(e,t){try{const a=t?JSON.parse(t):{},s=this.convertAttributes(a);this.mergeDeep(e,s)}catch(e){console.error(`Error parsing attributes JSON string ${t}:`,e)}}handleScriptAttributesChange(e){const t=e.target.getAttribute("name");if(!t||!this.component)return;const a=this.component.get(t);a&&this.applyAttributes(a,e.detail.attributes)}handleScriptEnableChange(e){const t=e.target.getAttribute("name");if(!t||!this.component)return;const a=this.component.get(t);a&&(a.enabled=e.detail.enabled)}createScript(e,t){if(!this.component)return null;let a={};if(t)try{a=JSON.parse(t),a=this.preprocessAttributes(a)}catch(e){console.error(`Error parsing attributes JSON string ${t}:`,e)}return this.component.create(e,{properties:a})}destroyScript(e){this.component&&this.component.destroy(e)}handleMutations(e){for(const t of e)t.addedNodes.forEach((e=>{if(e instanceof HTMLElement&&"pc-script"===e.tagName.toLowerCase()){const t=e.getAttribute("name"),a=e.getAttribute("attributes");t&&this.createScript(t,a)}})),t.removedNodes.forEach((e=>{if(e instanceof HTMLElement&&"pc-script"===e.tagName.toLowerCase()){const t=e.getAttribute("name");t&&this.destroyScript(t)}}))}disconnectedCallback(){var e;this.observer.disconnect(),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}get component(){return super.component}}customElements.define("pc-scripts",E);class S extends HTMLElement{constructor(){super(...arguments),this._attributes="{}",this._enabled=!0,this._name=""}set scriptAttributes(e){this._attributes=e,this.dispatchEvent(new CustomEvent("scriptattributeschange",{detail:{attributes:e},bubbles:!0}))}get scriptAttributes(){return this._attributes}set enabled(e){this._enabled=e,this.dispatchEvent(new CustomEvent("scriptenablechange",{detail:{enabled:e},bubbles:!0}))}get enabled(){return this._enabled}set name(e){this._name=e}get name(){return this._name}static get observedAttributes(){return["attributes","enabled","name"]}attributeChangedCallback(e,t,a){switch(e){case"attributes":this.scriptAttributes=a;break;case"enabled":this.enabled="false"!==a;break;case"name":this.name=a}}}customElements.define("pc-script",S);class O extends g{constructor(){super("sound"),this._distanceModel="linear",this._maxDistance=1e4,this._pitch=1,this._positional=!1,this._refDistance=1,this._rollOffFactor=1,this._volume=1}getInitialComponentData(){return{distanceModel:this._distanceModel,maxDistance:this._maxDistance,pitch:this._pitch,positional:this._positional,refDistance:this._refDistance,rollOffFactor:this._rollOffFactor,volume:this._volume}}get component(){return super.component}set distanceModel(e){this._distanceModel=e,this.component&&(this.component.distanceModel=e)}get distanceModel(){return this._distanceModel}set maxDistance(e){this._maxDistance=e,this.component&&(this.component.maxDistance=e)}get maxDistance(){return this._maxDistance}set pitch(e){this._pitch=e,this.component&&(this.component.pitch=e)}get pitch(){return this._pitch}set positional(e){this._positional=e,this.component&&(this.component.positional=e)}get positional(){return this._positional}set refDistance(e){this._refDistance=e,this.component&&(this.component.refDistance=e)}get refDistance(){return this._refDistance}set rollOffFactor(e){this._rollOffFactor=e,this.component&&(this.component.rollOffFactor=e)}get rollOffFactor(){return this._rollOffFactor}set volume(e){this._volume=e,this.component&&(this.component.volume=e)}get volume(){return this._volume}static get observedAttributes(){return[...super.observedAttributes,"distance-model","max-distance","pitch","positional","ref-distance","roll-off-factor","volume"]}attributeChangedCallback(e,t,a){switch(super.attributeChangedCallback(e,t,a),e){case"distance-model":this.distanceModel=a;break;case"max-distance":this.maxDistance=parseFloat(a);break;case"pitch":this.pitch=parseFloat(a);break;case"positional":this.positional=this.hasAttribute("positional");break;case"ref-distance":this.refDistance=parseFloat(a);break;case"roll-off-factor":this.rollOffFactor=parseFloat(a);break;case"volume":this.volume=parseFloat(a)}}}customElements.define("pc-sounds",O);class R extends a{constructor(){super(...arguments),this._asset="",this._autoPlay=!1,this._duration=null,this._loop=!1,this._name="",this._overlap=!1,this._pitch=1,this._startTime=0,this._volume=1,this.soundSlot=null}async connectedCallback(){var e;await(null===(e=this.soundElement)||void 0===e?void 0:e.ready());const t={autoPlay:this._autoPlay,loop:this._loop,overlap:this._overlap,pitch:this._pitch,startTime:this._startTime,volume:this._volume};this._duration&&(t.duration=this._duration),this.soundSlot=this.soundElement.component.addSlot(this._name,t),this.asset=this._asset,this.soundSlot.play(),this._onReady()}disconnectedCallback(){this.soundElement.component.removeSlot(this._name)}get soundElement(){const e=this.parentElement;return e instanceof O?e:(console.warn("pc-sound-slot must be a direct child of a pc-sound element"),null)}set asset(e){var t;if(this._asset=e,this.soundSlot){const a=null===(t=f.get(e))||void 0===t?void 0:t.id;a&&(this.soundSlot.asset=a)}}get asset(){return this._asset}set autoPlay(e){this._autoPlay=e,this.soundSlot&&(this.soundSlot.autoPlay=e)}get autoPlay(){return this._autoPlay}set duration(e){this._duration=e,this.soundSlot&&(this.soundSlot.duration=e)}get duration(){return this._duration}set loop(e){this._loop=e,this.soundSlot&&(this.soundSlot.loop=e)}get loop(){return this._loop}set name(e){this._name=e,this.soundSlot&&(this.soundSlot.name=e)}get name(){return this._name}set overlap(e){this._overlap=e,this.soundSlot&&(this.soundSlot.overlap=e)}get overlap(){return this._overlap}set pitch(e){this._pitch=e,this.soundSlot&&(this.soundSlot.pitch=e)}get pitch(){return this._pitch}set startTime(e){this._startTime=e,this.soundSlot&&(this.soundSlot.startTime=e)}get startTime(){return this._startTime}set volume(e){this._volume=e,this.soundSlot&&(this.soundSlot.volume=e)}get volume(){return this._volume}static get observedAttributes(){return["asset","autoPlay","duration","loop","name","overlap","pitch","startTime","volume"]}attributeChangedCallback(e,t,a){switch(e){case"asset":this.asset=a;break;case"duration":this.duration=parseFloat(a);break;case"loop":this.loop=this.hasAttribute("loop");break;case"name":this.name=a;break;case"overlap":this.overlap=this.hasAttribute("overlap");break;case"pitch":this.pitch=parseFloat(a);break;case"startTime":this.startTime=parseFloat(a);break;case"volume":this.volume=parseFloat(a)}}}customElements.define("pc-sound",R);class P extends g{constructor(){super("gsplat"),this._asset=""}getInitialComponentData(){return{asset:f.get(this._asset)}}get component(){return super.component}set asset(e){this._asset=e;const t=f.get(e);this.component&&t&&(this.component.asset=t)}get asset(){return this._asset}static get observedAttributes(){return[...super.observedAttributes,"asset"]}attributeChangedCallback(e,t,a){if(super.attributeChangedCallback(e,t,a),"asset"===e)this.asset=a}}customElements.define("pc-splat",P);class D extends a{constructor(){super(...arguments),this._asset="",this._entity=null}connectedCallback(){this._loadModel(),this._onReady()}disconnectedCallback(){this._unloadModel()}_instantiate(e){this._entity=e.instantiateRenderEntity(),e.animations.length>0&&(this._entity.addComponent("anim"),this._entity.anim.assignAnimation("animation",e.animations[0].resource));const t=this.closestEntity;if(t)t.ready().then((()=>{t.entity.addChild(this._entity)}));else{const e=this.closestApp;e&&e.ready().then((()=>{e.app.root.addChild(this._entity)}))}}async _loadModel(){var e;this._unloadModel();const t=await(null===(e=this.closestApp)||void 0===e?void 0:e.ready()),a=null==t?void 0:t.app,s=f.get(this._asset);s&&(s.loaded?this._instantiate(s.resource):(s.once("load",(()=>{this._instantiate(s.resource)})),a.assets.load(s)))}_unloadModel(){var e;null===(e=this._entity)||void 0===e||e.destroy(),this._entity=null}set asset(e){this._asset=e,this.isConnected&&this._loadModel()}get asset(){return this._asset}static get observedAttributes(){return["asset"]}attributeChangedCallback(e,t,a){if("asset"===e)this.asset=a}}customElements.define("pc-model",D);class G extends a{constructor(){super(...arguments),this._fog="none",this._fogColor=new t.Color(1,1,1),this._fogDensity=0,this._fogStart=0,this._fogEnd=1e3,this._gravity=new t.Vec3(0,-9.81,0),this.scene=null}async connectedCallback(){var e;await(null===(e=this.closestApp)||void 0===e?void 0:e.ready()),this.scene=this.closestApp.app.scene,this.updateSceneSettings(),this._onReady()}updateSceneSettings(){if(this.scene){this.scene.fog.type=this._fog,this.scene.fog.color=this._fogColor,this.scene.fog.density=this._fogDensity,this.scene.fog.start=this._fogStart,this.scene.fog.end=this._fogEnd;this.parentElement.app.systems.rigidbody.gravity.copy(this._gravity)}}set fog(e){this._fog=e,this.scene&&(this.scene.fog.type=e)}get fog(){return this._fog}set fogColor(e){this._fogColor=e,this.scene&&(this.scene.fog.color=e)}get fogColor(){return this._fogColor}set fogDensity(e){this._fogDensity=e,this.scene&&(this.scene.fog.density=e)}get fogDensity(){return this._fogDensity}set fogStart(e){this._fogStart=e,this.scene&&(this.scene.fog.start=e)}get fogStart(){return this._fogStart}set fogEnd(e){this._fogEnd=e,this.scene&&(this.scene.fog.end=e)}get fogEnd(){return this._fogEnd}set gravity(e){if(this._gravity=e,this.scene){this.parentElement.app.systems.rigidbody.gravity.copy(e)}}get gravity(){return this._gravity}static get observedAttributes(){return["fog","fog-color","fog-density","fog-start","fog-end","gravity"]}attributeChangedCallback(e,t,a){switch(e){case"fog":this.fog=a;break;case"fog-color":this.fogColor=o(a);break;case"fog-density":this.fogDensity=parseFloat(a);break;case"fog-start":this.fogStart=parseFloat(a);break;case"fog-end":this.fogEnd=parseFloat(a);break;case"gravity":this.gravity=r(a)}}}customElements.define("pc-scene",G);class z extends a{constructor(){super(...arguments),this._asset="",this._center=new t.Vec3(0,.01,0),this._intensity=1,this._rotation=new t.Vec3,this._level=0,this._lighting=!1,this._scale=new t.Vec3(100,100,100),this._type="infinite",this._scene=null}connectedCallback(){this._loadSkybox(),this._onReady()}disconnectedCallback(){this._unloadSkybox()}_generateSkybox(e){if(!this._scene)return;const a=e.resource,s=t.EnvLighting.generateSkyboxCubemap(a);if(s.anisotropy=4,this._scene.skybox=s,this._lighting){const e=t.EnvLighting.generateLightingSource(a),s=t.EnvLighting.generateAtlas(e);this._scene.envAtlas=s}const i=this._scene.layers.getLayerById(t.LAYERID_SKYBOX);i&&(i.enabled="none"!==this._type),this._scene.sky.type=this._type,this._scene.sky.node.setLocalScale(this._scale),this._scene.sky.center=this._center,this._scene.skyboxIntensity=this._intensity}async _loadSkybox(){var e;const t=await(null===(e=this.closestApp)||void 0===e?void 0:e.ready()),a=null==t?void 0:t.app;if(!a)return;const s=f.get(this._asset);s&&(this._scene=a.scene,s.loaded?this._generateSkybox(s):(s.once("load",(()=>{this._generateSkybox(s)})),a.assets.load(s)))}_unloadSkybox(){var e,t;this._scene&&(null===(e=this._scene.skybox)||void 0===e||e.destroy(),this._scene.skybox=null,null===(t=this._scene.envAtlas)||void 0===t||t.destroy(),this._scene.envAtlas=null,this._scene=null)}set asset(e){this._asset=e,this.isConnected&&this._loadSkybox()}get asset(){return this._asset}set center(e){this._center=e,this._scene&&(this._scene.sky.center=this._center)}get center(){return this._center}set intensity(e){this._intensity=e,this._scene&&(this._scene.skyboxIntensity=this._intensity)}get intensity(){return this._intensity}set level(e){this._level=e,this._scene&&(this._scene.skyboxMip=this._level)}get level(){return this._level}set lighting(e){this._lighting=e}get lighting(){return this._lighting}set rotation(e){this._rotation=e,this._scene&&(this._scene.skyboxRotation=(new t.Quat).setFromEulerAngles(e))}get rotation(){return this._rotation}set scale(e){this._scale=e,this._scene&&this._scene.sky.node.setLocalScale(this._scale)}get scale(){return this._scale}set type(e){if(this._type=e,this._scene){this._scene.sky.type=this._type;const e=this._scene.layers.getLayerById(t.LAYERID_SKYBOX);e&&(e.enabled="none"!==this._type)}}get type(){return this._type}static get observedAttributes(){return["asset","center","intensity","level","lighting","rotation","scale","type"]}attributeChangedCallback(e,t,a){switch(e){case"asset":this.asset=a;break;case"center":this.center=r(a);break;case"intensity":this.intensity=parseFloat(a);break;case"level":this.level=parseInt(a,10);break;case"lighting":this.lighting=this.hasAttribute(e);break;case"rotation":this.rotation=r(a);break;case"scale":this.scale=r(a);break;case"type":this.type=a}}}customElements.define("pc-sky",z),e.AppElement=i,e.AssetElement=f,e.AsyncElement=a,e.CameraComponentElement=_,e.CollisionComponentElement=k,e.ComponentElement=g,e.ElementComponentElement=v,e.EntityElement=h,e.LightComponentElement=w,e.ListenerComponentElement=u,e.MaterialElement=x,e.ModelElement=D,e.ModuleElement=s,e.ParticleSystemComponentElement=A,e.RenderComponentElement=C,e.RigidBodyComponentElement=j,e.SceneElement=G,e.ScreenComponentElement=F,e.ScriptComponentElement=E,e.ScriptElement=S,e.SkyElement=z,e.SoundComponentElement=O,e.SoundSlotElement=R,e.SplatComponentElement=P}));
2
2
  //# sourceMappingURL=pwc.min.js.map