@needle-tools/engine 3.5.9-beta → 3.5.9-beta.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.5.9-beta.1] - 2023-05-19
8
+ - Fix: SceneSwitcher should ignore swipe events when `useSwipe` is disabled
9
+
7
10
  ## [3.5.9-beta] - 2023-05-19
8
11
  - Add: Support for progressive texture loading for custom shaders
9
12
  - Fix: react-three-fiber template
@@ -74944,7 +74944,7 @@ class yo extends mA {
74944
74944
  r(this, "normalizedSwipeThresholdX", 0.1);
74945
74945
  r(this, "_didSwipe", !1);
74946
74946
  r(this, "onPointerMove", (e) => {
74947
- if (!this._didSwipe && e.button === 0 && e.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
74947
+ if (this.useSwipe && !this._didSwipe && e.button === 0 && e.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
74948
74948
  const t = this.context.input.getPointerPositionDelta(e.button);
74949
74949
  if (t) {
74950
74950
  const g = t.x / this.context.domWidth;
@@ -74944,7 +74944,7 @@ class ho extends Se {
74944
74944
  u(this, "normalizedSwipeThresholdX", 0.1);
74945
74945
  u(this, "_didSwipe", !1);
74946
74946
  u(this, "onPointerMove", (t) => {
74947
- if (!this._didSwipe && t.button === 0 && t.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
74947
+ if (this.useSwipe && !this._didSwipe && t.button === 0 && t.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
74948
74948
  const i = this.context.input.getPointerPositionDelta(t.button);
74949
74949
  if (i) {
74950
74950
  const s = i.x / this.context.domWidth;
@@ -4970,7 +4970,7 @@ void main() {
4970
4970
  `,r=function(d,p,f){p=p||1024;let g=d.pos,m=-1,v=0,A="",b=String.fromCharCode.apply(null,new Uint16Array(d.subarray(g,g+128)));for(;0>(m=b.indexOf(s))&&v<p&&g<d.byteLength;)A+=b,v+=b.length,g+=128,b+=String.fromCharCode.apply(null,new Uint16Array(d.subarray(g,g+128)));return-1<m?(f!==!1&&(d.pos+=v+m+1),A+b.slice(0,m)):!1},n=function(d){const p=/^#\?(\S+)/,f=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,g=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,m=/^\s*FORMAT=(\S+)\s*$/,v=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,A={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let b,y;if(d.pos>=d.byteLength||!(b=r(d)))return t(1,"no header found");if(!(y=b.match(p)))return t(3,"bad initial token");for(A.valid|=1,A.programtype=y[1],A.string+=b+`
4971
4971
  `;b=r(d),b!==!1;){if(A.string+=b+`
4972
4972
  `,b.charAt(0)==="#"){A.comments+=b+`
4973
- `;continue}if((y=b.match(f))&&(A.gamma=parseFloat(y[1])),(y=b.match(g))&&(A.exposure=parseFloat(y[1])),(y=b.match(m))&&(A.valid|=2,A.format=y[1]),(y=b.match(v))&&(A.valid|=4,A.height=parseInt(y[1],10),A.width=parseInt(y[2],10)),A.valid&2&&A.valid&4)break}return A.valid&2?A.valid&4?A:t(3,"missing image size specifier"):t(3,"missing format specifier")},o=function(d,p,f){const g=p;if(g<8||g>32767||d[0]!==2||d[1]!==2||d[2]&128)return new Uint8Array(d);if(g!==(d[2]<<8|d[3]))return t(3,"wrong scanline width");const m=new Uint8Array(4*p*f);if(!m.length)return t(4,"unable to allocate buffer space");let v=0,A=0;const b=4*g,y=new Uint8Array(4),_=new Uint8Array(b);let w=f;for(;w>0&&A<d.byteLength;){if(A+4>d.byteLength)return t(1);if(y[0]=d[A++],y[1]=d[A++],y[2]=d[A++],y[3]=d[A++],y[0]!=2||y[1]!=2||(y[2]<<8|y[3])!=g)return t(3,"bad rgbe scanline format");let E=0,P;for(;E<b&&A<d.byteLength;){P=d[A++];const R=P>128;if(R&&(P-=128),P===0||E+P>b)return t(3,"bad scanline data");if(R){const T=d[A++];for(let z=0;z<P;z++)_[E++]=T}else _.set(d.subarray(A,A+P),E),E+=P,A+=P}const C=g;for(let R=0;R<C;R++){let T=0;m[v]=_[R+T],T+=g,m[v+1]=_[R+T],T+=g,m[v+2]=_[R+T],T+=g,m[v+3]=_[R+T],v+=4}w--}return m},a=function(d,p,f,g){const m=d[p+3],v=Math.pow(2,m-128)/255;f[g+0]=d[p+0]*v,f[g+1]=d[p+1]*v,f[g+2]=d[p+2]*v,f[g+3]=1},l=function(d,p,f,g){const m=d[p+3],v=Math.pow(2,m-128)/255;f[g+0]=Oh.toHalfFloat(Math.min(d[p+0]*v,65504)),f[g+1]=Oh.toHalfFloat(Math.min(d[p+1]*v,65504)),f[g+2]=Oh.toHalfFloat(Math.min(d[p+2]*v,65504)),f[g+3]=Oh.toHalfFloat(1)},c=new Uint8Array(e);c.pos=0;const u=n(c);if(u!==-1){const d=u.width,p=u.height,f=o(c.subarray(c.pos),d,p);if(f!==-1){let g,m,v;switch(this.type){case is:v=f.length/4;const A=new Float32Array(v*4);for(let y=0;y<v;y++)a(f,y*4,A,y*4);g=A,m=is;break;case ms:v=f.length/4;const b=new Uint16Array(v*4);for(let y=0;y<v;y++)l(f,y*4,b,y*4);g=b,m=ms;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:d,height:p,data:g,header:u.string,gamma:u.gamma,exposure:u.exposure,type:m}}}return null}setDataType(e){return this.type=e,this}load(e,t,s,r){function n(o,a){switch(o.type){case is:case ms:o.encoding=Gi,o.minFilter=Qt,o.magFilter=Qt,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,n,s,r)}}const tU=oe("debugautosync"),GM=Symbol("syncerId");class Yse{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Jse(e);return t[GM]=e.guid,this._syncers[t[GM]]=t,t}removeSyncer(e){delete this._syncers[e[GM]]}}const HM=new Yse;class Jse{constructor(e){h(this,"comp"),h(this,"hasChanges",!1),h(this,"changedProperties",{}),h(this,"data",{}),h(this,"_boundEvent"),h(this,"_handleReceivingMethod"),h(this,"_isReceiving",!1),h(this,"_isInit",!1),this.comp=e}get networkingKey(){return this.comp.constructor.name}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const s=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=s}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){tU&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const s in e){if(s==="guid")continue;const r=e[s];this.comp[s]=r}}catch(s){console.error(s)}finally{this._isReceiving=!1}}}}function Kse(i,e){let t=e!==i;if(!t&&i&&e){if(Array.isArray(i)&&Array.isArray(e))t=!0;else if(typeof i=="object"&&typeof e=="object"){for(const s of Object.keys(i))if(i[s]!==e[s]){t=!0;break}}}return t}const Jm=Symbol("AutoSyncHandler");function Zse(i){if(i[Jm])return i[Jm];const e=HM.getOrCreateSyncer(i);return e?.init(i),i[Jm]=e,e}function $se(i){const e=i[Jm];e&&(HM.removeSyncer(e),e.destroy(),delete i[Jm])}const VM=function(i){return function(e,t){let s=null,r;typeof i=="string"?r=e[i]:typeof i=="function"&&(r=i);const n=e,o=n.__internalAwake;tU&&console.log(t);const a=Symbol(t);n.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[t],o.call(this),s=HM.getOrCreateSyncer(this);const c=Object.getOwnPropertyDescriptor(this,t);c?.set===void 0&&Object.defineProperty(this,t,{set:function(u){var d;const p=this[a];this[a]=u,Kse(u,p)&&r?.call(this,u,p)!==!1&&((d=Zse(this))==null||d.notifyChanged(t,u))},get:function(){return this[a]},configurable:!0,enumerable:!0}),s?.init(this)};const l=n.__internalDestroy;n.__internalDestroy=function(){$se(this),l.call(this)}}};var ere=Object.defineProperty,tre=Object.getOwnPropertyDescriptor,m_=(i,e,t,s)=>{for(var r=s>1?void 0:s?tre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ere(e,t,r),r};const Km=oe("debugskybox");class _u extends Ee{constructor(){super(...arguments),h(this,"url"),h(this,"allowDrop",!0),h(this,"background",!0),h(this,"environment",!0),h(this,"_loader"),h(this,"_prevUrl"),h(this,"_prevLoadedEnvironment"),h(this,"_prevEnvironment",null),h(this,"_prevBackground",null),h(this,"dragOverEvent"),h(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Ei.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}async setSkybox(e){var t;if(!e)return;if(!(e!=null&&e.endsWith(".hdr"))&&!e.endsWith(".exr")&&!e.endsWith(".jpg")&&!e.endsWith(".png")&&!e.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),Km&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment){this.applySkybox();return}else(t=this._prevLoadedEnvironment)==null||t.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=e;const s=e.endsWith(".exr"),r=e.endsWith(".hdr");s?this._loader instanceof fS||(this._loader=new fS):r?this._loader instanceof eU||(this._loader=new eU):this._loader instanceof tc||(this._loader=new tc),Km&&console.log("Loading skybox: "+e);const n=await this._loader.loadAsync(e);if(!n||!this.enabled)return;this.url=e;const o=e.lastIndexOf("/");n.name=e.substring(o>=0?o+1:0),this._loader instanceof tc&&(n.encoding=yt),this._prevLoadedEnvironment=n,this.applySkybox()}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Lu,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Km&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!Ei.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)t==="text/uri-list"&&e.preventDefault()},this.dropEvent=e=>{var t,s,r,n;if(this.allowDrop&&(e.preventDefault(),!!e.dataTransfer)){for(const o of e.dataTransfer.types)if(o==="text/uri-list"){const a=e.dataTransfer.getData(o);Km&&console.log(o,a);let l=(s=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:s.name;if(l||(l=(n=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:n.name),Km&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";this.setSkybox(c)}else console.warn("Could not resolve skybox name from dropped url",a)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}m_([VM("setSkybox"),x(URL)],_u.prototype,"url",2),m_([x()],_u.prototype,"allowDrop",2),m_([x()],_u.prototype,"background",2),m_([x()],_u.prototype,"environment",2);var ire=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,fa=(i,e,t,s)=>{for(var r=s>1?void 0:s?sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ire(e,t,r),r};const Ml=oe("debugsceneswitcher"),Zm="scene";ts.registerCallback($r.ContextRegistered,async i=>{Promise.resolve().then(()=>Xne).then(e=>{const t=e.NeedleEngineHTMLElement;Ml&&console.log("SceneSwitcher: registering scene attribute",t.observedAttributes),t.observedAttributes.includes(Zm)||t.observedAttributes.push(Zm)})});const Kc=Promise.resolve(!1);class mn extends Ee{constructor(){super(...arguments),h(this,"scenes"),h(this,"queryParameterName","scene"),h(this,"clamp",!0),h(this,"useHistory",!0),h(this,"useKeyboard",!0),h(this,"useSwipe",!0),h(this,"useSceneLighting",!0),h(this,"preloadNext",1),h(this,"preloadPrevious",1),h(this,"preloadConcurrent",2),h(this,"_currentIndex",-1),h(this,"_currentScene"),h(this,"_engineElementOverserver"),h(this,"_preloadScheduler"),h(this,"onPopState",async e=>{if(!this.useHistory)return;let t=this.useHistory;try{this.useHistory=!1;let s=!1;if(this.queryParameterName&&(s=await this.tryLoadFromQueryParam()),!s){const r=e.state;if(r!==null&&r.startsWith(this.guid)){const n=r.substr(this.guid.length+2);console.log(n),await this.trySelectSceneFromValue(n)}}}finally{this.useHistory=t}}),h(this,"normalizedSwipeThresholdX",.1),h(this,"_didSwipe",!1),h(this,"onPointerMove",e=>{if(!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const s=t.x/this.context.domWidth;s>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):s<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),h(this,"onPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),h(this,"onKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const s=parseInt(t)-1;if(s>=0){this.trySelectSceneFromValue(s);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Ml&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(Zm);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(Uo.KeyDown,this.onKeyDown),this.context.input.addEventListener(Uo.PointerMove,this.onPointerMove),this.context.input.addEventListener(Uo.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===Zm){const s=this.context.domElement.getAttribute(Zm);s!==null&&this.trySelectSceneFromValue(s)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new rre(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(Uo.KeyDown,this.onKeyDown),this.context.input.removeEventListener(Uo.PointerMove,this.onPointerMove),this.context.input.removeEventListener(Uo.PointerUp,this.onPointerUp),(e=this._preloadScheduler)==null||e.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,s;if(Ml&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const n=(t=this.scenes)==null?void 0:t.find(o=>o.uri===e);if(!n){const o=lr.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(o)}if(n)e=this.scenes.indexOf(n);else return Kc}if(!((s=this.scenes)!=null&&s.length))return Kc;if(e<0){if(this.clamp)return Kc;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Kc;e=0}const r=this.scenes[e];return this.switchScene(r)}async switchScene(e){var t,s;if(e===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;this._currentScene=e;try{const n=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(n),await e.loadAssetAsync();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),o.defaultPrevented)return Ml&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return Ml&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if($.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0)if((s=this.queryParameterName)!=null&&s.length)NI(this.queryParameterName,r.toString(),this.useHistory);else{const a=history.state,l=this.guid+"::"+r;a!==l&&history.pushState(l,"unused",location.href)}return!0}}catch(n){console.error(n)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof lr)return t.preload()}return Kc}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return Kc;const t=oe(this.queryParameterName);return typeof t=="boolean"?Kc:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);for(let s=0;s<this.scenes.length;s++)if(this.scenes[s].uri.toLowerCase().includes(e))return this.select(s)}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return gr()&&console.warn('Can not find scene: "'+e+'"',this),Kc}}fa([x(lr)],mn.prototype,"scenes",2),fa([x()],mn.prototype,"queryParameterName",2),fa([x()],mn.prototype,"clamp",2),fa([x()],mn.prototype,"useHistory",2),fa([x()],mn.prototype,"useKeyboard",2),fa([x()],mn.prototype,"useSwipe",2),fa([x()],mn.prototype,"useSceneLighting",2),fa([x()],mn.prototype,"preloadNext",2),fa([x()],mn.prototype,"preloadPrevious",2),fa([x()],mn.prototype,"preloadConcurrent",2);class rre{constructor(e,t=1,s=1,r=2){h(this,"maxLoadAhead"),h(this,"maxLoadBehind"),h(this,"maxConcurrent"),h(this,"_isRunning",!1),h(this,"_switcher"),h(this,"_loadTasks",[]),h(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=s,this.maxConcurrent=r}begin(){if(this._isRunning)return;Ml&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,s;const r=this._switcher.scenes;let n=setInterval(()=>{if(this.allLoaded()&&(Ml&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(n);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,s=0,t=0);const o=s%2===0;o&&(t+=1),s+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;let l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new nre(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1;return!0}}class nre{constructor(e,t,s){h(this,"index"),h(this,"asset"),h(this,"tasks"),this.index=e,this.asset=t,this.tasks=s,s.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Ml&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Ml&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function ore(){return new Promise((i,e)=>{let t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function are(i){await ore(),i()}var iU=(i=>(i[i.Quad=0]="Quad",i))(iU||{});class lre{static createPrimitive(e,t){let s;switch(e){case 0:const r=new Os(1,1,1,1),n=t?.material??new di({color:16777215});s=new ye(r,n)}return t!=null&&t.name&&(s.name=t.name),s}}var cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,Yn=(i,e,t,s)=>{for(var r=s>1?void 0:s?hre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&cre(e,t,r),r};const ga=oe("debugvideo");var sU=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(sU||{});class Js extends Ee{constructor(){super(),h(this,"renderer",null),h(this,"playOnAwake",!0),h(this,"aspectMode",0),h(this,"clip",null),h(this,"renderMode"),h(this,"targetMaterialProperty"),h(this,"targetMaterialRenderer"),h(this,"targetTexture"),h(this,"time",0),h(this,"_playbackSpeed",1),h(this,"_isLooping",!1),h(this,"_muted",!1),h(this,"_audioOutputMode",2),h(this,"playInBackground",!0),h(this,"_crossOrigin","anonymous"),h(this,"source"),h(this,"url",null),h(this,"_videoElement",null),h(this,"_videoTexture",null),h(this,"_videoMaterial",null),h(this,"_isPlaying",!1),h(this,"wasPlaying",!1),h(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),h(this,"_receivedInput",!1),h(this,"_overlay",null),h(this,"_targetObjects"),h(this,"_updateAspectRoutineId",-1),are(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],oe("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&Rn()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(e){this.url!==e&&(this.url=e,this.source=1,ga&&console.log("set url",e),this._videoElement?(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var e,t;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var e;this._videoElement&&((e=this._videoElement.parentElement)==null||e.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(s=>{var r;console.log(s),ga&&console.error("Error playing video",s,"CODE="+s.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),ga&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),ga&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),ga&&console.log("PAUSE",this,this.currentTime)}create(e){var t;let s;switch(this.source){case 0:s=this.clip;break;case 1:s=this.url;break}s&&(this._videoElement||(ga&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(t=this.context.domElement)==null||t.prepend(this._videoElement),this.updateVideoElementStyles()),typeof s=="string"?(ga&&console.log("Set Video src",s),this._videoElement.src=s):(ga&&console.log("Set Video srcObject",s),this._videoElement.srcObject=s),this._videoTexture||(this._videoTexture=new iP(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=yt,this.handleBeginPlaying(e),ga&&console.log(this,e))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new ure(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),ga&&console.log("created video element",e),e}handleBeginPlaying(e){var t,s;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(s=$.getComponent(this.gameObject,Ui))==null?void 0:s.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,sU[this.renderMode],this);return}const n=r.material;if(n)if(this._targetObjects.push(r),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),r.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,s=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&s===this.clip&&this._isPlaying;){if(!s||typeof s=="string")return;let r;for(const n of s.getVideoTracks()){const o=n.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let n=0;n<10;n++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const n of this._targetObjects){let o=1;if(n.parent){const a=Us(n.parent);o=a.x/a.y}switch(this.aspectMode){case 1:n.scale.y=1/r*n.scale.x*o;break;case 2:n.scale.x=r*n.scale.y*o;break}}for(let n=0;n<3;n++)yield}}}Yn([x(Me)],Js.prototype,"renderer",2),Yn([x()],Js.prototype,"playOnAwake",2),Yn([x()],Js.prototype,"aspectMode",2),Yn([x(URL)],Js.prototype,"clip",2),Yn([x()],Js.prototype,"renderMode",2),Yn([x()],Js.prototype,"targetMaterialProperty",2),Yn([x(Ui)],Js.prototype,"targetMaterialRenderer",2),Yn([x(Ut)],Js.prototype,"targetTexture",2),Yn([x()],Js.prototype,"time",2),Yn([x()],Js.prototype,"playbackSpeed",1),Yn([x()],Js.prototype,"isLooping",1),Yn([x()],Js.prototype,"audioOutputMode",1);class ure{constructor(e){h(this,"context"),h(this,"_videos",[]),h(this,"_screenspaceModeQuad"),h(this,"_isInScreenspaceMode",!1),h(this,"_input"),this.context=e,this._input=new dre(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=lre.createPrimitive(iU.Quad,{material:new pre(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const s=this._screenspaceModeQuad;this.context.scene.add(s),this.updateScreenspaceMaterialUniforms();const r=s.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class dre{constructor(e){h(this,"_onResizeScreenFn"),h(this,"_onKeyUpFn"),h(this,"_onMouseWheelFn"),h(this,"context"),h(this,"overlay"),h(this,"_material"),h(this,"_isPinching",!1),h(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new W;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const n=new W(r.movementX,r.movementY);n.x/=this.context.domElement.clientWidth,n.y/=this.context.domElement.clientHeight,t.set(n.x,n.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let s=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-s<.3&&this.overlay.stop(),s=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const n=r.touches[0],o=r.touches[1],a=n.clientX-o.clientX,l=n.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class pre extends Vt{constructor(e){super(),h(this,"_offset",new W),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new it(0,0,1,1)}},this.vertexShader=`
4973
+ `;continue}if((y=b.match(f))&&(A.gamma=parseFloat(y[1])),(y=b.match(g))&&(A.exposure=parseFloat(y[1])),(y=b.match(m))&&(A.valid|=2,A.format=y[1]),(y=b.match(v))&&(A.valid|=4,A.height=parseInt(y[1],10),A.width=parseInt(y[2],10)),A.valid&2&&A.valid&4)break}return A.valid&2?A.valid&4?A:t(3,"missing image size specifier"):t(3,"missing format specifier")},o=function(d,p,f){const g=p;if(g<8||g>32767||d[0]!==2||d[1]!==2||d[2]&128)return new Uint8Array(d);if(g!==(d[2]<<8|d[3]))return t(3,"wrong scanline width");const m=new Uint8Array(4*p*f);if(!m.length)return t(4,"unable to allocate buffer space");let v=0,A=0;const b=4*g,y=new Uint8Array(4),_=new Uint8Array(b);let w=f;for(;w>0&&A<d.byteLength;){if(A+4>d.byteLength)return t(1);if(y[0]=d[A++],y[1]=d[A++],y[2]=d[A++],y[3]=d[A++],y[0]!=2||y[1]!=2||(y[2]<<8|y[3])!=g)return t(3,"bad rgbe scanline format");let E=0,P;for(;E<b&&A<d.byteLength;){P=d[A++];const R=P>128;if(R&&(P-=128),P===0||E+P>b)return t(3,"bad scanline data");if(R){const T=d[A++];for(let z=0;z<P;z++)_[E++]=T}else _.set(d.subarray(A,A+P),E),E+=P,A+=P}const C=g;for(let R=0;R<C;R++){let T=0;m[v]=_[R+T],T+=g,m[v+1]=_[R+T],T+=g,m[v+2]=_[R+T],T+=g,m[v+3]=_[R+T],v+=4}w--}return m},a=function(d,p,f,g){const m=d[p+3],v=Math.pow(2,m-128)/255;f[g+0]=d[p+0]*v,f[g+1]=d[p+1]*v,f[g+2]=d[p+2]*v,f[g+3]=1},l=function(d,p,f,g){const m=d[p+3],v=Math.pow(2,m-128)/255;f[g+0]=Oh.toHalfFloat(Math.min(d[p+0]*v,65504)),f[g+1]=Oh.toHalfFloat(Math.min(d[p+1]*v,65504)),f[g+2]=Oh.toHalfFloat(Math.min(d[p+2]*v,65504)),f[g+3]=Oh.toHalfFloat(1)},c=new Uint8Array(e);c.pos=0;const u=n(c);if(u!==-1){const d=u.width,p=u.height,f=o(c.subarray(c.pos),d,p);if(f!==-1){let g,m,v;switch(this.type){case is:v=f.length/4;const A=new Float32Array(v*4);for(let y=0;y<v;y++)a(f,y*4,A,y*4);g=A,m=is;break;case ms:v=f.length/4;const b=new Uint16Array(v*4);for(let y=0;y<v;y++)l(f,y*4,b,y*4);g=b,m=ms;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:d,height:p,data:g,header:u.string,gamma:u.gamma,exposure:u.exposure,type:m}}}return null}setDataType(e){return this.type=e,this}load(e,t,s,r){function n(o,a){switch(o.type){case is:case ms:o.encoding=Gi,o.minFilter=Qt,o.magFilter=Qt,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,n,s,r)}}const tU=oe("debugautosync"),GM=Symbol("syncerId");class Yse{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Jse(e);return t[GM]=e.guid,this._syncers[t[GM]]=t,t}removeSyncer(e){delete this._syncers[e[GM]]}}const HM=new Yse;class Jse{constructor(e){h(this,"comp"),h(this,"hasChanges",!1),h(this,"changedProperties",{}),h(this,"data",{}),h(this,"_boundEvent"),h(this,"_handleReceivingMethod"),h(this,"_isReceiving",!1),h(this,"_isInit",!1),this.comp=e}get networkingKey(){return this.comp.constructor.name}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const s=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=s}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){tU&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const s in e){if(s==="guid")continue;const r=e[s];this.comp[s]=r}}catch(s){console.error(s)}finally{this._isReceiving=!1}}}}function Kse(i,e){let t=e!==i;if(!t&&i&&e){if(Array.isArray(i)&&Array.isArray(e))t=!0;else if(typeof i=="object"&&typeof e=="object"){for(const s of Object.keys(i))if(i[s]!==e[s]){t=!0;break}}}return t}const Jm=Symbol("AutoSyncHandler");function Zse(i){if(i[Jm])return i[Jm];const e=HM.getOrCreateSyncer(i);return e?.init(i),i[Jm]=e,e}function $se(i){const e=i[Jm];e&&(HM.removeSyncer(e),e.destroy(),delete i[Jm])}const VM=function(i){return function(e,t){let s=null,r;typeof i=="string"?r=e[i]:typeof i=="function"&&(r=i);const n=e,o=n.__internalAwake;tU&&console.log(t);const a=Symbol(t);n.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[t],o.call(this),s=HM.getOrCreateSyncer(this);const c=Object.getOwnPropertyDescriptor(this,t);c?.set===void 0&&Object.defineProperty(this,t,{set:function(u){var d;const p=this[a];this[a]=u,Kse(u,p)&&r?.call(this,u,p)!==!1&&((d=Zse(this))==null||d.notifyChanged(t,u))},get:function(){return this[a]},configurable:!0,enumerable:!0}),s?.init(this)};const l=n.__internalDestroy;n.__internalDestroy=function(){$se(this),l.call(this)}}};var ere=Object.defineProperty,tre=Object.getOwnPropertyDescriptor,m_=(i,e,t,s)=>{for(var r=s>1?void 0:s?tre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ere(e,t,r),r};const Km=oe("debugskybox");class _u extends Ee{constructor(){super(...arguments),h(this,"url"),h(this,"allowDrop",!0),h(this,"background",!0),h(this,"environment",!0),h(this,"_loader"),h(this,"_prevUrl"),h(this,"_prevLoadedEnvironment"),h(this,"_prevEnvironment",null),h(this,"_prevBackground",null),h(this,"dragOverEvent"),h(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Ei.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}async setSkybox(e){var t;if(!e)return;if(!(e!=null&&e.endsWith(".hdr"))&&!e.endsWith(".exr")&&!e.endsWith(".jpg")&&!e.endsWith(".png")&&!e.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),Km&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment){this.applySkybox();return}else(t=this._prevLoadedEnvironment)==null||t.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=e;const s=e.endsWith(".exr"),r=e.endsWith(".hdr");s?this._loader instanceof fS||(this._loader=new fS):r?this._loader instanceof eU||(this._loader=new eU):this._loader instanceof tc||(this._loader=new tc),Km&&console.log("Loading skybox: "+e);const n=await this._loader.loadAsync(e);if(!n||!this.enabled)return;this.url=e;const o=e.lastIndexOf("/");n.name=e.substring(o>=0?o+1:0),this._loader instanceof tc&&(n.encoding=yt),this._prevLoadedEnvironment=n,this.applySkybox()}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Lu,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Km&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!Ei.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)t==="text/uri-list"&&e.preventDefault()},this.dropEvent=e=>{var t,s,r,n;if(this.allowDrop&&(e.preventDefault(),!!e.dataTransfer)){for(const o of e.dataTransfer.types)if(o==="text/uri-list"){const a=e.dataTransfer.getData(o);Km&&console.log(o,a);let l=(s=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:s.name;if(l||(l=(n=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:n.name),Km&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";this.setSkybox(c)}else console.warn("Could not resolve skybox name from dropped url",a)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}m_([VM("setSkybox"),x(URL)],_u.prototype,"url",2),m_([x()],_u.prototype,"allowDrop",2),m_([x()],_u.prototype,"background",2),m_([x()],_u.prototype,"environment",2);var ire=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,fa=(i,e,t,s)=>{for(var r=s>1?void 0:s?sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ire(e,t,r),r};const Ml=oe("debugsceneswitcher"),Zm="scene";ts.registerCallback($r.ContextRegistered,async i=>{Promise.resolve().then(()=>Xne).then(e=>{const t=e.NeedleEngineHTMLElement;Ml&&console.log("SceneSwitcher: registering scene attribute",t.observedAttributes),t.observedAttributes.includes(Zm)||t.observedAttributes.push(Zm)})});const Kc=Promise.resolve(!1);class mn extends Ee{constructor(){super(...arguments),h(this,"scenes"),h(this,"queryParameterName","scene"),h(this,"clamp",!0),h(this,"useHistory",!0),h(this,"useKeyboard",!0),h(this,"useSwipe",!0),h(this,"useSceneLighting",!0),h(this,"preloadNext",1),h(this,"preloadPrevious",1),h(this,"preloadConcurrent",2),h(this,"_currentIndex",-1),h(this,"_currentScene"),h(this,"_engineElementOverserver"),h(this,"_preloadScheduler"),h(this,"onPopState",async e=>{if(!this.useHistory)return;let t=this.useHistory;try{this.useHistory=!1;let s=!1;if(this.queryParameterName&&(s=await this.tryLoadFromQueryParam()),!s){const r=e.state;if(r!==null&&r.startsWith(this.guid)){const n=r.substr(this.guid.length+2);console.log(n),await this.trySelectSceneFromValue(n)}}}finally{this.useHistory=t}}),h(this,"normalizedSwipeThresholdX",.1),h(this,"_didSwipe",!1),h(this,"onPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const s=t.x/this.context.domWidth;s>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):s<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),h(this,"onPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),h(this,"onKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const s=parseInt(t)-1;if(s>=0){this.trySelectSceneFromValue(s);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Ml&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(Zm);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(Uo.KeyDown,this.onKeyDown),this.context.input.addEventListener(Uo.PointerMove,this.onPointerMove),this.context.input.addEventListener(Uo.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===Zm){const s=this.context.domElement.getAttribute(Zm);s!==null&&this.trySelectSceneFromValue(s)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new rre(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(Uo.KeyDown,this.onKeyDown),this.context.input.removeEventListener(Uo.PointerMove,this.onPointerMove),this.context.input.removeEventListener(Uo.PointerUp,this.onPointerUp),(e=this._preloadScheduler)==null||e.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,s;if(Ml&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const n=(t=this.scenes)==null?void 0:t.find(o=>o.uri===e);if(!n){const o=lr.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(o)}if(n)e=this.scenes.indexOf(n);else return Kc}if(!((s=this.scenes)!=null&&s.length))return Kc;if(e<0){if(this.clamp)return Kc;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Kc;e=0}const r=this.scenes[e];return this.switchScene(r)}async switchScene(e){var t,s;if(e===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;this._currentScene=e;try{const n=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(n),await e.loadAssetAsync();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),o.defaultPrevented)return Ml&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return Ml&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if($.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0)if((s=this.queryParameterName)!=null&&s.length)NI(this.queryParameterName,r.toString(),this.useHistory);else{const a=history.state,l=this.guid+"::"+r;a!==l&&history.pushState(l,"unused",location.href)}return!0}}catch(n){console.error(n)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof lr)return t.preload()}return Kc}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return Kc;const t=oe(this.queryParameterName);return typeof t=="boolean"?Kc:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);for(let s=0;s<this.scenes.length;s++)if(this.scenes[s].uri.toLowerCase().includes(e))return this.select(s)}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return gr()&&console.warn('Can not find scene: "'+e+'"',this),Kc}}fa([x(lr)],mn.prototype,"scenes",2),fa([x()],mn.prototype,"queryParameterName",2),fa([x()],mn.prototype,"clamp",2),fa([x()],mn.prototype,"useHistory",2),fa([x()],mn.prototype,"useKeyboard",2),fa([x()],mn.prototype,"useSwipe",2),fa([x()],mn.prototype,"useSceneLighting",2),fa([x()],mn.prototype,"preloadNext",2),fa([x()],mn.prototype,"preloadPrevious",2),fa([x()],mn.prototype,"preloadConcurrent",2);class rre{constructor(e,t=1,s=1,r=2){h(this,"maxLoadAhead"),h(this,"maxLoadBehind"),h(this,"maxConcurrent"),h(this,"_isRunning",!1),h(this,"_switcher"),h(this,"_loadTasks",[]),h(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=s,this.maxConcurrent=r}begin(){if(this._isRunning)return;Ml&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,s;const r=this._switcher.scenes;let n=setInterval(()=>{if(this.allLoaded()&&(Ml&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(n);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,s=0,t=0);const o=s%2===0;o&&(t+=1),s+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;let l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new nre(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1;return!0}}class nre{constructor(e,t,s){h(this,"index"),h(this,"asset"),h(this,"tasks"),this.index=e,this.asset=t,this.tasks=s,s.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Ml&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Ml&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function ore(){return new Promise((i,e)=>{let t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function are(i){await ore(),i()}var iU=(i=>(i[i.Quad=0]="Quad",i))(iU||{});class lre{static createPrimitive(e,t){let s;switch(e){case 0:const r=new Os(1,1,1,1),n=t?.material??new di({color:16777215});s=new ye(r,n)}return t!=null&&t.name&&(s.name=t.name),s}}var cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,Yn=(i,e,t,s)=>{for(var r=s>1?void 0:s?hre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&cre(e,t,r),r};const ga=oe("debugvideo");var sU=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(sU||{});class Js extends Ee{constructor(){super(),h(this,"renderer",null),h(this,"playOnAwake",!0),h(this,"aspectMode",0),h(this,"clip",null),h(this,"renderMode"),h(this,"targetMaterialProperty"),h(this,"targetMaterialRenderer"),h(this,"targetTexture"),h(this,"time",0),h(this,"_playbackSpeed",1),h(this,"_isLooping",!1),h(this,"_muted",!1),h(this,"_audioOutputMode",2),h(this,"playInBackground",!0),h(this,"_crossOrigin","anonymous"),h(this,"source"),h(this,"url",null),h(this,"_videoElement",null),h(this,"_videoTexture",null),h(this,"_videoMaterial",null),h(this,"_isPlaying",!1),h(this,"wasPlaying",!1),h(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),h(this,"_receivedInput",!1),h(this,"_overlay",null),h(this,"_targetObjects"),h(this,"_updateAspectRoutineId",-1),are(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],oe("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&Rn()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(e){this.url!==e&&(this.url=e,this.source=1,ga&&console.log("set url",e),this._videoElement?(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var e,t;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var e;this._videoElement&&((e=this._videoElement.parentElement)==null||e.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(s=>{var r;console.log(s),ga&&console.error("Error playing video",s,"CODE="+s.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),ga&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),ga&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),ga&&console.log("PAUSE",this,this.currentTime)}create(e){var t;let s;switch(this.source){case 0:s=this.clip;break;case 1:s=this.url;break}s&&(this._videoElement||(ga&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(t=this.context.domElement)==null||t.prepend(this._videoElement),this.updateVideoElementStyles()),typeof s=="string"?(ga&&console.log("Set Video src",s),this._videoElement.src=s):(ga&&console.log("Set Video srcObject",s),this._videoElement.srcObject=s),this._videoTexture||(this._videoTexture=new iP(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=yt,this.handleBeginPlaying(e),ga&&console.log(this,e))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new ure(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),ga&&console.log("created video element",e),e}handleBeginPlaying(e){var t,s;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(s=$.getComponent(this.gameObject,Ui))==null?void 0:s.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,sU[this.renderMode],this);return}const n=r.material;if(n)if(this._targetObjects.push(r),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),r.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,s=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&s===this.clip&&this._isPlaying;){if(!s||typeof s=="string")return;let r;for(const n of s.getVideoTracks()){const o=n.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let n=0;n<10;n++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const n of this._targetObjects){let o=1;if(n.parent){const a=Us(n.parent);o=a.x/a.y}switch(this.aspectMode){case 1:n.scale.y=1/r*n.scale.x*o;break;case 2:n.scale.x=r*n.scale.y*o;break}}for(let n=0;n<3;n++)yield}}}Yn([x(Me)],Js.prototype,"renderer",2),Yn([x()],Js.prototype,"playOnAwake",2),Yn([x()],Js.prototype,"aspectMode",2),Yn([x(URL)],Js.prototype,"clip",2),Yn([x()],Js.prototype,"renderMode",2),Yn([x()],Js.prototype,"targetMaterialProperty",2),Yn([x(Ui)],Js.prototype,"targetMaterialRenderer",2),Yn([x(Ut)],Js.prototype,"targetTexture",2),Yn([x()],Js.prototype,"time",2),Yn([x()],Js.prototype,"playbackSpeed",1),Yn([x()],Js.prototype,"isLooping",1),Yn([x()],Js.prototype,"audioOutputMode",1);class ure{constructor(e){h(this,"context"),h(this,"_videos",[]),h(this,"_screenspaceModeQuad"),h(this,"_isInScreenspaceMode",!1),h(this,"_input"),this.context=e,this._input=new dre(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=lre.createPrimitive(iU.Quad,{material:new pre(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const s=this._screenspaceModeQuad;this.context.scene.add(s),this.updateScreenspaceMaterialUniforms();const r=s.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class dre{constructor(e){h(this,"_onResizeScreenFn"),h(this,"_onKeyUpFn"),h(this,"_onMouseWheelFn"),h(this,"context"),h(this,"overlay"),h(this,"_material"),h(this,"_isPinching",!1),h(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new W;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const n=new W(r.movementX,r.movementY);n.x/=this.context.domElement.clientWidth,n.y/=this.context.domElement.clientHeight,t.set(n.x,n.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let s=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-s<.3&&this.overlay.stop(),s=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const n=r.touches[0],o=r.touches[1],a=n.clientX-o.clientX,l=n.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class pre extends Vt{constructor(e){super(),h(this,"_offset",new W),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new it(0,0,1,1)}},this.vertexShader=`
4974
4974
  uniform sampler2D map;
4975
4975
  uniform float screenAspect;
4976
4976
  uniform vec4 offsetScale;
@@ -4970,7 +4970,7 @@ void main() {
4970
4970
  `,f=function(y,_,C){_=_||1024;let T=y.pos,x=-1,M=0,P="",k=String.fromCharCode.apply(null,new Uint16Array(y.subarray(T,T+128)));for(;0>(x=k.indexOf(d))&&M<_&&T<y.byteLength;)P+=k,M+=k.length,T+=128,k+=String.fromCharCode.apply(null,new Uint16Array(y.subarray(T,T+128)));return-1<x?(C!==!1&&(y.pos+=M+x+1),P+k.slice(0,x)):!1},p=function(y){const _=/^#\?(\S+)/,C=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,T=/^\s*FORMAT=(\S+)\s*$/,x=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,M={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let P,k;if(y.pos>=y.byteLength||!(P=f(y)))return a(1,"no header found");if(!(k=P.match(_)))return a(3,"bad initial token");for(M.valid|=1,M.programtype=k[1],M.string+=P+`
4971
4971
  `;P=f(y),P!==!1;){if(M.string+=P+`
4972
4972
  `,P.charAt(0)==="#"){M.comments+=P+`
4973
- `;continue}if((k=P.match(C))&&(M.gamma=parseFloat(k[1])),(k=P.match(S))&&(M.exposure=parseFloat(k[1])),(k=P.match(T))&&(M.valid|=2,M.format=k[1]),(k=P.match(x))&&(M.valid|=4,M.height=parseInt(k[1],10),M.width=parseInt(k[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2?M.valid&4?M:a(3,"missing image size specifier"):a(3,"missing format specifier")},g=function(y,_,C){const S=_;if(S<8||S>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);if(S!==(y[2]<<8|y[3]))return a(3,"wrong scanline width");const T=new Uint8Array(4*_*C);if(!T.length)return a(4,"unable to allocate buffer space");let x=0,M=0;const P=4*S,k=new Uint8Array(4),G=new Uint8Array(P);let z=C;for(;z>0&&M<y.byteLength;){if(M+4>y.byteLength)return a(1);if(k[0]=y[M++],k[1]=y[M++],k[2]=y[M++],k[3]=y[M++],k[0]!=2||k[1]!=2||(k[2]<<8|k[3])!=S)return a(3,"bad rgbe scanline format");let L=0,H;for(;L<P&&M<y.byteLength;){H=y[M++];const K=H>128;if(K&&(H-=128),H===0||L+H>P)return a(3,"bad scanline data");if(K){const J=y[M++];for(let ue=0;ue<H;ue++)G[L++]=J}else G.set(y.subarray(M,M+H),L),L+=H,M+=H}const Z=S;for(let K=0;K<Z;K++){let J=0;T[x]=G[K+J],J+=S,T[x+1]=G[K+J],J+=S,T[x+2]=G[K+J],J+=S,T[x+3]=G[K+J],x+=4}z--}return T},m=function(y,_,C,S){const T=y[_+3],x=Math.pow(2,T-128)/255;C[S+0]=y[_+0]*x,C[S+1]=y[_+1]*x,C[S+2]=y[_+2]*x,C[S+3]=1},A=function(y,_,C,S){const T=y[_+3],x=Math.pow(2,T-128)/255;C[S+0]=Yh.toHalfFloat(Math.min(y[_+0]*x,65504)),C[S+1]=Yh.toHalfFloat(Math.min(y[_+1]*x,65504)),C[S+2]=Yh.toHalfFloat(Math.min(y[_+2]*x,65504)),C[S+3]=Yh.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const b=p(v);if(b!==-1){const y=b.width,_=b.height,C=g(v.subarray(v.pos),y,_);if(C!==-1){let S,T,x;switch(this.type){case vn:x=C.length/4;const M=new Float32Array(x*4);for(let k=0;k<x;k++)m(C,k*4,M,k*4);S=M,T=vn;break;case Rn:x=C.length/4;const P=new Uint16Array(x*4);for(let k=0;k<x;k++)A(C,k*4,P,k*4);S=P,T=Rn;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:y,height:_,data:S,header:b.string,gamma:b.gamma,exposure:b.exposure,type:T}}}return null}setDataType(e){return this.type=e,this}load(e,t,i,s){function r(o,a){switch(o.type){case vn:case Rn:o.encoding=an,o.minFilter=Vt,o.magFilter=Vt,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,i,s)}}const DN=ce("debugautosync"),cC=Symbol("syncerId");class ese{constructor(){u(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new tse(e);return t[cC]=e.guid,this._syncers[t[cC]]=t,t}removeSyncer(e){delete this._syncers[e[cC]]}}const TM=new ese;class tse{constructor(e){u(this,"comp");u(this,"hasChanges",!1);u(this,"changedProperties",{});u(this,"data",{});u(this,"_boundEvent");u(this,"_handleReceivingMethod");u(this,"_isReceiving",!1);u(this,"_isInit",!1);this.comp=e}get networkingKey(){return this.comp.constructor.name}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const i=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=i}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){DN&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const i in e){if(i==="guid")continue;const s=e[i];this.comp[i]=s}}catch(i){console.error(i)}finally{this._isReceiving=!1}}}}function ise(n,e){let t=e!==n;if(!t&&n&&e){if(Array.isArray(n)&&Array.isArray(e))t=!0;else if(typeof n=="object"&&typeof e=="object"){for(const i of Object.keys(n))if(n[i]!==e[i]){t=!0;break}}}return t}const Qg=Symbol("AutoSyncHandler");function nse(n){if(n[Qg])return n[Qg];const e=TM.getOrCreateSyncer(n);return e==null||e.init(n),n[Qg]=e,e}function sse(n){const e=n[Qg];e&&(TM.removeSyncer(e),e.destroy(),delete n[Qg])}const PM=function(n){return function(e,t){let i=null,s;typeof n=="string"?s=e[n]:typeof n=="function"&&(s=n);const r=e,o=r.__internalAwake;DN&&console.log(t);const a=Symbol(t);r.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[t],o.call(this),i=TM.getOrCreateSyncer(this);const l=Object.getOwnPropertyDescriptor(this,t);(l==null?void 0:l.set)===void 0&&Object.defineProperty(this,t,{set:function(h){var f;const d=this[a];this[a]=h,ise(h,d)&&(s==null?void 0:s.call(this,h,d))!==!1&&((f=nse(this))==null||f.notifyChanged(t,h))},get:function(){return this[a]},configurable:!0,enumerable:!0}),i==null||i.init(this)};const c=r.__internalDestroy;r.__internalDestroy=function(){sse(this),c.call(this)}}};var rse=Object.defineProperty,ose=Object.getOwnPropertyDescriptor,ox=(n,e,t,i)=>{for(var s=i>1?void 0:i?ose(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rse(e,t,s),s};const eg=ce("debugskybox");class ju extends Ce{constructor(){super(...arguments);u(this,"url");u(this,"allowDrop",!0);u(this,"background",!0);u(this,"environment",!0);u(this,"_loader");u(this,"_prevUrl");u(this,"_prevLoadedEnvironment");u(this,"_prevEnvironment",null);u(this,"_prevBackground",null);u(this,"dragOverEvent");u(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,ki.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}async setSkybox(t){var a;if(!t)return;if(!(t!=null&&t.endsWith(".hdr"))&&!t.endsWith(".exr")&&!t.endsWith(".jpg")&&!t.endsWith(".png")&&!t.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),eg&&console.log("Remote skybox url?: "+t),this._prevUrl===t&&this._prevLoadedEnvironment){this.applySkybox();return}else(a=this._prevLoadedEnvironment)==null||a.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=t;const i=t.endsWith(".exr"),s=t.endsWith(".hdr");i?this._loader instanceof QS||(this._loader=new QS):s?this._loader instanceof SD||(this._loader=new SD):this._loader instanceof kl||(this._loader=new kl),eg&&console.log("Loading skybox: "+t);const r=await this._loader.loadAsync(t);if(!r||!this.enabled)return;this.url=t;const o=t.lastIndexOf("/");r.name=t.substring(o>=0?o+1:0),this._loader instanceof kl&&(r.encoding=yt),this._prevLoadedEnvironment=r,this.applySkybox()}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=ff,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),eg&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!ki.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)i==="text/uri-list"&&t.preventDefault()},this.dropEvent=t=>{var i,s,r,o;if(this.allowDrop&&(t.preventDefault(),!!t.dataTransfer)){for(const a of t.dataTransfer.types)if(a==="text/uri-list"){const c=t.dataTransfer.getData(a);eg&&console.log(a,c);let l=(s=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(c))==null?void 0:i.groups)==null?void 0:s.name;if(l||(l=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(c))==null?void 0:r.groups)==null?void 0:o.name),eg&&console.log(l),l){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";this.setSkybox(h)}else console.warn("Could not resolve skybox name from dropped url",c)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}ox([PM("setSkybox"),w(URL)],ju.prototype,"url",2);ox([w()],ju.prototype,"allowDrop",2);ox([w()],ju.prototype,"background",2);ox([w()],ju.prototype,"environment",2);var ase=Object.defineProperty,cse=Object.getOwnPropertyDescriptor,Ha=(n,e,t,i)=>{for(var s=i>1?void 0:i?cse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ase(e,t,s),s};const Cc=ce("debugsceneswitcher"),Hg="scene";mn.registerCallback(xr.ContextRegistered,async n=>{Promise.resolve().then(()=>$re).then(e=>{const t=e.NeedleEngineHTMLElement;Cc&&console.log("SceneSwitcher: registering scene attribute",t.observedAttributes),t.observedAttributes.includes(Hg)||t.observedAttributes.push(Hg)})});const ml=Promise.resolve(!1);class Dr extends Ce{constructor(){super(...arguments);u(this,"scenes");u(this,"queryParameterName","scene");u(this,"clamp",!0);u(this,"useHistory",!0);u(this,"useKeyboard",!0);u(this,"useSwipe",!0);u(this,"useSceneLighting",!0);u(this,"preloadNext",1);u(this,"preloadPrevious",1);u(this,"preloadConcurrent",2);u(this,"_currentIndex",-1);u(this,"_currentScene");u(this,"_engineElementOverserver");u(this,"_preloadScheduler");u(this,"onPopState",async t=>{if(!this.useHistory)return;let i=this.useHistory;try{this.useHistory=!1;let s=!1;if(this.queryParameterName&&(s=await this.tryLoadFromQueryParam()),!s){const r=t.state;if(r!==null&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);console.log(o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});u(this,"normalizedSwipeThresholdX",.1);u(this,"_didSwipe",!1);u(this,"onPointerMove",t=>{if(!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const s=i.x/this.context.domWidth;s>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):s<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});u(this,"onPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});u(this,"onKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const s=parseInt(i)-1;if(s>=0){this.trySelectSceneFromValue(s);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Cc&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const t=this.context.domElement.getAttribute(Hg);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(ha.KeyDown,this.onKeyDown),this.context.input.addEventListener(ha.PointerMove,this.onPointerMove),this.context.input.addEventListener(ha.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===Hg){const s=this.context.domElement.getAttribute(Hg);s!==null&&this.trySelectSceneFromValue(s)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new lse(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(ha.KeyDown,this.onKeyDown),this.context.input.removeEventListener(ha.PointerMove,this.onPointerMove),this.context.input.removeEventListener(ha.PointerUp,this.onPointerUp),(t=this._preloadScheduler)==null||t.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var s,r;if(Cc&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const o=(s=this.scenes)==null?void 0:s.find(a=>a.uri===t);if(!o){const a=qn.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(a)}if(o)t=this.scenes.indexOf(o);else return ml}if(!((r=this.scenes)!=null&&r.length))return ml;if(t<0){if(this.clamp)return ml;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return ml;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){var s,r;if(t===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const i=this._currentIndex=((s=this.scenes)==null?void 0:s.indexOf(t))??-1;this._currentScene=t;try{const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await t.loadAssetAsync();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),a.defaultPrevented)return Cc&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return Cc&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if($.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0)if((r=this.queryParameterName)!=null&&r.length)JD(this.queryParameterName,i.toString(),this.useHistory);else{const c=history.state,l=this.guid+"::"+i;c!==l&&history.pushState(l,"unused",location.href)}return!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof qn)return i.preload()}return ml}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return ml;const t=ce(this.queryParameterName);return typeof t=="boolean"?ml:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);for(let s=0;s<this.scenes.length;s++)if(this.scenes[s].uri.toLowerCase().includes(t))return this.select(s)}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return zs()&&console.warn('Can not find scene: "'+t+'"',this),ml}}Ha([w(qn)],Dr.prototype,"scenes",2);Ha([w()],Dr.prototype,"queryParameterName",2);Ha([w()],Dr.prototype,"clamp",2);Ha([w()],Dr.prototype,"useHistory",2);Ha([w()],Dr.prototype,"useKeyboard",2);Ha([w()],Dr.prototype,"useSwipe",2);Ha([w()],Dr.prototype,"useSceneLighting",2);Ha([w()],Dr.prototype,"preloadNext",2);Ha([w()],Dr.prototype,"preloadPrevious",2);Ha([w()],Dr.prototype,"preloadConcurrent",2);class lse{constructor(e,t=1,i=1,s=2){u(this,"maxLoadAhead");u(this,"maxLoadBehind");u(this,"maxConcurrent");u(this,"_isRunning",!1);u(this,"_switcher");u(this,"_loadTasks",[]);u(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=s}begin(){if(this._isRunning)return;Cc&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const s=this._switcher.scenes;let r=setInterval(()=>{if(this.allLoaded()&&(Cc&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;let c=o?e+t:e-t;if(c<0||c<0||c>=s.length)return;const l=s[c];new hse(c,l,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1;return!0}}class hse{constructor(e,t,i){u(this,"index");u(this,"asset");u(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Cc&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Cc&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function use(){return new Promise((n,e)=>{let i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),n())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function dse(n){await use(),n()}var kN=(n=>(n[n.Quad=0]="Quad",n))(kN||{});class fse{static createPrimitive(e,t){let i;switch(e){case 0:const s=new Yn(1,1,1,1),r=(t==null?void 0:t.material)??new vi({color:16777215});i=new ve(s,r)}return t!=null&&t.name&&(i.name=t.name),i}}var pse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,yo=(n,e,t,i)=>{for(var s=i>1?void 0:i?gse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pse(e,t,s),s};const ia=ce("debugvideo");var ON=(n=>(n[n.CameraFarPlane=0]="CameraFarPlane",n[n.CameraNearPlane=1]="CameraNearPlane",n[n.RenderTexture=2]="RenderTexture",n[n.MaterialOverride=3]="MaterialOverride",n))(ON||{});class us extends Ce{constructor(){super();u(this,"renderer",null);u(this,"playOnAwake",!0);u(this,"aspectMode",0);u(this,"clip",null);u(this,"renderMode");u(this,"targetMaterialProperty");u(this,"targetMaterialRenderer");u(this,"targetTexture");u(this,"time",0);u(this,"_playbackSpeed",1);u(this,"_isLooping",!1);u(this,"_muted",!1);u(this,"_audioOutputMode",2);u(this,"playInBackground",!0);u(this,"_crossOrigin","anonymous");u(this,"source");u(this,"url",null);u(this,"_videoElement",null);u(this,"_videoTexture",null);u(this,"_videoMaterial",null);u(this,"_isPlaying",!1);u(this,"wasPlaying",!1);u(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});u(this,"_receivedInput",!1);u(this,"_overlay",null);u(this,"_targetObjects");u(this,"_updateAspectRoutineId",-1);dse(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ce("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&ho()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(t){this.url!==t&&(this.url=t,this.source=1,ia&&console.log("set url",t),this._videoElement?(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var t,i;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var t;this._videoElement&&((t=this._videoElement.parentElement)==null||t.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(s=>{var r;console.log(s),ia&&console.error("Error playing video",s,"CODE="+s.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),ia&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),ia&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),ia&&console.log("PAUSE",this,this.currentTime)}create(t){var s;let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url;break}i&&(this._videoElement||(ia&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(s=this.context.domElement)==null||s.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(ia&&console.log("Set Video src",i),this._videoElement.src=i):(ia&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new g2(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=yt,this.handleBeginPlaying(t),ia&&console.log(this,t))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new mse(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),ia&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=$.getComponent(this.gameObject,Ki))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,ON[this.renderMode],this);return}const s=i.material;if(s)if(this._targetObjects.push(i),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),i.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),t&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const t=++this._updateAspectRoutineId,i=void 0,s=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&s===this.clip&&this._isPlaying;){if(!s||typeof s=="string")return;let r;for(const o of s.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const c=is(o.parent);a=c.x/c.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}}yo([w(Ie)],us.prototype,"renderer",2);yo([w()],us.prototype,"playOnAwake",2);yo([w()],us.prototype,"aspectMode",2);yo([w(URL)],us.prototype,"clip",2);yo([w()],us.prototype,"renderMode",2);yo([w()],us.prototype,"targetMaterialProperty",2);yo([w(Ki)],us.prototype,"targetMaterialRenderer",2);yo([w(Gt)],us.prototype,"targetTexture",2);yo([w()],us.prototype,"time",2);yo([w()],us.prototype,"playbackSpeed",1);yo([w()],us.prototype,"isLooping",1);yo([w()],us.prototype,"audioOutputMode",1);class mse{constructor(e){u(this,"context");u(this,"_videos",[]);u(this,"_screenspaceModeQuad");u(this,"_isInScreenspaceMode",!1);u(this,"_input");this.context=e,this._input=new Ase(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var s;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=fse.createPrimitive(kN.Quad,{material:new vse(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(s=this._input)==null||s.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Ase{constructor(e){u(this,"_onResizeScreenFn");u(this,"_onKeyUpFn");u(this,"_onMouseWheelFn");u(this,"context");u(this,"overlay");u(this,"_material");u(this,"_isPinching",!1);u(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=s=>{s.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=s=>{this.overlay.enabled&&(e.zoom+=s.deltaY*5e-4,s.preventDefault())},{passive:!1});const t=new q;window.addEventListener("mousemove",s=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new q(s.movementX,s.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",s=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(s.movementX,s.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",s=>{if(s.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",s=>{if(!this._isPinching||!this._material)return;const r=s.touches[0],o=s.touches[1],a=r.clientX-o.clientX,c=r.clientY-o.clientY,l=Math.sqrt(a*a+c*c);if(this._lastPinch!==0){const h=l-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=l}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class vse extends Xt{constructor(t){super();u(this,"_offset",new q);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new rt(0,0,1,1)}},this.vertexShader=`
4973
+ `;continue}if((k=P.match(C))&&(M.gamma=parseFloat(k[1])),(k=P.match(S))&&(M.exposure=parseFloat(k[1])),(k=P.match(T))&&(M.valid|=2,M.format=k[1]),(k=P.match(x))&&(M.valid|=4,M.height=parseInt(k[1],10),M.width=parseInt(k[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2?M.valid&4?M:a(3,"missing image size specifier"):a(3,"missing format specifier")},g=function(y,_,C){const S=_;if(S<8||S>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);if(S!==(y[2]<<8|y[3]))return a(3,"wrong scanline width");const T=new Uint8Array(4*_*C);if(!T.length)return a(4,"unable to allocate buffer space");let x=0,M=0;const P=4*S,k=new Uint8Array(4),G=new Uint8Array(P);let z=C;for(;z>0&&M<y.byteLength;){if(M+4>y.byteLength)return a(1);if(k[0]=y[M++],k[1]=y[M++],k[2]=y[M++],k[3]=y[M++],k[0]!=2||k[1]!=2||(k[2]<<8|k[3])!=S)return a(3,"bad rgbe scanline format");let L=0,H;for(;L<P&&M<y.byteLength;){H=y[M++];const K=H>128;if(K&&(H-=128),H===0||L+H>P)return a(3,"bad scanline data");if(K){const J=y[M++];for(let ue=0;ue<H;ue++)G[L++]=J}else G.set(y.subarray(M,M+H),L),L+=H,M+=H}const Z=S;for(let K=0;K<Z;K++){let J=0;T[x]=G[K+J],J+=S,T[x+1]=G[K+J],J+=S,T[x+2]=G[K+J],J+=S,T[x+3]=G[K+J],x+=4}z--}return T},m=function(y,_,C,S){const T=y[_+3],x=Math.pow(2,T-128)/255;C[S+0]=y[_+0]*x,C[S+1]=y[_+1]*x,C[S+2]=y[_+2]*x,C[S+3]=1},A=function(y,_,C,S){const T=y[_+3],x=Math.pow(2,T-128)/255;C[S+0]=Yh.toHalfFloat(Math.min(y[_+0]*x,65504)),C[S+1]=Yh.toHalfFloat(Math.min(y[_+1]*x,65504)),C[S+2]=Yh.toHalfFloat(Math.min(y[_+2]*x,65504)),C[S+3]=Yh.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const b=p(v);if(b!==-1){const y=b.width,_=b.height,C=g(v.subarray(v.pos),y,_);if(C!==-1){let S,T,x;switch(this.type){case vn:x=C.length/4;const M=new Float32Array(x*4);for(let k=0;k<x;k++)m(C,k*4,M,k*4);S=M,T=vn;break;case Rn:x=C.length/4;const P=new Uint16Array(x*4);for(let k=0;k<x;k++)A(C,k*4,P,k*4);S=P,T=Rn;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:y,height:_,data:S,header:b.string,gamma:b.gamma,exposure:b.exposure,type:T}}}return null}setDataType(e){return this.type=e,this}load(e,t,i,s){function r(o,a){switch(o.type){case vn:case Rn:o.encoding=an,o.minFilter=Vt,o.magFilter=Vt,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,i,s)}}const DN=ce("debugautosync"),cC=Symbol("syncerId");class ese{constructor(){u(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new tse(e);return t[cC]=e.guid,this._syncers[t[cC]]=t,t}removeSyncer(e){delete this._syncers[e[cC]]}}const TM=new ese;class tse{constructor(e){u(this,"comp");u(this,"hasChanges",!1);u(this,"changedProperties",{});u(this,"data",{});u(this,"_boundEvent");u(this,"_handleReceivingMethod");u(this,"_isReceiving",!1);u(this,"_isInit",!1);this.comp=e}get networkingKey(){return this.comp.constructor.name}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const i=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=i}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){DN&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const i in e){if(i==="guid")continue;const s=e[i];this.comp[i]=s}}catch(i){console.error(i)}finally{this._isReceiving=!1}}}}function ise(n,e){let t=e!==n;if(!t&&n&&e){if(Array.isArray(n)&&Array.isArray(e))t=!0;else if(typeof n=="object"&&typeof e=="object"){for(const i of Object.keys(n))if(n[i]!==e[i]){t=!0;break}}}return t}const Qg=Symbol("AutoSyncHandler");function nse(n){if(n[Qg])return n[Qg];const e=TM.getOrCreateSyncer(n);return e==null||e.init(n),n[Qg]=e,e}function sse(n){const e=n[Qg];e&&(TM.removeSyncer(e),e.destroy(),delete n[Qg])}const PM=function(n){return function(e,t){let i=null,s;typeof n=="string"?s=e[n]:typeof n=="function"&&(s=n);const r=e,o=r.__internalAwake;DN&&console.log(t);const a=Symbol(t);r.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[t],o.call(this),i=TM.getOrCreateSyncer(this);const l=Object.getOwnPropertyDescriptor(this,t);(l==null?void 0:l.set)===void 0&&Object.defineProperty(this,t,{set:function(h){var f;const d=this[a];this[a]=h,ise(h,d)&&(s==null?void 0:s.call(this,h,d))!==!1&&((f=nse(this))==null||f.notifyChanged(t,h))},get:function(){return this[a]},configurable:!0,enumerable:!0}),i==null||i.init(this)};const c=r.__internalDestroy;r.__internalDestroy=function(){sse(this),c.call(this)}}};var rse=Object.defineProperty,ose=Object.getOwnPropertyDescriptor,ox=(n,e,t,i)=>{for(var s=i>1?void 0:i?ose(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rse(e,t,s),s};const eg=ce("debugskybox");class ju extends Ce{constructor(){super(...arguments);u(this,"url");u(this,"allowDrop",!0);u(this,"background",!0);u(this,"environment",!0);u(this,"_loader");u(this,"_prevUrl");u(this,"_prevLoadedEnvironment");u(this,"_prevEnvironment",null);u(this,"_prevBackground",null);u(this,"dragOverEvent");u(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,ki.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}async setSkybox(t){var a;if(!t)return;if(!(t!=null&&t.endsWith(".hdr"))&&!t.endsWith(".exr")&&!t.endsWith(".jpg")&&!t.endsWith(".png")&&!t.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),eg&&console.log("Remote skybox url?: "+t),this._prevUrl===t&&this._prevLoadedEnvironment){this.applySkybox();return}else(a=this._prevLoadedEnvironment)==null||a.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=t;const i=t.endsWith(".exr"),s=t.endsWith(".hdr");i?this._loader instanceof QS||(this._loader=new QS):s?this._loader instanceof SD||(this._loader=new SD):this._loader instanceof kl||(this._loader=new kl),eg&&console.log("Loading skybox: "+t);const r=await this._loader.loadAsync(t);if(!r||!this.enabled)return;this.url=t;const o=t.lastIndexOf("/");r.name=t.substring(o>=0?o+1:0),this._loader instanceof kl&&(r.encoding=yt),this._prevLoadedEnvironment=r,this.applySkybox()}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=ff,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),eg&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!ki.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)i==="text/uri-list"&&t.preventDefault()},this.dropEvent=t=>{var i,s,r,o;if(this.allowDrop&&(t.preventDefault(),!!t.dataTransfer)){for(const a of t.dataTransfer.types)if(a==="text/uri-list"){const c=t.dataTransfer.getData(a);eg&&console.log(a,c);let l=(s=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(c))==null?void 0:i.groups)==null?void 0:s.name;if(l||(l=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(c))==null?void 0:r.groups)==null?void 0:o.name),eg&&console.log(l),l){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";this.setSkybox(h)}else console.warn("Could not resolve skybox name from dropped url",c)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}ox([PM("setSkybox"),w(URL)],ju.prototype,"url",2);ox([w()],ju.prototype,"allowDrop",2);ox([w()],ju.prototype,"background",2);ox([w()],ju.prototype,"environment",2);var ase=Object.defineProperty,cse=Object.getOwnPropertyDescriptor,Ha=(n,e,t,i)=>{for(var s=i>1?void 0:i?cse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ase(e,t,s),s};const Cc=ce("debugsceneswitcher"),Hg="scene";mn.registerCallback(xr.ContextRegistered,async n=>{Promise.resolve().then(()=>$re).then(e=>{const t=e.NeedleEngineHTMLElement;Cc&&console.log("SceneSwitcher: registering scene attribute",t.observedAttributes),t.observedAttributes.includes(Hg)||t.observedAttributes.push(Hg)})});const ml=Promise.resolve(!1);class Dr extends Ce{constructor(){super(...arguments);u(this,"scenes");u(this,"queryParameterName","scene");u(this,"clamp",!0);u(this,"useHistory",!0);u(this,"useKeyboard",!0);u(this,"useSwipe",!0);u(this,"useSceneLighting",!0);u(this,"preloadNext",1);u(this,"preloadPrevious",1);u(this,"preloadConcurrent",2);u(this,"_currentIndex",-1);u(this,"_currentScene");u(this,"_engineElementOverserver");u(this,"_preloadScheduler");u(this,"onPopState",async t=>{if(!this.useHistory)return;let i=this.useHistory;try{this.useHistory=!1;let s=!1;if(this.queryParameterName&&(s=await this.tryLoadFromQueryParam()),!s){const r=t.state;if(r!==null&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);console.log(o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});u(this,"normalizedSwipeThresholdX",.1);u(this,"_didSwipe",!1);u(this,"onPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const s=i.x/this.context.domWidth;s>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):s<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});u(this,"onPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});u(this,"onKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const s=parseInt(i)-1;if(s>=0){this.trySelectSceneFromValue(s);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Cc&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const t=this.context.domElement.getAttribute(Hg);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(ha.KeyDown,this.onKeyDown),this.context.input.addEventListener(ha.PointerMove,this.onPointerMove),this.context.input.addEventListener(ha.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===Hg){const s=this.context.domElement.getAttribute(Hg);s!==null&&this.trySelectSceneFromValue(s)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new lse(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(ha.KeyDown,this.onKeyDown),this.context.input.removeEventListener(ha.PointerMove,this.onPointerMove),this.context.input.removeEventListener(ha.PointerUp,this.onPointerUp),(t=this._preloadScheduler)==null||t.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var s,r;if(Cc&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const o=(s=this.scenes)==null?void 0:s.find(a=>a.uri===t);if(!o){const a=qn.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(a)}if(o)t=this.scenes.indexOf(o);else return ml}if(!((r=this.scenes)!=null&&r.length))return ml;if(t<0){if(this.clamp)return ml;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return ml;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){var s,r;if(t===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const i=this._currentIndex=((s=this.scenes)==null?void 0:s.indexOf(t))??-1;this._currentScene=t;try{const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await t.loadAssetAsync();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),a.defaultPrevented)return Cc&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return Cc&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if($.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0)if((r=this.queryParameterName)!=null&&r.length)JD(this.queryParameterName,i.toString(),this.useHistory);else{const c=history.state,l=this.guid+"::"+i;c!==l&&history.pushState(l,"unused",location.href)}return!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof qn)return i.preload()}return ml}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return ml;const t=ce(this.queryParameterName);return typeof t=="boolean"?ml:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);for(let s=0;s<this.scenes.length;s++)if(this.scenes[s].uri.toLowerCase().includes(t))return this.select(s)}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return zs()&&console.warn('Can not find scene: "'+t+'"',this),ml}}Ha([w(qn)],Dr.prototype,"scenes",2);Ha([w()],Dr.prototype,"queryParameterName",2);Ha([w()],Dr.prototype,"clamp",2);Ha([w()],Dr.prototype,"useHistory",2);Ha([w()],Dr.prototype,"useKeyboard",2);Ha([w()],Dr.prototype,"useSwipe",2);Ha([w()],Dr.prototype,"useSceneLighting",2);Ha([w()],Dr.prototype,"preloadNext",2);Ha([w()],Dr.prototype,"preloadPrevious",2);Ha([w()],Dr.prototype,"preloadConcurrent",2);class lse{constructor(e,t=1,i=1,s=2){u(this,"maxLoadAhead");u(this,"maxLoadBehind");u(this,"maxConcurrent");u(this,"_isRunning",!1);u(this,"_switcher");u(this,"_loadTasks",[]);u(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=s}begin(){if(this._isRunning)return;Cc&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const s=this._switcher.scenes;let r=setInterval(()=>{if(this.allLoaded()&&(Cc&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;let c=o?e+t:e-t;if(c<0||c<0||c>=s.length)return;const l=s[c];new hse(c,l,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1;return!0}}class hse{constructor(e,t,i){u(this,"index");u(this,"asset");u(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Cc&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Cc&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function use(){return new Promise((n,e)=>{let i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),n())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function dse(n){await use(),n()}var kN=(n=>(n[n.Quad=0]="Quad",n))(kN||{});class fse{static createPrimitive(e,t){let i;switch(e){case 0:const s=new Yn(1,1,1,1),r=(t==null?void 0:t.material)??new vi({color:16777215});i=new ve(s,r)}return t!=null&&t.name&&(i.name=t.name),i}}var pse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,yo=(n,e,t,i)=>{for(var s=i>1?void 0:i?gse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pse(e,t,s),s};const ia=ce("debugvideo");var ON=(n=>(n[n.CameraFarPlane=0]="CameraFarPlane",n[n.CameraNearPlane=1]="CameraNearPlane",n[n.RenderTexture=2]="RenderTexture",n[n.MaterialOverride=3]="MaterialOverride",n))(ON||{});class us extends Ce{constructor(){super();u(this,"renderer",null);u(this,"playOnAwake",!0);u(this,"aspectMode",0);u(this,"clip",null);u(this,"renderMode");u(this,"targetMaterialProperty");u(this,"targetMaterialRenderer");u(this,"targetTexture");u(this,"time",0);u(this,"_playbackSpeed",1);u(this,"_isLooping",!1);u(this,"_muted",!1);u(this,"_audioOutputMode",2);u(this,"playInBackground",!0);u(this,"_crossOrigin","anonymous");u(this,"source");u(this,"url",null);u(this,"_videoElement",null);u(this,"_videoTexture",null);u(this,"_videoMaterial",null);u(this,"_isPlaying",!1);u(this,"wasPlaying",!1);u(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});u(this,"_receivedInput",!1);u(this,"_overlay",null);u(this,"_targetObjects");u(this,"_updateAspectRoutineId",-1);dse(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ce("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&ho()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(t){this.url!==t&&(this.url=t,this.source=1,ia&&console.log("set url",t),this._videoElement?(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var t,i;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var t;this._videoElement&&((t=this._videoElement.parentElement)==null||t.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(s=>{var r;console.log(s),ia&&console.error("Error playing video",s,"CODE="+s.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),ia&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),ia&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),ia&&console.log("PAUSE",this,this.currentTime)}create(t){var s;let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url;break}i&&(this._videoElement||(ia&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(s=this.context.domElement)==null||s.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(ia&&console.log("Set Video src",i),this._videoElement.src=i):(ia&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new g2(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=yt,this.handleBeginPlaying(t),ia&&console.log(this,t))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new mse(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),ia&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=$.getComponent(this.gameObject,Ki))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!i){console.error("Missing target for video material renderer",this.name,ON[this.renderMode],this);return}const s=i.material;if(s)if(this._targetObjects.push(i),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),i.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),t&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const t=++this._updateAspectRoutineId,i=void 0,s=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&s===this.clip&&this._isPlaying;){if(!s||typeof s=="string")return;let r;for(const o of s.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const c=is(o.parent);a=c.x/c.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;break}}for(let o=0;o<3;o++)yield}}}yo([w(Ie)],us.prototype,"renderer",2);yo([w()],us.prototype,"playOnAwake",2);yo([w()],us.prototype,"aspectMode",2);yo([w(URL)],us.prototype,"clip",2);yo([w()],us.prototype,"renderMode",2);yo([w()],us.prototype,"targetMaterialProperty",2);yo([w(Ki)],us.prototype,"targetMaterialRenderer",2);yo([w(Gt)],us.prototype,"targetTexture",2);yo([w()],us.prototype,"time",2);yo([w()],us.prototype,"playbackSpeed",1);yo([w()],us.prototype,"isLooping",1);yo([w()],us.prototype,"audioOutputMode",1);class mse{constructor(e){u(this,"context");u(this,"_videos",[]);u(this,"_screenspaceModeQuad");u(this,"_isInScreenspaceMode",!1);u(this,"_input");this.context=e,this._input=new Ase(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var s;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=fse.createPrimitive(kN.Quad,{material:new vse(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(s=this._input)==null||s.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Ase{constructor(e){u(this,"_onResizeScreenFn");u(this,"_onKeyUpFn");u(this,"_onMouseWheelFn");u(this,"context");u(this,"overlay");u(this,"_material");u(this,"_isPinching",!1);u(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=s=>{s.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=s=>{this.overlay.enabled&&(e.zoom+=s.deltaY*5e-4,s.preventDefault())},{passive:!1});const t=new q;window.addEventListener("mousemove",s=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new q(s.movementX,s.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",s=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(s.movementX,s.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",s=>{if(s.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",s=>{if(!this._isPinching||!this._material)return;const r=s.touches[0],o=s.touches[1],a=r.clientX-o.clientX,c=r.clientY-o.clientY,l=Math.sqrt(a*a+c*c);if(this._lastPinch!==0){const h=l-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=l}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class vse extends Xt{constructor(t){super();u(this,"_offset",new q);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new rt(0,0,1,1)}},this.vertexShader=`
4974
4974
  uniform sampler2D map;
4975
4975
  uniform float screenAspect;
4976
4976
  uniform vec4 offsetScale;
@@ -4970,7 +4970,7 @@ void main() {
4970
4970
  `,I=function(B,Q,E){Q=Q||1024;let h=B.pos,c=-1,l=0,d="",u=String.fromCharCode.apply(null,new Uint16Array(B.subarray(h,h+128)));for(;0>(c=u.indexOf(t))&&l<Q&&h<B.byteLength;)d+=u,l+=u.length,h+=128,u+=String.fromCharCode.apply(null,new Uint16Array(B.subarray(h,h+128)));return-1<c?(E!==!1&&(B.pos+=l+c+1),d+u.slice(0,c)):!1},i=function(B){const Q=/^#\?(\S+)/,E=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,h=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,c=/^\s*FORMAT=(\S+)\s*$/,l=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,d={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let u,p;if(B.pos>=B.byteLength||!(u=I(B)))return e(1,"no header found");if(!(p=u.match(Q)))return e(3,"bad initial token");for(d.valid|=1,d.programtype=p[1],d.string+=u+`
4971
4971
  `;u=I(B),u!==!1;){if(d.string+=u+`
4972
4972
  `,u.charAt(0)==="#"){d.comments+=u+`
4973
- `;continue}if((p=u.match(E))&&(d.gamma=parseFloat(p[1])),(p=u.match(h))&&(d.exposure=parseFloat(p[1])),(p=u.match(c))&&(d.valid|=2,d.format=p[1]),(p=u.match(l))&&(d.valid|=4,d.height=parseInt(p[1],10),d.width=parseInt(p[2],10)),d.valid&2&&d.valid&4)break}return d.valid&2?d.valid&4?d:e(3,"missing image size specifier"):e(3,"missing format specifier")},o=function(B,Q,E){const h=Q;if(h<8||h>32767||B[0]!==2||B[1]!==2||B[2]&128)return new Uint8Array(B);if(h!==(B[2]<<8|B[3]))return e(3,"wrong scanline width");const c=new Uint8Array(4*Q*E);if(!c.length)return e(4,"unable to allocate buffer space");let l=0,d=0;const u=4*h,p=new Uint8Array(4),D=new Uint8Array(u);let w=E;for(;w>0&&d<B.byteLength;){if(d+4>B.byteLength)return e(1);if(p[0]=B[d++],p[1]=B[d++],p[2]=B[d++],p[3]=B[d++],p[0]!=2||p[1]!=2||(p[2]<<8|p[3])!=h)return e(3,"bad rgbe scanline format");let k=0,F;for(;k<u&&d<B.byteLength;){F=B[d++];const U=F>128;if(U&&(F-=128),F===0||k+F>u)return e(3,"bad scanline data");if(U){const M=B[d++];for(let Y=0;Y<F;Y++)D[k++]=M}else D.set(B.subarray(d,d+F),k),k+=F,d+=F}const S=h;for(let U=0;U<S;U++){let M=0;c[l]=D[U+M],M+=h,c[l+1]=D[U+M],M+=h,c[l+2]=D[U+M],M+=h,c[l+3]=D[U+M],l+=4}w--}return c},C=function(B,Q,E,h){const c=B[Q+3],l=Math.pow(2,c-128)/255;E[h+0]=B[Q+0]*l,E[h+1]=B[Q+1]*l,E[h+2]=B[Q+2]*l,E[h+3]=1},s=function(B,Q,E,h){const c=B[Q+3],l=Math.pow(2,c-128)/255;E[h+0]=Ir.toHalfFloat(Math.min(B[Q+0]*l,65504)),E[h+1]=Ir.toHalfFloat(Math.min(B[Q+1]*l,65504)),E[h+2]=Ir.toHalfFloat(Math.min(B[Q+2]*l,65504)),E[h+3]=Ir.toHalfFloat(1)},a=new Uint8Array(A);a.pos=0;const n=i(a);if(n!==-1){const B=n.width,Q=n.height,E=o(a.subarray(a.pos),B,Q);if(E!==-1){let h,c,l;switch(this.type){case rt:l=E.length/4;const d=new Float32Array(l*4);for(let p=0;p<l;p++)C(E,p*4,d,p*4);h=d,c=rt;break;case Gt:l=E.length/4;const u=new Uint16Array(l*4);for(let p=0;p<l;p++)s(E,p*4,u,p*4);h=u,c=Gt;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:B,height:Q,data:h,header:n.string,gamma:n.gamma,exposure:n.exposure,type:c}}}return null}setDataType(A){return this.type=A,this}load(A,e,t,I){function i(o,C){switch(o.type){case rt:case Gt:o.encoding=Zg,o.minFilter=_e,o.magFilter=_e,o.generateMipmaps=!1,o.flipY=!0;break}e&&e(o,C)}return super.load(A,i,t,I)}}const YT=aA("debugautosync"),sR=Symbol("syncerId");class uiA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new DiA(A);return e[sR]=A.guid,this._syncers[e[sR]]=e,e}removeSyncer(A){delete this._syncers[A[sR]]}}const aR=new uiA;class DiA{constructor(A){r(this,"comp"),r(this,"hasChanges",!1),r(this,"changedProperties",{}),r(this,"data",{}),r(this,"_boundEvent"),r(this,"_handleReceivingMethod"),r(this,"_isReceiving",!1),r(this,"_isInit",!1),this.comp=A}get networkingKey(){return this.comp.constructor.name}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){YT&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const I=A[t];this.comp[t]=I}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function wiA(g,A){let e=A!==g;if(!e&&g&&A){if(Array.isArray(g)&&Array.isArray(A))e=!0;else if(typeof g=="object"&&typeof A=="object"){for(const t of Object.keys(g))if(g[t]!==A[t]){e=!0;break}}}return e}const Gl=Symbol("AutoSyncHandler");function yiA(g){if(g[Gl])return g[Gl];const A=aR.getOrCreateSyncer(g);return A?.init(g),g[Gl]=A,A}function SiA(g){const A=g[Gl];A&&(aR.removeSyncer(A),A.destroy(),delete g[Gl])}const nR=function(g){return function(A,e){let t=null,I;typeof g=="string"?I=A[g]:typeof g=="function"&&(I=g);const i=A,o=i.__internalAwake;YT&&console.log(e);const C=Symbol(e);i.__internalAwake=function(){if(this[C]!==void 0)return;this[C]=this[e],o.call(this),t=aR.getOrCreateSyncer(this);const a=Object.getOwnPropertyDescriptor(this,e);a?.set===void 0&&Object.defineProperty(this,e,{set:function(n){var B;const Q=this[C];this[C]=n,wiA(n,Q)&&I?.call(this,n,Q)!==!1&&((B=yiA(this))==null||B.notifyChanged(e,n))},get:function(){return this[C]},configurable:!0,enumerable:!0}),t?.init(this)};const s=i.__internalDestroy;i.__internalDestroy=function(){SiA(this),s.call(this)}}};var fiA=Object.defineProperty,kiA=Object.getOwnPropertyDescriptor,Xw=(g,A,e,t)=>{for(var I=t>1?void 0:t?kiA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&fiA(A,e,I),I};const ml=aA("debugskybox");class _r extends RA{constructor(){super(...arguments),r(this,"url"),r(this,"allowDrop",!0),r(this,"background",!0),r(this,"environment",!0),r(this,"_loader"),r(this,"_prevUrl"),r(this,"_prevLoadedEnvironment"),r(this,"_prevEnvironment",null),r(this,"_prevBackground",null),r(this,"dragOverEvent"),r(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Kg.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}async setSkybox(A){var e;if(!A)return;if(!(A!=null&&A.endsWith(".hdr"))&&!A.endsWith(".exr")&&!A.endsWith(".jpg")&&!A.endsWith(".png")&&!A.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),ml&&console.log("Remote skybox url?: "+A),this._prevUrl===A&&this._prevLoadedEnvironment){this.applySkybox();return}else(e=this._prevLoadedEnvironment)==null||e.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=A;const t=A.endsWith(".exr"),I=A.endsWith(".hdr");t?this._loader instanceof NG||(this._loader=new NG):I?this._loader instanceof xT||(this._loader=new xT):this._loader instanceof pa||(this._loader=new pa),ml&&console.log("Loading skybox: "+A);const i=await this._loader.loadAsync(A);if(!i||!this.enabled)return;this.url=A;const o=A.lastIndexOf("/");i.name=A.substring(o>=0?o+1:0),this._loader instanceof pa&&(i.encoding=ue),this._prevLoadedEnvironment=i,this.applySkybox()}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=sB,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),ml&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!Kg.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)e==="text/uri-list"&&A.preventDefault()},this.dropEvent=A=>{var e,t,I,i;if(this.allowDrop&&(A.preventDefault(),!!A.dataTransfer)){for(const o of A.dataTransfer.types)if(o==="text/uri-list"){const C=A.dataTransfer.getData(o);ml&&console.log(o,C);let s=(t=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(C))==null?void 0:e.groups)==null?void 0:t.name;if(s||(s=(i=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(C))==null?void 0:I.groups)==null?void 0:i.name),ml&&console.log(s),s){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+s+"_1k.exr";this.setSkybox(a)}else console.warn("Could not resolve skybox name from dropped url",C)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}Xw([nR("setSkybox"),y(URL)],_r.prototype,"url",2),Xw([y()],_r.prototype,"allowDrop",2),Xw([y()],_r.prototype,"background",2),Xw([y()],_r.prototype,"environment",2);var GiA=Object.defineProperty,miA=Object.getOwnPropertyDescriptor,MC=(g,A,e,t)=>{for(var I=t>1?void 0:t?miA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&GiA(A,e,I),I};const Ys=aA("debugsceneswitcher"),Ml="scene";zg.registerCallback(WI.ContextRegistered,async g=>{Promise.resolve().then(()=>pCA).then(A=>{const e=A.NeedleEngineHTMLElement;Ys&&console.log("SceneSwitcher: registering scene attribute",e.observedAttributes),e.observedAttributes.includes(Ml)||e.observedAttributes.push(Ml)})});const cn=Promise.resolve(!1);class mi extends RA{constructor(){super(...arguments),r(this,"scenes"),r(this,"queryParameterName","scene"),r(this,"clamp",!0),r(this,"useHistory",!0),r(this,"useKeyboard",!0),r(this,"useSwipe",!0),r(this,"useSceneLighting",!0),r(this,"preloadNext",1),r(this,"preloadPrevious",1),r(this,"preloadConcurrent",2),r(this,"_currentIndex",-1),r(this,"_currentScene"),r(this,"_engineElementOverserver"),r(this,"_preloadScheduler"),r(this,"onPopState",async A=>{if(!this.useHistory)return;let e=this.useHistory;try{this.useHistory=!1;let t=!1;if(this.queryParameterName&&(t=await this.tryLoadFromQueryParam()),!t){const I=A.state;if(I!==null&&I.startsWith(this.guid)){const i=I.substr(this.guid.length+2);console.log(i),await this.trySelectSceneFromValue(i)}}}finally{this.useHistory=e}}),r(this,"normalizedSwipeThresholdX",.1),r(this,"_didSwipe",!1),r(this,"onPointerMove",A=>{if(!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const t=e.x/this.context.domWidth;t>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):t<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),r(this,"onPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),r(this,"onKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const t=parseInt(e)-1;if(t>=0){this.trySelectSceneFromValue(t);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Ys&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(Ml);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(AC.KeyDown,this.onKeyDown),this.context.input.addEventListener(AC.PointerMove,this.onPointerMove),this.context.input.addEventListener(AC.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===Ml){const t=this.context.domElement.getAttribute(Ml);t!==null&&this.trySelectSceneFromValue(t)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new MiA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(AC.KeyDown,this.onKeyDown),this.context.input.removeEventListener(AC.PointerMove,this.onPointerMove),this.context.input.removeEventListener(AC.PointerUp,this.onPointerUp),(A=this._preloadScheduler)==null||A.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,t;if(Ys&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const i=(e=this.scenes)==null?void 0:e.find(o=>o.uri===A);if(!i){const o=dI.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(o)}if(i)A=this.scenes.indexOf(i);else return cn}if(!((t=this.scenes)!=null&&t.length))return cn;if(A<0){if(this.clamp)return cn;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return cn;A=0}const I=this.scenes[A];return this.switchScene(I)}async switchScene(A){var e,t;if(A===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const I=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;this._currentScene=A;try{const i=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:I}});this.dispatchEvent(i),await A.loadAssetAsync();const o=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:I}});if(this.dispatchEvent(o),o.defaultPrevented)return Ys&&console.warn("Adding loaded scene prevented:",A,o),!1;if(!A.asset)return Ys&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===I){if(eA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&I>=0)if((t=this.queryParameterName)!=null&&t.length)SU(this.queryParameterName,I.toString(),this.useHistory);else{const C=history.state,s=this.guid+"::"+I;C!==s&&history.pushState(s,"unused",location.href)}return!0}}catch(i){console.error(i)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof dI)return e.preload()}return cn}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return cn;const e=aA(this.queryParameterName);return typeof e=="boolean"?cn:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);for(let t=0;t<this.scenes.length;t++)if(this.scenes[t].uri.toLowerCase().includes(A))return this.select(t)}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return fI()&&console.warn('Can not find scene: "'+A+'"',this),cn}}MC([y(dI)],mi.prototype,"scenes",2),MC([y()],mi.prototype,"queryParameterName",2),MC([y()],mi.prototype,"clamp",2),MC([y()],mi.prototype,"useHistory",2),MC([y()],mi.prototype,"useKeyboard",2),MC([y()],mi.prototype,"useSwipe",2),MC([y()],mi.prototype,"useSceneLighting",2),MC([y()],mi.prototype,"preloadNext",2),MC([y()],mi.prototype,"preloadPrevious",2),MC([y()],mi.prototype,"preloadConcurrent",2);class MiA{constructor(A,e=1,t=1,I=2){r(this,"maxLoadAhead"),r(this,"maxLoadBehind"),r(this,"maxConcurrent"),r(this,"_isRunning",!1),r(this,"_switcher"),r(this,"_loadTasks",[]),r(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=t,this.maxConcurrent=I}begin(){if(this._isRunning)return;Ys&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,t;const I=this._switcher.scenes;let i=setInterval(()=>{if(this.allLoaded()&&(Ys&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(i);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,t=0,e=0);const o=t%2===0;o&&(e+=1),t+=1;const C=o?this.maxLoadAhead:this.maxLoadBehind;if(e>C)return;let s=o?A+e:A-e;if(s<0||s<0||s>=I.length)return;const a=I[s];new RiA(s,a,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1;return!0}}class RiA{constructor(A,e,t){r(this,"index"),r(this,"asset"),r(this,"tasks"),this.index=A,this.asset=e,this.tasks=t,t.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Ys&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Ys&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function UiA(){return new Promise((g,A)=>{let e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),g())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function FiA(g){await UiA(),g()}var HT=(g=>(g[g.Quad=0]="Quad",g))(HT||{});class NiA{static createPrimitive(A,e){let t;switch(A){case 0:const I=new jt(1,1,1,1),i=e?.material??new lg({color:16777215});t=new yA(I,i)}return e!=null&&e.name&&(t.name=e.name),t}}var KiA=Object.defineProperty,JiA=Object.getOwnPropertyDescriptor,so=(g,A,e,t)=>{for(var I=t>1?void 0:t?JiA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&KiA(A,e,I),I};const RC=aA("debugvideo");var TT=(g=>(g[g.CameraFarPlane=0]="CameraFarPlane",g[g.CameraNearPlane=1]="CameraNearPlane",g[g.RenderTexture=2]="RenderTexture",g[g.MaterialOverride=3]="MaterialOverride",g))(TT||{});class CI extends RA{constructor(){super(),r(this,"renderer",null),r(this,"playOnAwake",!0),r(this,"aspectMode",0),r(this,"clip",null),r(this,"renderMode"),r(this,"targetMaterialProperty"),r(this,"targetMaterialRenderer"),r(this,"targetTexture"),r(this,"time",0),r(this,"_playbackSpeed",1),r(this,"_isLooping",!1),r(this,"_muted",!1),r(this,"_audioOutputMode",2),r(this,"playInBackground",!0),r(this,"_crossOrigin","anonymous"),r(this,"source"),r(this,"url",null),r(this,"_videoElement",null),r(this,"_videoTexture",null),r(this,"_videoMaterial",null),r(this,"_isPlaying",!1),r(this,"wasPlaying",!1),r(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),r(this,"_receivedInput",!1),r(this,"_overlay",null),r(this,"_targetObjects"),r(this,"_updateAspectRoutineId",-1),FiA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],aA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&Ti()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(A){this.url!==A&&(this.url=A,this.source=1,RC&&console.log("set url",A),this._videoElement?(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var A,e;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var A;this._videoElement&&((A=this._videoElement.parentElement)==null||A.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(t=>{var I;console.log(t),RC&&console.error("Error playing video",t,"CODE="+t.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),RC&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),RC&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),RC&&console.log("PAUSE",this,this.currentTime)}create(A){var e;let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url;break}t&&(this._videoElement||(RC&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(e=this.context.domElement)==null||e.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(RC&&console.log("Set Video src",t),this._videoElement.src=t):(RC&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new HN(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=ue,this.handleBeginPlaying(A),RC&&console.log(this,A))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new qiA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),RC&&console.log("created video element",A),A}handleBeginPlaying(A){var e,t;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let I=this.gameObject;switch(this.renderMode){case 3:I=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,I||(I=(t=eA.getComponent(this.gameObject,Pg))==null?void 0:t.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!I){console.error("Missing target for video material renderer",this.name,TT[this.renderMode],this);return}const i=I.material;if(i)if(this._targetObjects.push(I),i!==this._videoMaterial&&(this._videoMaterial=i.clone(),I.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,t=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&t===this.clip&&this._isPlaying;){if(!t||typeof t=="string")return;let I;for(const i of t.getVideoTracks()){const o=i.getSettings();if(o&&o.width&&o.height){I=o.width/o.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let i=0;i<10;i++)yield;if(!this.isPlaying)break;continue}if(e===I){yield;continue}for(const i of this._targetObjects){let o=1;if(i.parent){const C=zt(i.parent);o=C.x/C.y}switch(this.aspectMode){case 1:i.scale.y=1/I*i.scale.x*o;break;case 2:i.scale.x=I*i.scale.y*o;break}}for(let i=0;i<3;i++)yield}}}so([y(UA)],CI.prototype,"renderer",2),so([y()],CI.prototype,"playOnAwake",2),so([y()],CI.prototype,"aspectMode",2),so([y(URL)],CI.prototype,"clip",2),so([y()],CI.prototype,"renderMode",2),so([y()],CI.prototype,"targetMaterialProperty",2),so([y(Pg)],CI.prototype,"targetMaterialRenderer",2),so([y(Ye)],CI.prototype,"targetTexture",2),so([y()],CI.prototype,"time",2),so([y()],CI.prototype,"playbackSpeed",1),so([y()],CI.prototype,"isLooping",1),so([y()],CI.prototype,"audioOutputMode",1);class qiA{constructor(A){r(this,"context"),r(this,"_videos",[]),r(this,"_screenspaceModeQuad"),r(this,"_isInScreenspaceMode",!1),r(this,"_input"),this.context=A,this._input=new biA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=NiA.createPrimitive(HT.Quad,{material:new viA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const I=t.material;I?.reset(),(A=this._input)==null||A.enable(I)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class biA{constructor(A){r(this,"_onResizeScreenFn"),r(this,"_onKeyUpFn"),r(this,"_onMouseWheelFn"),r(this,"context"),r(this,"overlay"),r(this,"_material"),r(this,"_isPinching",!1),r(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=I=>{I.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=I=>{this.overlay.enabled&&(A.zoom+=I.deltaY*5e-4,I.preventDefault())},{passive:!1});const e=new W;window.addEventListener("mousemove",I=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const i=new W(I.movementX,I.movementY);i.x/=this.context.domElement.clientWidth,i.y/=this.context.domElement.clientHeight,e.set(i.x,i.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",I=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(I.movementX,I.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let t=0;window.addEventListener("touchstart",I=>{if(I.touches.length<2){this.context.time.time-t<.3&&this.overlay.stop(),t=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",I=>{if(!this._isPinching||!this._material)return;const i=I.touches[0],o=I.touches[1],C=i.clientX-o.clientX,s=i.clientY-o.clientY,a=Math.sqrt(C*C+s*s);if(this._lastPinch!==0){const n=a-this._lastPinch;this._material.zoom-=n*.004}this._lastPinch=a}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class viA extends je{constructor(A){super(),r(this,"_offset",new W),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new Ie(0,0,1,1)}},this.vertexShader=`
4973
+ `;continue}if((p=u.match(E))&&(d.gamma=parseFloat(p[1])),(p=u.match(h))&&(d.exposure=parseFloat(p[1])),(p=u.match(c))&&(d.valid|=2,d.format=p[1]),(p=u.match(l))&&(d.valid|=4,d.height=parseInt(p[1],10),d.width=parseInt(p[2],10)),d.valid&2&&d.valid&4)break}return d.valid&2?d.valid&4?d:e(3,"missing image size specifier"):e(3,"missing format specifier")},o=function(B,Q,E){const h=Q;if(h<8||h>32767||B[0]!==2||B[1]!==2||B[2]&128)return new Uint8Array(B);if(h!==(B[2]<<8|B[3]))return e(3,"wrong scanline width");const c=new Uint8Array(4*Q*E);if(!c.length)return e(4,"unable to allocate buffer space");let l=0,d=0;const u=4*h,p=new Uint8Array(4),D=new Uint8Array(u);let w=E;for(;w>0&&d<B.byteLength;){if(d+4>B.byteLength)return e(1);if(p[0]=B[d++],p[1]=B[d++],p[2]=B[d++],p[3]=B[d++],p[0]!=2||p[1]!=2||(p[2]<<8|p[3])!=h)return e(3,"bad rgbe scanline format");let k=0,F;for(;k<u&&d<B.byteLength;){F=B[d++];const U=F>128;if(U&&(F-=128),F===0||k+F>u)return e(3,"bad scanline data");if(U){const M=B[d++];for(let Y=0;Y<F;Y++)D[k++]=M}else D.set(B.subarray(d,d+F),k),k+=F,d+=F}const S=h;for(let U=0;U<S;U++){let M=0;c[l]=D[U+M],M+=h,c[l+1]=D[U+M],M+=h,c[l+2]=D[U+M],M+=h,c[l+3]=D[U+M],l+=4}w--}return c},C=function(B,Q,E,h){const c=B[Q+3],l=Math.pow(2,c-128)/255;E[h+0]=B[Q+0]*l,E[h+1]=B[Q+1]*l,E[h+2]=B[Q+2]*l,E[h+3]=1},s=function(B,Q,E,h){const c=B[Q+3],l=Math.pow(2,c-128)/255;E[h+0]=Ir.toHalfFloat(Math.min(B[Q+0]*l,65504)),E[h+1]=Ir.toHalfFloat(Math.min(B[Q+1]*l,65504)),E[h+2]=Ir.toHalfFloat(Math.min(B[Q+2]*l,65504)),E[h+3]=Ir.toHalfFloat(1)},a=new Uint8Array(A);a.pos=0;const n=i(a);if(n!==-1){const B=n.width,Q=n.height,E=o(a.subarray(a.pos),B,Q);if(E!==-1){let h,c,l;switch(this.type){case rt:l=E.length/4;const d=new Float32Array(l*4);for(let p=0;p<l;p++)C(E,p*4,d,p*4);h=d,c=rt;break;case Gt:l=E.length/4;const u=new Uint16Array(l*4);for(let p=0;p<l;p++)s(E,p*4,u,p*4);h=u,c=Gt;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:B,height:Q,data:h,header:n.string,gamma:n.gamma,exposure:n.exposure,type:c}}}return null}setDataType(A){return this.type=A,this}load(A,e,t,I){function i(o,C){switch(o.type){case rt:case Gt:o.encoding=Zg,o.minFilter=_e,o.magFilter=_e,o.generateMipmaps=!1,o.flipY=!0;break}e&&e(o,C)}return super.load(A,i,t,I)}}const YT=aA("debugautosync"),sR=Symbol("syncerId");class uiA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new DiA(A);return e[sR]=A.guid,this._syncers[e[sR]]=e,e}removeSyncer(A){delete this._syncers[A[sR]]}}const aR=new uiA;class DiA{constructor(A){r(this,"comp"),r(this,"hasChanges",!1),r(this,"changedProperties",{}),r(this,"data",{}),r(this,"_boundEvent"),r(this,"_handleReceivingMethod"),r(this,"_isReceiving",!1),r(this,"_isInit",!1),this.comp=A}get networkingKey(){return this.comp.constructor.name}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){YT&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const I=A[t];this.comp[t]=I}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function wiA(g,A){let e=A!==g;if(!e&&g&&A){if(Array.isArray(g)&&Array.isArray(A))e=!0;else if(typeof g=="object"&&typeof A=="object"){for(const t of Object.keys(g))if(g[t]!==A[t]){e=!0;break}}}return e}const Gl=Symbol("AutoSyncHandler");function yiA(g){if(g[Gl])return g[Gl];const A=aR.getOrCreateSyncer(g);return A?.init(g),g[Gl]=A,A}function SiA(g){const A=g[Gl];A&&(aR.removeSyncer(A),A.destroy(),delete g[Gl])}const nR=function(g){return function(A,e){let t=null,I;typeof g=="string"?I=A[g]:typeof g=="function"&&(I=g);const i=A,o=i.__internalAwake;YT&&console.log(e);const C=Symbol(e);i.__internalAwake=function(){if(this[C]!==void 0)return;this[C]=this[e],o.call(this),t=aR.getOrCreateSyncer(this);const a=Object.getOwnPropertyDescriptor(this,e);a?.set===void 0&&Object.defineProperty(this,e,{set:function(n){var B;const Q=this[C];this[C]=n,wiA(n,Q)&&I?.call(this,n,Q)!==!1&&((B=yiA(this))==null||B.notifyChanged(e,n))},get:function(){return this[C]},configurable:!0,enumerable:!0}),t?.init(this)};const s=i.__internalDestroy;i.__internalDestroy=function(){SiA(this),s.call(this)}}};var fiA=Object.defineProperty,kiA=Object.getOwnPropertyDescriptor,Xw=(g,A,e,t)=>{for(var I=t>1?void 0:t?kiA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&fiA(A,e,I),I};const ml=aA("debugskybox");class _r extends RA{constructor(){super(...arguments),r(this,"url"),r(this,"allowDrop",!0),r(this,"background",!0),r(this,"environment",!0),r(this,"_loader"),r(this,"_prevUrl"),r(this,"_prevLoadedEnvironment"),r(this,"_prevEnvironment",null),r(this,"_prevBackground",null),r(this,"dragOverEvent"),r(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Kg.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}async setSkybox(A){var e;if(!A)return;if(!(A!=null&&A.endsWith(".hdr"))&&!A.endsWith(".exr")&&!A.endsWith(".jpg")&&!A.endsWith(".png")&&!A.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),ml&&console.log("Remote skybox url?: "+A),this._prevUrl===A&&this._prevLoadedEnvironment){this.applySkybox();return}else(e=this._prevLoadedEnvironment)==null||e.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=A;const t=A.endsWith(".exr"),I=A.endsWith(".hdr");t?this._loader instanceof NG||(this._loader=new NG):I?this._loader instanceof xT||(this._loader=new xT):this._loader instanceof pa||(this._loader=new pa),ml&&console.log("Loading skybox: "+A);const i=await this._loader.loadAsync(A);if(!i||!this.enabled)return;this.url=A;const o=A.lastIndexOf("/");i.name=A.substring(o>=0?o+1:0),this._loader instanceof pa&&(i.encoding=ue),this._prevLoadedEnvironment=i,this.applySkybox()}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=sB,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),ml&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!Kg.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)e==="text/uri-list"&&A.preventDefault()},this.dropEvent=A=>{var e,t,I,i;if(this.allowDrop&&(A.preventDefault(),!!A.dataTransfer)){for(const o of A.dataTransfer.types)if(o==="text/uri-list"){const C=A.dataTransfer.getData(o);ml&&console.log(o,C);let s=(t=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(C))==null?void 0:e.groups)==null?void 0:t.name;if(s||(s=(i=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(C))==null?void 0:I.groups)==null?void 0:i.name),ml&&console.log(s),s){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+s+"_1k.exr";this.setSkybox(a)}else console.warn("Could not resolve skybox name from dropped url",C)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}Xw([nR("setSkybox"),y(URL)],_r.prototype,"url",2),Xw([y()],_r.prototype,"allowDrop",2),Xw([y()],_r.prototype,"background",2),Xw([y()],_r.prototype,"environment",2);var GiA=Object.defineProperty,miA=Object.getOwnPropertyDescriptor,MC=(g,A,e,t)=>{for(var I=t>1?void 0:t?miA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&GiA(A,e,I),I};const Ys=aA("debugsceneswitcher"),Ml="scene";zg.registerCallback(WI.ContextRegistered,async g=>{Promise.resolve().then(()=>pCA).then(A=>{const e=A.NeedleEngineHTMLElement;Ys&&console.log("SceneSwitcher: registering scene attribute",e.observedAttributes),e.observedAttributes.includes(Ml)||e.observedAttributes.push(Ml)})});const cn=Promise.resolve(!1);class mi extends RA{constructor(){super(...arguments),r(this,"scenes"),r(this,"queryParameterName","scene"),r(this,"clamp",!0),r(this,"useHistory",!0),r(this,"useKeyboard",!0),r(this,"useSwipe",!0),r(this,"useSceneLighting",!0),r(this,"preloadNext",1),r(this,"preloadPrevious",1),r(this,"preloadConcurrent",2),r(this,"_currentIndex",-1),r(this,"_currentScene"),r(this,"_engineElementOverserver"),r(this,"_preloadScheduler"),r(this,"onPopState",async A=>{if(!this.useHistory)return;let e=this.useHistory;try{this.useHistory=!1;let t=!1;if(this.queryParameterName&&(t=await this.tryLoadFromQueryParam()),!t){const I=A.state;if(I!==null&&I.startsWith(this.guid)){const i=I.substr(this.guid.length+2);console.log(i),await this.trySelectSceneFromValue(i)}}}finally{this.useHistory=e}}),r(this,"normalizedSwipeThresholdX",.1),r(this,"_didSwipe",!1),r(this,"onPointerMove",A=>{if(this.useSwipe&&!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const t=e.x/this.context.domWidth;t>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):t<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),r(this,"onPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),r(this,"onKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const t=parseInt(e)-1;if(t>=0){this.trySelectSceneFromValue(t);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){Ys&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(Ml);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(AC.KeyDown,this.onKeyDown),this.context.input.addEventListener(AC.PointerMove,this.onPointerMove),this.context.input.addEventListener(AC.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===Ml){const t=this.context.domElement.getAttribute(Ml);t!==null&&this.trySelectSceneFromValue(t)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new MiA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(AC.KeyDown,this.onKeyDown),this.context.input.removeEventListener(AC.PointerMove,this.onPointerMove),this.context.input.removeEventListener(AC.PointerUp,this.onPointerUp),(A=this._preloadScheduler)==null||A.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,t;if(Ys&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const i=(e=this.scenes)==null?void 0:e.find(o=>o.uri===A);if(!i){const o=dI.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(o)}if(i)A=this.scenes.indexOf(i);else return cn}if(!((t=this.scenes)!=null&&t.length))return cn;if(A<0){if(this.clamp)return cn;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return cn;A=0}const I=this.scenes[A];return this.switchScene(I)}async switchScene(A){var e,t;if(A===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const I=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;this._currentScene=A;try{const i=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:I}});this.dispatchEvent(i),await A.loadAssetAsync();const o=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:I}});if(this.dispatchEvent(o),o.defaultPrevented)return Ys&&console.warn("Adding loaded scene prevented:",A,o),!1;if(!A.asset)return Ys&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===I){if(eA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&I>=0)if((t=this.queryParameterName)!=null&&t.length)SU(this.queryParameterName,I.toString(),this.useHistory);else{const C=history.state,s=this.guid+"::"+I;C!==s&&history.pushState(s,"unused",location.href)}return!0}}catch(i){console.error(i)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof dI)return e.preload()}return cn}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return cn;const e=aA(this.queryParameterName);return typeof e=="boolean"?cn:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);for(let t=0;t<this.scenes.length;t++)if(this.scenes[t].uri.toLowerCase().includes(A))return this.select(t)}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return fI()&&console.warn('Can not find scene: "'+A+'"',this),cn}}MC([y(dI)],mi.prototype,"scenes",2),MC([y()],mi.prototype,"queryParameterName",2),MC([y()],mi.prototype,"clamp",2),MC([y()],mi.prototype,"useHistory",2),MC([y()],mi.prototype,"useKeyboard",2),MC([y()],mi.prototype,"useSwipe",2),MC([y()],mi.prototype,"useSceneLighting",2),MC([y()],mi.prototype,"preloadNext",2),MC([y()],mi.prototype,"preloadPrevious",2),MC([y()],mi.prototype,"preloadConcurrent",2);class MiA{constructor(A,e=1,t=1,I=2){r(this,"maxLoadAhead"),r(this,"maxLoadBehind"),r(this,"maxConcurrent"),r(this,"_isRunning",!1),r(this,"_switcher"),r(this,"_loadTasks",[]),r(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=t,this.maxConcurrent=I}begin(){if(this._isRunning)return;Ys&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,t;const I=this._switcher.scenes;let i=setInterval(()=>{if(this.allLoaded()&&(Ys&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(i);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,t=0,e=0);const o=t%2===0;o&&(e+=1),t+=1;const C=o?this.maxLoadAhead:this.maxLoadBehind;if(e>C)return;let s=o?A+e:A-e;if(s<0||s<0||s>=I.length)return;const a=I[s];new RiA(s,a,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1;return!0}}class RiA{constructor(A,e,t){r(this,"index"),r(this,"asset"),r(this,"tasks"),this.index=A,this.asset=e,this.tasks=t,t.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(Ys&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Ys&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function UiA(){return new Promise((g,A)=>{let e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),g())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function FiA(g){await UiA(),g()}var HT=(g=>(g[g.Quad=0]="Quad",g))(HT||{});class NiA{static createPrimitive(A,e){let t;switch(A){case 0:const I=new jt(1,1,1,1),i=e?.material??new lg({color:16777215});t=new yA(I,i)}return e!=null&&e.name&&(t.name=e.name),t}}var KiA=Object.defineProperty,JiA=Object.getOwnPropertyDescriptor,so=(g,A,e,t)=>{for(var I=t>1?void 0:t?JiA(A,e):A,i=g.length-1,o;i>=0;i--)(o=g[i])&&(I=(t?o(A,e,I):o(I))||I);return t&&I&&KiA(A,e,I),I};const RC=aA("debugvideo");var TT=(g=>(g[g.CameraFarPlane=0]="CameraFarPlane",g[g.CameraNearPlane=1]="CameraNearPlane",g[g.RenderTexture=2]="RenderTexture",g[g.MaterialOverride=3]="MaterialOverride",g))(TT||{});class CI extends RA{constructor(){super(),r(this,"renderer",null),r(this,"playOnAwake",!0),r(this,"aspectMode",0),r(this,"clip",null),r(this,"renderMode"),r(this,"targetMaterialProperty"),r(this,"targetMaterialRenderer"),r(this,"targetTexture"),r(this,"time",0),r(this,"_playbackSpeed",1),r(this,"_isLooping",!1),r(this,"_muted",!1),r(this,"_audioOutputMode",2),r(this,"playInBackground",!0),r(this,"_crossOrigin","anonymous"),r(this,"source"),r(this,"url",null),r(this,"_videoElement",null),r(this,"_videoTexture",null),r(this,"_videoMaterial",null),r(this,"_isPlaying",!1),r(this,"wasPlaying",!1),r(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),r(this,"_receivedInput",!1),r(this,"_overlay",null),r(this,"_targetObjects"),r(this,"_updateAspectRoutineId",-1),FiA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],aA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&Ti()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(A){this.url!==A&&(this.url=A,this.source=1,RC&&console.log("set url",A),this._videoElement?(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var A,e;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var A;this._videoElement&&((A=this._videoElement.parentElement)==null||A.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(t=>{var I;console.log(t),RC&&console.error("Error playing video",t,"CODE="+t.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),RC&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),RC&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),RC&&console.log("PAUSE",this,this.currentTime)}create(A){var e;let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url;break}t&&(this._videoElement||(RC&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(e=this.context.domElement)==null||e.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(RC&&console.log("Set Video src",t),this._videoElement.src=t):(RC&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new HN(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=ue,this.handleBeginPlaying(A),RC&&console.log(this,A))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new qiA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),RC&&console.log("created video element",A),A}handleBeginPlaying(A){var e,t;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let I=this.gameObject;switch(this.renderMode){case 3:I=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,I||(I=(t=eA.getComponent(this.gameObject,Pg))==null?void 0:t.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!I){console.error("Missing target for video material renderer",this.name,TT[this.renderMode],this);return}const i=I.material;if(i)if(this._targetObjects.push(I),i!==this._videoMaterial&&(this._videoMaterial=i.clone(),I.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,t=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&t===this.clip&&this._isPlaying;){if(!t||typeof t=="string")return;let I;for(const i of t.getVideoTracks()){const o=i.getSettings();if(o&&o.width&&o.height){I=o.width/o.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let i=0;i<10;i++)yield;if(!this.isPlaying)break;continue}if(e===I){yield;continue}for(const i of this._targetObjects){let o=1;if(i.parent){const C=zt(i.parent);o=C.x/C.y}switch(this.aspectMode){case 1:i.scale.y=1/I*i.scale.x*o;break;case 2:i.scale.x=I*i.scale.y*o;break}}for(let i=0;i<3;i++)yield}}}so([y(UA)],CI.prototype,"renderer",2),so([y()],CI.prototype,"playOnAwake",2),so([y()],CI.prototype,"aspectMode",2),so([y(URL)],CI.prototype,"clip",2),so([y()],CI.prototype,"renderMode",2),so([y()],CI.prototype,"targetMaterialProperty",2),so([y(Pg)],CI.prototype,"targetMaterialRenderer",2),so([y(Ye)],CI.prototype,"targetTexture",2),so([y()],CI.prototype,"time",2),so([y()],CI.prototype,"playbackSpeed",1),so([y()],CI.prototype,"isLooping",1),so([y()],CI.prototype,"audioOutputMode",1);class qiA{constructor(A){r(this,"context"),r(this,"_videos",[]),r(this,"_screenspaceModeQuad"),r(this,"_isInScreenspaceMode",!1),r(this,"_input"),this.context=A,this._input=new biA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=NiA.createPrimitive(HT.Quad,{material:new viA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const I=t.material;I?.reset(),(A=this._input)==null||A.enable(I)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class biA{constructor(A){r(this,"_onResizeScreenFn"),r(this,"_onKeyUpFn"),r(this,"_onMouseWheelFn"),r(this,"context"),r(this,"overlay"),r(this,"_material"),r(this,"_isPinching",!1),r(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=I=>{I.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=I=>{this.overlay.enabled&&(A.zoom+=I.deltaY*5e-4,I.preventDefault())},{passive:!1});const e=new W;window.addEventListener("mousemove",I=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const i=new W(I.movementX,I.movementY);i.x/=this.context.domElement.clientWidth,i.y/=this.context.domElement.clientHeight,e.set(i.x,i.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",I=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(I.movementX,I.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let t=0;window.addEventListener("touchstart",I=>{if(I.touches.length<2){this.context.time.time-t<.3&&this.overlay.stop(),t=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",I=>{if(!this._isPinching||!this._material)return;const i=I.touches[0],o=I.touches[1],C=i.clientX-o.clientX,s=i.clientY-o.clientY,a=Math.sqrt(C*C+s*s);if(this._lastPinch!==0){const n=a-this._lastPinch;this._material.zoom-=n*.004}this._lastPinch=a}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class viA extends je{constructor(A){super(),r(this,"_offset",new W),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new Ie(0,0,1,1)}},this.vertexShader=`
4974
4974
  uniform sampler2D map;
4975
4975
  uniform float screenAspect;
4976
4976
  uniform vec4 offsetScale;
@@ -4970,7 +4970,7 @@ void main() {
4970
4970
  `,Q=function(u,D,y){D=D||1024;let R=u.pos,f=-1,M=0,U="",J=String.fromCharCode.apply(null,new Uint16Array(u.subarray(R,R+128)));for(;0>(f=J.indexOf(B))&&M<D&&R<u.byteLength;)U+=J,M+=J.length,R+=128,J+=String.fromCharCode.apply(null,new Uint16Array(u.subarray(R,R+128)));return-1<f?(y!==!1&&(u.pos+=M+f+1),U+J.slice(0,f)):!1},E=function(u){const D=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,R=/^\s*FORMAT=(\S+)\s*$/,f=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,M={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let U,J;if(u.pos>=u.byteLength||!(U=Q(u)))return C(1,"no header found");if(!(J=U.match(D)))return C(3,"bad initial token");for(M.valid|=1,M.programtype=J[1],M.string+=U+`
4971
4971
  `;U=Q(u),U!==!1;){if(M.string+=U+`
4972
4972
  `,U.charAt(0)==="#"){M.comments+=U+`
4973
- `;continue}if((J=U.match(y))&&(M.gamma=parseFloat(J[1])),(J=U.match(S))&&(M.exposure=parseFloat(J[1])),(J=U.match(R))&&(M.valid|=2,M.format=J[1]),(J=U.match(f))&&(M.valid|=4,M.height=parseInt(J[1],10),M.width=parseInt(J[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2?M.valid&4?M:C(3,"missing image size specifier"):C(3,"missing format specifier")},c=function(u,D,y){const S=D;if(S<8||S>32767||u[0]!==2||u[1]!==2||u[2]&128)return new Uint8Array(u);if(S!==(u[2]<<8|u[3]))return C(3,"wrong scanline width");const R=new Uint8Array(4*D*y);if(!R.length)return C(4,"unable to allocate buffer space");let f=0,M=0;const U=4*S,J=new Uint8Array(4),T=new Uint8Array(U);let Y=y;for(;Y>0&&M<u.byteLength;){if(M+4>u.byteLength)return C(1);if(J[0]=u[M++],J[1]=u[M++],J[2]=u[M++],J[3]=u[M++],J[0]!=2||J[1]!=2||(J[2]<<8|J[3])!=S)return C(3,"bad rgbe scanline format");let b=0,_;for(;b<U&&M<u.byteLength;){_=u[M++];const $=_>128;if($&&(_-=128),_===0||b+_>U)return C(3,"bad scanline data");if($){const X=u[M++];for(let cA=0;cA<_;cA++)T[b++]=X}else T.set(u.subarray(M,M+_),b),b+=_,M+=_}const AA=S;for(let $=0;$<AA;$++){let X=0;R[f]=T[$+X],X+=S,R[f+1]=T[$+X],X+=S,R[f+2]=T[$+X],X+=S,R[f+3]=T[$+X],f+=4}Y--}return R},h=function(u,D,y,S){const R=u[D+3],f=Math.pow(2,R-128)/255;y[S+0]=u[D+0]*f,y[S+1]=u[D+1]*f,y[S+2]=u[D+2]*f,y[S+3]=1},l=function(u,D,y,S){const R=u[D+3],f=Math.pow(2,R-128)/255;y[S+0]=dr.toHalfFloat(Math.min(u[D+0]*f,65504)),y[S+1]=dr.toHalfFloat(Math.min(u[D+1]*f,65504)),y[S+2]=dr.toHalfFloat(Math.min(u[D+2]*f,65504)),y[S+3]=dr.toHalfFloat(1)},d=new Uint8Array(A);d.pos=0;const p=E(d);if(p!==-1){const u=p.width,D=p.height,y=c(d.subarray(d.pos),u,D);if(y!==-1){let S,R,f;switch(this.type){case Mi:f=y.length/4;const M=new Float32Array(f*4);for(let J=0;J<f;J++)h(y,J*4,M,J*4);S=M,R=Mi;break;case Yi:f=y.length/4;const U=new Uint16Array(f*4);for(let J=0;J<f;J++)l(y,J*4,U,J*4);S=U,R=Yi;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:u,height:D,data:S,header:p.string,gamma:p.gamma,exposure:p.exposure,type:R}}}return null}setDataType(A){return this.type=A,this}load(A,e,t,g){function I(o,C){switch(o.type){case Mi:case Yi:o.encoding=hi,o.minFilter=Pe,o.magFilter=Pe,o.generateMipmaps=!1,o.flipY=!0;break}e&&e(o,C)}return super.load(A,I,t,g)}}const r_=rA("debugautosync"),G0=Symbol("syncerId");class SIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new kIA(A);return e[G0]=A.guid,this._syncers[e[G0]]=e,e}removeSyncer(A){delete this._syncers[A[G0]]}}const _R=new SIA;class kIA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_boundEvent");r(this,"_handleReceivingMethod");r(this,"_isReceiving",!1);r(this,"_isInit",!1);this.comp=A}get networkingKey(){return this.comp.constructor.name}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){r_&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const g=A[t];this.comp[t]=g}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function GIA(i,A){let e=A!==i;if(!e&&i&&A){if(Array.isArray(i)&&Array.isArray(A))e=!0;else if(typeof i=="object"&&typeof A=="object"){for(const t of Object.keys(i))if(i[t]!==A[t]){e=!0;break}}}return e}const dh=Symbol("AutoSyncHandler");function MIA(i){if(i[dh])return i[dh];const A=_R.getOrCreateSyncer(i);return A==null||A.init(i),i[dh]=A,A}function mIA(i){const A=i[dh];A&&(_R.removeSyncer(A),A.destroy(),delete i[dh])}const OR=function(i){return function(A,e){let t=null,g;typeof i=="string"?g=A[i]:typeof i=="function"&&(g=i);const I=A,o=I.__internalAwake;r_&&console.log(e);const C=Symbol(e);I.__internalAwake=function(){if(this[C]!==void 0)return;this[C]=this[e],o.call(this),t=_R.getOrCreateSyncer(this);const n=Object.getOwnPropertyDescriptor(this,e);(n==null?void 0:n.set)===void 0&&Object.defineProperty(this,e,{set:function(a){var Q;const B=this[C];this[C]=a,GIA(a,B)&&(g==null?void 0:g.call(this,a,B))!==!1&&((Q=MIA(this))==null||Q.notifyChanged(e,a))},get:function(){return this[C]},configurable:!0,enumerable:!0}),t==null||t.init(this)};const s=I.__internalDestroy;I.__internalDestroy=function(){mIA(this),s.call(this)}}};var RIA=Object.defineProperty,UIA=Object.getOwnPropertyDescriptor,Iy=(i,A,e,t)=>{for(var g=t>1?void 0:t?UIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RIA(A,e,g),g};const Rc=rA("debugskybox");class hB extends MA{constructor(){super(...arguments);r(this,"url");r(this,"allowDrop",!0);r(this,"background",!0);r(this,"environment",!0);r(this,"_loader");r(this,"_prevUrl");r(this,"_prevLoadedEnvironment");r(this,"_prevEnvironment",null);r(this,"_prevBackground",null);r(this,"dragOverEvent");r(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Yt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}async setSkybox(e){var C;if(!e)return;if(!(e!=null&&e.endsWith(".hdr"))&&!e.endsWith(".exr")&&!e.endsWith(".jpg")&&!e.endsWith(".png")&&!e.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),Rc&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment){this.applySkybox();return}else(C=this._prevLoadedEnvironment)==null||C.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=e;const t=e.endsWith(".exr"),g=e.endsWith(".hdr");t?this._loader instanceof sG||(this._loader=new sG):g?this._loader instanceof rq||(this._loader=new rq):this._loader instanceof ta||(this._loader=new ta),Rc&&console.log("Loading skybox: "+e);const I=await this._loader.loadAsync(e);if(!I||!this.enabled)return;this.url=e;const o=e.lastIndexOf("/");I.name=e.substring(o>=0?o+1:0),this._loader instanceof ta&&(I.encoding=De),this._prevLoadedEnvironment=I,this.applySkybox()}applySkybox(){var t;const e=this._prevLoadedEnvironment;e&&(e.mapping=JQ,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Rc&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!Yt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((t=this.context.mainCameraComponent)==null?void 0:t.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)t==="text/uri-list"&&e.preventDefault()},this.dropEvent=e=>{var t,g,I,o;if(this.allowDrop&&(e.preventDefault(),!!e.dataTransfer)){for(const C of e.dataTransfer.types)if(C==="text/uri-list"){const s=e.dataTransfer.getData(C);Rc&&console.log(C,s);let n=(g=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(s))==null?void 0:t.groups)==null?void 0:g.name;if(n||(n=(o=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(s))==null?void 0:I.groups)==null?void 0:o.name),Rc&&console.log(n),n){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+n+"_1k.exr";this.setSkybox(a)}else console.warn("Could not resolve skybox name from dropped url",s)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}Iy([OR("setSkybox"),w(URL)],hB.prototype,"url",2);Iy([w()],hB.prototype,"allowDrop",2);Iy([w()],hB.prototype,"background",2);Iy([w()],hB.prototype,"environment",2);var FIA=Object.defineProperty,NIA=Object.getOwnPropertyDescriptor,is=(i,A,e,t)=>{for(var g=t>1?void 0:t?NIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&FIA(A,e,g),g};const vs=rA("debugsceneswitcher"),uh="scene";Bi.registerCallback(BI.ContextRegistered,async i=>{Promise.resolve().then(()=>yCA).then(A=>{const e=A.NeedleEngineHTMLElement;vs&&console.log("SceneSwitcher: registering scene attribute",e.observedAttributes),e.observedAttributes.includes(uh)||e.observedAttributes.push(uh)})});const Jn=Promise.resolve(!1);class PI extends MA{constructor(){super(...arguments);r(this,"scenes");r(this,"queryParameterName","scene");r(this,"clamp",!0);r(this,"useHistory",!0);r(this,"useKeyboard",!0);r(this,"useSwipe",!0);r(this,"useSceneLighting",!0);r(this,"preloadNext",1);r(this,"preloadPrevious",1);r(this,"preloadConcurrent",2);r(this,"_currentIndex",-1);r(this,"_currentScene");r(this,"_engineElementOverserver");r(this,"_preloadScheduler");r(this,"onPopState",async e=>{if(!this.useHistory)return;let t=this.useHistory;try{this.useHistory=!1;let g=!1;if(this.queryParameterName&&(g=await this.tryLoadFromQueryParam()),!g){const I=e.state;if(I!==null&&I.startsWith(this.guid)){const o=I.substr(this.guid.length+2);console.log(o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=t}});r(this,"normalizedSwipeThresholdX",.1);r(this,"_didSwipe",!1);r(this,"onPointerMove",e=>{if(!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const g=t.x/this.context.domWidth;g>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):g<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});r(this,"onPointerUp",e=>{e.button===0&&(this._didSwipe=!1)});r(this,"onKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const g=parseInt(t)-1;if(g>=0){this.trySelectSceneFromValue(g);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){vs&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(uh);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(wC.KeyDown,this.onKeyDown),this.context.input.addEventListener(wC.PointerMove,this.onPointerMove),this.context.input.addEventListener(wC.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===uh){const g=this.context.domElement.getAttribute(uh);g!==null&&this.trySelectSceneFromValue(g)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new KIA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(wC.KeyDown,this.onKeyDown),this.context.input.removeEventListener(wC.PointerMove,this.onPointerMove),this.context.input.removeEventListener(wC.PointerUp,this.onPointerUp),(e=this._preloadScheduler)==null||e.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var g,I;if(vs&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(g=this.scenes)==null?void 0:g.find(C=>C.uri===e);if(!o){const C=ig.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(C)}if(o)e=this.scenes.indexOf(o);else return Jn}if(!((I=this.scenes)!=null&&I.length))return Jn;if(e<0){if(this.clamp)return Jn;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Jn;e=0}const t=this.scenes[e];return this.switchScene(t)}async switchScene(e){var g,I;if(e===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const t=this._currentIndex=((g=this.scenes)==null?void 0:g.indexOf(e))??-1;this._currentScene=e;try{const o=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:t}});this.dispatchEvent(o),await e.loadAssetAsync();const C=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:t}});if(this.dispatchEvent(C),C.defaultPrevented)return vs&&console.warn("Adding loaded scene prevented:",e,C),!1;if(!e.asset)return vs&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===t){if(eA.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&t>=0)if((I=this.queryParameterName)!=null&&I.length)Mq(this.queryParameterName,t.toString(),this.useHistory);else{const s=history.state,n=this.guid+"::"+t;s!==n&&history.pushState(n,"unused",location.href)}return!0}}catch(o){console.error(o)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof ig)return t.preload()}return Jn}tryLoadFromQueryParam(){var t;if(!((t=this.queryParameterName)!=null&&t.length))return Jn;const e=rA(this.queryParameterName);return typeof e=="boolean"?Jn:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);for(let g=0;g<this.scenes.length;g++)if(this.scenes[g].uri.toLowerCase().includes(e))return this.select(g)}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return zg()&&console.warn('Can not find scene: "'+e+'"',this),Jn}}is([w(ig)],PI.prototype,"scenes",2);is([w()],PI.prototype,"queryParameterName",2);is([w()],PI.prototype,"clamp",2);is([w()],PI.prototype,"useHistory",2);is([w()],PI.prototype,"useKeyboard",2);is([w()],PI.prototype,"useSwipe",2);is([w()],PI.prototype,"useSceneLighting",2);is([w()],PI.prototype,"preloadNext",2);is([w()],PI.prototype,"preloadPrevious",2);is([w()],PI.prototype,"preloadConcurrent",2);class KIA{constructor(A,e=1,t=1,g=2){r(this,"maxLoadAhead");r(this,"maxLoadBehind");r(this,"maxConcurrent");r(this,"_isRunning",!1);r(this,"_switcher");r(this,"_loadTasks",[]);r(this,"_maxConcurrentLoads",1);this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=t,this.maxConcurrent=g}begin(){if(this._isRunning)return;vs&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,t;const g=this._switcher.scenes;let I=setInterval(()=>{if(this.allLoaded()&&(vs&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(I);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,t=0,e=0);const o=t%2===0;o&&(e+=1),t+=1;const C=o?this.maxLoadAhead:this.maxLoadBehind;if(e>C)return;let s=o?A+e:A-e;if(s<0||s<0||s>=g.length)return;const n=g[s];new JIA(s,n,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const A of this._switcher.scenes)if((A==null?void 0:A.isLoaded())===!1)return!1;return!0}}class JIA{constructor(A,e,t){r(this,"index");r(this,"asset");r(this,"tasks");this.index=A,this.asset=e,this.tasks=t,t.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(vs&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),vs&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function qIA(){return new Promise((i,A)=>{let t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function bIA(i){await qIA(),i()}var B_=(i=>(i[i.Quad=0]="Quad",i))(B_||{});class LIA{static createPrimitive(A,e){let t;switch(A){case 0:const g=new Ig(1,1,1,1),I=(e==null?void 0:e.material)??new wt({color:16777215});t=new fA(g,I)}return e!=null&&e.name&&(t.name=e.name),t}}var vIA=Object.defineProperty,xIA=Object.getOwnPropertyDescriptor,Fo=(i,A,e,t)=>{for(var g=t>1?void 0:t?xIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&vIA(A,e,g),g};const lC=rA("debugvideo");var Q_=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(Q_||{});class pg extends MA{constructor(){super();r(this,"renderer",null);r(this,"playOnAwake",!0);r(this,"aspectMode",0);r(this,"clip",null);r(this,"renderMode");r(this,"targetMaterialProperty");r(this,"targetMaterialRenderer");r(this,"targetTexture");r(this,"time",0);r(this,"_playbackSpeed",1);r(this,"_isLooping",!1);r(this,"_muted",!1);r(this,"_audioOutputMode",2);r(this,"playInBackground",!0);r(this,"_crossOrigin","anonymous");r(this,"source");r(this,"url",null);r(this,"_videoElement",null);r(this,"_videoTexture",null);r(this,"_videoMaterial",null);r(this,"_isPlaying",!1);r(this,"wasPlaying",!1);r(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});r(this,"_receivedInput",!1);r(this,"_overlay",null);r(this,"_targetObjects");r(this,"_updateAspectRoutineId",-1);bIA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],rA("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;if(e){if(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA)return!0;if(e.srcObject&&e.srcObject.active)return!0}return!1}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&yo()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(e){this.url!==e&&(this.url=e,this.source=1,lC&&console.log("set url",e),this._videoElement?(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var e,t;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var e;this._videoElement&&((e=this._videoElement.parentElement)==null||e.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(g=>{var I;console.log(g),lC&&console.error("Error playing video",g,"CODE="+g.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),lC&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),lC&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),lC&&console.log("PAUSE",this,this.currentTime)}create(e){var g;let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url;break}t&&(this._videoElement||(lC&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(g=this.context.domElement)==null||g.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(lC&&console.log("Set Video src",t),this._videoElement.src=t):(lC&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new Wb(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=De,this.handleBeginPlaying(e),lC&&console.log(this,e))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new YIA(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),lC&&console.log("created video element",e),e}handleBeginPlaying(e){var I,o;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let t=this.gameObject;switch(this.renderMode){case 3:t=(I=this.targetMaterialRenderer)==null?void 0:I.gameObject,t||(t=(o=eA.getComponent(this.gameObject,gi))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!t){console.error("Missing target for video material renderer",this.name,Q_[this.renderMode],this);return}const g=t.material;if(g)if(this._targetObjects.push(t),g!==this._videoMaterial&&(this._videoMaterial=g.clone(),t.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,g=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&g===this.clip&&this._isPlaying;){if(!g||typeof g=="string")return;let I;for(const o of g.getVideoTracks()){const C=o.getSettings();if(C&&C.width&&C.height){I=C.width/C.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(t===I){yield;continue}for(const o of this._targetObjects){let C=1;if(o.parent){const s=Bg(o.parent);C=s.x/s.y}switch(this.aspectMode){case 1:o.scale.y=1/I*o.scale.x*C;break;case 2:o.scale.x=I*o.scale.y*C;break}}for(let o=0;o<3;o++)yield}}}Fo([w(UA)],pg.prototype,"renderer",2);Fo([w()],pg.prototype,"playOnAwake",2);Fo([w()],pg.prototype,"aspectMode",2);Fo([w(URL)],pg.prototype,"clip",2);Fo([w()],pg.prototype,"renderMode",2);Fo([w()],pg.prototype,"targetMaterialProperty",2);Fo([w(gi)],pg.prototype,"targetMaterialRenderer",2);Fo([w(He)],pg.prototype,"targetTexture",2);Fo([w()],pg.prototype,"time",2);Fo([w()],pg.prototype,"playbackSpeed",1);Fo([w()],pg.prototype,"isLooping",1);Fo([w()],pg.prototype,"audioOutputMode",1);class YIA{constructor(A){r(this,"context");r(this,"_videos",[]);r(this,"_screenspaceModeQuad");r(this,"_isInScreenspaceMode",!1);r(this,"_input");this.context=A,this._input=new TIA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var g;if(this._isInScreenspaceMode||this._videos.length<0)return;const A=this._videos[this._videos.length-1];if(!A)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=LIA.createPrimitive(B_.Quad,{material:new HIA(A)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const e=this._screenspaceModeQuad;this.context.scene.add(e),this.updateScreenspaceMaterialUniforms();const t=e.material;t==null||t.reset(),(g=this._input)==null||g.enable(t)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const A=(e=this._screenspaceModeQuad)==null?void 0:e.material;A&&(A.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class TIA{constructor(A){r(this,"_onResizeScreenFn");r(this,"_onKeyUpFn");r(this,"_onMouseWheelFn");r(this,"context");r(this,"overlay");r(this,"_material");r(this,"_isPinching",!1);r(this,"_lastPinch",0);this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=g=>{g.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=g=>{this.overlay.enabled&&(A.zoom+=g.deltaY*5e-4,g.preventDefault())},{passive:!1});const e=new j;window.addEventListener("mousemove",g=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const I=new j(g.movementX,g.movementY);I.x/=this.context.domElement.clientWidth,I.y/=this.context.domElement.clientHeight,e.set(I.x,I.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",g=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(g.movementX,g.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let t=0;window.addEventListener("touchstart",g=>{if(g.touches.length<2){this.context.time.time-t<.3&&this.overlay.stop(),t=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",g=>{if(!this._isPinching||!this._material)return;const I=g.touches[0],o=g.touches[1],C=I.clientX-o.clientX,s=I.clientY-o.clientY,n=Math.sqrt(C*C+s*s);if(this._lastPinch!==0){const a=n-this._lastPinch;this._material.zoom-=a*.004}this._lastPinch=n}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class HIA extends Ze{constructor(e){super();r(this,"_offset",new j);this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new Ce(0,0,1,1)}},this.vertexShader=`
4973
+ `;continue}if((J=U.match(y))&&(M.gamma=parseFloat(J[1])),(J=U.match(S))&&(M.exposure=parseFloat(J[1])),(J=U.match(R))&&(M.valid|=2,M.format=J[1]),(J=U.match(f))&&(M.valid|=4,M.height=parseInt(J[1],10),M.width=parseInt(J[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2?M.valid&4?M:C(3,"missing image size specifier"):C(3,"missing format specifier")},c=function(u,D,y){const S=D;if(S<8||S>32767||u[0]!==2||u[1]!==2||u[2]&128)return new Uint8Array(u);if(S!==(u[2]<<8|u[3]))return C(3,"wrong scanline width");const R=new Uint8Array(4*D*y);if(!R.length)return C(4,"unable to allocate buffer space");let f=0,M=0;const U=4*S,J=new Uint8Array(4),T=new Uint8Array(U);let Y=y;for(;Y>0&&M<u.byteLength;){if(M+4>u.byteLength)return C(1);if(J[0]=u[M++],J[1]=u[M++],J[2]=u[M++],J[3]=u[M++],J[0]!=2||J[1]!=2||(J[2]<<8|J[3])!=S)return C(3,"bad rgbe scanline format");let b=0,_;for(;b<U&&M<u.byteLength;){_=u[M++];const $=_>128;if($&&(_-=128),_===0||b+_>U)return C(3,"bad scanline data");if($){const X=u[M++];for(let cA=0;cA<_;cA++)T[b++]=X}else T.set(u.subarray(M,M+_),b),b+=_,M+=_}const AA=S;for(let $=0;$<AA;$++){let X=0;R[f]=T[$+X],X+=S,R[f+1]=T[$+X],X+=S,R[f+2]=T[$+X],X+=S,R[f+3]=T[$+X],f+=4}Y--}return R},h=function(u,D,y,S){const R=u[D+3],f=Math.pow(2,R-128)/255;y[S+0]=u[D+0]*f,y[S+1]=u[D+1]*f,y[S+2]=u[D+2]*f,y[S+3]=1},l=function(u,D,y,S){const R=u[D+3],f=Math.pow(2,R-128)/255;y[S+0]=dr.toHalfFloat(Math.min(u[D+0]*f,65504)),y[S+1]=dr.toHalfFloat(Math.min(u[D+1]*f,65504)),y[S+2]=dr.toHalfFloat(Math.min(u[D+2]*f,65504)),y[S+3]=dr.toHalfFloat(1)},d=new Uint8Array(A);d.pos=0;const p=E(d);if(p!==-1){const u=p.width,D=p.height,y=c(d.subarray(d.pos),u,D);if(y!==-1){let S,R,f;switch(this.type){case Mi:f=y.length/4;const M=new Float32Array(f*4);for(let J=0;J<f;J++)h(y,J*4,M,J*4);S=M,R=Mi;break;case Yi:f=y.length/4;const U=new Uint16Array(f*4);for(let J=0;J<f;J++)l(y,J*4,U,J*4);S=U,R=Yi;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:u,height:D,data:S,header:p.string,gamma:p.gamma,exposure:p.exposure,type:R}}}return null}setDataType(A){return this.type=A,this}load(A,e,t,g){function I(o,C){switch(o.type){case Mi:case Yi:o.encoding=hi,o.minFilter=Pe,o.magFilter=Pe,o.generateMipmaps=!1,o.flipY=!0;break}e&&e(o,C)}return super.load(A,I,t,g)}}const r_=rA("debugautosync"),G0=Symbol("syncerId");class SIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new kIA(A);return e[G0]=A.guid,this._syncers[e[G0]]=e,e}removeSyncer(A){delete this._syncers[A[G0]]}}const _R=new SIA;class kIA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_boundEvent");r(this,"_handleReceivingMethod");r(this,"_isReceiving",!1);r(this,"_isInit",!1);this.comp=A}get networkingKey(){return this.comp.constructor.name}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){r_&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const g=A[t];this.comp[t]=g}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function GIA(i,A){let e=A!==i;if(!e&&i&&A){if(Array.isArray(i)&&Array.isArray(A))e=!0;else if(typeof i=="object"&&typeof A=="object"){for(const t of Object.keys(i))if(i[t]!==A[t]){e=!0;break}}}return e}const dh=Symbol("AutoSyncHandler");function MIA(i){if(i[dh])return i[dh];const A=_R.getOrCreateSyncer(i);return A==null||A.init(i),i[dh]=A,A}function mIA(i){const A=i[dh];A&&(_R.removeSyncer(A),A.destroy(),delete i[dh])}const OR=function(i){return function(A,e){let t=null,g;typeof i=="string"?g=A[i]:typeof i=="function"&&(g=i);const I=A,o=I.__internalAwake;r_&&console.log(e);const C=Symbol(e);I.__internalAwake=function(){if(this[C]!==void 0)return;this[C]=this[e],o.call(this),t=_R.getOrCreateSyncer(this);const n=Object.getOwnPropertyDescriptor(this,e);(n==null?void 0:n.set)===void 0&&Object.defineProperty(this,e,{set:function(a){var Q;const B=this[C];this[C]=a,GIA(a,B)&&(g==null?void 0:g.call(this,a,B))!==!1&&((Q=MIA(this))==null||Q.notifyChanged(e,a))},get:function(){return this[C]},configurable:!0,enumerable:!0}),t==null||t.init(this)};const s=I.__internalDestroy;I.__internalDestroy=function(){mIA(this),s.call(this)}}};var RIA=Object.defineProperty,UIA=Object.getOwnPropertyDescriptor,Iy=(i,A,e,t)=>{for(var g=t>1?void 0:t?UIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RIA(A,e,g),g};const Rc=rA("debugskybox");class hB extends MA{constructor(){super(...arguments);r(this,"url");r(this,"allowDrop",!0);r(this,"background",!0);r(this,"environment",!0);r(this,"_loader");r(this,"_prevUrl");r(this,"_prevLoadedEnvironment");r(this,"_prevEnvironment",null);r(this,"_prevBackground",null);r(this,"dragOverEvent");r(this,"dropEvent")}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Yt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}async setSkybox(e){var C;if(!e)return;if(!(e!=null&&e.endsWith(".hdr"))&&!e.endsWith(".exr")&&!e.endsWith(".jpg")&&!e.endsWith(".png")&&!e.endsWith(".jpeg")&&console.warn("Potentially invalid skybox url",this.url,"on",this.name),Rc&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment){this.applySkybox();return}else(C=this._prevLoadedEnvironment)==null||C.dispose(),this._prevLoadedEnvironment=void 0;this._prevUrl=e;const t=e.endsWith(".exr"),g=e.endsWith(".hdr");t?this._loader instanceof sG||(this._loader=new sG):g?this._loader instanceof rq||(this._loader=new rq):this._loader instanceof ta||(this._loader=new ta),Rc&&console.log("Loading skybox: "+e);const I=await this._loader.loadAsync(e);if(!I||!this.enabled)return;this.url=e;const o=e.lastIndexOf("/");I.name=e.substring(o>=0?o+1:0),this._loader instanceof ta&&(I.encoding=De),this._prevLoadedEnvironment=I,this.applySkybox()}applySkybox(){var t;const e=this._prevLoadedEnvironment;e&&(e.mapping=JQ,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Rc&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!Yt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((t=this.context.mainCameraComponent)==null?void 0:t.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}registerDropEvents(){this.dragOverEvent||(this.dragOverEvent=e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)t==="text/uri-list"&&e.preventDefault()},this.dropEvent=e=>{var t,g,I,o;if(this.allowDrop&&(e.preventDefault(),!!e.dataTransfer)){for(const C of e.dataTransfer.types)if(C==="text/uri-list"){const s=e.dataTransfer.getData(C);Rc&&console.log(C,s);let n=(g=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(s))==null?void 0:t.groups)==null?void 0:g.name;if(n||(n=(o=(I=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(s))==null?void 0:I.groups)==null?void 0:o.name),Rc&&console.log(n),n){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+n+"_1k.exr";this.setSkybox(a)}else console.warn("Could not resolve skybox name from dropped url",s)}}},this.context.domElement.addEventListener("dragover",this.dragOverEvent),this.context.domElement.addEventListener("drop",this.dropEvent))}unregisterDropEvents(){this.dragOverEvent&&(this.context.domElement.removeEventListener("dragover",this.dragOverEvent),this.context.domElement.removeEventListener("drop",this.dropEvent))}}Iy([OR("setSkybox"),w(URL)],hB.prototype,"url",2);Iy([w()],hB.prototype,"allowDrop",2);Iy([w()],hB.prototype,"background",2);Iy([w()],hB.prototype,"environment",2);var FIA=Object.defineProperty,NIA=Object.getOwnPropertyDescriptor,is=(i,A,e,t)=>{for(var g=t>1?void 0:t?NIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&FIA(A,e,g),g};const vs=rA("debugsceneswitcher"),uh="scene";Bi.registerCallback(BI.ContextRegistered,async i=>{Promise.resolve().then(()=>yCA).then(A=>{const e=A.NeedleEngineHTMLElement;vs&&console.log("SceneSwitcher: registering scene attribute",e.observedAttributes),e.observedAttributes.includes(uh)||e.observedAttributes.push(uh)})});const Jn=Promise.resolve(!1);class PI extends MA{constructor(){super(...arguments);r(this,"scenes");r(this,"queryParameterName","scene");r(this,"clamp",!0);r(this,"useHistory",!0);r(this,"useKeyboard",!0);r(this,"useSwipe",!0);r(this,"useSceneLighting",!0);r(this,"preloadNext",1);r(this,"preloadPrevious",1);r(this,"preloadConcurrent",2);r(this,"_currentIndex",-1);r(this,"_currentScene");r(this,"_engineElementOverserver");r(this,"_preloadScheduler");r(this,"onPopState",async e=>{if(!this.useHistory)return;let t=this.useHistory;try{this.useHistory=!1;let g=!1;if(this.queryParameterName&&(g=await this.tryLoadFromQueryParam()),!g){const I=e.state;if(I!==null&&I.startsWith(this.guid)){const o=I.substr(this.guid.length+2);console.log(o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=t}});r(this,"normalizedSwipeThresholdX",.1);r(this,"_didSwipe",!1);r(this,"onPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const g=t.x/this.context.domWidth;g>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):g<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});r(this,"onPointerUp",e=>{e.button===0&&(this._didSwipe=!1)});r(this,"onKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const g=parseInt(t)-1;if(g>=0){this.trySelectSceneFromValue(g);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}})}get currentIndex(){return this._currentIndex}awake(){vs&&console.log("SceneSwitcher",this)}async start(){if(this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const e=this.context.domElement.getAttribute(uh);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onEnable(){globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(wC.KeyDown,this.onKeyDown),this.context.input.addEventListener(wC.PointerMove,this.onPointerMove),this.context.input.addEventListener(wC.PointerUp,this.onPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===uh){const g=this.context.domElement.getAttribute(uh);g!==null&&this.trySelectSceneFromValue(g)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new KIA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin()}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(wC.KeyDown,this.onKeyDown),this.context.input.removeEventListener(wC.PointerMove,this.onPointerMove),this.context.input.removeEventListener(wC.PointerUp,this.onPointerUp),(e=this._preloadScheduler)==null||e.stop()}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var g,I;if(vs&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(g=this.scenes)==null?void 0:g.find(C=>C.uri===e);if(!o){const C=ig.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(C)}if(o)e=this.scenes.indexOf(o);else return Jn}if(!((I=this.scenes)!=null&&I.length))return Jn;if(e<0){if(this.clamp)return Jn;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Jn;e=0}const t=this.scenes[e];return this.switchScene(t)}async switchScene(e){var g,I;if(e===this._currentScene)return!0;this._currentScene&&this._currentScene.unload();const t=this._currentIndex=((g=this.scenes)==null?void 0:g.indexOf(e))??-1;this._currentScene=e;try{const o=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:t}});this.dispatchEvent(o),await e.loadAssetAsync();const C=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:t}});if(this.dispatchEvent(C),C.defaultPrevented)return vs&&console.warn("Adding loaded scene prevented:",e,C),!1;if(!e.asset)return vs&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===t){if(eA.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&t>=0)if((I=this.queryParameterName)!=null&&I.length)Mq(this.queryParameterName,t.toString(),this.useHistory);else{const s=history.state,n=this.guid+"::"+t;s!==n&&history.pushState(n,"unused",location.href)}return!0}}catch(o){console.error(o)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof ig)return t.preload()}return Jn}tryLoadFromQueryParam(){var t;if(!((t=this.queryParameterName)!=null&&t.length))return Jn;const e=rA(this.queryParameterName);return typeof e=="boolean"?Jn:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);for(let g=0;g<this.scenes.length;g++)if(this.scenes[g].uri.toLowerCase().includes(e))return this.select(g)}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return zg()&&console.warn('Can not find scene: "'+e+'"',this),Jn}}is([w(ig)],PI.prototype,"scenes",2);is([w()],PI.prototype,"queryParameterName",2);is([w()],PI.prototype,"clamp",2);is([w()],PI.prototype,"useHistory",2);is([w()],PI.prototype,"useKeyboard",2);is([w()],PI.prototype,"useSwipe",2);is([w()],PI.prototype,"useSceneLighting",2);is([w()],PI.prototype,"preloadNext",2);is([w()],PI.prototype,"preloadPrevious",2);is([w()],PI.prototype,"preloadConcurrent",2);class KIA{constructor(A,e=1,t=1,g=2){r(this,"maxLoadAhead");r(this,"maxLoadBehind");r(this,"maxConcurrent");r(this,"_isRunning",!1);r(this,"_switcher");r(this,"_loadTasks",[]);r(this,"_maxConcurrentLoads",1);this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=t,this.maxConcurrent=g}begin(){if(this._isRunning)return;vs&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,t;const g=this._switcher.scenes;let I=setInterval(()=>{if(this.allLoaded()&&(vs&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(I);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,t=0,e=0);const o=t%2===0;o&&(e+=1),t+=1;const C=o?this.maxLoadAhead:this.maxLoadBehind;if(e>C)return;let s=o?A+e:A-e;if(s<0||s<0||s>=g.length)return;const n=g[s];new JIA(s,n,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){for(const A of this._switcher.scenes)if((A==null?void 0:A.isLoaded())===!1)return!1;return!0}}class JIA{constructor(A,e,t){r(this,"index");r(this,"asset");r(this,"tasks");this.index=A,this.asset=e,this.tasks=t,t.push(this),this.awaitLoading()}async awaitLoading(){this.asset.isLoaded()||(vs&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),vs&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function qIA(){return new Promise((i,A)=>{let t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function bIA(i){await qIA(),i()}var B_=(i=>(i[i.Quad=0]="Quad",i))(B_||{});class LIA{static createPrimitive(A,e){let t;switch(A){case 0:const g=new Ig(1,1,1,1),I=(e==null?void 0:e.material)??new wt({color:16777215});t=new fA(g,I)}return e!=null&&e.name&&(t.name=e.name),t}}var vIA=Object.defineProperty,xIA=Object.getOwnPropertyDescriptor,Fo=(i,A,e,t)=>{for(var g=t>1?void 0:t?xIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&vIA(A,e,g),g};const lC=rA("debugvideo");var Q_=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(Q_||{});class pg extends MA{constructor(){super();r(this,"renderer",null);r(this,"playOnAwake",!0);r(this,"aspectMode",0);r(this,"clip",null);r(this,"renderMode");r(this,"targetMaterialProperty");r(this,"targetMaterialRenderer");r(this,"targetTexture");r(this,"time",0);r(this,"_playbackSpeed",1);r(this,"_isLooping",!1);r(this,"_muted",!1);r(this,"_audioOutputMode",2);r(this,"playInBackground",!0);r(this,"_crossOrigin","anonymous");r(this,"source");r(this,"url",null);r(this,"_videoElement",null);r(this,"_videoTexture",null);r(this,"_videoMaterial",null);r(this,"_isPlaying",!1);r(this,"wasPlaying",!1);r(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});r(this,"_receivedInput",!1);r(this,"_overlay",null);r(this,"_targetObjects");r(this,"_updateAspectRoutineId",-1);bIA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],rA("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;if(e){if(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA)return!0;if(e.srcObject&&e.srcObject.active)return!0}return!1}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return this._videoMaterial}get videoTexture(){return this._videoTexture}get videoElement(){return this._videoElement}get muted(){var e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&yo()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(!0)}setClipURL(e){this.url!==e&&(this.url=e,this.source=1,lC&&console.log("set url",e),this._videoElement?(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(!0))}onEnable(){var e,t;window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0&&this.create(!0),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){window.removeEventListener("visibilitychange",this.visibilityChanged),this.pause()}onDestroy(){var e;this._videoElement&&((e=this._videoElement.parentElement)==null||e.removeChild(this._videoElement),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;this._videoElement||this.create(!1),this._videoElement&&(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused)||(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.updateVideoElementSettings(),this._videoElement.currentTime=this.time,this._videoElement.play().catch(g=>{var I;console.log(g),lC&&console.error("Error playing video",g,"CODE="+g.code,(I=this.videoElement)==null?void 0:I.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),lC&&console.log("play",this._videoElement,this.time)))}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),lC&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),lC&&console.log("PAUSE",this,this.currentTime)}create(e){var g;let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url;break}t&&(this._videoElement||(lC&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),(g=this.context.domElement)==null||g.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(lC&&console.log("Set Video src",t),this._videoElement.src=t):(lC&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new Wb(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.encoding=De,this.handleBeginPlaying(e),lC&&console.log(this,e))}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new YIA(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),lC&&console.log("created video element",e),e}handleBeginPlaying(e){var I,o;if(!this.enabled||!this._videoElement)return;this._targetObjects.length=0;let t=this.gameObject;switch(this.renderMode){case 3:t=(I=this.targetMaterialRenderer)==null?void 0:I.gameObject,t||(t=(o=eA.getComponent(this.gameObject,gi))==null?void 0:o.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!t){console.error("Missing target for video material renderer",this.name,Q_[this.renderMode],this);return}const g=t.material;if(g)if(this._targetObjects.push(t),g!==this._videoMaterial&&(this._videoMaterial=g.clone(),t.material=this._videoMaterial),!this.targetMaterialProperty)this._videoMaterial.map=this._videoTexture;else switch(this.targetMaterialProperty){default:this._videoMaterial.map=this._videoTexture;break}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),e&&this.play()}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const e=++this._updateAspectRoutineId,t=void 0,g=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&g===this.clip&&this._isPlaying;){if(!g||typeof g=="string")return;let I;for(const o of g.getVideoTracks()){const C=o.getSettings();if(C&&C.width&&C.height){I=C.width/C.height;break}else I=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(I===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(t===I){yield;continue}for(const o of this._targetObjects){let C=1;if(o.parent){const s=Bg(o.parent);C=s.x/s.y}switch(this.aspectMode){case 1:o.scale.y=1/I*o.scale.x*C;break;case 2:o.scale.x=I*o.scale.y*C;break}}for(let o=0;o<3;o++)yield}}}Fo([w(UA)],pg.prototype,"renderer",2);Fo([w()],pg.prototype,"playOnAwake",2);Fo([w()],pg.prototype,"aspectMode",2);Fo([w(URL)],pg.prototype,"clip",2);Fo([w()],pg.prototype,"renderMode",2);Fo([w()],pg.prototype,"targetMaterialProperty",2);Fo([w(gi)],pg.prototype,"targetMaterialRenderer",2);Fo([w(He)],pg.prototype,"targetTexture",2);Fo([w()],pg.prototype,"time",2);Fo([w()],pg.prototype,"playbackSpeed",1);Fo([w()],pg.prototype,"isLooping",1);Fo([w()],pg.prototype,"audioOutputMode",1);class YIA{constructor(A){r(this,"context");r(this,"_videos",[]);r(this,"_screenspaceModeQuad");r(this,"_isInScreenspaceMode",!1);r(this,"_input");this.context=A,this._input=new TIA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var g;if(this._isInScreenspaceMode||this._videos.length<0)return;const A=this._videos[this._videos.length-1];if(!A)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=LIA.createPrimitive(B_.Quad,{material:new HIA(A)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const e=this._screenspaceModeQuad;this.context.scene.add(e),this.updateScreenspaceMaterialUniforms();const t=e.material;t==null||t.reset(),(g=this._input)==null||g.enable(t)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const A=(e=this._screenspaceModeQuad)==null?void 0:e.material;A&&(A.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class TIA{constructor(A){r(this,"_onResizeScreenFn");r(this,"_onKeyUpFn");r(this,"_onMouseWheelFn");r(this,"context");r(this,"overlay");r(this,"_material");r(this,"_isPinching",!1);r(this,"_lastPinch",0);this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=g=>{g.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=g=>{this.overlay.enabled&&(A.zoom+=g.deltaY*5e-4,g.preventDefault())},{passive:!1});const e=new j;window.addEventListener("mousemove",g=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const I=new j(g.movementX,g.movementY);I.x/=this.context.domElement.clientWidth,I.y/=this.context.domElement.clientHeight,e.set(I.x,I.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",g=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(g.movementX,g.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let t=0;window.addEventListener("touchstart",g=>{if(g.touches.length<2){this.context.time.time-t<.3&&this.overlay.stop(),t=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",g=>{if(!this._isPinching||!this._material)return;const I=g.touches[0],o=g.touches[1],C=I.clientX-o.clientX,s=I.clientY-o.clientY,n=Math.sqrt(C*C+s*s);if(this._lastPinch!==0){const a=n-this._lastPinch;this._material.zoom-=a*.004}this._lastPinch=n}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class HIA extends Ze{constructor(e){super();r(this,"_offset",new j);this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new Ce(0,0,1,1)}},this.vertexShader=`
4974
4974
  uniform sampler2D map;
4975
4975
  uniform float screenAspect;
4976
4976
  uniform vec4 offsetScale;
@@ -127,6 +127,8 @@ export class SceneSwitcher extends Behaviour {
127
127
  normalizedSwipeThresholdX = 0.1;
128
128
  _didSwipe = false;
129
129
  onPointerMove = (e) => {
130
+ if (!this.useSwipe)
131
+ return;
130
132
  if (!this._didSwipe && e.button === 0 && e.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
131
133
  const delta = this.context.input.getPointerPositionDelta(e.button);
132
134
  if (delta) {
@@ -1 +1 @@
1
- {"version":3,"file":"SceneSwitcher.js","sourceRoot":"","sources":["../../src/engine-components/SceneSwitcher.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAkB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAA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,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;SACtE;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "3.5.9-beta",
3
+ "version": "3.5.9-beta.1",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "type": "module",
@@ -162,6 +162,7 @@ export class SceneSwitcher extends Behaviour {
162
162
  private normalizedSwipeThresholdX = 0.1;
163
163
  private _didSwipe: boolean = false;
164
164
  private onPointerMove = (e: any) => {
165
+ if(!this.useSwipe) return;
165
166
  if (!this._didSwipe && e.button === 0 && e.pointerType === "touch" && this.context.input.getPointerPressedCount() === 1) {
166
167
  const delta = this.context.input.getPointerPositionDelta(e.button);
167
168
  if (delta) {