@zylem/game-lib 0.9.2 → 0.9.4

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.
@@ -0,0 +1 @@
1
+ import{b as jt,c as gi,f as yi}from"./chunk-47HAZZWF.js";import{c as he,j as fe}from"./chunk-2HSR5XDQ.js";import{a as Kt,b as D,c as pe,d as Qt,f as ct,m as Jt,o as j}from"./chunk-3CLQWJ2I.js";import{a as Yt,c as at,d as lt,e as $t,f as ue,g as Xt}from"./chunk-BQRMYLYD.js";import{A as de,b as nt,d as p,e as Gt,i as le,k as ce,o as ot,q as Zt,s as Nt,t as Ht,u as V,y as Ut,z as st}from"./chunk-GPCSX3M6.js";import{a as ye,b as ci}from"./chunk-WBQ5TNRZ.js";import{b as ge,d as di}from"./chunk-YQS7CGXE.js";import{a as W,k as ri,l as ni,m as oi,n as si,o as F,p as ai,q,t as li,u as pt}from"./chunk-KP6DLLJO.js";import{a as dt,b as ti,g as I,h as me,i as ii}from"./chunk-6FGXC4T6.js";import{a as qt,b as T}from"./chunk-AIQ6IVT5.js";import{g as K}from"./chunk-UUOPT2N4.js";import{a as ve,b as pi,c as be,d as ui,e as hi,f as mi,g as fi,m as G}from"./chunk-D2PATZCC.js";import{c as ae,d as rt,j as v}from"./chunk-4QLJUQSJ.js";import{c as P,i as ei,j as h}from"./chunk-7WRQ2UAN.js";import{a as vi}from"./chunk-BH53MBAZ.js";import{l as Wt}from"./chunk-UG22Z42P.js";import{Vector2 as wi,RenderTarget as Dr,HalfFloatType as Lr}from"three";import{WebGPURenderer as Ar,RenderPipeline as Or}from"three/webgpu";import{pass as Br,renderOutput as Ei,screenCoordinate as zr,vec2 as ut,vec4 as Ri,fract as xi,sin as Mi,dot as Ti,texture as Vr,uniform as Ir}from"three/tsl";import{setConsoleFunction as kr,getConsoleFunction as _r}from"three";var bi="THREE.Abstract function.",Ci=!1,Si=!1;function Pi(){if(Ci)return;Ci=!0;let o=_r();kr((e,t,...i)=>{if(e==="warn"&&t===bi){Si||(Si=!0,console.warn(`${bi} (suppressing further per-frame repeats; a WebGPU node is scheduled for updates without an update() implementation)`));return}if(o){o(e,t,...i);return}let r=i[0],n=e==="log"?console.log:e==="error"?console.error:console.warn;r&&r.isStackTrace&&typeof r.getError=="function"?n(r.getError(t)):n(t,...i)})}var ki={x:0,y:0,width:1,height:1},Fr=1/20;async function Zo(){if(!("gpu"in navigator))return!1;try{return await navigator.gpu.requestAdapter()!==null}catch{return!1}}var Ce=class{renderer;postProcessing=null;renderScale=1;screenResolution;_initialized=!1;_sceneRef=null;_lastAnimationTimestamp=null;_postEffects=[];_postSceneRef=null;_postCameraRef=null;_transition=null;constructor(e){this.screenResolution=e||new wi(window.innerWidth,window.innerHeight)}get initialized(){return this._initialized}get isWebGPU(){return!0}async initRenderer(){this._initialized||(Pi(),this.renderer=new Ar({antialias:!0,alpha:!0}),await this.renderer.init(),this.renderer.setSize(this.screenResolution.x,this.screenResolution.y),this.renderer.shadowMap.enabled=!0,this._initialized=!0)}setScene(e){this._sceneRef=e}setupPostProcessing(e,t){this.disposePostProcessing(),this._postSceneRef=e,this._postCameraRef=t;let i=new Or(this.renderer),r=Br(e,t);this.renderScale!==1&&r.setResolutionScale(this.renderScale);let n=r;for(let l of this._postEffects)try{n=l(n,{scenePass:r,scene:e,camera:t})}catch(c){console.error("RendererManager: post-processing effect failed, skipping.",c)}i.outputColorTransform=!1;let s=Ei(n),a=this._transition;if(a)try{s=Ri(a.resolved.shader({fromNode:a.fromNode,toNode:s,progress:a.progressUniform})),a.composed=!0}catch(l){console.error("RendererManager: stage transition shader failed, skipping.",l)}i.outputNode=s.add(Zr()),this.postProcessing=i}rebindPostProcessingCamera(e){!this.postProcessing||!this._postSceneRef||this.setupPostProcessing(this._postSceneRef,e)}get transitionActive(){return this._transition!==null}beginSnapshotTransition(e,t,i){this.finishTransition();let r=new wi;this.renderer.getDrawingBufferSize(r);let n=new Dr(Math.max(1,r.x),Math.max(1,r.y),{type:Lr}),s=this.renderer.getRenderTarget();try{this.renderer.setScissorTest(!1),this.renderer.setRenderTarget(n),this.renderer.render(t,i)}catch(a){console.error("RendererManager: failed to capture transition snapshot.",a)}finally{this.renderer.setRenderTarget(s)}this._transition={resolved:e,progressUniform:Ir(0),fromNode:Ei(Vr(n.texture)),elapsed:0,snapshotTarget:n,composed:!1}}beginInStageTransition(e,t,i){this._initialized&&(this.beginSnapshotTransition(e,t,i),this.setupPostProcessing(t,i))}finishTransition(){let e=this._transition;if(e){this._transition=null,e.progressUniform.value=1,this._postSceneRef&&this._postCameraRef&&this.setupPostProcessing(this._postSceneRef,this._postCameraRef);try{e.resolved.onComplete?.()}catch(t){console.error("RendererManager: transition onComplete failed.",t)}this.releaseTransitionResources(e)}}cancelTransition(){let e=this._transition;if(e){this._transition=null;try{e.resolved.onComplete?.()}catch{}this.releaseTransitionResources(e)}}releaseTransitionResources(e){try{e.snapshotTarget?.dispose()}catch{}}advanceTransition(e){let t=this._transition;if(!t||!t.composed)return;t.elapsed+=Math.min(e,Fr);let i=Math.min(t.elapsed/t.resolved.duration,1);t.progressUniform.value=t.resolved.easing(i),i>=1&&this.finishTransition()}setPostProcessingEffects(e){this._postEffects=[...e],this.postProcessing&&this._postSceneRef&&this._postCameraRef&&this.setupPostProcessing(this._postSceneRef,this._postCameraRef)}setRenderScale(e){this.renderScale=Math.max(1,Number.isFinite(e)?e:1)}disposePostProcessing(){try{this.postProcessing?.dispose?.()}catch{}this.postProcessing=null}startRenderLoop(e){this._lastAnimationTimestamp=null,this.renderer.setAnimationLoop(t=>{let i=this._lastAnimationTimestamp===null?0:Math.max(0,(t-this._lastAnimationTimestamp)/1e3);this._lastAnimationTimestamp=t,this.advanceTransition(i),e(i)})}stopRenderLoop(){this._lastAnimationTimestamp=null;try{this.renderer.setAnimationLoop(null)}catch{}}renderCamera(e,t,i=!1){let r=t.viewport,n=this.screenResolution.x,s=this.screenResolution.y,a=Math.floor(r.x*n),l=Math.floor(r.y*s),c=Math.floor(r.width*n),d=Math.floor(r.height*s);this.renderer.setViewport(a,l,c,d),this.renderer.setScissor(a,l,c,d),this.renderer.setScissorTest(!0),i&&this.postProcessing?this.postProcessing.render():this.renderer.render(e,t.camera)}renderCameraToTarget(e,t){if(!t.renderTarget)return;let i=this.renderer.getRenderTarget();this.renderer.setScissorTest(!1),this.renderer.setRenderTarget(t.renderTarget),this.renderer.clear(),this.renderer.render(e,t.camera),this.renderer.setRenderTarget(i)}renderCameras(e,t){if(!e||t.length===0)return;this.renderer.setScissorTest(!1),this.renderer.clear();let i=t.length===1&&Gr(t[0].viewport);for(let r of t)this.renderCamera(e,r,i);this.renderer.setScissorTest(!1)}render(e,t){this.postProcessing?this.postProcessing.render():this.renderer.render(e,t)}resize(e,t){this.screenResolution.set(e,t),this.renderer.setSize(e,t,!1)}setPixelRatio(e){let t=Math.max(1,Number.isFinite(e)?e:1);this.renderer.setPixelRatio(t)}getDomElement(){return this.renderer.domElement}dispose(){this.stopRenderLoop(),this.cancelTransition(),this.disposePostProcessing();try{this.renderer.dispose()}catch{}this._sceneRef=null,this._postSceneRef=null,this._postCameraRef=null,this._postEffects=[],this._initialized=!1}};function Gr(o){return o.x===0&&o.y===0&&o.width===1&&o.height===1}function Zr(){let o=zr.xy,e=xi(Mi(Ti(o,ut(12.9898,78.233))).mul(43758.5453)),t=xi(Mi(Ti(o.add(ut(13,7)),ut(12.9898,78.233))).mul(43758.5453)),i=e.sub(t).mul(1/255);return Ri(i,i,i,0)}function Q(o){return o?.category??"none"}function Y(o){let e=Q(o);return e==="environment"||e==="pack"}function L(o){return o.isInstanced===!0||o.isBundled===!0}import{BundleGroup as Nr}from"three/webgpu";var Se=class{bundles=new Map;entityToBundle=new Map;scene=null;setScene(e){this.scene=e}register(e,t,i,r){if(e.isBundled)return!0;let n=e.mesh??e.group;if(!n)return!1;let s=this.getOrCreateBundle(r);return n.matrixAutoUpdate=!0,n.userData.zylemEntityUuid=e.uuid,n.parent&&n.parent.remove(n),s.add(n),s.needsUpdate=!0,e.isBundled=!0,e.bundleKey=r,this.entityToBundle.set(e.uuid,r),!0}unregister(e){let t=this.entityToBundle.get(e.uuid);if(!t)return;let i=this.bundles.get(t),r=e.mesh??e.group;i&&r&&(i.remove(r),i.needsUpdate=!0),e.isBundled=!1,e.bundleKey=null,this.entityToBundle.delete(e.uuid)}getStats(){return{bundleCount:this.bundles.size,entityCount:this.entityToBundle.size}}dispose(){for(let e of this.bundles.values())this.scene&&this.scene.remove(e);this.bundles.clear(),this.entityToBundle.clear()}getOrCreateBundle(e){let t=this.bundles.get(e);return t||(t=new Nr,t.name=`bundle:${e}`,t.static=!0,this.bundles.set(e,t),this.scene&&this.scene.add(t),t)}};import{InstancedMesh as _i,Matrix4 as $,Vector3 as Di,Quaternion as Hr}from"three";var X=class o{packs=new Map;entityToPack=new Map;scene=null;static DEFAULT_CAPACITY=128;static GROWTH_FACTOR=2;setScene(e){this.scene=e}static generatePackKey(e){let t={geo:`${e.geometryType}:${dt(e.dimensions)}`,mat:e.materialPath||"none",shader:e.shaderType||"standard",color:e.colorHex??16777215};return ti(dt(t))}static generateEntityPackKey(e){let t=e.options;if(t.runtime?.packKeyOverride)return t.runtime.packKeyOverride;let i=e.constructor?.type?.description||"unknown",r=t.size||{x:1,y:1,z:1},n=t.material||{};return o.generatePackKey({geometryType:i,dimensions:{x:r.x,y:r.y,z:r.z},materialPath:n.path||null,shaderType:n.shader?"custom":"standard",colorHex:n.color?.getHex?.()||t.color?.getHex?.()||16777215})}register(e,t,i,r){let n=this.packs.get(r);n||(n=this.createPack(r,t,i));let s;return n.freeIndices.length>0?s=n.freeIndices.pop():(s=n.entities.length,s>=n.capacity&&this.growPack(n),n.entities.push(null)),n.entities[s]=e,n.entityMap.set(e.uuid,s),this.entityToPack.set(e.uuid,r),n.instancedMesh.count=Math.max(n.instancedMesh.count,s+1),n.activeIndices.push(s),n.dirtyIndices.add(s),s}unregister(e){let t=this.entityToPack.get(e.uuid);if(!t)return;let i=this.packs.get(t);if(!i)return;let r=i.entityMap.get(e.uuid);if(r===void 0)return;i.entities[r]=null,i.entityMap.delete(e.uuid),this.entityToPack.delete(e.uuid),i.freeIndices.push(r);let n=i.activeIndices.indexOf(r);if(n!==-1){let a=i.activeIndices.pop();n<i.activeIndices.length&&(i.activeIndices[n]=a)}i.dirtyIndices.delete(r);let s=new $;s.makeScale(0,0,0),i.instancedMesh.setMatrixAt(r,s),i.instancedMesh.instanceMatrix.needsUpdate=!0}markDirty(e){let t=this.entityToPack.get(e.uuid);if(!t)return;let i=this.packs.get(t);if(!i)return;let r=i.entityMap.get(e.uuid);r!==void 0&&i.dirtyIndices.add(r)}update(e=0){let t=new $,i=new Di,r=new Hr,n=new Di(1,1,1);for(let s of this.packs.values()){if(s.activeIndices.length===0)continue;let a=!1;for(let l of s.activeIndices){let c=s.entities[l];if(!c)continue;if(ri(c)){t.makeScale(0,0,0),s.instancedMesh.setMatrixAt(l,t),a=!0;continue}let d=s.dirtyIndices.has(l),u=!!c.body;if(!(!d&&!u)){if(!d&&u){let f=c.body;if(typeof f.isRenderSleeping=="function"&&f.isRenderSleeping())continue}this.updateInstanceMatrix(s,l,t,i,r,n,e),a=!0}}s.dirtyIndices.clear(),a&&(s.instancedMesh.instanceMatrix.needsUpdate=!0)}}updateInstanceMatrix(e,t,i,r,n,s,a){let l=e.entities[t];if(l){if(l.body){let c=l.body;if(typeof c.writeRenderPose=="function")c.writeRenderPose(a,r,n);else{let d=ye(l.body,a);r.set(d.position.x,d.position.y,d.position.z),n.set(d.rotation.x,d.rotation.y,d.rotation.z,d.rotation.w)}i.compose(r,n,s)}else l.mesh?(l.mesh.updateMatrix(),i.copy(l.mesh.matrix)):l.group&&(l.group.updateMatrix(),i.copy(l.group.matrix));e.instancedMesh.setMatrixAt(t,i)}}getPackInfo(e){let t=this.entityToPack.get(e.uuid);if(!t)return null;let i=this.packs.get(t);if(!i)return null;let r=i.entityMap.get(e.uuid);return r===void 0?null:{packKey:t,instanceId:r}}getStats(){let e=0,t=[];for(let[i,r]of this.packs){let n=r.entityMap.size;e+=n,t.push({key:i,count:n,capacity:r.capacity})}return{packCount:this.packs.size,totalInstances:e,packs:t}}dispose(){for(let e of this.packs.values())this.scene&&this.scene.remove(e.instancedMesh),e.instancedMesh.dispose(),e.geometry.dispose();this.packs.clear(),this.entityToPack.clear()}createPack(e,t,i){let r=o.DEFAULT_CAPACITY,n=new _i(t,i,r);n.count=0,n.frustumCulled=!1;let s=new $().makeScale(0,0,0);for(let l=0;l<r;l++)n.setMatrixAt(l,s);n.instanceMatrix.needsUpdate=!0;let a={key:e,instancedMesh:n,geometry:t,material:i,entityMap:new Map,entities:[],freeIndices:[],activeIndices:[],dirtyIndices:new Set,capacity:r};return this.packs.set(e,a),this.scene&&this.scene.add(n),a}growPack(e){let t=e.capacity*o.GROWTH_FACTOR,i=new _i(e.geometry,e.material,t);i.count=e.instancedMesh.count,i.frustumCulled=!1;let r=new $;for(let s=0;s<e.capacity;s++)e.instancedMesh.getMatrixAt(s,r),i.setMatrixAt(s,r);let n=new $().makeScale(0,0,0);for(let s=e.capacity;s<t;s++)i.setMatrixAt(s,n);i.instanceMatrix.needsUpdate=!0,this.scene&&(this.scene.remove(e.instancedMesh),this.scene.add(i)),e.instancedMesh.dispose(),e.instancedMesh=i,e.capacity=t}};var Pe=class{bundles=new Se;instances=new X;setScene(e){this.bundles.setScene(e),this.instances.setScene(e)}register(e){let t=Q(e.options);if(t==="none")return!1;if(e.isInstanced||e.isBundled)return!0;if(!e.mesh?.geometry||!e.materials?.length)return!1;let i=e.mesh.geometry,r=e.materials[0],n=X.generateEntityPackKey(e);if(t==="pack"){let s=this.instances.register(e,i,r,n);return s<0?!1:(e.packKey=n,e.instanceId=s,e.isInstanced=!0,e.mesh&&(e.mesh.visible=!1),!0)}return t==="environment"&&this.bundles.register(e,i,r,n)?(e.mesh&&(e.mesh.visible=!0),!0):!1}unregister(e){e.isInstanced&&(this.instances.unregister(e),e.isInstanced=!1,e.instanceId=-1,e.packKey=null),e.isBundled&&this.bundles.unregister(e)}update(e=0){this.instances.update(e)}dispose(){this.bundles.dispose(),this.instances.dispose()}};var we=!1,w={},Li=0,Ai=0,J=null;function Oi(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function ht(){return we?!0:(typeof globalThis<"u"&&globalThis.__ZYLEM_PROFILE_STAGE__===!0&&(we=!0),we)}function ns(o){we=o,typeof globalThis<"u"&&(globalThis.__ZYLEM_PROFILE_STAGE__=o)}function mt(o){ht()&&(J=o,Ai=Oi())}function ft(){if(!ht()||J===null)return;let o=Oi()-Ai;w[J]=(w[J]??0)+o,J=null}function Bi(){if(!ht()||(Li++,Li%60!==0))return;let o=Object.values(w).reduce((t,i)=>t+(i??0),0),e=Object.keys(w).sort((t,i)=>(w[i]??0)-(w[t]??0)).map(t=>{let i=w[t]??0,r=o>0?(i/o*100).toFixed(1):"0.0";return`${t}=${i.toFixed(2)}ms (${r}%)`});console.info(`[ZylemStage profile] avg over 60 frames (${o.toFixed(2)}ms/frame): ${e.join(", ")}`);for(let t of Object.keys(w))w[t]=0}function E(o,e){mt(o);try{return e()}finally{ft()}}var m={FirstPerson:"first-person",ThirdPerson:"third-person",SecondPerson:"second-person",Isometric:"isometric",Flat2D:"flat-2d",Fixed2D:"fixed-2d",TopDown:"top-down"};function gt(o){switch(o){case m.Isometric:case m.TopDown:case m.Flat2D:case m.Fixed2D:return"orthographic";default:return"perspective"}}import{Vector3 as Ur,Quaternion as jr,MathUtils as yt}from"three";function Ee(){return{position:new Ur(0,0,10),rotation:new jr,fov:75,zoom:1,near:.1,far:1e3}}function A(o){return{position:o.position.clone(),rotation:o.rotation.clone(),fov:o.fov,zoom:o.zoom,near:o.near,far:o.far,lookAt:o.lookAt?.clone()}}function zi(o,e){let t=A(o);return e.position&&t.position.add(e.position),e.rotation&&t.rotation.multiply(e.rotation),e.fov!=null&&t.fov!=null&&(t.fov+=e.fov),e.zoom!=null&&t.zoom!=null&&(t.zoom+=e.zoom),t}function Vi(o,e,t,i){let r=1-Math.pow(1-yt.clamp(t,0,1),i*60),n=A(o);return n.position.lerp(e.position,r),n.rotation.slerp(e.rotation,r),e.fov!=null&&n.fov!=null&&(n.fov=yt.lerp(n.fov,e.fov,r)),e.zoom!=null&&n.zoom!=null&&(n.zoom=yt.lerp(n.zoom,e.zoom,r)),e.near!=null&&(n.near=e.near),e.far!=null&&(n.far=e.far),e.lookAt?n.lookAt?n.lookAt.lerp(e.lookAt,r):n.lookAt=e.lookAt.clone():n.lookAt=void 0,n}var xe=class{perspective=null;behaviors=new Map;actions=[];_desiredPose=Ee();_finalPose=Ee();_initialized=!1;damping=.15;constructor(e){e&&(this.perspective=e,e.defaults?.damping!=null&&(this.damping=e.defaults.damping))}run(e){let t=this.perspective?this.perspective.getBasePose(e):Ee(),i=this.getSortedBehaviors();for(let r of i)r.enabled!==!1&&(t=r.update(e,t));this._desiredPose=A(t);for(let r=this.actions.length-1;r>=0;r--){let n=this.actions[r],s=n.update(e);t=zi(t,s),n.isDone(e)&&this.actions.splice(r,1)}return this._initialized?this._finalPose=Vi(this._finalPose,t,this.damping,e.dt):(this._finalPose=A(t),this._initialized=!0),this._finalPose}addBehavior(e,t,i){let r=this.behaviors.get(e);r?.onDetach&&i&&r.onDetach(i),this.behaviors.set(e,t),t.onAttach&&i&&t.onAttach(i)}removeBehavior(e,t){let i=this.behaviors.get(e);return i?(i.onDetach&&t&&i.onDetach(t),this.behaviors.delete(e)):!1}hasBehavior(e){return this.behaviors.has(e)}addAction(e){this.actions.push(e)}getState(){return{perspectiveId:this.perspective?.id??null,desiredPose:this._desiredPose?A(this._desiredPose):null,finalPose:this._finalPose?A(this._finalPose):null,activeBehaviors:Array.from(this.behaviors.keys()),activeActionCount:this.actions.length}}setPerspective(e){this.perspective=e,this._initialized=!1,e.defaults?.damping!=null&&(this.damping=e.defaults.damping)}getSortedBehaviors(){return Array.from(this.behaviors.values()).sort((e,t)=>(e.priority??0)-(t.priority??0))}};import{Vector3 as R,Quaternion as Me}from"three";var Wr={distance:8,height:5,shoulderOffset:0,targetKey:"primary",fov:75,paddingFactor:1.5,minDistance:5,trailDelay:.1,trailBufferSize:120},Z=class{id="third-person";projection="perspective";defaults={damping:.12};opts;initialPosition;initialLookAt;_trailBuffers=new Map;constructor(e){let{initialPosition:t,initialLookAt:i,...r}=e??{};this.opts={...Wr,...r},this.initialPosition=t?h(t,P):void 0,this.initialLookAt=i?h(i,P):void 0}getBasePose(e){let t=Object.keys(e.targets),i=e.targets[this.opts.targetKey];return t.length===0||!i?this.staticPose():t.length===1?this.singleTargetPose(i.position,e,this.opts.targetKey):this.multiTargetPose(e)}staticPose(){return this.initialPosition?{position:this.initialPosition.clone(),rotation:new Me,fov:this.opts.fov,zoom:1,near:.1,far:1e3,lookAt:this.initialLookAt?.clone()??new R(0,0,0)}:{position:new R(this.opts.shoulderOffset,this.opts.height,this.opts.distance),rotation:new Me,fov:this.opts.fov,zoom:1,near:.1,far:1e3,lookAt:new R(0,0,0)}}singleTargetPose(e,t,i){let r=this.getTrailedPosition(i,e,t.time);return{position:new R(r.x+this.opts.shoulderOffset,r.y+this.opts.height,r.z+this.opts.distance),rotation:new Me,fov:this.opts.fov,zoom:1,near:.1,far:1e3,lookAt:r.clone()}}multiTargetPose(e){let i=Object.entries(e.targets).map(([u,f])=>this.getTrailedPosition(u,f.position,e.time)),r=new R;for(let u of i)r.add(u);r.divideScalar(i.length);let n=0;for(let u of i){let f=r.distanceTo(u);f>n&&(n=f)}let s=Math.max(n*this.opts.paddingFactor,this.opts.minDistance),a=new R(this.opts.shoulderOffset,this.opts.height,this.opts.distance),l=a.length(),c=l>0?a.clone().normalize():new R(0,.5,1).normalize(),d=r.clone().add(c.multiplyScalar(s));if(l>0){let u=this.opts.height/l;d.y=r.y+s*u}return{position:d,rotation:new Me,fov:this.opts.fov,zoom:1,near:.1,far:1e3,lookAt:r.clone()}}getTrailedPosition(e,t,i){let r=this.opts.trailDelay;if(r<=0)return t;let n=this._trailBuffers.get(e);n||(n=[],this._trailBuffers.set(e,n)),n.push({time:i,pos:t.clone()});let s=i-r-.05;for(;n.length>1&&n[0].time<s;)n.shift();n.length>this.opts.trailBufferSize&&n.splice(0,n.length-this.opts.trailBufferSize);let a=i-r;if(n[0].time>=a)return n[0].pos.clone();for(let l=1;l<n.length;l++){let c=n[l-1],d=n[l];if(c.time<=a&&a<=d.time){let u=d.time-c.time,f=u>1e-6?(a-c.time)/u:0;return new R().lerpVectors(c.pos,d.pos,f)}}return n[n.length-1].pos.clone()}};import{Vector3 as Ii,Quaternion as qr}from"three";var Fi={position:{x:0,y:0,z:10},zoom:10},N=class{id="fixed-2d";projection="orthographic";defaults={damping:1};opts;constructor(e){this.opts={...Fi,...e,position:h(e?.position,Fi.position)}}getBasePose(e){return{position:new Ii(this.opts.position.x,this.opts.position.y,this.opts.position.z),rotation:new qr,zoom:this.opts.zoom,near:1,far:1e3,lookAt:new Ii(this.opts.position.x,this.opts.position.y,0)}}};import{Vector3 as vt,Quaternion as bt,Euler as Ni,MathUtils as b}from"three";var Kr={eyeHeight:1.7,defaultFov:75,pitchLimit:Math.PI/2-.01,lookAtLerpSpeed:5,fovLerpSpeed:8,targetKey:"primary",verticalSmoothing:1},ee=class{id="first-person";projection="perspective";defaults={damping:1};opts;initialPosition;initialLookAt;_yaw=0;_pitch=0;_currentFov;_targetFov;_lookAtTarget=null;_lookAtLerpSpeed;_currentRotation=new bt;_rotationInitialized=!1;_smoothedY=null;constructor(e){let{initialPosition:t,initialLookAt:i,...r}=e??{};this.opts={...Kr,...r},this.initialPosition=t?h(t,P):void 0,this.initialLookAt=i?h(i,P):void 0,this._currentFov=this.opts.defaultFov,this._targetFov=this.opts.defaultFov,this._lookAtLerpSpeed=this.opts.lookAtLerpSpeed,this.initialPosition&&this.initialLookAt&&this.deriveYawPitchFromLookAt(this.initialPosition,this.initialLookAt)}look(e,t){this._yaw+=e,this._pitch=b.clamp(this._pitch+t,-this.opts.pitchLimit,this.opts.pitchLimit)}setLook(e,t){this._yaw=e,this._pitch=b.clamp(t,-this.opts.pitchLimit,this.opts.pitchLimit)}setEyeHeight(e){this.opts.eyeHeight=e}get yaw(){return this._yaw}get pitch(){return this._pitch}zoom(e){this._targetFov=e}resetZoom(){this._targetFov=this.opts.defaultFov}get currentFov(){return this._currentFov}lookAt(e,t){this._lookAtTarget=e,t!=null&&(this._lookAtLerpSpeed=t)}clearLookAt(){this._lookAtTarget&&this.deriveYawPitchFromQuaternion(this._currentRotation),this._lookAtTarget=null}getBasePose(e){let t=this.computePosition(e),i=this.computeRotation(t,e.dt);return this._currentFov=this.lerpFov(e.dt),{position:t,rotation:i,fov:this._currentFov,near:.1,far:1e3}}computePosition(e){let t=e.targets[this.opts.targetKey];if(t){let i=t.position.y+this.opts.eyeHeight,r=this.smoothVertical(i,e.dt);return new vt(t.position.x,r,t.position.z)}return this.initialPosition?this.initialPosition.clone():new vt(0,this.opts.eyeHeight,0)}smoothVertical(e,t){if(this.opts.verticalSmoothing>=1)return this._smoothedY=e,e;if(this._smoothedY==null)return this._smoothedY=e,e;let i=b.clamp(this.opts.verticalSmoothing,0,1),r=1-Math.pow(1-i,t*60);return this._smoothedY=b.lerp(this._smoothedY,e,r),this._smoothedY}computeRotation(e,t){let i=new bt().setFromEuler(new Ni(this._pitch,this._yaw,0,"YXZ"));if(this._rotationInitialized||(this._currentRotation.copy(i),this._rotationInitialized=!0),this._lookAtTarget){let r=Gi.copy(this._lookAtTarget).sub(e);if(r.lengthSq()>1e-4){r.normalize();let n=Math.atan2(-r.x,-r.z),s=Math.asin(b.clamp(r.y,-1,1)),a=Qr.setFromEuler(Zi.set(s,n,0,"YXZ")),l=1-Math.pow(1-Math.min(this._lookAtLerpSpeed*t,1),1);return this._currentRotation.slerp(a,b.clamp(l,0,1)),this._currentRotation.clone()}}return this._currentRotation.copy(i),i}lerpFov(e){if(Math.abs(this._currentFov-this._targetFov)<.01)return this._targetFov;let t=1-Math.pow(1-Math.min(this.opts.fovLerpSpeed*e,1),1);return b.lerp(this._currentFov,this._targetFov,b.clamp(t,0,1))}deriveYawPitchFromLookAt(e,t){let i=Gi.copy(t).sub(e).normalize();this._yaw=Math.atan2(-i.x,-i.z),this._pitch=Math.asin(b.clamp(i.y,-1,1))}deriveYawPitchFromQuaternion(e){let t=Zi.setFromQuaternion(e,"YXZ");this._yaw=t.y,this._pitch=b.clamp(t.x,-this.opts.pitchLimit,this.opts.pitchLimit)}},Gi=new vt,Qr=new bt,Zi=new Ni;import{Quaternion as Yr,Vector3 as Ct}from"three";var $r={distance:10,zoom:10,targetKey:"primary"},Hi=new Ct(1,1,1).normalize(),te=class{id="isometric";projection="orthographic";defaults={damping:1};opts;initialPosition;initialLookAt;constructor(e){let{initialPosition:t,initialLookAt:i,...r}=e??{};this.opts={...$r,...r},this.initialPosition=t?h(t):void 0,this.initialLookAt=i?h(i):void 0}getBasePose(e){let t=e.targets[this.opts.targetKey];if(!t)return this.staticPose();let i=t.position.clone(),r=i.clone().addScaledVector(Hi,this.opts.distance);return this.pose(r,i)}staticPose(){return this.initialPosition?this.pose(this.initialPosition.clone(),this.initialLookAt?.clone()??new Ct(0,0,0)):this.pose(Hi.clone().multiplyScalar(this.opts.distance),new Ct(0,0,0))}pose(e,t){return{position:e,rotation:new Yr,zoom:this.opts.zoom,near:1,far:1e3,lookAt:t}}};import{Quaternion as Xr,Vector3 as Te}from"three";var Jr={height:10,zoom:10,targetKey:"primary"},ie=class{id="top-down";projection="orthographic";defaults={damping:1};opts;initialPosition;initialLookAt;constructor(e){let{initialPosition:t,initialLookAt:i,...r}=e??{};this.opts={...Jr,...r},this.initialPosition=t?h(t):void 0,this.initialLookAt=i?h(i):void 0}getBasePose(e){let t=e.targets[this.opts.targetKey];if(!t)return this.staticPose();let i=t.position.clone();return this.pose(new Te(i.x,i.y+this.opts.height,i.z),i)}staticPose(){if(this.initialPosition){let e=this.initialLookAt?.clone()??new Te(this.initialPosition.x,this.initialPosition.y-this.opts.height,this.initialPosition.z);return this.pose(this.initialPosition.clone(),e)}return this.pose(new Te(0,this.opts.height,0),new Te(0,0,0))}pose(e,t){return{position:e,rotation:new Xr,zoom:this.opts.zoom,near:1,far:1e3,lookAt:t}}};import{Quaternion as Ui,Vector3 as Re}from"three";var en={anchorKey:"anchor",subjectKey:"primary",eyeHeight:1.7,fov:75},St=new Re,re=class{id="second-person";projection="perspective";defaults={damping:1};opts;initialPosition;initialLookAt;constructor(e){let{initialPosition:t,initialLookAt:i,...r}=e??{};this.opts={...en,...r},this.initialPosition=t?h(t):void 0,this.initialLookAt=i?h(i):void 0}getBasePose(e){let t=e.targets[this.opts.anchorKey];if(!t)return this.staticPose();let i=new Re(t.position.x,t.position.y+this.opts.eyeHeight,t.position.z),r=e.targets[this.opts.subjectKey],n=r?r.position.clone():i.clone().add(this.anchorForward(t.rotation));return{position:i,rotation:new Ui,fov:this.opts.fov,near:.1,far:1e3,lookAt:n}}staticPose(){let e=this.initialPosition?.clone()??new Re(0,this.opts.eyeHeight,0),t=this.initialLookAt?.clone()??e.clone().add(new Re(0,0,-1));return{position:e,rotation:new Ui,fov:this.opts.fov,near:.1,far:1e3,lookAt:t}}anchorForward(e){return St.set(0,0,-1),e&&St.applyQuaternion(e),St.clone()}};function O(o,e){switch(o){case"third-person":return new Z(e);case"first-person":return new ee(e);case"second-person":return new re(e);case"isometric":return new te(e);case"top-down":return new ie(e);case"flat-2d":return new N(e);case"fixed-2d":return new N(e);default:return new Z(e)}}import{Vector2 as on,Vector3 as M,OrthographicCamera as sn,PerspectiveCamera as an}from"three";import{PerspectiveCamera as Pt,Vector3 as rn,OrthographicCamera as De,RenderTarget as nn,LinearFilter as ji}from"three";import{Vector3 as ke}from"three";import{OrbitControls as tn}from"three/addons/controls/OrbitControls.js";var _e=class{camera;domElement;cameraRig=null;sceneRef=null;orbitControls=null;orbitTarget=null;orbitTargetWorldPos=new ke;debugDelegate=null;debugUnsubscribe=null;debugStateSnapshot={enabled:!1,selected:[]};savedCameraPosition=null;savedCameraQuaternion=null;savedCameraZoom=null;savedCameraLocalPosition=null;savedDebugCameraPosition=null;savedDebugCameraQuaternion=null;savedDebugCameraZoom=null;savedDebugOrbitTarget=null;_userOrbitEnabled=!1;_isDebugViewCamera=!1;_defaultOrbitTarget=null;_debugPoseSeeded=!1;_interactionEnabled=!0;_followSelection=!0;_rotationLocked=!1;_screenSpacePanning=!1;_seededLookAt=null;constructor(e,t,i){this.camera=e,this.domElement=t,this.cameraRig=i??null}setScene(e){this.sceneRef=e}setDebugViewCamera(e){this._isDebugViewCamera=e}setDefaultOrbitTarget(e){this._defaultOrbitTarget=e,e&&!this.orbitTarget&&this.debugStateSnapshot.enabled&&this._followSelection&&(this.orbitTarget=e)}seedOrbitPose(e,t){this._seededLookAt=t.clone(),this.camera.position.copy(e),this.camera.lookAt(t),this.orbitControls&&(this.orbitControls.target.copy(t),this.orbitControls.update(),this._rotationLocked&&this.applyRotationLock()),this._debugPoseSeeded=!0}get isDebugViewCamera(){return this._isDebugViewCamera}get isDebugOrbitPoseSeeded(){return this._debugPoseSeeded}get isActive(){return this.debugStateSnapshot.enabled}get isOrbitActive(){return this.debugStateSnapshot.enabled||this._userOrbitEnabled}update(){this._followSelection&&this.orbitControls&&this.orbitTarget&&(this.orbitTarget.getWorldPosition(this.orbitTargetWorldPos),this.orbitControls.target.copy(this.orbitTargetWorldPos)),this.orbitControls?.update()}enableUserOrbitControls(){this._userOrbitEnabled=!0,this.orbitControls||this.enableOrbitControls()}disableUserOrbitControls(){this._userOrbitEnabled=!1,this.debugStateSnapshot.enabled||this.disableOrbitControls()}setDebugDelegate(e){if(this.debugDelegate===e)return;if(this.detachDebugDelegate(),this.debugDelegate=e,!e){this.applyDebugState({enabled:!1,selected:[]});return}let t=e.subscribe(i=>{this.applyDebugState(i)});this.debugUnsubscribe=()=>{t?.()}}dispose(){this.disableOrbitControls(),this.detachDebugDelegate()}setRotationLocked(e){this._rotationLocked=e,e?this.applyRotationLock():this.releaseRotationLock()}setScreenSpacePanning(e){this._screenSpacePanning=e,this.orbitControls&&(this.orbitControls.screenSpacePanning=e)}get debugState(){return this.debugStateSnapshot}frameTarget(e){!this.orbitControls&&(this.debugStateSnapshot.enabled||this._userOrbitEnabled)&&this.enableOrbitControls(),this.orbitControls||this.enableOrbitControls(),this.orbitTarget=e;let t=new ke().subVectors(this.camera.position,this.orbitControls.target).normalize();t.lengthSq()<1e-8&&t.set(1,1,1).normalize();let i=jt(e,this.camera,t);this.orbitControls.target.copy(i.center),this.orbitControls.update()}applyDebugState(e){let t=this.debugStateSnapshot.enabled;if(this.debugStateSnapshot={enabled:e.enabled,selected:[...e.selected]},this._isDebugViewCamera){e.enabled&&!t?(this.enableOrbitControls(),this._debugPoseSeeded&&this.restoreDebugCameraState(),this.updateOrbitTargetFromSelection(e.selected),this._rotationLocked&&this.applyRotationLock()):!e.enabled&&t?(this.saveDebugCameraState(),this._userOrbitEnabled||this.disableOrbitControls()):e.enabled&&this.updateOrbitTargetFromSelection(e.selected);return}e.enabled&&!t?(this.saveCameraState(),this.detachCameraFromRig(),this.enableOrbitControls(),this.restoreDebugCameraState(),this.updateOrbitTargetFromSelection(e.selected),this._rotationLocked&&this.applyRotationLock()):!e.enabled&&t?(this.saveDebugCameraState(),this.orbitTarget=null,this._userOrbitEnabled||this.disableOrbitControls(),this.reattachCameraToRig(),this.restoreCameraState()):e.enabled&&this.updateOrbitTargetFromSelection(e.selected)}enableOrbitControls(){this.orbitControls||(this.orbitControls=new tn(this.camera,this.domElement),this.orbitControls.enableDamping=!0,this.orbitControls.dampingFactor=.05,this.orbitControls.screenSpacePanning=this._screenSpacePanning,this.orbitControls.minDistance=1,this.orbitControls.maxDistance=500,this.orbitControls.maxPolarAngle=Math.PI/2,this.orbitControls.enabled=this._interactionEnabled,this.orbitControls.target.copy(this._seededLookAt??new ke),this._rotationLocked&&this.applyRotationLock())}applyRotationLock(){let e=this.orbitControls;if(!e)return;e.update();let t=e.getPolarAngle(),i=e.getAzimuthalAngle();e.minPolarAngle=t,e.maxPolarAngle=t,e.minAzimuthAngle=i,e.maxAzimuthAngle=i,e.enableRotate=!1,e.update()}releaseRotationLock(){let e=this.orbitControls;e&&(e.minPolarAngle=0,e.maxPolarAngle=Math.PI/2,e.minAzimuthAngle=-1/0,e.maxAzimuthAngle=1/0,e.enableRotate=!0,e.update())}rebindCamera(e){this.camera=e,this.orbitControls&&(this.orbitControls.object=e,this._rotationLocked&&this.applyRotationLock())}setInteractionEnabled(e){this._interactionEnabled=e,this.orbitControls&&(this.orbitControls.enabled=e)}setFollowSelectionEnabled(e){if(this._followSelection!==e){if(this._followSelection=e,!e){this.orbitTarget=null;return}this.updateOrbitTargetFromSelection(this.debugStateSnapshot.selected)}}get isFollowingSelection(){return this._followSelection}disableOrbitControls(){this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=null)}updateOrbitTargetFromSelection(e){if(this._followSelection){if(!this.debugDelegate||e.length===0){this.orbitTarget=this._defaultOrbitTarget,this.orbitControls&&(this.orbitTarget?(this.orbitTarget.getWorldPosition(this.orbitTargetWorldPos),this.orbitControls.target.copy(this.orbitTargetWorldPos)):this.orbitControls.target.set(0,0,0));return}for(let t=e.length-1;t>=0;t-=1){let i=e[t],r=this.debugDelegate.resolveTarget(i);if(r){this.orbitTarget=r,this.orbitControls&&(r.getWorldPosition(this.orbitTargetWorldPos),this.orbitControls.target.copy(this.orbitTargetWorldPos));return}}this.orbitTarget=this._defaultOrbitTarget,this.orbitControls&&(this.orbitTarget?(this.orbitTarget.getWorldPosition(this.orbitTargetWorldPos),this.orbitControls.target.copy(this.orbitTargetWorldPos)):this.orbitControls.target.set(0,0,0))}}detachDebugDelegate(){if(this.debugUnsubscribe)try{this.debugUnsubscribe()}catch{}this.debugUnsubscribe=null,this.debugDelegate=null}saveCameraState(){this.savedCameraPosition=this.camera.position.clone(),this.savedCameraQuaternion=this.camera.quaternion.clone(),"zoom"in this.camera&&(this.savedCameraZoom=this.camera.zoom)}restoreCameraState(){this.savedCameraPosition&&(this.camera.position.copy(this.savedCameraPosition),this.savedCameraPosition=null),this.savedCameraQuaternion&&(this.camera.quaternion.copy(this.savedCameraQuaternion),this.savedCameraQuaternion=null),this.savedCameraZoom!==null&&"zoom"in this.camera&&(this.camera.zoom=this.savedCameraZoom,this.camera.updateProjectionMatrix?.(),this.savedCameraZoom=null)}saveDebugCameraState(){this.savedDebugCameraPosition=this.camera.position.clone(),this.savedDebugCameraQuaternion=this.camera.quaternion.clone(),"zoom"in this.camera&&(this.savedDebugCameraZoom=this.camera.zoom),this.orbitControls&&(this.savedDebugOrbitTarget=this.orbitControls.target.clone())}restoreDebugCameraState(){this.savedDebugCameraPosition&&this.camera.position.copy(this.savedDebugCameraPosition),this.savedDebugCameraQuaternion&&this.camera.quaternion.copy(this.savedDebugCameraQuaternion),this.savedDebugCameraZoom!==null&&"zoom"in this.camera&&(this.camera.zoom=this.savedDebugCameraZoom,this.camera.updateProjectionMatrix?.()),this.savedDebugOrbitTarget&&this.orbitControls&&this.orbitControls.target.copy(this.savedDebugOrbitTarget)}detachCameraFromRig(){if(!this.cameraRig||this.camera.parent!==this.cameraRig)return;this.savedCameraLocalPosition=this.camera.position.clone();let e=new ke;this.camera.getWorldPosition(e),this.cameraRig.remove(this.camera),this.sceneRef&&this.sceneRef.add(this.camera),this.camera.position.copy(e)}reattachCameraToRig(){!this.cameraRig||this.camera.parent===this.cameraRig||(this.sceneRef&&this.camera.parent===this.sceneRef&&this.sceneRef.remove(this.camera),this.cameraRig.add(this.camera),this.savedCameraLocalPosition&&(this.camera.position.copy(this.savedCameraLocalPosition),this.savedCameraLocalPosition=null))}};var x=class{cameraRig=null;camera;screenResolution;_perspective;frustumSize=10;sceneRef=null;name="";viewport={...ki};targets=[];pipeline;renderTarget=null;get target(){return this.targets.length>0?this.targets[0]:null}set target(e){e?this.targets.length===0?this.targets.push(e):this.targets[0]=e:this.targets=[]}orbitController=null;_useOrbitalControls=!1;_skipDebugOrbit=!1;isDebugViewCamera=!1;_rendererManager=null;_elapsedTime=0;constructor(e,t,i=10){this._perspective=e,this.screenResolution=t,this.frustumSize=i;let r=t.x/t.y;this.camera=this.createCameraForPerspective(r),this.camera.position.set(0,0,10),this.camera.lookAt(new rn(0,0,0));let n=O(e);this.pipeline=new xe(n)}async setup(e,t){this.sceneRef=e,t&&(this._rendererManager=t),this._rendererManager&&!this._rendererManager.initialized&&await this._rendererManager.initRenderer(),this._rendererManager&&(this.orbitController=new _e(this.camera,this._rendererManager.renderer.domElement,null),this.orbitController.setScene(e),this.isDebugViewCamera&&this.orbitController.setDebugViewCamera(!0),this._useOrbitalControls&&this.orbitController.enableUserOrbitControls())}async setupLegacy(e){this._rendererManager||(this._rendererManager=new Ce(this.screenResolution),await this._rendererManager.initRenderer(),this._rendererManager.setupPostProcessing(e,this.camera),this._rendererManager.startRenderLoop(()=>{this._rendererManager&&this.sceneRef&&(this.isOrbitActive&&this.updateOrbitControls(),this._rendererManager.render(this.sceneRef,this.camera))})),await this.setup(e,this._rendererManager)}update(e){if(this.isDebugModeActive()||this._useOrbitalControls)return;this._elapsedTime+=e;let t=this.buildContext(e),i=this.pipeline.run(t);this.commitPose(i)}isDebugModeActive(){return this.orbitController?.isActive??!1}get isOrbitActive(){return this.orbitController?.isOrbitActive??!1}updateOrbitControls(){this.orbitController?.update()}enableOrbitalControls(){this._useOrbitalControls=!0,this.orbitController?.enableUserOrbitControls()}disableOrbitalControls(){this._useOrbitalControls=!1,this.orbitController?.disableUserOrbitControls()}armEditorOrbit(e,t=!1){this._skipDebugOrbit=!0,this.orbitController?.setScreenSpacePanning(t),this.orbitController?.setRotationLocked(e),this.enableOrbitalControls(),this.setOrbitInteractionEnabled(!0)}disarmEditorOrbit(){this.setOrbitInteractionEnabled(!1)}get useOrbitalControls(){return this._useOrbitalControls}addTarget(e){this.targets.includes(e)||this.targets.push(e)}removeTarget(e){let t=this.targets.indexOf(e);t!==-1&&this.targets.splice(t,1)}clearTargets(){this.targets=[]}setViewport(e,t,i,r){this.viewport={x:e,y:t,width:i,height:r}}resize(e,t){if(this.screenResolution.set(e,t),this.camera instanceof Pt&&(this.camera.aspect=e/t,this.camera.updateProjectionMatrix()),this.camera instanceof De){let i=e/t;this.camera.left=this.frustumSize*i/-2,this.camera.right=this.frustumSize*i/2,this.camera.top=this.frustumSize/2,this.camera.bottom=this.frustumSize/-2,this.camera.updateProjectionMatrix()}}createRenderTarget(e=512,t=512){return this.renderTarget&&this.renderTarget.dispose(),this.renderTarget=new nn(e,t,{minFilter:ji,magFilter:ji}),this.renderTarget}getRenderTexture(){return this.renderTarget?.texture??null}destroy(){try{this.orbitController?.dispose()}catch{}try{this.renderTarget?.dispose()}catch{}this.renderTarget=null,this.sceneRef=null,this.targets=[],this._rendererManager=null}setDefaultOrbitTarget(e){this.orbitController?.setDefaultOrbitTarget(e)}seedDebugOrbitPose(e,t){this.isDebugViewCamera&&this.isDebugOrbitPoseSeeded()||this.orbitController?.seedOrbitPose(e,t)}isDebugOrbitPoseSeeded(){return this.orbitController?.isDebugOrbitPoseSeeded??!1}setDebugDelegate(e){this._skipDebugOrbit||this.orbitController?.setDebugDelegate(e)}frameObject(e){this.orbitController?.frameTarget(e)}setOrbitInteractionEnabled(e){this.orbitController?.setInteractionEnabled(e)}setOrbitFollowEnabled(e){this.orbitController?.setFollowSelectionEnabled(e)}move(e){(this._perspective===m.Flat2D||this._perspective===m.Fixed2D)&&(this.frustumSize=e.z),this.camera.position.set(e.x,e.y,e.z)}rotate(e,t,i){this.camera.rotateX(e),this.camera.rotateY(t),this.camera.rotateZ(i)}getDomElement(){if(this._rendererManager)return this._rendererManager.getDomElement();throw new Error("ZylemCamera: No renderer manager available. Call setup() first.")}getRendererManager(){return this._rendererManager}setRendererManager(e){this._rendererManager=e}get renderer(){return this._rendererManager?.renderer}get composer(){return this._rendererManager?.postProcessing}setPixelRatio(e){this._rendererManager?.setPixelRatio(e)}buildContext(e){let t={};for(let i=0;i<this.targets.length;i++){let r=this.targets[i],n=i===0?"primary":`target_${i}`;r.group&&(t[n]={position:r.group.position,rotation:r.group.quaternion})}return{dt:e,time:this._elapsedTime,viewport:{width:this.screenResolution.x,height:this.screenResolution.y,aspect:this.screenResolution.x/this.screenResolution.y},targets:t}}commitPose(e){if(this.camera.position.copy(e.position),e.lookAt){let t=e.lookAt.x-e.position.x,i=e.lookAt.y-e.position.y,r=e.lookAt.z-e.position.z,n=Math.hypot(t,i,r);n>1e-8&&Math.abs(i)/n>.999?this.camera.up.set(0,0,-1):this.camera.up.set(0,1,0),this.camera.lookAt(e.lookAt)}else this.camera.quaternion.copy(e.rotation);if(this.camera instanceof Pt&&(e.fov!=null&&(this.camera.fov=e.fov),e.near!=null&&(this.camera.near=e.near),e.far!=null&&(this.camera.far=e.far),this.camera.updateProjectionMatrix()),this.camera instanceof De){if(e.zoom!=null){let t=this.screenResolution.x/this.screenResolution.y,i=e.zoom;this.camera.left=-i*t/2,this.camera.right=i*t/2,this.camera.top=i/2,this.camera.bottom=-i/2}e.near!=null&&(this.camera.near=e.near),e.far!=null&&(this.camera.far=e.far),this.camera.updateProjectionMatrix()}}applyPerspective(e,t){this._perspective=e,this.pipeline.setPerspective(t),this.ensureProjection(t.projection??gt(e))}ensureProjection(e){if((this.camera instanceof De?"orthographic":"perspective")===e)return;let i=this.screenResolution.x/Math.max(this.screenResolution.y,1),r=e==="orthographic"?this.createOrthographicCamera(i):this.createPerspectiveCamera(i);if(r.position.copy(this.camera.position),r.quaternion.copy(this.camera.quaternion),r.up.copy(this.camera.up),r.layers.mask=this.camera.layers.mask,r.name=this.camera.name,"near"in this.camera&&"near"in r){let s=this.camera,a=r;a.near=s.near,a.far=s.far,a.zoom=s.zoom,a.updateProjectionMatrix()}let n=this.camera.parent;n&&(n.add(r),n.remove(this.camera)),this.camera=r,this.orbitController?.rebindCamera(r),this._rendererManager?.rebindPostProcessingCamera(r)}createCameraForPerspective(e){return gt(this._perspective)==="orthographic"?this.createOrthographicCamera(e):this.createPerspectiveCamera(e)}createPerspectiveCamera(e){return new Pt(75,e,.1,1e3)}createOrthographicCamera(e){return new De(this.frustumSize*e/-2,this.frustumSize*e/2,this.frustumSize/2,this.frustumSize/-2,1,1e3)}};var Wi=1e4,ln=[{id:D.side,perspective:m.Fixed2D,lockRotation:!0,screenSpacePan:!0,position:(o,e)=>new M(o.x+e,o.y,o.z),up:()=>new M(0,1,0)},{id:D.top,perspective:m.TopDown,lockRotation:!0,screenSpacePan:!0,position:(o,e)=>new M(o.x,o.y+e,o.z),up:()=>new M(0,0,-1)},{id:D.isometric,perspective:m.Isometric,lockRotation:!0,screenSpacePan:!0,near:-Wi,far:Wi,position:(o,e)=>o.clone().add(new M(1,1,1).normalize().multiplyScalar(e)),up:()=>new M(0,1,0)},{id:D.free,perspective:m.ThirdPerson,lockRotation:!1,screenSpacePan:!1,position:(o,e,t)=>t.distanceTo(o)>.5?t.clone():o.clone().add(new M(0,e*.5,e)),up:o=>o.clone()}];function cn(o){let e=new M;o.getWorldDirection(e);let i=new M().sub(o.position).dot(e),r=i>1?i:12;return{lookAt:o.position.clone().add(e.multiplyScalar(r)),distance:r}}var Le=class{cameras=new Map;_activeCameras=[];_editorCameras=new Map;_lockedEditorIds=new Set;_screenSpacePanIds=new Set;_rememberedGameCamera=null;_editorViewLocked=!1;_suspendedOrbits=new Set;_editorCamerasPromise=null;_rendererManager=null;_sceneRef=null;_autoNameCounter=0;_unregisterEditorHost=null;get activeCameras(){return this._activeCameras}get primaryCamera(){return this._activeCameras.length>0?this._activeCameras[0]:null}isEditorViewActive(){return this._editorViewLocked}hasEditorCameras(){return this._editorCameras.size>0}get allCameras(){return Array.from(this.cameras.values())}addCamera(e,t){let i=t||e.name||`camera_${this._autoNameCounter++}`;return e.name=i,this.cameras.set(i,e),this._activeCameras.length===0&&this._activeCameras.push(e),i}removeCamera(e){let t;if(typeof e=="string")t=e;else for(let[n,s]of this.cameras.entries())if(s===e){t=n;break}if(!t)return!1;let i=this.cameras.get(t);if(!i)return!1;this.cameras.delete(t);let r=this._activeCameras.indexOf(i);return r!==-1&&this._activeCameras.splice(r,1),this._rememberedGameCamera===i&&(this._rememberedGameCamera=null),this._suspendedOrbits.delete(i),!0}setActiveCamera(e){let t=this.resolveCamera(e);return t?this._editorViewLocked&&!this.isEditorCamera(t)?(this._rememberedGameCamera=t,!0):(this.isEditorCamera(t)||(this._rememberedGameCamera=t,this.restoreOrbitFor(t)),this.commitActive(t)):(console.warn(`CameraManager: Camera not found: ${e}`),!1)}addActiveCamera(e){let t=this.resolveCamera(e);return t?(this._activeCameras.includes(t)||this._activeCameras.push(t),!0):!1}deactivateCamera(e){let t=this.resolveCamera(e);if(!t)return!1;let i=this._activeCameras.indexOf(t);return i!==-1?(this._activeCameras.splice(i,1),!0):!1}getCamera(e){return this.cameras.get(e)??null}async setup(e,t){this._sceneRef=e,this._rendererManager=t;for(let i of this.cameras.values())i.setRendererManager(t),await i.setup(e,t);this._unregisterEditorHost=Qt(this),pe()&&await this.ensureEditorCameras()}ensureEditorCameras(){return this._editorCameras.size>0?Promise.resolve():this._editorCamerasPromise?this._editorCamerasPromise:(this._editorCamerasPromise=this.createEditorCameras().finally(()=>{this._editorCamerasPromise=null}),this._editorCamerasPromise)}destroyEditorCameras(){let e=this.primaryCamera!==null&&this.isEditorCamera(this.primaryCamera);if(this._editorViewLocked=!1,e){let t=this.gameCameraToRestore();t&&(this.restoreOrbitFor(t),this.commitActive(t))}for(let t of this._editorCameras.values())this.removeCamera(t),t.destroy();this._editorCameras.clear(),this._lockedEditorIds.clear(),this._screenSpacePanIds.clear()}activateCameraById(e){if(e===Kt){let r=this.gameCameraToRestore();return r?this.showGameCamera(r):!1}let t=this._editorCameras.get(e);if(t)return this.showEditorCamera(e,t);let i=this.getCamera(e);return!i||this.isEditorCamera(i)?!1:(this._rememberedGameCamera=i,this.showGameCamera(i))}update(e){for(let t of this._activeCameras)t.update(e)}render(e){if(!this._rendererManager||this._activeCameras.length===0)return;this.updateOrbitingCamerasForRender();let t=[],i=[];for(let r of this._activeCameras)r.renderTarget?t.push(r):i.push(r);for(let r of t)this._rendererManager.renderCameraToTarget(e,r);i.length>0&&this._rendererManager.renderCameras(e,i)}updateOrbitingCamerasForRender(){for(let e of this._activeCameras)e.isOrbitActive&&e.updateOrbitControls()}ensureDefaultCamera(){if(this.cameras.size===0||this._activeCameras.length===0){let e=this._rendererManager?.screenResolution||new on(window.innerWidth,window.innerHeight),t=new x(m.ThirdPerson,e);return this.addCamera(t,"default"),t}return this._activeCameras[0]}dispose(){this._unregisterEditorHost?.(),this._unregisterEditorHost=null,this._editorViewLocked=!1;for(let e of this.cameras.values())e.destroy();this.cameras.clear(),this._activeCameras=[],this._editorCameras.clear(),this._lockedEditorIds.clear(),this._screenSpacePanIds.clear(),this._rememberedGameCamera=null,this._suspendedOrbits.clear(),this._rendererManager=null,this._sceneRef=null}async createEditorCameras(){if(this._editorCameras.size>0||!this._sceneRef||!this._rendererManager)return;let e=this.primaryCamera??this.ensureDefaultCamera();e.sceneRef||(e.setRendererManager(this._rendererManager),await e.setup(this._sceneRef,this._rendererManager));let t=cn(e.camera),i=this._rendererManager.screenResolution.clone(),r=Math.max(t.distance,4);this.isEditorCamera(e)||(this._rememberedGameCamera=e);for(let n of ln){let s=new x(n.perspective,i,r);s._skipDebugOrbit=!0;let a=n.position(t.lookAt,t.distance,e.camera.position),l=n.up(e.camera.up);s.camera.up.copy(l),s.camera.position.copy(a),s.camera.lookAt(t.lookAt),(s.camera instanceof sn||s.camera instanceof an)&&(s.camera.near=n.near??.1,s.camera.far=n.far??2e3,s.camera.updateProjectionMatrix()),this.addCamera(s,n.id),this._editorCameras.set(n.id,s),n.lockRotation&&this._lockedEditorIds.add(n.id),n.screenSpacePan&&this._screenSpacePanIds.add(n.id),s.setRendererManager(this._rendererManager),await s.setup(this._sceneRef,this._rendererManager),s.seedDebugOrbitPose(a,t.lookAt)}}showEditorCamera(e,t){if(!this._editorViewLocked){let i=this.primaryCamera;i&&!this.isEditorCamera(i)&&(this._rememberedGameCamera=i)}return this._editorViewLocked=!0,this.suspendOtherOrbits(t),this.syncEditorOrbit(e),this.commitActive(t)}showGameCamera(e){return this._editorViewLocked=!1,this.syncEditorOrbit(null),this.restoreOrbitFor(e),this.commitActive(e)}syncEditorOrbit(e){for(let[t,i]of this._editorCameras)t===e?i.armEditorOrbit(this._lockedEditorIds.has(t),this._screenSpacePanIds.has(t)):i.disarmEditorOrbit()}suspendOtherOrbits(e){for(let t of this.cameras.values())t===e||this.isEditorCamera(t)||t.isOrbitActive&&(t.setOrbitInteractionEnabled(!1),this._suspendedOrbits.add(t))}restoreOrbitFor(e){this._suspendedOrbits.has(e)&&(e.setOrbitInteractionEnabled(!0),this._suspendedOrbits.delete(e))}gameCameraToRestore(){if(this._rememberedGameCamera&&this.cameraIsRegistered(this._rememberedGameCamera))return this._rememberedGameCamera;for(let e of this.cameras.values())if(!this.isEditorCamera(e))return e;return null}cameraIsRegistered(e){for(let t of this.cameras.values())if(t===e)return!0;return!1}isEditorCamera(e){for(let t of this._editorCameras.values())if(t===e)return!0;return!1}commitActive(e){let t=this.primaryCamera,i=this._activeCameras.filter(r=>r!==this._activeCameras[0]&&r.viewport.width<1);return this._activeCameras=[e,...i],t!==e&&this._rendererManager?.rebindPostProcessingCamera(e.camera),!0}resolveCamera(e){if(typeof e=="string")return this.cameras.get(e)??null;for(let t of this.cameras.values())if(t===e)return t;return null}};var C=class{cameraRef;constructor(e){this.cameraRef=e}addTarget(e){this.cameraRef.addTarget(e)}removeTarget(e){this.cameraRef.removeTarget(e)}clearTargets(){this.cameraRef.clearTargets()}enableOrbitalControls(){this.cameraRef.enableOrbitalControls()}disableOrbitalControls(){this.cameraRef.disableOrbitalControls()}setViewport(e,t,i,r){this.cameraRef.setViewport(e,t,i,r)}addBehavior(e,t){this.cameraRef.pipeline.addBehavior(e,t)}removeBehavior(e){return this.cameraRef.pipeline.removeBehavior(e)}addAction(e){this.cameraRef.pipeline.addAction(e)}setPerspective(e,t){this.cameraRef.applyPerspective(e,O(e,t))}getPerspective(){return this.cameraRef.pipeline.perspective}getState(){return this.cameraRef.pipeline.getState()}getRenderTexture(){return this.cameraRef.getRenderTexture()}};function Ra(o){let e=ei(o.screenResolution,{x:window.innerWidth,y:window.innerHeight}),t=10;(o.perspective==="fixed-2d"||o.perspective==="isometric"||o.perspective==="top-down")&&(t=o.zoom||10);let i=new x(o.perspective||"third-person",e,t);o.name&&(i.name=o.name);let r=h(o.position,P),n=h(o.target,P);i.move(r),i.camera.lookAt(n);let s=o.perspective||"third-person";if(s==="fixed-2d"||s==="flat-2d"?i.applyPerspective(s,O(s,{zoom:t})):s==="isometric"||s==="top-down"?i.applyPerspective(s,O(s,{zoom:t,initialPosition:r.clone(),initialLookAt:n.clone()})):i.applyPerspective(s,O(s,{initialPosition:r.clone(),initialLookAt:n.clone()})),o.viewport&&(i.viewport={...o.viewport}),o.useOrbitalControls&&(i._useOrbitalControls=!0),o.skipDebugOrbit&&(i._skipDebugOrbit=!0),o.damping!=null&&(i.pipeline.damping=o.damping),o.behaviors)for(let[a,l]of Object.entries(o.behaviors))i.pipeline.addBehavior(a,l);if(o.renderToTexture){let{width:a=512,height:l=512}=o.renderToTexture;i.createRenderTarget(a,l)}return new C(i)}import{Vector3 as dn}from"three";function k(o){return!!o&&typeof o=="object"&&typeof o.create=="function"}function ne(o){return!!o&&typeof o.then=="function"}function wt(o){return!!o&&typeof o=="object"&&o instanceof C}function qi(o){return!o||typeof o!="object"||k(o)||wt(o)||ne(o)||typeof o.then=="function"?!1:o.constructor===Object||o.constructor?.name==="Object"}function Ki(o){return o?!!(k(o)||typeof o=="function"||ne(o)):!1}var pn="/three/basis/";function Oe(o){return{...o,ktx2TranscoderPath:o?.ktx2TranscoderPath??pn}}var Ae=class{constructor(e,t,i,r,n,s,a=60,l={},c=!0,d=[]){this.inputs=e;this.backgroundColor=t;this.backgroundImage=i;this.backgroundShader=r;this.gravity=n;this.variables=s;this.physicsRate=a;this.assetLoaders=l;this.defaultLighting=c;this.postProcessingEffects=d}};function un(){return new Ae({p1:["gamepad-1","keyboard-1"],p2:["gamepad-2","keyboard-2"]},ve,null,null,new dn(0,0,0),{},60,{},!0)}function Qi(o=[]){let e=un(),t={},i=[],r=[],n=[];for(let l of o)wt(l)?n.push(l):k(l)?i.push(l):Ki(l)&&!k(l)?r.push(l):qi(l)&&(t={...t,...l});let s=new Ae(t.inputs??e.inputs,t.backgroundColor??e.backgroundColor,t.backgroundImage??e.backgroundImage,t.backgroundShader??e.backgroundShader,t.gravity??e.gravity,t.variables??e.variables,t.physicsRate??e.physicsRate,t.assetLoaders??e.assetLoaders,t.defaultLighting??e.defaultLighting,t.postProcessingEffects??e.postProcessingEffects),a=n.length>0?n[0]:void 0;return{config:s,entities:i,asyncEntities:r,camera:a,cameras:n}}function za(o){return{...o}}var hn=Symbol("vessel"),oe=class extends W{static type=hn;_setup(e){}async _loaded(e){}_update(e){}_destroy(e){}_cleanup(e){}create(){return this}clone(){let e=mn();return this.replayUserLifecycleRegistrationsTo(e),this.cloneChildrenInto(e),e}add(...e){for(let t of e)super.add(t);return this}};function mn(...o){let e=new oe;return o.forEach(t=>e.add(t)),e.enableUserLifecycleTracking(),e}import{Color as Mr,Vector3 as Tr}from"three";import{createSimulation as fn}from"@zylem/behaviors/core";function Et(o){return typeof o?.handlePostCollision=="function"&&typeof o?.handleIntersectionEvent=="function"}function gn(o,e){return o<e?`${o}|${e}`:`${e}|${o}`}var Be=class o{type="World";simulation;collisionMap=new Map;collisionBehaviorMap=new Map;_removalMap=new Map;activeCollisionPairs=new Map;livePairs=new Map;handleIdToUuid=new Map;currentCollisionTimeMs=0;zeroGravity;fixedTimestep;interpolationAlpha=0;stepClock={steps:0};static async create(e,t=60){let i={x:e?.x??0,y:e?.y??0,z:e?.z??0},r=await fn({gravity:[i.x,i.y,i.z],fixedTimestep:1/t,initialCapacity:4096});return new o(r,t,i.x===0&&i.y===0&&i.z===0)}constructor(e,t=60,i=!1){this.simulation=e,this.fixedTimestep=1/t,this.zeroGravity=i,this.simulation?.setEventsEnabled?.(!1)}addEntity(e){let t={...e.bodyDesc??{}},i=e.colliderDescs?.length?e.colliderDescs:e.colliderDesc?[e.colliderDesc]:[];this.zeroGravity&&(t.lockTranslation=t.lockTranslation??[!0,!0,!0],t.lockRotation=t.lockRotation??[!0,!0,!0]),(e.controlledRotation||e instanceof ge)&&e.bodyDesc?.lockRotation===void 0&&(t.lockRotation=[!0,!0,!0]);let r=this.simulation.spawn({body:t,colliders:i});if(!r){console.warn(`ZylemWorld: failed to spawn entity ${e.uuid} into simulation`);return}e.body=new ci(this.simulation,r,this.stepClock),e.physicsAttached=!0,e.physicsWorldRef=this,e.simulationHandle=r,e.runtimeHandle=r.slot,e.runtimeAttached=!0,e.wasmStageRef=this.simulation.adapter,this.handleIdToUuid.set(r.id,e.uuid),this.collisionMap.set(e.uuid,e)}setForRemoval(e){e.physicsAttached&&this._removalMap.set(e.uuid,e)}destroyEntity(e){if(!(e.physicsWorldRef===this)){this.removeEntityFromTracking(e.uuid);return}let i=e.simulationHandle;if(i){try{this.simulation.despawn(i)}catch{}this.handleIdToUuid.delete(i.id)}this.removeEntityFromTracking(e.uuid),this.clearEntityPhysicsState(e)}setup(){}update(e){let{delta:t}=e;this.currentCollisionTimeMs+=t*1e3,this.processPendingRemovals();let i=this.hasCollisionPhaseListeners();i&&!this.simulation.areEventsEnabled&&this.simulation.setEventsEnabled?.(!0);let r=this.simulation.update(t);this.stepClock.steps+=r.stepsTaken,this.interpolationAlpha=r.alpha,i&&(this.applyCollisionEvents(r.events),this.processCollisionPairs(t,this.currentCollisionTimeMs))}hasCollisionPhaseListeners(){for(let e of this.collisionMap.values())if(e?.collisionDelegate?.collision?.length)return!0;return!1}applyCollisionEvents(e){for(let t of e){if(t.type!=="collisionStarted"&&t.type!=="collisionStopped")continue;let i=t.a?this.handleIdToUuid.get(t.a.id):void 0,r=t.b?this.handleIdToUuid.get(t.b.id):void 0;if(!i||!r||i===r)continue;let n=gn(i,r),s=this.livePairs.get(n);s||(s={uuidA:i<r?i:r,uuidB:i<r?r:i,contactCount:0,intersectionCount:0},this.livePairs.set(n,s));let a=t.type==="collisionStarted"?1:-1;t.sensor?s.intersectionCount=Math.max(0,s.intersectionCount+a):s.contactCount=Math.max(0,s.contactCount+a),s.contactCount===0&&s.intersectionCount===0&&this.livePairs.delete(n)}}snapshotLivePairs(){let e=new Map;for(let[t,i]of this.livePairs)e.set(t,{uuidA:i.uuidA,uuidB:i.uuidB,hasContact:i.contactCount>0,hasIntersection:i.intersectionCount>0});return e}updatePostCollisionBehaviors(e){let t=this.collisionBehaviorMap;for(let[i,r]of t){let n=r;if(!Et(n))continue;n.handlePostCollision({entity:n,delta:e})||this.collisionBehaviorMap.delete(i)}}processPendingRemovals(){if(this._removalMap.size!==0){for(let[,e]of this._removalMap)this.destroyEntity(e);this._removalMap.clear()}}removeEntityFromTracking(e){this.collisionMap.delete(e),this._removalMap.delete(e),this.pruneActiveCollisionPairs(e)}pruneActiveCollisionPairs(e){for(let[t,i]of this.activeCollisionPairs)(i.uuidA===e||i.uuidB===e)&&this.activeCollisionPairs.delete(t);for(let[t,i]of this.livePairs)(i.uuidA===e||i.uuidB===e)&&this.livePairs.delete(t)}entityHasCollisionPhaseListener(e,t){let i=e?.collisionDelegate.collision;if(!i?.length)return!1;for(let r of i)if(r.options.phase===t)return!0;return!1}processCollisionPairs(e,t=this.currentCollisionTimeMs){let i=this.snapshotLivePairs();for(let[r,n]of i){let s=this.collisionMap.get(n.uuidA),a=this.collisionMap.get(n.uuidB);this.activeCollisionPairs.has(r)||this.dispatchCollisionPhase(n,"enter",t),(this.entityHasCollisionPhaseListener(s,"stay")||this.entityHasCollisionPhaseListener(a,"stay"))&&this.dispatchCollisionPhase(n,"stay",t),n.hasIntersection&&this.dispatchIntersectionDelegates(n,e)}this.updatePostCollisionBehaviors(e),this.activeCollisionPairs=i}dispatchCollisionPhase(e,t,i){let r={phase:t,nowMs:i},n=this.collisionMap.get(e.uuidA),s=this.collisionMap.get(e.uuidB);n&&s&&n._collision(s,rt.globals,r);let a=this.collisionMap.get(e.uuidA),l=this.collisionMap.get(e.uuidB);a&&l&&l._collision(a,rt.globals,r)}dispatchIntersectionDelegates(e,t){let i=this.collisionMap.get(e.uuidA),r=this.collisionMap.get(e.uuidB);i&&r&&Et(i)&&(i.handleIntersectionEvent({entity:i,other:r,delta:t}),this.collisionBehaviorMap.set(i.uuid,i));let n=this.collisionMap.get(e.uuidA),s=this.collisionMap.get(e.uuidB);n&&s&&Et(s)&&(s.handleIntersectionEvent({entity:s,other:n,delta:t}),this.collisionBehaviorMap.set(s.uuid,s))}raycast(e,t,i){let r=this.simulation.castRay([e.x,e.y,e.z],[t.x,t.y,t.z],i,!0);return r?{uuid:r.entity?this.handleIdToUuid.get(r.entity.id)??null:null,distance:r.distance,normal:r.normal}:null}destroy(){try{for(let[,e]of this.collisionMap)try{this.clearEntityPhysicsState(e)}catch{}try{this.simulation.dispose()}catch{}this.collisionMap.clear(),this.collisionBehaviorMap.clear(),this._removalMap.clear(),this.activeCollisionPairs.clear(),this.livePairs.clear(),this.handleIdToUuid.clear()}catch{}}clearEntityPhysicsState(e){e.physicsAttached=!1,e.body=null,e.runtimeHandle=-1,e.runtimeAttached=!1,e.wasmStageRef=null,e.simulationHandle=void 0,e.physicsWorldRef===this&&(e.physicsWorldRef=null)}};import{Scene as yn,Color as Yi,AmbientLight as vn,DirectionalLight as bn,Vector3 as ze,GridHelper as Cn,Texture as Sn,SRGBColorSpace as Pn}from"three";var Ve=class{type="Scene";_setup;scene;zylemCamera;cameraManager=null;containerElement=null;update=()=>{};_collision;_destroy;name;tag;constructor(e,t,i){let r=new yn,s=i.backgroundColor instanceof Yi?i.backgroundColor:new Yi(i.backgroundColor);r.background=s,i.backgroundShader?this.setupBackgroundShader(r,i.backgroundShader):i.backgroundImage&&I.loadTexture(i.backgroundImage,{colorSpace:Pn}).then(a=>{r.background=a}),this.scene=r,this.zylemCamera=t,i.defaultLighting!==!1&&this.setupLighting(r),p.enabled&&this.debugScene()}setupBackgroundShader(e,t){if(!me(t)){console.warn("ZylemScene: GLSL background shaders are not supported on the WebGPU renderer. Provide a TSL shader (ZylemTSLShader) as backgroundShader. Keeping solid background.");return}e.background=null,e.backgroundNode=t.colorNode}setup(){this._setup&&this._setup({me:this,camera:this.zylemCamera,globals:v()})}destroy(){this.cameraManager?(this.cameraManager.dispose(),this.cameraManager=null):this.zylemCamera&&this.zylemCamera.destroy&&this.zylemCamera.destroy(),this.scene&&(this.scene.backgroundNode=null,this.scene.background instanceof Sn&&(this.scene.background.dispose(),this.scene.background=null),this.scene.traverse(e=>{if(e.geometry&&e.geometry.dispose?.(),e.material){let t=Array.isArray(e.material)?e.material:[e.material];for(let i of t)i.map&&i.map.dispose?.(),i.normalMap&&i.normalMap.dispose?.(),i.aoMap&&i.aoMap.dispose?.(),i.emissiveMap&&i.emissiveMap.dispose?.(),i.roughnessMap&&i.roughnessMap.dispose?.(),i.metalnessMap&&i.metalnessMap.dispose?.(),i.envMap&&i.envMap.dispose?.(),i.lightMap&&i.lightMap.dispose?.(),i.bumpMap&&i.bumpMap.dispose?.(),i.displacementMap&&i.displacementMap.dispose?.(),i.alphaMap&&i.alphaMap.dispose?.(),i.dispose?.()}e.isLight&&e.shadow?.map&&e.shadow.map.dispose()}),this.scene.clear())}async setupCamera(e,t,i){this.addCameraToScene(e,t),i?await t.setup(e,i):await t.setupLegacy(e)}async setupCameraManager(e,t,i){this.cameraManager=t;for(let r of t.activeCameras)this.addCameraToScene(e,r);await t.setup(e,i)}addCameraToScene(e,t){t.cameraRig?e.add(t.cameraRig):e.add(t.camera)}setupLighting(e){let t=new vn(16777215,1);e.add(t);let i=new bn(16777215,2);i.name="Light",i.position.set(0,100,0),i.castShadow=!0,i.shadow.camera.near=.1,i.shadow.camera.far=2e3,i.shadow.camera.left=-100,i.shadow.camera.right=100,i.shadow.camera.top=100,i.shadow.camera.bottom=-100,i.shadow.mapSize.width=2048,i.shadow.mapSize.height=2048,e.add(i)}updateRenderer(e,t){if(this.cameraManager)for(let i of this.cameraManager.allCameras)i.resize(e,t);else this.zylemCamera.resize(e,t)}add(e,t=new ze(0,0,0)){e.position.set(t.x,t.y,t.z),this.scene.add(e)}addEntity(e){let t=e.group??e.mesh;!t||this.isAttachedOutsideScene(t)||this.add(t,e.options.position)}addEntityGroup(e){if(L(e))return;let t=e.group??e.mesh;if(!t||this.isAttachedOutsideScene(t))return;let i=wn(e);i&&i.attachToScene(this.scene);let r=e.options.position??new ze(0,0,0);if(e.physicsAttached&&e.body)try{let n=e.body.translation();r=new ze(n.x,n.y,n.z)}catch{r=e.options.position??new ze(0,0,0)}this.add(t,r),q(e)}isAttachedOutsideScene(e){return e.parent!=null&&e.parent!==this.scene}debugScene(){let i=new Cn(1e3,100);this.scene.add(i)}};function wn(o){return o.constructor.type===di?o:null}var Ie=class{update=()=>{};setup=()=>{};destroy=()=>{};nodeSetup(e){typeof this._setup=="function"&&this._setup(e),this.setup&&this.setup(e)}nodeUpdate(e){typeof this._update=="function"&&this._update(e),this.update&&this.update(e)}nodeDestroy(e){this.destroy&&this.destroy(e),typeof this._destroy=="function"&&this._destroy(e)}};import{Quaternion as En}from"three";var $i=new En;function Xi(o){let e=o._childrenMap,t=o._world;for(let[,i]of e){if(!i?.body||i.markedForRemoval||i.isInstanced||i.isBundled||i.skipRenderPoseSync)continue;let r=i.body,n=i.group??i.mesh,s=n?ye(r,t?.interpolationAlpha??0):null;n&&s&&n.position.set(s.position.x,s.position.y,s.position.z),!i.controlledRotation&&n&&s&&($i.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w),n.setRotationFromQuaternion($i))}}import{nanoid as To}from"nanoid";import{Box3 as Vt,BufferAttribute as Sr,BufferGeometry as vo,LineBasicMaterial as bo,LineSegments as Co,Raycaster as So,Vector2 as Po,Vector3 as It}from"three";import{subscribe as wo}from"valtio/vanilla";import{nanoid as Pr}from"nanoid";import{Box3 as xn,BoxGeometry as Ji,Color as Mn,EdgesGeometry as er,Group as Tn,LineBasicMaterial as Rn,LineSegments as kn,Mesh as _n,MeshBasicMaterial as Dn,Vector3 as tr}from"three";var Fe=class{scene;container;fillMesh;edgeLines;currentColor=new Mn(65280);bbox=new xn;size=new tr;center=new tr;constructor(e){this.scene=e;let t=new Ji(1,1,1);this.fillMesh=new _n(t,new Dn({color:this.currentColor,transparent:!0,opacity:.12,depthWrite:!1}));let i=new er(t);this.edgeLines=new kn(i,new Rn({color:this.currentColor,linewidth:1})),this.container=new Tn,this.container.name="DebugEntityCursor",this.container.add(this.fillMesh),this.container.add(this.edgeLines),this.container.visible=!1,this.scene.add(this.container)}setColor(e){this.currentColor.set(e),this.fillMesh.material.color.set(this.currentColor),this.edgeLines.material.color.set(this.currentColor)}updateFromObject(e){if(!e){this.hide();return}this.bbox.setFromObject(e),this.updateFromBounds(this.bbox)}updateFromBounds(e){if(!e||e.isEmpty()){this.hide();return}if(e!==this.bbox&&this.bbox.copy(e),!isFinite(this.bbox.min.x)||!isFinite(this.bbox.max.x)){this.hide();return}this.bbox.getSize(this.size),this.bbox.getCenter(this.center);let t=new Ji(Math.max(this.size.x,1e-6),Math.max(this.size.y,1e-6),Math.max(this.size.z,1e-6));this.fillMesh.geometry.dispose(),this.fillMesh.geometry=t;let i=new er(t);this.edgeLines.geometry.dispose(),this.edgeLines.geometry=i,this.container.position.copy(this.center),this.container.visible=!0}hide(){this.container.visible=!1}dispose(){this.scene.remove(this.container),this.fillMesh.geometry.dispose(),this.fillMesh.material.dispose(),this.edgeLines.geometry.dispose(),this.edgeLines.material.dispose()}};import{Box3 as Ln,BoxGeometry as An,Group as On,Mesh as Bn,MeshBasicMaterial as zn,Vector3 as ir}from"three";var Vn={x:0,y:0,z:0},In=7128319,Fn=.35;function Gn(){return new zn({color:In,transparent:!0,opacity:Fn,depthWrite:!1})}function Zn(o){let e=o.size;return new ir(e?.x??1,e?.y??1,e?.z??1)}function Nn(o,e){try{let t=o.create({position:Vn,props:e});if(!t||typeof t.then=="function")return null;let i=t,r=i.group??i.mesh??null;return r?r.clone():null}catch(t){return console.warn(`[zylem] placement ghost: the "${o.id}" factory failed, falling back to a box`,t),null}}function Hn(o,e){o.traverse(t=>{let i=t;i.isMesh&&(i.material=e,i.castShadow=!1,i.receiveShadow=!1)})}var Ge=class{scene;container;builtFor=null;builtProps=null;material=null;extent=null;bounds=new Ln;constructor(e){this.scene=e,this.container=new On,this.container.name="PlacementGhost",this.container.visible=!1,this.scene.add(this.container)}setType(e,t){let i=t??null;if(e===this.builtFor&&i===this.builtProps)return;if(this.builtFor=e,this.builtProps=i,this.clearSilhouette(),!e){this.hide();return}let r=he(e),n={...r?.defaultProps??{},...t??{}},a=(r?Nn(r,n):null)??new Bn(new An(...Zn(n).toArray()));a.position.set(0,0,0),this.material=Gn(),Hn(a,this.material),this.container.add(a),this.bounds.setFromObject(a),this.extent=this.bounds.isEmpty()?null:this.bounds.getSize(new ir)}measure(){return this.extent}showAt(e){if(this.container.children.length===0){this.hide();return}this.container.position.copy(e),this.container.visible=!0}hide(){this.container.visible=!1}dispose(){this.clearSilhouette(),this.scene.remove(this.container),this.builtFor=null,this.builtProps=null}clearSilhouette(){for(let e of[...this.container.children])this.container.remove(e),e.traverse(t=>{let i=t;i.isMesh&&i.geometry?.dispose()});this.material?.dispose(),this.material=null,this.extent=null}};import{Vector3 as xt}from"three";var Un=0;function jn(o,e){if(e)return{position:o.origin.clone().add(o.direction.clone().multiplyScalar(e.distance)),normal:new xt(e.normal[0],e.normal[1],e.normal[2])};if(Math.abs(o.direction.y)<1e-6)return null;let t=(Un-o.origin.y)/o.direction.y;return t<0?null:{position:o.origin.clone().add(o.direction.clone().multiplyScalar(t)),normal:new xt(0,1,0)}}function Wn(o,e){if(e.lengthSq()<1e-8)return 0;let t=e.clone().normalize();return(Math.abs(t.x)*o.x+Math.abs(t.y)*o.y+Math.abs(t.z)*o.z)/2}function Mt(o,e,t){let i=Wn(e,t);return i<=0?o.clone():o.clone().add(t.clone().normalize().multiplyScalar(i))}function Tt(o,e,t,i){let r=jn(o,e);if(!r)return null;let{normal:n}=r,s=t.enabled?ue(r.position,t.translate):r.position,a=new xt(s.x,s.y,s.z);return{position:i?Mt(a,i,n):a,normal:n}}import{Box3 as Yn,Quaternion as Ue,Vector3 as S}from"three";import{nanoid as $n}from"nanoid";import{Vector3 as H}from"three";var kt=.95,qn=16,se=new H,Kn=new H,rr=new H,Rt=new H;function nr(o){return o?o.isPerspectiveCamera===!0||o.isOrthographicCamera===!0:!1}function Ze(o,e,t=kt){return se.copy(o).project(e),Math.abs(se.x)<=t&&Math.abs(se.y)<=t&&se.z>=-1&&se.z<=1}function or(o){let e=0,t=1;for(let i=0;i<qn;i+=1){let r=(e+t)/2;o(r)?e=r:t=r}return e}function sr(o,e,t,i=kt){if(!nr(t))return e.clone();let r=t;if(Ze(e,r,i)||!Ze(o,r,i))return e.clone();let n=or(s=>Ze(Kn.copy(o).lerp(e,s),r,i));return o.clone().lerp(e,n)}function ar(o,e,t,i,r=kt){if(!nr(i)||t.x<=1&&t.y<=1&&t.z<=1||o.isEmpty())return t.clone();let n=i;rr.copy(e);let s=new H(1,1,1),a=c=>(s.set(1+(t.x-1)*c,1+(t.y-1)*c,1+(t.z-1)*c),Qn(o,rr,s,n,r));if(a(1))return t.clone();let l=or(a);return new H(1+(t.x-1)*l,1+(t.y-1)*l,1+(t.z-1)*l)}function Qn(o,e,t,i,r){for(let n=0;n<8;n+=1)if(Rt.set(n&1?o.max.x:o.min.x,n&2?o.max.y:o.min.y,n&4?o.max.z:o.min.z),Rt.sub(e).multiply(t).add(e),!Ze(Rt,i,r))return!1;return!0}var Xn={translate:"Move",rotate:"Rotate",scale:"Scale"};function _t(o){let e=typeof o?.getPose=="function"?o.getPose():null,t=o?.group??o?.mesh,i=e?.position??(t?{x:t.position.x,y:t.position.y,z:t.position.z}:null)??{x:0,y:0,z:0},r=e?.rotation??{x:0,y:0,z:0,w:1},n=typeof o?.getScale=="function"?o.getScale():{x:1,y:1,z:1};return{position:new S(i.x,i.y,i.z),quaternion:new Ue(r.x,r.y,r.z,r.w),scale:new S(n.x,n.y,n.z)}}function lr(o){let e=lt(o.quaternion);return{position:{x:o.position.x,y:o.position.y,z:o.position.z},rotation:e,quaternion:{x:o.quaternion.x,y:o.quaternion.y,z:o.quaternion.z,w:o.quaternion.w},scale:{x:o.scale.x,y:o.scale.y,z:o.scale.z}}}function Jn(o,e){return o.position.distanceToSquared(e.position)>1e-5*1e-5||Math.abs(o.quaternion.dot(e.quaternion))<1-1e-5||o.scale.distanceToSquared(e.scale)>1e-5*1e-5}function Ne(o,e){(e.position||e.quaternion)&&o.setPose?.({position:e.position?{x:e.position.x,y:e.position.y,z:e.position.z}:void 0,rotation:e.quaternion?{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}:void 0}),e.scale&&o.setScale?.(e.scale.x,e.scale.y,e.scale.z)}function eo(o){let e=o?.group??o?.mesh;if(!e?.isObject3D)return null;let t=new Yn().setFromObject(e);return t.isEmpty()?null:t}var Dt=.02,Lt=50;function to(o){return new S(At(o.x,Dt,Lt),At(o.y,Dt,Lt),At(o.z,Dt,Lt))}function At(o,e,t){return Math.min(Math.max(o,e),t)}var Ot=new Ue,io=new S,He=class{gizmo=new yi;context;mode=null;session=null;pausedBeforeEntry=null;constructor(e){this.context=e}setMode(e){if(this.mode!==e){if(e&&this.pausedBeforeEntry===null?(this.pausedBeforeEntry=p.paused,p.paused=!0):!e&&this.pausedBeforeEntry!==null&&(p.paused=this.pausedBeforeEntry,this.pausedBeforeEntry=null),this.mode=e,this.cancelDrag(),!e){this.gizmo.hide();return}this.gizmo.setMode(e)}}getMode(){return this.mode}get isDragging(){return this.session!==null}update(){let e=this.context.getScene();if(e&&this.gizmo.addTo(e),!this.mode){this.gizmo.hide();return}if(!this.session){let i=this.selectionPivot();if(!i){this.gizmo.hide();return}this.gizmo.show(i)}let t=this.context.getCamera();t&&this.gizmo.update(t)}hover(e){if(!this.mode||this.session)return null;let t=this.gizmo.pick(e);return this.gizmo.setHighlight(t),t}pointerDown(e){if(!this.mode)return!1;let t=this.context.getCamera();if(!t)return!1;let i=this.gizmo.pick(e);if(!i||!this.gizmo.beginDrag(i,e,t))return!1;let r=[];for(let n of p.selectedEntityIds){let s=this.context.resolveEntity(n);s&&r.push({uuid:n,entity:s,start:_t(s),startBounds:this.mode==="scale"?eo(s):null})}return r.length?(this.session={mode:this.mode,axis:i,entries:r,pivotStart:this.gizmo.pivot.clone(),changed:!1},!0):(this.gizmo.endDrag(),!1)}pointerMove(e,t){let i=this.session;if(!i)return;let r=this.context.getCamera();if(!r)return;let n=this.gizmo.updateDrag(e,r);if(!n)return;let s=V(),a=s.enabled&&!t;switch(n.kind){case"translate":this.applyTranslate(i,n.offset,a?s.translate:0,r);break;case"rotate":this.applyRotate(i,n.axis,n.angle,a?s.rotate:0);break;case"scale":this.applyScale(i,n.factor,a?s.scale:0,r);break}i.changed=!0}pointerUp(){let e=this.session;if(this.session=null,this.gizmo.endDrag(),!e)return;let t=[];for(let i of e.entries){let r=_t(i.entity);Jn(i.start,r)&&(e.mode==="scale"&&ct(i.entity),t.push({uuid:i.uuid,before:lr(i.start),after:lr(r)}))}t.length&&j({opId:$n(10),kind:"transform",label:this.describeOperation(e),entries:t})}cancelDrag(){this.session=null,this.gizmo.endDrag()}dispose(){this.cancelDrag(),this.pausedBeforeEntry!==null&&(p.paused=this.pausedBeforeEntry,this.pausedBeforeEntry=null),this.gizmo.dispose()}applyTranslate(e,t,i,r){let n=io.copy(e.pivotStart).add(t),s=sr(e.pivotStart,n,r),a=i>0?ue(s,i):s,l=new S(a.x-e.pivotStart.x,a.y-e.pivotStart.y,a.z-e.pivotStart.z);for(let c of e.entries)Ne(c.entity,{position:c.start.position.clone().add(l)})}applyRotate(e,t,i,r){let n=e.axis;for(let s of e.entries){Ot.setFromAxisAngle(t,i);let a=Ot.clone().multiply(s.start.quaternion),l=a;if(r>0&&(n==="x"||n==="y"||n==="z")){let d=lt(a);d[n]=$t(d[n],r);let u=at(d);l=new Ue(u.x,u.y,u.z,u.w)}let c=s.start.position.clone().sub(e.pivotStart).applyQuaternion(Ot).add(e.pivotStart);Ne(s.entity,{position:c,quaternion:l})}}applyScale(e,t,i,r){for(let n of e.entries){let s=n.startBounds?ar(n.startBounds,n.start.position,t,r):t,a=to(s),l=new S(n.start.scale.x*a.x,n.start.scale.y*a.y,n.start.scale.z*a.z),c=i>0?Xt(l,i):l;Ne(n.entity,{scale:new S(c.x,c.y,c.z)})}}describeOperation(e){let t=Xn[e.mode];if(e.entries.length>1)return`${t} ${e.entries.length} entities`;let i=e.entries[0]?.entity,r=i?.name||String(i?.constructor?.type??"").replace("Symbol(","").replace(")","")||"Entity";return`${t} ${r}`}selectionPivot(){let e=p.selectedEntityIds;if(!e.length)return null;let t=new S,i=0;for(let r of e){let n=this.context.resolveEntity(r);n&&(t.add(_t(n).position),i++)}return i?t.divideScalar(i):null}};function cr(o,e,t){for(let i of o.entries){let r=e==="undo"?i.before:i.after;if(!r)continue;let n=t(i.uuid);if(!n)continue;let s=r.quaternion??(r.rotation?at(r.rotation):void 0);Ne(n,{position:r.position?new S(r.position.x,r.position.y,r.position.z):void 0,quaternion:s?new Ue(s.x,s.y,s.z,s.w):void 0,scale:r.scale?new S(r.scale.x,r.scale.y,r.scale.z):void 0}),r.scale&&ct(n)}}var ro=200;function dr(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function no(o){return dr(o)&&(me(o)||ii(o))}var je=class{stage;snapshots=new Map;constructor(e){this.stage=e}applySwatches(e){let t=new Map,i=[],r=[];for(let n of e.uuids)for(let s of e.swatches){let{result:a,entry:l}=this.applyPair(n,s,t);i.push(a),l&&r.push(l)}return t.size>0&&this.remember(e.opId,t),{results:i,entries:r}}applySceneOperation(e,t){if(e.kind!=="swatch")return;let i=this.snapshots.get(e.opId);if(i){t==="undo"?this.undoFromSnapshot(i):this.redoFromSnapshot(i);return}if(t==="redo"){let r=new Map;for(let n of e.entries)n.swatch&&this.applyPair(n.uuid,n.swatch,r);r.size>0&&this.remember(e.opId,r);return}this.undoWithoutSnapshot(e)}hasSnapshot(e){return this.snapshots.has(e)}dispose(){for(let[e]of this.snapshots)this.forget(e)}applyPair(e,t,i){let r={uuid:e,kind:t.kind,source:t.source},n=this.stage.resolveEntity(e);if(!n)return{result:{...r,ok:!1,reason:"entity-not-found"}};if(!dr(t.props))return{result:{...r,ok:!1,reason:"invalid-props"}};let s=i.get(e)??{previousRefs:new Map,appliedRefs:new Map},a=t.kind==="shader"?this.applyShader(n,t,s):this.applyBehavior(n,t,s);return a.ok?(i.set(e,s),{result:{...r,ok:!0,replaced:a.replaced},entry:{uuid:e,swatch:t,...a.replacedSpec?{replaced:a.replacedSpec}:{}}}):{result:{...r,ok:!1,reason:a.reason}}}applyShader(e,t,i){let r=fe("shader",t.source);if(!r)return{ok:!1,reason:"unknown-source"};if(!e.hasMaterial())return{ok:!1,reason:"no-material"};let n;try{n=r.create(t.props)}catch(a){return console.warn(`[zylem] swatch shader "${t.source}" threw`,a),{ok:!1,reason:"invalid-props"}}if(!no(n))return{ok:!1,reason:"invalid-props"};let s=e.setMaterial({shader:n},{disposePrevious:!1});return s?(i.previousMaterials?Bt(s,i.previousMaterials):i.previousMaterials=s,{ok:!0,replaced:!1}):{ok:!1,reason:"no-material"}}applyBehavior(e,t,i){let r=fe("behavior",t.source);if(!r)return{ok:!1,reason:"unknown-source"};let{descriptor:n}=r,s=n.key,a=!1,l,c=e.getBehaviorRef(n);c&&(e.removeBehavior(c),this.stage.detachBehaviorLink(e,c),i.appliedRefs.get(s)===c||(a=!0,l={source:t.source,props:{...c.options}},i.previousRefs.has(s)||i.previousRefs.set(s,c)));let d;try{e.use(n,t.props),d=e.getBehaviorRefs().at(-1)}catch(u){console.warn(`[zylem] swatch behavior "${t.source}" failed to attach`,u)}return!d||d.descriptor.key!==s?(c&&(e.restoreBehaviorRef(c),this.stage.attachBehaviorLink(e,c),i.previousRefs.get(s)===c&&i.previousRefs.delete(s)),{ok:!1,reason:"invalid-props"}):(this.stage.attachBehaviorLink(e,d),i.appliedRefs.set(s,d),{ok:!0,replaced:a,replacedSpec:l})}undoFromSnapshot(e){for(let[t,i]of[...e].reverse()){let r=this.stage.resolveEntity(t);if(r){if(i.previousMaterials){let n=r.replaceMaterials(i.previousMaterials,{disposePrevious:!1});n&&(i.redoMaterials=n)}for(let n of i.appliedRefs.values())r.removeBehavior(n)&&this.stage.detachBehaviorLink(r,n);for(let n of i.previousRefs.values())r.restoreBehaviorRef(n),this.stage.attachBehaviorLink(r,n)}}}redoFromSnapshot(e){for(let[t,i]of e){let r=this.stage.resolveEntity(t);if(r){i.redoMaterials&&r.replaceMaterials(i.redoMaterials,{disposePrevious:!1});for(let n of i.previousRefs.values())r.removeBehavior(n)&&this.stage.detachBehaviorLink(r,n);for(let n of i.appliedRefs.values())r.restoreBehaviorRef(n),this.stage.attachBehaviorLink(r,n)}}}undoWithoutSnapshot(e){for(let t of[...e.entries].reverse()){let i=this.stage.resolveEntity(t.uuid);if(!(!i||!t.swatch)){if(t.swatch.kind==="behavior"){let r=fe("behavior",t.swatch.source);if(!r)continue;let n=i.removeBehavior(r.descriptor);if(n&&this.stage.detachBehaviorLink(i,n),t.replaced){i.use(r.descriptor,t.replaced.props);let s=i.getBehaviorRefs().at(-1);s&&this.stage.attachBehaviorLink(i,s)}continue}i.setMaterial({})}}}remember(e,t){for(this.snapshots.has(e)&&this.forget(e),this.snapshots.set(e,t);this.snapshots.size>ro;){let i=this.snapshots.keys().next().value;if(i===void 0)break;this.forget(i)}}forget(e){let t=this.snapshots.get(e);if(this.snapshots.delete(e),!!t)for(let[i,r]of t){let n=this.stage.resolveEntity(i)?.getMaterials()??[];Bt(r.previousMaterials??[],n),Bt(r.redoMaterials??[],n)}}};function Bt(o,e){for(let t of o)e.includes(t)||t.dispose()}import{Box3 as lo,Frustum as co,Vector2 as qe}from"three";import{Frustum as oo,Vector2 as pr,Vector3 as so}from"three";var ur=Array.from({length:8},()=>new so),g=new pr,y=new pr;function hr(o,e,t,i=new oo){g.set(Math.min(e.x,t.x),Math.min(e.y,t.y)),y.set(Math.max(e.x,t.x),Math.max(e.y,t.y));let r=1e-5;y.x-g.x<r&&(y.x=g.x+r),y.y-g.y<r&&(y.y=g.y+r),_(0,g.x,g.y,-1,o),_(1,y.x,g.y,-1,o),_(2,y.x,y.y,-1,o),_(3,g.x,y.y,-1,o),_(4,g.x,g.y,1,o),_(5,y.x,g.y,1,o),_(6,y.x,y.y,1,o),_(7,g.x,y.y,1,o);let[n,s,a,l,c,d,u,f]=ur,z=i.planes;return U(z[0],n,c,f),U(z[1],s,u,d),U(z[2],l,f,u),U(z[3],n,d,c),U(z[4],n,l,a),U(z[5],c,u,f),i}function _(o,e,t,i,r){ur[o].set(e,t,i).unproject(r)}function U(o,e,t,i){o.setFromCoplanarPoints(e,t,i)}function mr(o,e){return e.isEmpty()||!Number.isFinite(e.min.x)||!Number.isFinite(e.max.x)?!1:o.intersectsBox(e)}function fr(o,e,t){switch(t){case"add":{let i=new Set(o),r=[...o];for(let n of e)i.has(n)||(i.add(n),r.push(n));return r}case"subtract":{let i=new Set(e);return o.filter(r=>!i.has(r))}default:return[...new Set(e)]}}function gr(o){return o.altKey?"subtract":o.shiftKey?"add":"replace"}var ao="[data-zylem-overlay-root]";function yr(o){let e=o.parentElement;return e?e.querySelector(ao)??e:null}var We=class{element=null;host=null;show(e,t){let i=this.ensureElement(e);i.style.left=`${t.left}px`,i.style.top=`${t.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`,i.style.display="block"}hide(){this.element&&(this.element.style.display="none")}dispose(){this.element?.remove(),this.element=null,this.host=null}ensureElement(e){if(this.element&&this.host===e)return this.element;this.element?.remove();let t=document.createElement("div");t.dataset.zylemMarquee="true";let i=t.style;return i.position="absolute",i.pointerEvents="none",i.boxSizing="border-box",i.border="1px solid rgba(34, 255, 34, 0.9)",i.background="rgba(34, 255, 34, 0.12)",i.display="none",i.zIndex="20",e.appendChild(t),this.element=t,this.host=e,t}};var po=4,uo=new lo,vr=new co,Ke=class{context;overlay=new We;armed=!1;dragging=!1;mode="replace";baseSelection=[];startNdc=new qe;currentNdc=new qe;startClient=new qe;currentClient=new qe;host=null;constructor(e){this.context=e}get isArmed(){return this.armed}get isDragging(){return this.dragging}pointerDown(e,t,i){this.armed=!0,this.dragging=!1,this.mode=gr(t),this.baseSelection=[...p.selectedEntityIds],this.startNdc.copy(e),this.currentNdc.copy(e),this.startClient.set(t.clientX,t.clientY),this.currentClient.copy(this.startClient),this.host=yr(i)}pointerMove(e,t){if(!this.armed)return!1;this.currentNdc.copy(e),this.currentClient.set(t.clientX,t.clientY);let i=!1;if(!this.dragging){if(this.currentClient.distanceTo(this.startClient)<po)return!1;this.dragging=!0,i=!0}return this.drawOverlay(),i}pointerUp(e){if(!this.armed)return"idle";let t=this.dragging;return this.currentNdc.copy(e),this.reset(),t?(this.commit(),"marquee"):"click"}cancel(){this.reset()}dispose(){this.reset(),this.overlay.dispose()}reset(){this.armed=!1,this.dragging=!1,this.overlay.hide()}drawOverlay(){if(!this.host)return;let e=this.host.getBoundingClientRect(),t=Math.min(this.startClient.x,this.currentClient.x)-e.left,i=Math.min(this.startClient.y,this.currentClient.y)-e.top;this.overlay.show(this.host,{left:t,top:i,width:Math.abs(this.currentClient.x-this.startClient.x),height:Math.abs(this.currentClient.y-this.startClient.y)})}commit(){let e=this.context.getCamera();if(!e)return;hr(e,this.startNdc,this.currentNdc,vr);let t=[];this.context.forEachEntity((i,r)=>{let n=K(r,uo);n&&mr(vr,n)&&t.push(i)}),Zt(fr(this.baseSelection,t,this.mode))}};import{BoxGeometry as ho,EdgesGeometry as mo,Group as fo,LineBasicMaterial as go,LineSegments as yo,Vector3 as Cr}from"three";var Qe=new Cr,br=new Cr,Ye=class{scene;container=new fo;edges;material;pool=[];constructor(e,t=16765503){this.scene=e;let i=new ho(1,1,1);this.edges=new mo(i),i.dispose(),this.material=new go({color:t,depthTest:!1,transparent:!0,opacity:.9}),this.container.name="SelectionHighlight",this.container.renderOrder=999,this.scene.add(this.container)}setColor(e){this.material.color.set(e)}update(e){let t=0;for(let i of e){if(i.isEmpty()||!Number.isFinite(i.min.x)||!Number.isFinite(i.max.x))continue;i.getSize(Qe),i.getCenter(br);let r=this.acquire(t);t+=1,r.position.copy(br),r.scale.set(Math.max(Qe.x,1e-6),Math.max(Qe.y,1e-6),Math.max(Qe.z,1e-6)),r.visible=!0}for(let i=t;i<this.pool.length;i+=1)this.pool[i].visible=!1}hide(){for(let e of this.pool)e.visible=!1}dispose(){this.scene.remove(this.container),this.edges.dispose(),this.material.dispose(),this.pool.length=0}acquire(e){let t=this.pool[e];if(t)return t;let i=new yo(this.edges,this.material);return i.frustumCulled=!1,this.container.add(i),this.pool.push(i),i}};var wr=2293538,Eo=16724787,zt=new Vt,Er=new It,$e=class{stage;options;mouseNdc=new Po(-2,-2);raycaster=new So;domDisposeFns=[];domListenersAttached=!1;debugCursor=null;placementGhost=null;debugLines=null;debugStateUnsubscribe=null;focusContextUnregister=null;entityResolverUnregister=null;lastDebugEnabled=null;warnedMissingAddFactory=!1;transformTool;swatchApplier;marquee;selectionHighlight=null;selectionBoundsPool=[];hoverBounds=new Vt;grid=new gi;lastTool=null;capturedPointer=null;constructor(e,t){this.stage=e,this.options={maxRayDistance:t?.maxRayDistance??5e3,addEntityFactory:t?.addEntityFactory??null},this.transformTool=new He({getScene:()=>this.stage.scene?.scene??null,getCamera:()=>this.getDebugViewCamera()?.camera??null,resolveEntity:i=>this.resolveEntity(i)}),this.swatchApplier=new je({resolveEntity:i=>this.resolveEntity(i),attachBehaviorLink:(i,r)=>this.stage.entityDelegate.attachBehaviorLink(i,r),detachBehaviorLink:(i,r)=>this.stage.entityDelegate.detachBehaviorLink(i,r)}),this.marquee=new Ke({getCamera:()=>this.getDebugViewCamera()?.camera??null,forEachEntity:i=>this.forEachSelectableEntity(i)}),this.syncWithDebugState(),this.debugStateUnsubscribe=wo(p,()=>{this.syncWithDebugState()}),this.entityResolverUnregister=Gt(i=>this.resolveEntity(i)),this.focusContextUnregister=Yt({resolveEntity:i=>this.resolveEntity(i),frameObject:i=>{let r=this.stage.cameraManagerRef,n=()=>{r&&!r.isEditorViewActive()&&r.hasEditorCameras()&&r.activateCameraById(D.free),this.getDebugViewCamera()?.frameObject(i)};if(r&&pe()&&!r.hasEditorCameras()){r.ensureEditorCameras().then(n);return}n()},ensureDebugReady:()=>{p.enabled||(p.enabled=!0),this.lastDebugEnabled=!0,this.activate()}})}setAddEntityFactory(e){this.options.addEntityFactory=e,this.warnedMissingAddFactory=!1}getDebugViewCamera(){return this.stage.cameraManagerRef?.primaryCamera??this.stage.cameraRef??null}resolveEntity(e){let t=this.stage.entityDelegate.debugMap.get(e);if(t)return t;let i=this.stage.entityDelegate.childrenMap.get(e);return i||(this.stage.world?.collisionMap.get(e)??null)}forEachSelectableEntity(e){let t=new Set,i=(r,n)=>{t.has(n)||(t.add(n),e(n,r))};this.stage.entityDelegate.childrenMap.forEach(i),this.stage.entityDelegate.debugMap.forEach(i)}populateDebugMap(){this.stage.entityDelegate.childrenMap.forEach((e,t)=>{this.stage.entityDelegate.debugMap.set(t,e)})}syncWithDebugState(){this.syncToolMode(),this.syncGrid();let e=p.enabled;e!==this.lastDebugEnabled&&(this.lastDebugEnabled=e,e?this.activate():this.deactivate())}syncToolMode(){let e=p.tool;if(e===this.lastTool)return;this.lastTool=e,this.marquee.isArmed&&(this.marquee.cancel(),this.endPointerCapture()),e!=="none"&&(this.ensureInteraction(),this.populateDebugMap()),this.parkToolVisuals(e);let t=nt(e);this.getDebugViewCamera()?.setOrbitFollowEnabled(!t),this.transformTool.setMode(t?e:null)}syncGrid(){let e=this.stage.scene?.scene;e&&(this.grid.addTo(e),this.grid.setIncrement(V().translate),this.grid.setVisible(p.gridVisible))}activate(){this.domListenersAttached||(this.domListenersAttached=this.attachDomListeners()),this.populateDebugMap(),this.rebindPostProcessing(this.getDebugViewCamera()),document.pointerLockElement&&document.exitPointerLock()}deactivate(){this.disposeDebugVisuals(),this.transformTool.cancelDrag(),this.grid.setVisible(!1),this.rebindPostProcessing(this.getDebugViewCamera())}rebindPostProcessing(e){let t=this.stage.scene?.scene,i=this.stage.rendererManager;t&&i&&e&&i.setupPostProcessing(t,e.camera)}initDebugVisuals(){this.debugLines||!this.stage.scene||(this.debugLines=new Co(new vo,new bo({vertexColors:!0})),this.stage.scene.scene.add(this.debugLines),this.debugLines.visible=!0)}disposeDebugVisuals(){this.debugLines&&this.stage.scene&&(this.stage.scene.scene.remove(this.debugLines),this.debugLines.geometry.dispose(),this.debugLines.material.dispose(),this.debugLines=null)}ensureToolVisuals(){let e=this.stage.scene?.scene;e&&(this.debugCursor??=new Fe(e),this.placementGhost??=new Ge(e),this.selectionHighlight??=new Ye(e))}updateSelectionHighlight(){let e=this.selectionHighlight;if(!e)return;let t=p.selectedEntityIds;if(t.length===0){e.hide();return}let i=[];for(let r of t){let n=this.resolveEntity(r),s=this.selectionBoundsPool[i.length]??=new Vt,a=K(n,s);a&&i.push(a)}e.update(i)}parkToolVisuals(e){e!=="add"&&this.placementGhost?.hide(),e!=="select"&&e!=="delete"&&!p.pickMode&&this.debugCursor?.hide(),e==="none"&&!p.enabled&&this.selectionHighlight?.hide()}disposeToolVisuals(){this.debugCursor?.dispose(),this.debugCursor=null,this.placementGhost?.dispose(),this.placementGhost=null,this.selectionHighlight?.dispose(),this.selectionHighlight=null}update(){let e=this.getDebugViewCamera();if(!this.stage.scene||!this.stage.world||!e)return;let{world:t}=this.stage,i=le();if(this.ensureInteraction(),this.ensureToolVisuals(),p.enabled?(this.initDebugVisuals(),this.updateColliderWireframes(t)):this.disposeDebugVisuals(),this.updatePlacementGhost(i,t),this.updateSelectionHighlight(),nt(i)){this.debugCursor?.hide(),this.transformTool.update(),this.transformTool.isDragging||this.transformTool.hover(this.currentRay());return}if(this.transformTool.update(),!(i==="select"||i==="delete"||p.pickMode)){this.debugCursor?.hide();return}let n=this.currentRay(),s=t.raycast(n.origin,n.direction,this.options.maxRayDistance);s?st(s.uuid??null):de();let a=Ut();if(!a){this.debugCursor?.hide();return}let l=K(this.resolveEntity(a),this.hoverBounds);if(!l){this.debugCursor?.hide();return}switch(i){case"select":this.debugCursor?.setColor(wr);break;case"delete":this.debugCursor?.setColor(Eo);break;default:this.debugCursor?.setColor(p.pickMode?wr:16777215);break}this.debugCursor?.updateFromBounds(l)}pickAtNdc(e,t,i={}){let r=i.updateHover??p.pickMode;this.mouseNdc.set(e,t);let n=this.stage.world;if(!n||!this.getDebugViewCamera())return r&&de(),null;let s=this.currentRay(),l=n.raycast(s.origin,s.direction,this.options.maxRayDistance)?.uuid??null;if(!l)return r&&de(),null;r&&st(l);let c=this.resolveEntity(l);return{uuid:l,name:c?.name??""}}applySwatches(e){return this.swatchApplier.applySwatches(e)}updateColliderWireframes(e){if(!this.debugLines)return;let t=e.simulation.getDebugRender();t&&t.vertices.length>0?(this.debugLines.geometry.setAttribute("position",new Sr(new Float32Array(t.vertices),3)),this.debugLines.geometry.setAttribute("color",new Sr(new Float32Array(t.colors),4)),this.debugLines.geometry.attributes.position.needsUpdate=!0,this.debugLines.geometry.attributes.color.needsUpdate=!0,this.debugLines.visible=!0):this.debugLines.visible=!1}ensureInteraction(){this.domListenersAttached||!ce()||(this.domListenersAttached=this.attachDomListeners())}updatePlacementGhost(e,t){let i=this.placementGhost;if(!i)return;let r=p.addTypeId;if(e!=="add"||!r){i.hide();return}i.setType(r,p.addTypeProps??null);let n=this.currentRay(),s=t.raycast(n.origin,n.direction,this.options.maxRayDistance)??null,a=Tt(n,s,V(),i.measure());if(!a){i.hide();return}i.showAt(a.position)}dispose(){this.focusContextUnregister?.(),this.focusContextUnregister=null,this.entityResolverUnregister?.(),this.entityResolverUnregister=null,this.debugStateUnsubscribe?.(),this.debugStateUnsubscribe=null,this.endPointerCapture(),this.marquee.dispose(),this.transformTool.dispose(),this.swatchApplier.dispose(),this.grid.dispose(),this.deactivate(),this.disposeToolVisuals(),this.domDisposeFns.forEach(e=>e()),this.domDisposeFns=[],this.domListenersAttached=!1}applySceneOperation(e,t){let i=t==="undo";switch(e.kind){case"transform":cr(e,t,r=>this.resolveEntity(r));break;case"create":for(let r of e.entries)i?this.stage.entityDelegate.detachEntity(r.uuid):this.stage.entityDelegate.restoreEntity(r.uuid);break;case"delete":for(let r of e.entries)i?this.stage.entityDelegate.restoreEntity(r.uuid):this.stage.entityDelegate.detachEntity(r.uuid);break;case"swatch":this.swatchApplier.applySceneOperation(e,t);break}}currentRay(){let e=this.getDebugViewCamera();return e?(this.raycaster.setFromCamera(this.mouseNdc,e.camera),{origin:this.raycaster.ray.origin.clone(),direction:this.raycaster.ray.direction.clone().normalize()}):{origin:new It,direction:new It(0,0,-1)}}handleAction(e,t={shiftKey:!1,altKey:!1}){let i=le();if(i!=="select"&&i!=="delete"&&i!=="add")return;let n=this.stage.world?.raycast(e.origin,e.direction,this.options.maxRayDistance)??null;switch(i){case"select":{let s=n?.uuid??null,a=s&&this.resolveEntity(s)?s:null;t.altKey?a&&Nt([a]):t.shiftKey?a&&Ht(a):a?ot(a):ot(null);break}case"delete":{let s=n?.uuid??null;if(!s)break;this.stage.entityDelegate.detachEntity(s)&&j({opId:Pr(10),kind:"delete",label:"Delete entity",entries:[{uuid:s}]});break}case"add":this.placeEntity(e,n);break}}placeEntity(e,t){let i=Tt(e,t,V());if(!i)return;let{position:r,normal:n}=i,s=p.addTypeId?he(p.addTypeId):null;if(!s&&!this.options.addEntityFactory){this.warnMissingAddSource();return}let a=s?s.create({position:{x:r.x,y:r.y,z:r.z},normal:{x:n.x,y:n.y,z:n.z},props:{...s.defaultProps??{},...p.addTypeProps??{}}}):this.options.addEntityFactory({position:r,normal:n});a&&Promise.resolve(a).then(async l=>{l&&(await this.stage.entityDelegate.spawnEntity(l),this.restOnSurface(l,r,n),j({opId:Pr(10),kind:"create",label:`Add ${s?.label??"entity"}`,entries:[{uuid:l.uuid}]}))}).catch(l=>{console.error("Add tool: failed to spawn entity",l)})}restOnSurface(e,t,i){let r=e?.group??e?.mesh;if(!r||typeof e.setPose!="function"||(zt.setFromObject(r),zt.isEmpty()))return;zt.getSize(Er);let n=Mt(t,Er,i);n.equals(t)||e.setPose({position:{x:n.x,y:n.y,z:n.z}})}warnMissingAddSource(){if(this.warnedMissingAddFactory)return;this.warnedMissingAddFactory=!0;let e="Add tool: no entity type is armed and no `addEntityFactory` is configured, so there is nothing to spawn.";console.warn(e),Jt("warn",e)}attachDomListeners(){let e=this.stage.rendererManager?.getDomElement();if(!e)return!1;let t=a=>{let l=e.getBoundingClientRect(),c=(a.clientX-l.left)/l.width*2-1,d=-((a.clientY-l.top)/l.height*2-1);this.mouseNdc.set(c,d)},i=a=>{if(t(a),this.marquee.isArmed){this.marquee.pointerMove(this.mouseNdc,a);return}this.transformTool.isDragging&&this.transformTool.pointerMove(this.currentRay(),a.altKey)},r=a=>{if(a.button!==0)return;t(a);let l=this.currentRay();if(this.transformTool.pointerDown(l)){this.beginPointerCapture(e,a.pointerId);return}if(le()==="select"){this.marquee.pointerDown(this.mouseNdc,a,e),this.beginPointerCapture(e,a.pointerId);return}this.handleAction(l,a)},n=a=>{if(this.marquee.isArmed){let l=this.marquee.pointerUp(this.mouseNdc);this.endPointerCapture(),l==="click"&&this.handleAction(this.currentRay(),a);return}this.transformTool.isDragging&&(this.transformTool.pointerUp(),this.endPointerCapture())},s=a=>{if(this.marquee.isArmed){this.marquee.cancel(),this.endPointerCapture();return}n(a)};return e.addEventListener("pointermove",i),e.addEventListener("pointerdown",r),e.addEventListener("pointerup",n),e.addEventListener("pointercancel",s),this.domDisposeFns.push(()=>e.removeEventListener("pointermove",i),()=>e.removeEventListener("pointerdown",r),()=>e.removeEventListener("pointerup",n),()=>e.removeEventListener("pointercancel",s)),!0}beginPointerCapture(e,t){this.getDebugViewCamera()?.setOrbitInteractionEnabled(!1);try{e.setPointerCapture(t),this.capturedPointer={element:e,pointerId:t}}catch{this.capturedPointer=null}}endPointerCapture(){if(this.getDebugViewCamera()?.setOrbitInteractionEnabled(!0),!!this.capturedPointer){try{this.capturedPointer.element.releasePointerCapture(this.capturedPointer.pointerId)}catch{}this.capturedPointer=null}}};import{Vector2 as xo}from"three";var Xe=class{stage;constructor(e){this.stage=e}createDefaultCamera(){let e=window.innerWidth,t=window.innerHeight,i=new xo(e,t);return new x(m.ThirdPerson,i)}resolveCamera(e,t){return e||(t?t.cameraRef:this.createDefaultCamera())}buildCameraManager(e,...t){let i=new Le;if(e)return i.addCamera(e,e.name||"main"),i;let r=t.filter(n=>n!==void 0);if(r.length>0){for(let n of r){let s=n.cameraRef;i.addCamera(s,s.name||void 0)}for(let n=1;n<r.length;n++)i.addActiveCamera(r[n].cameraRef)}else{let n=this.createDefaultCamera();i.addCamera(n,"default")}return i}};var Je=class{loadingHandlers=[];stageName;stageIndex;setStageContext(e,t){this.stageName=e,this.stageIndex=t}onLoading(e){return this.loadingHandlers.push(e),()=>{this.loadingHandlers=this.loadingHandlers.filter(t=>t!==e)}}emit(e){for(let i of this.loadingHandlers)try{i(e)}catch(r){console.error("Loading handler failed",r)}let t={...e,stageName:this.stageName,stageIndex:this.stageIndex};e.type==="start"?ae.emit("stage:loading:start",t):e.type==="progress"?ae.emit("stage:loading:progress",t):e.type==="complete"&&ae.emit("stage:loading:complete",t)}emitStart(e="Loading stage..."){this.emit({type:"start",message:e,progress:0})}emitProgress(e,t,i){let r=i>0?t/i:0;this.emit({type:"progress",message:e,progress:r,current:t,total:i})}emitComplete(e="Stage loaded"){this.emit({type:"complete",message:e,progress:1})}dispose(){this.loadingHandlers=[]}};var et=class{scene=null;onEntityReady=null;pendingEntities=new Map;modelLoadedHandler=null;attach(e,t){this.scene=e,this.onEntityReady=t??null,this.modelLoadedHandler=i=>{this.handleModelLoaded(i.entityId,i.success)},T.on("entity:model:loaded",this.modelLoadedHandler)}observe(e){if(e.group||e.mesh){Y(e.options)||(this.scene?.addEntityGroup(e),q(e),F(e),this.onEntityReady?.(e));return}this.pendingEntities.set(e.uuid,e)}unobserve(e){this.pendingEntities.delete(e)}handleModelLoaded(e,t){let i=this.pendingEntities.get(e);if(!i||!t){this.pendingEntities.delete(e);return}this.scene?.addEntityGroup(i),q(i),F(i),Y(i.options)||this.onEntityReady?.(i),this.pendingEntities.delete(e)}dispose(){this.modelLoadedHandler&&(T.off("entity:model:loaded",this.modelLoadedHandler),this.modelLoadedHandler=null),this.pendingEntities.clear(),this.onEntityReady=null,this.scene=null}};import{StageBodyKind as xr}from"@zylem/behaviors/core";var Mo=200,tt=class o{static EMPTY_BEHAVIOR_LINKS=[];children=[];childrenMap=new Map;debugMap=new Map;detachedMap=new Map;pendingEntities=[];pendingPromises=[];_isLoaded=!1;entityAddedHandlers=[];behaviorSystems=[];behaviorSystemByKey=new Map;registeredSystemKeys=new Set;behaviorEntityIndex=new Map;behaviorLinksByUuid=new Map;scene=null;world=null;renderStrategy=null;camera=null;wasmStage=null;loadingDelegate;entityModelDelegate;constructor(e,t){this.loadingDelegate=e,this.entityModelDelegate=t}get isLoaded(){return this._isLoaded}set isLoaded(e){this._isLoaded=e}attach(e){this.scene=e.scene,this.world=e.world,this.renderStrategy=e.renderStrategy,this.camera=e.camera,this.wasmStage=e.world.simulation.adapter}async spawnEntity(e){if(!this.scene||!this.world)return;if(e instanceof oe){e.create();for(let i of e.getChildren())i instanceof W&&await this.spawnEntity(i);e.nodeSetup({me:e,globals:v(),camera:this.camera}),this.addEntityToStage(e);return}let t=e.create();oi(t),this.registerBehaviorLinks(t),this.ensureEnvironmentStatic(t),this.maybeAttachEntityPhysics(t);for(let i of e.getChildren())i instanceof W&&await this.spawnEntity(i);e.nodeSetup({me:e,globals:v(),camera:this.camera}),this.tryRegisterRenderStrategy(t),L(t)||this.scene.addEntityGroup(t),F(t),this.addEntityToStage(t),this.entityModelDelegate.observe(t),si(t)}handleLateModelReady(e){!this.world||!this.scene||!this.childrenMap.has(e.uuid)||(this.ensureEnvironmentStatic(e),this.maybeAttachEntityPhysics(e),this.tryRegisterRenderStrategy(e),L(e)||this.scene.addEntityGroup(e),F(e))}tryRegisterRenderStrategy(e){this.renderStrategy&&this.renderStrategy.register(e)}ensureEnvironmentStatic(e){if(Q(e.options)!=="environment")return;let t=e.options.collision??{};t.static!==!0&&(console.warn(`category 'environment' forces static collision for entity '${e.name||e.uuid}'`),e.options.collision={...t,static:!0}),e.bodyDesc&&e.bodyDesc.kind!==xr.Static&&(e.bodyDesc.kind=xr.Static)}maybeAttachEntityPhysics(e){if(!(!this.world||e.physicsAttached||!e.colliderDesc)){if(e instanceof ge){if(e.needsDeferredModelCollision())return;e.synchronizeRuntimeCollider()}this.world.addEntity(e)}}addEntityToStage(e){this.childrenMap.set(e.uuid,e),p.enabled&&this.debugMap.set(e.uuid,e);for(let t of this.entityAddedHandlers)try{t(e)}catch(i){console.error("onEntityAdded handler failed",i)}}removeEntityByUuid(e){return this.detachEntity(e)}detachEntity(e){if(!this.scene||!this.world)return!1;let t=this.world.collisionMap.get(e),i=this.childrenMap.get(e),r=t??i??this.debugMap.get(e);if(!r)return!1;let n=typeof r.getPose=="function"?r.getPose():null;return this.unregisterBehaviorLinks(r),this.entityModelDelegate.unobserve(e),L(r)&&this.renderStrategy?.unregister(r),this.world.destroyEntity(r),r.group?this.scene.scene.remove(r.group):r.mesh&&this.scene.scene.remove(r.mesh),this.childrenMap.delete(e),this.debugMap.delete(e),this.detachedMap.set(e,{entity:r,position:n?.position??null,rotation:n?.rotation??null}),this.evictOldestDetached(),T.emit("entity:destroyed",{entityId:e}),!0}restoreEntity(e){if(!this.scene||!this.world)return!1;let t=this.detachedMap.get(e);if(!t)return!1;this.detachedMap.delete(e);let{entity:i,position:r,rotation:n}=t;return i.bodyDesc&&(r&&(i.bodyDesc.position=[r.x,r.y,r.z]),n&&(i.bodyDesc.rotation=[n.x,n.y,n.z,n.w])),this.registerBehaviorLinks(i),this.maybeAttachEntityPhysics(i),this.tryRegisterRenderStrategy(i),L(i)||this.scene.addEntityGroup(i),ni(i),ai(i),this.addEntityToStage(i),this.entityModelDelegate.observe(i),!0}isDetached(e){return this.detachedMap.has(e)}evictOldestDetached(){for(;this.detachedMap.size>Mo;){let e=this.detachedMap.keys().next();if(e.done)return;let t=this.detachedMap.get(e.value);if(this.detachedMap.delete(e.value),!!t){try{t.entity.nodeDestroy?.({me:t.entity,globals:v()})}catch{}G(t.entity)}}}getEntityByName(e){for(let t of this.childrenMap.values())if(t.name===e)return t;return console.warn(`Entity ${e} not found`),null}buildEntityState(e){return e instanceof li?{...e.buildInfo()}:{uuid:e.uuid,name:e.name}}onEntityAdded(e,t){return this.entityAddedHandlers.push(e),t?.replayExisting&&this._isLoaded&&this.childrenMap.forEach(i=>{try{e(i)}catch(r){console.error("onEntityAdded replay failed",r)}}),()=>{this.entityAddedHandlers=this.entityAddedHandlers.filter(i=>i!==e)}}enqueue(...e){for(let t of e)if(t){if(k(t)){this.handleEntityImmediatelyOrQueue(t);continue}if(typeof t=="function"){try{let i=t();k(i)?this.handleEntityImmediatelyOrQueue(i):ne(i)&&this.handlePromiseWithSpawnOnResolve(i)}catch(i){console.error("Error executing entity factory",i)}continue}ne(t)&&this.handlePromiseWithSpawnOnResolve(t)}}handleEntityImmediatelyOrQueue(e){this._isLoaded?this.spawnEntity(e):this.children.push(e)}handlePromiseWithSpawnOnResolve(e){this._isLoaded?e.then(t=>this.spawnEntity(t)).catch(t=>console.error("Failed to build async entity",t)):this.pendingPromises.push(e)}yieldToEventLoop(){return new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(void 0)})}async runEntityLoadGenerator(){let t=0;if(this.pendingEntities.length){let n=[...this.pendingEntities];this.pendingEntities=[],this.enqueue(...n)}let i=[...this.pendingPromises];this.pendingPromises=[];let r=this.children.length+i.length;for(let n of this.children)await this.spawnEntity(n),t++,this.loadingDelegate.emitProgress(`Loaded ${n.name||"unknown"}`,t,r),t%5===0&&await this.yieldToEventLoop();for(let n of i){try{let s=await n;s&&await this.spawnEntity(s)}catch(s){console.error("Failed to resolve pending stage entity",s)}t++,this.loadingDelegate.emitProgress("Loaded async entity",t,r),t%5===0&&await this.yieldToEventLoop()}t%5!==0&&await this.yieldToEventLoop()}registerSystem(e){if(!this.world||!this.scene)return;let t;typeof e=="function"?t=e({world:this.world,scene:this.scene,getBehaviorLinks:i=>this.behaviorEntityIndex.get(i)??o.EMPTY_BEHAVIOR_LINKS,createEntity:pt,getGlobals:v}):t=e,this.behaviorSystems.push(t)}destroyAll(){for(let t of this.behaviorSystems)t.destroy?.();this.behaviorSystems.length=0,this.behaviorSystemByKey.clear(),this.registeredSystemKeys.clear(),this.behaviorEntityIndex.clear(),this.behaviorLinksByUuid.clear();let e=[];this.childrenMap.forEach(t=>{try{t.nodeDestroy({me:t,globals:v()})}catch{}G(t),e.push(t.uuid)}),this.detachedMap.forEach(({entity:t})=>{try{t.nodeDestroy?.({me:t,globals:v()})}catch{}G(t)}),this.detachedMap.clear(),this.childrenMap.clear(),this.debugMap.clear(),this.entityAddedHandlers=[];for(let t of e)T.emit("entity:destroyed",{entityId:t});this._isLoaded=!1,this.scene=null,this.world=null,this.renderStrategy=null,this.camera=null,this.wasmStage=null}registerBehaviorLinks(e){if(!this.world||!this.scene||typeof e?.getBehaviorRefs!="function")return;let t=e.getBehaviorRefs();if(!Array.isArray(t)||t.length===0)return;let i=[];for(let r of t)i.push(this.linkBehaviorRef(e,r));this.behaviorLinksByUuid.set(e.uuid,i)}linkBehaviorRef(e,t){let i=t.descriptor.key,r={entity:e,ref:t},n=this.behaviorEntityIndex.get(i);n||(n=new Set,this.behaviorEntityIndex.set(i,n)),n.add(r);let s=this.behaviorSystemByKey.get(i);if(!s&&!this.registeredSystemKeys.has(i)){let a=t.descriptor.systemFactory({world:this.world,scene:this.scene,wasmStage:this.wasmStage,getBehaviorLinks:l=>this.behaviorEntityIndex.get(l)??o.EMPTY_BEHAVIOR_LINKS,createEntity:pt,getGlobals:v});s=a,this.behaviorSystems.push(a),this.behaviorSystemByKey.set(i,a),this.registeredSystemKeys.add(i)}return s?.attach?.(r),r}unlinkBehaviorLink(e){let t=e.ref?.descriptor?.key;if(!t)return;this.behaviorSystemByKey.get(t)?.detach?.(e);let i=this.behaviorEntityIndex.get(t);i&&(i.delete(e),i.size===0&&this.behaviorEntityIndex.delete(t))}syncBehaviorLinks(e){this.unregisterBehaviorLinks(e),this.registerBehaviorLinks(e)}attachBehaviorLink(e,t){if(!this.world||!this.scene||!e?.uuid)return!1;let i=this.behaviorLinksByUuid.get(e.uuid)??[];return i.some(r=>r.ref===t)?!1:(i.push(this.linkBehaviorRef(e,t)),this.behaviorLinksByUuid.set(e.uuid,i),!0)}detachBehaviorLink(e,t){let i=this.behaviorLinksByUuid.get(e?.uuid);if(!i)return!1;let r=i.findIndex(s=>s.ref===t);if(r===-1)return!1;let[n]=i.splice(r,1);return n&&this.unlinkBehaviorLink(n),i.length===0&&this.behaviorLinksByUuid.delete(e.uuid),!0}unregisterBehaviorLinks(e){let t=this.behaviorLinksByUuid.get(e?.uuid);if(t){for(let i of t)this.unlinkBehaviorLink(i);this.behaviorLinksByUuid.delete(e.uuid)}}};var Ro="Stage",it=class extends Ie{type=Ro;state={...pi};gravity;world;scene;renderStrategy=null;debugDelegate=null;uuid;wrapperRef=null;camera;cameras=[];cameraRef=null;cameraManagerRef=null;rendererManager=null;cameraDelegate;loadingDelegate;entityModelDelegate;childUpdateParams={};entityDelegate;constructor(e=[]){super(),this.world=null,this.scene=null,this.uuid=To(),this.cameraDelegate=new Xe(this),this.loadingDelegate=new Je,this.entityModelDelegate=new et,this.entityDelegate=new tt(this.loadingDelegate,this.entityModelDelegate);let t=Qi(e);this.camera=t.camera,this.cameras=t.cameras,this.entityDelegate.children=t.entities,t.asyncEntities.length&&this.entityDelegate.enqueue(...t.asyncEntities),this.state={...this.state,inputs:t.config.inputs,backgroundColor:t.config.backgroundColor,backgroundImage:t.config.backgroundImage,backgroundShader:t.config.backgroundShader,gravity:t.config.gravity,variables:t.config.variables,physicsRate:t.config.physicsRate,assetLoaders:t.config.assetLoaders,defaultLighting:t.config.defaultLighting,postProcessingEffects:t.config.postProcessingEffects,entities:[]},this.gravity=t.config.gravity??new Tr(0,0,0)}setState(){let{backgroundColor:e,backgroundImage:t}=this.state,i=e instanceof Mr?e:new Mr(e);ui(i),hi(t),mi(this.state.variables??{})}resolveRenderer(e){return this.rendererManager?.renderer?this.rendererManager.renderer:e.renderer?e.renderer:null}async load(e,t,i){this.setState(),i&&(this.rendererManager=i),this.rendererManager&&(this.cameraManagerRef=this.cameraDelegate.buildCameraManager(t,...this.cameras));let r=this.cameraManagerRef?.primaryCamera??this.cameraDelegate.resolveCamera(t,this.camera);this.cameraRef=r,this.scene=new Ve(e,r,this.state);let n=this.gravity??new Tr(0,0,0);if(this.world=await Be.create(n,this.state.physicsRate),this.scene.setup(),this.cameraManagerRef&&this.rendererManager){await this.scene.setupCameraManager(this.scene.scene,this.cameraManagerRef,this.rendererManager);let a=this.cameraManagerRef.primaryCamera;a&&(this.rendererManager.setPostProcessingEffects(this.state.postProcessingEffects??[]),this.rendererManager.setupPostProcessing(this.scene.scene,a.camera)),this.rendererManager.startRenderLoop(()=>{this.cameraManagerRef?.render(this.scene.scene)})}else await this.scene.setupCamera(this.scene.scene,r);let s=this.resolveRenderer(r);await I.configureGLTFRuntime({renderer:s,...Oe(this.state.assetLoaders?.gltf)}),this.entityModelDelegate.attach(this.scene,a=>this.entityDelegate.handleLateModelReady(a)),this.renderStrategy=new Pe,this.renderStrategy.setScene(this.scene.scene),this.entityDelegate.attach({scene:this.scene,world:this.world,renderStrategy:this.renderStrategy,camera:r}),this.loadingDelegate.emitStart(),await this.entityDelegate.runEntityLoadGenerator(),this.entityDelegate.isLoaded=!0,this.loadingDelegate.emitComplete()}hasSetup=!1;_setup(e){if(!this.hasSetup){if(!this.scene||!this.world){this.logMissingEntities();return}this.debugDelegate=new $e(this),this.hasSetup=!0}}_update(e){let{delta:t}=e;if(!this.scene||!this.world){this.logMissingEntities();return}let i=this.world,r=this.scene;E("behaviorSystems",()=>{for(let n of this.entityDelegate.behaviorSystems)n.update(void 0,t)}),E("entityLoop",()=>{for(let n of this.entityDelegate.childrenMap.values()){let s=this.childUpdateParams;s.delta=e.delta,s.inputs=e.inputs,s.globals=e.globals,s.camera=e.camera,s.stage=e.stage,s.game=e.game,s.me=n,n.nodeUpdate(s);let a=n;a.transformStore&&vi(a,a.transformStore),n.markedForRemoval&&this.entityDelegate.removeEntityByUuid(n.uuid)}}),E("worldUpdate",()=>{i.update(e)}),E("behaviorPostUpdate",()=>{for(let n of this.entityDelegate.behaviorSystems)n.postUpdate?.(void 0,t)}),E("syncRenderPoses",()=>{Xi({_childrenMap:this.entityDelegate.childrenMap,_world:i})}),E("renderStrategy",()=>{this.renderStrategy?.update(i.interpolationAlpha)}),E("camera",()=>{this.cameraManagerRef?this.cameraManagerRef.update(t):this.cameraRef?.update(t)}),E("scene",()=>{r.update({delta:t})}),Bi()}outOfLoop(){this.debugUpdate()}debugUpdate(){ce()&&(mt("debugUpdate"),this.debugDelegate?.update(),ft())}_destroy(e){this.entityDelegate.destroyAll(),this.world?.destroy(),this.scene?.destroy(),this.debugDelegate?.dispose(),this.debugDelegate=null,this.entityModelDelegate.dispose(),this.renderStrategy?.dispose(),this.renderStrategy=null,this.rendererManager&&this.rendererManager.stopRenderLoop(),this.world=null,this.scene=null,this.cameraRef=null,this.cameraManagerRef=null,fi(),G(this)}async spawnEntity(e){return this.entityDelegate.spawnEntity(e)}buildEntityState(e){return this.entityDelegate.buildEntityState(e)}onEntityAdded(e,t){return this.entityDelegate.onEntityAdded(e,t)}onLoading(e){return this.loadingDelegate.onLoading(e)}registerSystem(e){return this.entityDelegate.registerSystem(e),this}removeEntityByUuid(e){return this.entityDelegate.removeEntityByUuid(e)}getEntityByName(e){return this.entityDelegate.getEntityByName(e)}enqueue(...e){this.entityDelegate.enqueue(...e)}logMissingEntities(){console.warn("Zylem world or scene is null")}addCamera(e,t){return this.cameraManagerRef?this.cameraManagerRef.addCamera(e,t):(console.warn("ZylemStage: CameraManager not available. Ensure stage is loaded with a RendererManager."),null)}removeCamera(e){return this.cameraManagerRef?.removeCamera(e)??!1}setActiveCamera(e){return this.cameraManagerRef?.setActiveCamera(e)??!1}getCamera(e){return this.cameraManagerRef?.getCamera(e)??null}resize(e,t){this.scene&&this.scene.updateRenderer(e,t)}};import{proxy as ko}from"valtio/vanilla";import{Vector3 as _o}from"three";var Do={backgroundColor:ve,backgroundImage:null,inputs:{p1:["gamepad-1","keyboard"],p2:["gamepad-2","keyboard"]},gravity:new _o(0,0,0),variables:{}},B=ko({...Do});function Rr(o){let e=Lo(),t={};return typeof o[0]=="object"&&(t=o.shift()??{}),[{...e,...t},...o]}function Lo(){return{backgroundColor:B.backgroundColor,backgroundImage:B.backgroundImage??null,inputs:B.inputs?{...B.inputs}:void 0,gravity:B.gravity,variables:B.variables?{...B.variables}:void 0}}var Ft=class{wrappedStage;options=[];_pendingEntities=[];setupCallbacks=[];updateCallbacks=[];destroyCallbacks=[];pendingLoadingCallbacks=[];eventDelegate=new qt;inputConfig=null;onInputConfigChanged=null;constructor(e){this.options=e,this.wrappedStage=null;let t=this.options[0];I.prepareGLTFRuntime(Oe(t?.assetLoaders?.gltf))}setInputConfiguration(...e){return this.inputConfig=Wt(...e),this.onInputConfigChanged&&this.onInputConfigChanged(),this}async load(e,t,i){be.entities=[];let r=[...this.options,...this._pendingEntities];this._pendingEntities=[],this.wrappedStage=new it(r),this.wrappedStage.wrapperRef=this,this.pendingLoadingCallbacks.forEach(c=>{this.wrappedStage.onLoading(c)}),this.pendingLoadingCallbacks=[];let n=t instanceof C?t.cameraRef:t;await this.wrappedStage.load(e,n,i);let s=null,a=!1,l=()=>{if(a=!1,!s?.length){s=null;return}let c=s;s=null,be.entities=[...be.entities,...c]};this.wrappedStage.onEntityAdded(c=>{if(Y(c.options))return;let d=this.wrappedStage.buildEntityState(c);s||(s=[]),s.push(d),a||(a=!0,queueMicrotask(l))},{replayExisting:!0}),this.applyLifecycleCallbacks()}applyLifecycleCallbacks(){this.wrappedStage&&(this.setupCallbacks.length>0&&(this.wrappedStage.setup=e=>{let t={...e,stage:this};this.setupCallbacks.forEach(i=>i(t))}),this.updateCallbacks.length>0&&(this.wrappedStage.update=e=>{let t={...e,stage:this};this.updateCallbacks.forEach(i=>i(t))}),this.destroyCallbacks.length>0&&(this.wrappedStage.destroy=e=>{let t={...e,stage:this};this.destroyCallbacks.forEach(i=>i(t))}))}async addEntities(e){this._pendingEntities.push(...e),this.wrappedStage&&this.wrappedStage.enqueue(...e)}add(...e){this.addToBlueprints(...e),this.addToStage(...e)}addToBlueprints(...e){this.wrappedStage||this.options.push(...e)}addToStage(...e){this.wrappedStage&&this.wrappedStage.enqueue(...e)}start(e){!this.wrappedStage||this.wrappedStage.hasSetup||this.wrappedStage.nodeSetup(e)}onUpdate(...e){return this.updateCallbacks.push(...e),this.wrappedStage&&(this.wrappedStage.update=t=>{let i={...t,stage:this};this.updateCallbacks.forEach(r=>r(i))}),this}onSetup(...e){return this.setupCallbacks.push(...e),this.wrappedStage&&(this.wrappedStage.setup=t=>{let i={...t,stage:this};this.setupCallbacks.forEach(r=>r(i))}),this}onDestroy(...e){return this.destroyCallbacks.push(...e),this.wrappedStage&&(this.wrappedStage.destroy=t=>{let i={...t,stage:this};this.destroyCallbacks.forEach(r=>r(i))}),this}onLoading(e){return this.wrappedStage?this.wrappedStage.onLoading(e):(this.pendingLoadingCallbacks.push(e),()=>{this.pendingLoadingCallbacks=this.pendingLoadingCallbacks.filter(t=>t!==e)})}getEntityByName(e,t){return this.wrappedStage?.getEntityByName(e)}addCamera(e,t){let i=e instanceof C?e.cameraRef:e;return this.wrappedStage?.addCamera(i,t)??null}removeCamera(e){return e instanceof C?this.wrappedStage?.removeCamera(e.cameraRef)??!1:this.wrappedStage?.removeCamera(e)??!1}setActiveCamera(e){return e instanceof C?this.wrappedStage?.setActiveCamera(e.cameraRef)??!1:this.wrappedStage?.setActiveCamera(e)??!1}getCamera(e){return this.wrappedStage?.getCamera(e)??null}dispatch(e,t){this.eventDelegate.dispatch(e,t),T.emit(e,t)}listen(e,t){return this.eventDelegate.listen(e,t)}dispose(){this.eventDelegate.dispose()}};function Td(...o){let e=Rr(o);return new Ft([...e])}export{Zo as a,Ce as b,Q as c,Y as d,L as e,Se as f,Pe as g,ns as h,m as i,A as j,xe as k,Z as l,N as m,ee as n,te as o,ie as p,re as q,O as r,Le as s,C as t,Ra as u,za as v,mn as w,Ft as x,Td as y};
@@ -1,4 +1,4 @@
1
- import{a as g}from"./chunk-BCFFS3FP.js";import{AmbientLight as k,Object3D as R,PerspectiveCamera as U,RenderTarget as T,Scene as C,Color as O,LinearFilter as w,SpotLight as P,Vector3 as v}from"three";function d(a,e,t,i={}){let s=e*4,r=new Uint8ClampedArray(t*s),n=null;if(i.srgb){n=new Uint8Array(256);for(let o=0;o<256;o+=1){let c=o/255,u=c<=.0031308?c*12.92:1.055*Math.pow(c,1/2.4)-.055;n[o]=Math.round(Math.max(0,Math.min(1,u))*255)}}for(let o=0;o<t;o+=1){let c=(i.flipY?t-1-o:o)*s,u=o*s;if(n===null){r.set(a.subarray(c,c+s),u);continue}for(let l=0;l<s;l+=4)r[u+l]=n[a[c+l]],r[u+l+1]=n[a[c+l+1]],r[u+l+2]=n[a[c+l+2]],r[u+l+3]=a[c+l+3]}return r}var x=`
1
+ import{a as g}from"./chunk-47HAZZWF.js";import{AmbientLight as k,Object3D as R,PerspectiveCamera as U,RenderTarget as T,Scene as C,Color as O,LinearFilter as w,SpotLight as P,Vector3 as v}from"three";function d(a,e,t,i={}){let s=e*4,r=new Uint8ClampedArray(t*s),n=null;if(i.srgb){n=new Uint8Array(256);for(let o=0;o<256;o+=1){let c=o/255,u=c<=.0031308?c*12.92:1.055*Math.pow(c,1/2.4)-.055;n[o]=Math.round(Math.max(0,Math.min(1,u))*255)}}for(let o=0;o<t;o+=1){let c=(i.flipY?t-1-o:o)*s,u=o*s;if(n===null){r.set(a.subarray(c,c+s),u);continue}for(let l=0;l<s;l+=4)r[u+l]=n[a[c+l]],r[u+l+1]=n[a[c+l+1]],r[u+l+2]=n[a[c+l+2]],r[u+l+3]=a[c+l+3]}return r}var x=`
2
2
  const encodeReadbackPixels = ${d.toString()};
3
3
 
4
4
  self.onmessage = async (event) => {
@@ -1,8 +1,8 @@
1
1
  import { k as CutsceneEasing, V as Vec3Def, h as CutsceneScene, n as CameraShot, g as CutsceneDefinition, s as DollyPath, i as CutsceneCamera, o as CameraTrack, x as SceneTransition, y as SceneTransitionType, v as EventItem, w as AudioItem } from './cutscene-definition-C479fkei.js';
2
2
  export { A as AudioItemSchema, q as AudioTrack, l as CameraKeyframe, c as CameraKeyframeSchema, m as CameraPoseDef, d as CameraShotSchema, j as CutsceneCameraKind, b as CutsceneCameraSchema, C as CutsceneDefinitionSchema, u as CutsceneEvent, e as CutsceneEventSchema, a as CutsceneSceneSchema, r as CutsceneTrack, f as CutsceneTrackSchema, D as DollyPathSchema, E as EventItemSchema, p as EventTrack, S as SceneTransitionSchema, t as ShotBlend } from './cutscene-definition-C479fkei.js';
3
- import { f as CameraBehavior, d as CameraContext, C as CameraPose, l as ZylemCamera } from './zylem-camera-CYDtrVgi.js';
3
+ import { f as CameraBehavior, d as CameraContext, C as CameraPose, l as ZylemCamera } from './zylem-camera-CWhIGXlW.js';
4
4
  import { Z as ZylemTransitionShader } from './stage-transition-CmGpV4tc.js';
5
- import { Z as ZylemStage, q as Stage } from './stage-CAPlk_cN.js';
5
+ import { Z as ZylemStage, q as Stage } from './stage-PBmwT5-Y.js';
6
6
  import { g as SongDefinition } from './song-definition-rEKksP0B.js';
7
7
  import { CutsceneStatusPayload, CutsceneViewPayload, CutsceneLoadPayload, CameraPosePayload } from '@zylem/bridge';
8
8
  import '@sinclair/typebox';
package/dist/core.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { S as StageStateInterface } from './game-D8KTP3fD.js';
2
- export { A as AspectRatio, f as AspectRatioValue, D as DeviceProfile, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, R as ResolutionInput, e as ResolveGameConfigRuntime, j as RetroPreset, k as RetroPresetKey, l as RetroResolution, c as createGame, g as gameConfig, h as getDisplayAspect, i as getPresetResolution, p as parseResolution } from './game-D8KTP3fD.js';
1
+ import { S as StageStateInterface } from './game-DBt7iVu4.js';
2
+ export { A as AspectRatio, f as AspectRatioValue, D as DeviceProfile, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, R as ResolutionInput, e as ResolveGameConfigRuntime, j as RetroPreset, k as RetroPresetKey, l as RetroResolution, c as createGame, g as gameConfig, h as getDisplayAspect, i as getPresetResolution, p as parseResolution } from './game-DBt7iVu4.js';
3
3
  export { G as GameInputConfig, a as GameInputPlayerConfig, K as KeyboardMapping, M as MouseConfig, b as MouseMapping, V as VirtualTouchButtonConfig, d as VirtualTouchButtonSlot, c as VirtualTouchButtonsConfig, e as VirtualTouchConfig, f as VirtualTouchJoystickConfig, g as VirtualTouchJoysticksConfig, h as VirtualTouchPosition, i as VirtualTouchStyle, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
4
- import { q as Stage, C as CameraWrapper } from './stage-CAPlk_cN.js';
5
- export { e as CameraManager, d as CameraOptions, l as FirstPersonOptions, f as FirstPersonPerspective, k as Fixed2DOptions, F as Fixed2DPerspective, n as IsometricOptions, I as IsometricPerspective, P as PerspectiveOptions, R as RenderBundleManager, p as RenderStrategyManager, m as SecondPersonOptions, g as SecondPersonPerspective, S as StageConfigLike, a as StageOptions, j as ThirdPersonOptions, T as ThirdPersonPerspective, o as TopDownOptions, h as TopDownPerspective, b as createCamera, i as createPerspective, c as createStage, s as stageConfig } from './stage-CAPlk_cN.js';
4
+ import { q as Stage, C as CameraWrapper } from './stage-PBmwT5-Y.js';
5
+ export { e as CameraManager, d as CameraOptions, l as FirstPersonOptions, f as FirstPersonPerspective, k as Fixed2DOptions, F as Fixed2DPerspective, n as IsometricOptions, I as IsometricPerspective, P as PerspectiveOptions, R as RenderBundleManager, p as RenderStrategyManager, m as SecondPersonOptions, g as SecondPersonPerspective, S as StageConfigLike, a as StageOptions, j as ThirdPersonOptions, T as ThirdPersonPerspective, o as TopDownOptions, h as TopDownPerspective, b as createCamera, i as createPerspective, c as createStage, s as stageConfig } from './stage-PBmwT5-Y.js';
6
6
  import { LevelBuffer, LevelEntry } from '@zylem/bridge';
7
7
  export { LevelBuffer } from '@zylem/bridge';
8
8
  import { B as BaseNode, N as NodeInterface } from './base-node-idopiSw5.js';
@@ -12,8 +12,8 @@ import { S as StageBlueprint } from './blueprints-TbGY-h53.js';
12
12
  import { a as SetupContext, k as LoadedContext, U as UpdateContext, D as DestroyContext, l as CleanupContext } from './base-node-life-cycle-BK9xebT9.js';
13
13
  export { L as LoadingEvent, S as StageNavigationOptions } from './base-node-life-cycle-BK9xebT9.js';
14
14
  export { S as StageTransitionConfig, a as StageTransitionEasing, Z as ZylemTransitionShader, c as crossfadeTransitionShader } from './stage-transition-CmGpV4tc.js';
15
- import { f as CameraBehavior } from './zylem-camera-CYDtrVgi.js';
16
- export { g as CameraAction, d as CameraContext, e as CameraPerspective, k as CameraPipeline, h as CameraPipelineState, C as CameraPose, j as CameraProjection, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-CYDtrVgi.js';
15
+ import { f as CameraBehavior } from './zylem-camera-CWhIGXlW.js';
16
+ export { g as CameraAction, d as CameraContext, e as CameraPerspective, k as CameraPipeline, h as CameraPipelineState, C as CameraPose, j as CameraProjection, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-CWhIGXlW.js';
17
17
  import { e as Vec3Input, c as Vec3 } from './vector-D3eDzvcA.js';
18
18
  export { f as VEC2_ONE, g as VEC2_ZERO, h as VEC3_ONE, i as VEC3_ZERO, V as Vec2, a as Vec2Components, b as Vec2Input, d as Vec3Components, n as normalizeVec2, j as normalizeVec3, t as toThreeVector2, k as toThreeVector3 } from './vector-D3eDzvcA.js';
19
19
  import { S as StageEntity } from './entity-BIf_a4dl.js';
package/dist/core.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as L,g as M,h as N,i as O,j as P,k as Q,l as R,m as S,n as T,o as U,p as V,q as W,r as X}from"./chunk-CGHGVX4T.js";import{a,c as q,d as r,e as s,f as t,g as u,h as v,i as w,k as x,l as y,m as z,n as A,o as B,p as C,q as D,r as E,s as F,t as G,u as H,v as I,w as J,y as K}from"./chunk-EA52VY4B.js";import"./chunk-PCFF4LLO.js";import"./chunk-Q2YDBMVY.js";import"./chunk-BCFFS3FP.js";import"./chunk-VSFULLND.js";import"./chunk-2HSR5XDQ.js";import{b as g}from"./chunk-G5IJBJ4E.js";import"./chunk-BQRMYLYD.js";import"./chunk-GPCSX3M6.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-LI43BZQN.js";import"./chunk-YQS7CGXE.js";import"./chunk-STVEILJJ.js";import"./chunk-KP6DLLJO.js";import"./chunk-6FGXC4T6.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-UUOPT2N4.js";import"./chunk-EVYHPR3J.js";import"./chunk-VUJXR5K5.js";import"./chunk-2XMG3NJS.js";import{a as p}from"./chunk-7GYFZKK7.js";import"./chunk-QGIYILYI.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import{a as h,b as i,c as j,d as k,g as l,h as m,i as n,j as o}from"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";export{b as AspectRatio,F as CameraManager,x as CameraPipeline,G as CameraWrapper,A as FirstPersonPerspective,z as Fixed2DPerspective,N as Game,B as IsometricPerspective,w as Perspectives,t as RenderBundleManager,u as RenderStrategyManager,R as STAGE_STATE_CHANGE,D as SecondPersonPerspective,M as StageManager,y as ThirdPersonPerspective,C as TopDownPerspective,i as VEC2_ONE,h as VEC2_ZERO,k as VEC3_ONE,j as VEC3_ZERO,H as createCamera,U as createFollowTarget,O as createGame,E as createPerspective,V as createPlatformFollow,K as createStage,W as createStrategyPan,p as crossfadeTransitionShader,T as dispatchStageState,Q as entitySpawner,f as gameConfig,c as getDisplayAspect,d as getPresetResolution,S as initStageStateDispatcher,s as isManagedRenderEntity,a as isWebGPUSupported,l as normalizeVec2,m as normalizeVec3,e as parseResolution,q as resolveRenderCategory,X as setCameraFeed,v as setStageFrameProfilerEnabled,I as stageConfig,L as stageState,g as streamLevel,P as streamLevelOnStage,n as toThreeVector2,o as toThreeVector3,r as usesManagedRenderPath,J as vessel};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as L,g as M,h as N,i as O,j as P,k as Q,l as R,m as S,n as T,o as U,p as V,q as W,r as X}from"./chunk-2IJLXFWY.js";import{a,c as q,d as r,e as s,f as t,g as u,h as v,i as w,k as x,l as y,m as z,n as A,o as B,p as C,q as D,r as E,s as F,t as G,u as H,v as I,w as J,y as K}from"./chunk-NK4IXK5V.js";import"./chunk-PCFF4LLO.js";import"./chunk-OCQ7A5IK.js";import"./chunk-47HAZZWF.js";import"./chunk-VSFULLND.js";import"./chunk-2HSR5XDQ.js";import{e as g}from"./chunk-3CLQWJ2I.js";import"./chunk-BQRMYLYD.js";import"./chunk-GPCSX3M6.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-LI43BZQN.js";import"./chunk-YQS7CGXE.js";import"./chunk-STVEILJJ.js";import"./chunk-KP6DLLJO.js";import"./chunk-6FGXC4T6.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-UUOPT2N4.js";import"./chunk-EVYHPR3J.js";import"./chunk-VUJXR5K5.js";import"./chunk-2XMG3NJS.js";import{a as p}from"./chunk-7GYFZKK7.js";import"./chunk-QGIYILYI.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import{a as h,b as i,c as j,d as k,g as l,h as m,i as n,j as o}from"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";export{b as AspectRatio,F as CameraManager,x as CameraPipeline,G as CameraWrapper,A as FirstPersonPerspective,z as Fixed2DPerspective,N as Game,B as IsometricPerspective,w as Perspectives,t as RenderBundleManager,u as RenderStrategyManager,R as STAGE_STATE_CHANGE,D as SecondPersonPerspective,M as StageManager,y as ThirdPersonPerspective,C as TopDownPerspective,i as VEC2_ONE,h as VEC2_ZERO,k as VEC3_ONE,j as VEC3_ZERO,H as createCamera,U as createFollowTarget,O as createGame,E as createPerspective,V as createPlatformFollow,K as createStage,W as createStrategyPan,p as crossfadeTransitionShader,T as dispatchStageState,Q as entitySpawner,f as gameConfig,c as getDisplayAspect,d as getPresetResolution,S as initStageStateDispatcher,s as isManagedRenderEntity,a as isWebGPUSupported,l as normalizeVec2,m as normalizeVec3,e as parseResolution,q as resolveRenderCategory,X as setCameraFeed,v as setStageFrameProfilerEnabled,I as stageConfig,L as stageState,g as streamLevel,P as streamLevelOnStage,n as toThreeVector2,o as toThreeVector3,r as usesManagedRenderPath,J as vessel};
package/dist/debug.d.ts CHANGED
@@ -216,8 +216,9 @@ interface EntityFocusContext {
216
216
  */
217
217
  declare function registerEntityFocusContext(context: EntityFocusContext): () => void;
218
218
  /**
219
- * Select an entity by UUID and frame the debug camera to fit it.
220
- * Enables debug mode so orbit controls are active.
219
+ * Select an entity by UUID and frame the active editor camera to fit it.
220
+ * When the game camera is showing, the stage switches to the free editor
221
+ * camera first. Enables debug mode so the selection is visible.
221
222
  *
222
223
  * @returns true if the entity was found and framed
223
224
  */
package/dist/debug.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ELQN62PQ.js";import{a as x,b as y}from"./chunk-Q2YDBMVY.js";import{c as P,d as Q,e as R,f as S}from"./chunk-BCFFS3FP.js";import{a as z,b as A,c as B,d as C,e as D,f as E,g as F,h as G,i as H}from"./chunk-BQRMYLYD.js";import{B as u,C as v,D as w,a,b,c,d,e,f,h as g,j as h,l as i,m as j,n as k,o as l,p as m,q as n,u as o,v as p,w as q,x as r,y as s,z as t}from"./chunk-GPCSX3M6.js";import{a as I,b as J,c as K,d as L,e as M,f as N,g as O}from"./chunk-UUOPT2N4.js";import"./chunk-WOT6VMZA.js";export{P as ConstructionGrid,c as DEFAULT_SNAP_SETTINGS,x as EntityThumbnailCache,I as SELECTION_BOUNDS_MARGIN,J as SELECTION_THIN_AXIS_FRACTION,L as SELECTION_THIN_AXIS_MAX,K as SELECTION_THIN_AXIS_MIN,a as TRANSFORM_TOOLS,S as TransformGizmo,Q as closestAxisValue,d as debugState,G as degreesToRadians,y as entityThumbnailCache,B as eulerToQuaternion,A as focusEntity,v as getHoveredEntity,s as getHoveredEntityId,u as getSelectedEntity,k as getSelectedEntityId,m as getSelectedEntityIds,o as getSnapSettings,R as intersectPlane,j as isPickMode,b as isTransformTool,N as measureObjectSelectionBounds,M as padSelectionBounds,C as quaternionToEuler,H as radiansToDegrees,e as registerDebugEntityResolver,z as registerEntityFocusContext,f as resolveDebugEntity,O as resolveSelectionBounds,r as setAddType,h as setDebugTool,q as setGridVisible,t as setHoveredEntityId,g as setPaused,i as setPickMode,w as setSelectedEntity,l as setSelectedEntityId,n as setSelectedEntityIds,p as setSnapSettings,F as snapScale,D as snapToIncrement,E as snapVec3};
1
+ import"./chunk-ELQN62PQ.js";import{a as x,b as y}from"./chunk-OCQ7A5IK.js";import{c as P,d as Q,e as R,f as S}from"./chunk-47HAZZWF.js";import{a as z,b as A,c as B,d as C,e as D,f as E,g as F,h as G,i as H}from"./chunk-BQRMYLYD.js";import{B as u,C as v,D as w,a,b,c,d,e,f,h as g,j as h,l as i,m as j,n as k,o as l,p as m,q as n,u as o,v as p,w as q,x as r,y as s,z as t}from"./chunk-GPCSX3M6.js";import{a as I,b as J,c as K,d as L,e as M,f as N,g as O}from"./chunk-UUOPT2N4.js";import"./chunk-WOT6VMZA.js";export{P as ConstructionGrid,c as DEFAULT_SNAP_SETTINGS,x as EntityThumbnailCache,I as SELECTION_BOUNDS_MARGIN,J as SELECTION_THIN_AXIS_FRACTION,L as SELECTION_THIN_AXIS_MAX,K as SELECTION_THIN_AXIS_MIN,a as TRANSFORM_TOOLS,S as TransformGizmo,Q as closestAxisValue,d as debugState,G as degreesToRadians,y as entityThumbnailCache,B as eulerToQuaternion,A as focusEntity,v as getHoveredEntity,s as getHoveredEntityId,u as getSelectedEntity,k as getSelectedEntityId,m as getSelectedEntityIds,o as getSnapSettings,R as intersectPlane,j as isPickMode,b as isTransformTool,N as measureObjectSelectionBounds,M as padSelectionBounds,C as quaternionToEuler,H as radiansToDegrees,e as registerDebugEntityResolver,z as registerEntityFocusContext,f as resolveDebugEntity,O as resolveSelectionBounds,r as setAddType,h as setDebugTool,q as setGridVisible,t as setHoveredEntityId,g as setPaused,i as setPickMode,w as setSelectedEntity,l as setSelectedEntityId,n as setSelectedEntityIds,p as setSnapSettings,F as snapScale,D as snapToIncrement,E as snapVec3};
@@ -1,14 +1,14 @@
1
1
  import { e as InputPlayerNumber, f as InputProvider, I as Inputs, a as SetupContext, U as UpdateContext, D as DestroyContext, m as IGame, h as SetupFunction, g as UpdateFunction, j as DestroyFunction, S as StageNavigationOptions } from './base-node-life-cycle-BK9xebT9.js';
2
2
  import { G as GameInputConfig, B as BaseGlobals, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
3
3
  import { B as BaseNode } from './base-node-idopiSw5.js';
4
- import { B as BaseEntityInterface, q as Stage } from './stage-CAPlk_cN.js';
4
+ import { B as BaseEntityInterface, q as Stage } from './stage-PBmwT5-Y.js';
5
5
  import { y as GameEntityLifeCycle } from './entity-XqvuWgPm.js';
6
6
  import { Color, Vector3 } from 'three';
7
7
  import { d as Vec3Components } from './vector-D3eDzvcA.js';
8
8
  import { D as DefaultTouchControlsOptions } from './default-controls-CAKJ5zlo.js';
9
9
  import { GameEvents } from './events.js';
10
10
  import { Simulation } from '@zylem/behaviors/core';
11
- import { l as ZylemCamera, R as RendererManager } from './zylem-camera-CYDtrVgi.js';
11
+ import { l as ZylemCamera, R as RendererManager } from './zylem-camera-CWhIGXlW.js';
12
12
  import { S as StageTransitionConfig } from './stage-transition-CmGpV4tc.js';
13
13
 
14
14
  declare class InputManager {
@@ -1 +1 @@
1
- import{y as e}from"./chunk-EA52VY4B.js";import"./chunk-BCFFS3FP.js";import"./chunk-2HSR5XDQ.js";import"./chunk-G5IJBJ4E.js";import"./chunk-BQRMYLYD.js";import"./chunk-GPCSX3M6.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-YQS7CGXE.js";import"./chunk-KP6DLLJO.js";import"./chunk-6FGXC4T6.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-UUOPT2N4.js";import"./chunk-EVYHPR3J.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";import{proxy as t}from"valtio/vanilla";var s=()=>({id:"zylem",globals:{},stages:[e()],debug:!1,time:0,input:void 0}),a=t({...s()});function o(){return{id:a.id??"zylem",globals:a.globals??{},stages:a.stages??[e()],debug:a.debug,time:a.time,input:a.input}}export{o as getGameDefaultConfig};
1
+ import{y as e}from"./chunk-NK4IXK5V.js";import"./chunk-47HAZZWF.js";import"./chunk-2HSR5XDQ.js";import"./chunk-3CLQWJ2I.js";import"./chunk-BQRMYLYD.js";import"./chunk-GPCSX3M6.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-YQS7CGXE.js";import"./chunk-KP6DLLJO.js";import"./chunk-6FGXC4T6.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-UUOPT2N4.js";import"./chunk-EVYHPR3J.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";import{proxy as t}from"valtio/vanilla";var s=()=>({id:"zylem",globals:{},stages:[e()],debug:!1,time:0,input:void 0}),a=t({...s()});function o(){return{id:a.id??"zylem",globals:a.globals??{},stages:a.stages??[e()],debug:a.debug,time:a.time,input:a.input}}export{o as getGameDefaultConfig};
@@ -1,6 +1,6 @@
1
1
  import { b as ZylemTSLShader } from './material-CxxAyJYp.js';
2
2
  export { d as ZylemShader, Z as ZylemShaderObject, c as createNodeMaterialFromTSL, a as isGLSLShader, i as isTSLShader } from './material-CxxAyJYp.js';
3
- export { Z as ZylemPostEffect } from './zylem-camera-CYDtrVgi.js';
3
+ export { Z as ZylemPostEffect } from './zylem-camera-CWhIGXlW.js';
4
4
  export { S as StageTransitionConfig, a as StageTransitionEasing, Z as ZylemTransitionShader, c as crossfadeTransitionShader } from './stage-transition-CmGpV4tc.js';
5
5
  export { Fn, abs, asin, atan, clamp, cos, dot, exp, float, floor, fract, length, max, min, mix, mod, normalize, positionWorld, positionWorldDirection, pow, sin, smoothstep, step, time, uniform, uv, vec2, vec3, vec4 } from 'three/tsl';
6
6
  import 'three';
package/dist/public.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { A as AspectRatio, f as AspectRatioValue, D as DeviceProfile, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, R as ResolutionInput, e as ResolveGameConfigRuntime, j as RetroPreset, k as RetroPresetKey, l as RetroResolution, c as createGame, g as gameConfig, h as getDisplayAspect, i as getPresetResolution, p as parseResolution } from './game-D8KTP3fD.js';
1
+ export { A as AspectRatio, f as AspectRatioValue, D as DeviceProfile, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, R as ResolutionInput, e as ResolveGameConfigRuntime, j as RetroPreset, k as RetroPresetKey, l as RetroResolution, c as createGame, g as gameConfig, h as getDisplayAspect, i as getPresetResolution, p as parseResolution } from './game-DBt7iVu4.js';
2
2
  export { G as GameInputConfig, a as GameInputPlayerConfig, K as KeyboardMapping, M as MouseConfig, b as MouseMapping, V as VirtualTouchButtonConfig, d as VirtualTouchButtonSlot, c as VirtualTouchButtonsConfig, e as VirtualTouchConfig, f as VirtualTouchJoystickConfig, g as VirtualTouchJoysticksConfig, h as VirtualTouchPosition, i as VirtualTouchStyle, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
3
- export { e as CameraManager, d as CameraOptions, C as CameraWrapper, l as FirstPersonOptions, f as FirstPersonPerspective, k as Fixed2DOptions, F as Fixed2DPerspective, n as IsometricOptions, I as IsometricPerspective, P as PerspectiveOptions, R as RenderBundleManager, p as RenderStrategyManager, m as SecondPersonOptions, g as SecondPersonPerspective, S as StageConfigLike, a as StageOptions, j as ThirdPersonOptions, T as ThirdPersonPerspective, o as TopDownOptions, h as TopDownPerspective, b as createCamera, i as createPerspective, c as createStage, s as stageConfig } from './stage-CAPlk_cN.js';
3
+ export { e as CameraManager, d as CameraOptions, C as CameraWrapper, l as FirstPersonOptions, f as FirstPersonPerspective, k as Fixed2DOptions, F as Fixed2DPerspective, n as IsometricOptions, I as IsometricPerspective, P as PerspectiveOptions, R as RenderBundleManager, p as RenderStrategyManager, m as SecondPersonOptions, g as SecondPersonPerspective, S as StageConfigLike, a as StageOptions, j as ThirdPersonOptions, T as ThirdPersonPerspective, o as TopDownOptions, h as TopDownPerspective, b as createCamera, i as createPerspective, c as createStage, s as stageConfig } from './stage-PBmwT5-Y.js';
4
4
  export { CameraFeedOptions, FollowTargetOptions, LevelStage, PlatformAxisMode, PlatformAxisModes, PlatformFollowOptions, RenderCategory, STAGE_STATE_CHANGE, StageManager, StageStateChangeEvent, StrategyPanBehavior, StrategyPanInput, StrategyPanOptions, StrategyPointer, StreamLevelOptions, StreamLevelResult, Vect3, createFollowTarget, createPlatformFollow, createStrategyPan, dispatchStageState, entitySpawner, initStageStateDispatcher, isManagedRenderEntity, resolveRenderCategory, setCameraFeed, setStageFrameProfilerEnabled, stageState, streamLevel, streamLevelOnStage, usesManagedRenderPath, vessel } from './core.js';
5
5
  export { BRIDGE_READY_EVENT, BridgeChannel, BridgeDebugTool, BridgeHandler, GameLoadingPayload as BridgeLoadingPayload, BridgeMessageType, BridgeMessages, BridgeNdc, BridgeVec3, CameraPosePayload, CutsceneLoadPayload, CutscenePlaybackState, CutsceneStatusPayload, CutsceneViewPayload, EditorToGameMessages, EntityApplySwatchPayload, EntityPickPayload, EntityPickResultPayload, EntitySummaryPayload, EntitySwatchAppliedPayload, EntityThumbnailPayload, GameConfigPayload, GameToEditorMessages, GameVariablePayload, LevelBuffer, StageConfigPayload, StageSnapshotPayload, SwatchApplyFailureReason, SwatchApplyResult, SwatchKind, SwatchSpec, ZylemBridge, announceBridgeReady, applySwatchesToSelection, getZylemBridge } from '@zylem/bridge';
6
6
  export { f as EntityBlueprint, j as EntityJson, d as EntityJsonSchema, E as EntitySchema, i as LineEntityData, L as LineEntityDataSchema, h as SpriteEntityData, b as SpriteEntityDataSchema, S as StageBlueprint, k as StageJson, e as StageJsonSchema, c as StageSchema, g as TextEntityData, T as TextEntityDataSchema, V as Vector2Schema, a as Vector3TupleSchema } from './blueprints-TbGY-h53.js';
7
7
  export { A as AnalogState, d as ButtonName, B as ButtonState, c as InputGamepad, b as InputPlayer, e as InputPlayerNumber, f as InputProvider, I as Inputs, L as LoadingEvent, a as SetupContext, S as StageNavigationOptions, U as UpdateContext } from './base-node-life-cycle-BK9xebT9.js';
8
8
  export { S as StageTransitionConfig, a as StageTransitionEasing, Z as ZylemTransitionShader, c as crossfadeTransitionShader } from './stage-transition-CmGpV4tc.js';
9
- export { g as CameraAction, f as CameraBehavior, d as CameraContext, e as CameraPerspective, k as CameraPipeline, h as CameraPipelineState, C as CameraPose, j as CameraProjection, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, Z as ZylemPostEffect, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-CYDtrVgi.js';
9
+ export { g as CameraAction, f as CameraBehavior, d as CameraContext, e as CameraPerspective, k as CameraPipeline, h as CameraPipelineState, C as CameraPose, j as CameraProjection, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, Z as ZylemPostEffect, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-CWhIGXlW.js';
10
10
  export { S as StageEntity } from './entity-BIf_a4dl.js';
11
11
  export { f as VEC2_ONE, g as VEC2_ZERO, h as VEC3_ONE, i as VEC3_ZERO, V as Vec2, a as Vec2Components, b as Vec2Input, c as Vec3, d as Vec3Components, e as Vec3Input, n as normalizeVec2, j as normalizeVec3, t as toThreeVector2, k as toThreeVector3 } from './vector-D3eDzvcA.js';
12
12
  export { A as ACTOR_TYPE, a0 as AmbientLightOptions, B as BOX_TYPE, E as CONE_TYPE, K as CYLINDER_TYPE, C as CollisionShapeType, D as DISK_TYPE, a2 as DirectionalLightOptions, ak as EntityForType, aj as EntityTypeMap, a8 as FOG_TYPE, a1 as HemisphereLightOptions, _ as LIGHT_TYPE, ab as LINE_TYPE, a5 as LightShadowOptions, ae as LinePickResult, o as OnEnterParams, p as OnExitParams, O as OnHeldParams, V as PARTICLE_SYSTEM_TYPE, N as PILL_TYPE, P as PLANE_TYPE, H as PYRAMID_TYPE, a3 as PointLightOptions, R as RECT_TYPE, S as SPHERE_TYPE, f as SPRITE_TYPE, a4 as SpotLightOptions, h as SpriteAnimation, g as SpriteImage, i as SpriteSheet, T as TEXT_TYPE, n as ZONE_TYPE, r as ZylemActor, Z as ZylemBox, z as ZylemCone, J as ZylemCylinder, x as ZylemDisk, a7 as ZylemFog, ah as ZylemFogHeightOptions, ai as ZylemFogNoiseOptions, af as ZylemFogOptions, ag as ZylemFogType, Y as ZylemLight, $ as ZylemLightOptions, aa as ZylemLine, ad as ZylemLineOptions, U as ZylemParticleSystem, W as ZylemParticleSystemOptions, M as ZylemPill, k as ZylemPlane, G as ZylemPyramid, v as ZylemRect, b as ZylemSphere, e as ZylemSprite, t as ZylemText, m as ZylemZone, q as createActor, c as createBox, y as createCone, I as createCylinder, w as createDisk, a6 as createFog, X as createLight, a9 as createLine, Q as createParticleSystem, L as createPill, j as createPlane, F as createPyramid, u as createRect, a as createSphere, d as createSprite, s as createText, l as createZone, ac as pickZylemLine } from './entity-type-map-CrsrKT8c.js';
package/dist/public.js CHANGED
@@ -1 +1 @@
1
- import{A as Ox,B as Px,C as Vx,a as cx,b as sx,c as nx,d as lx,e as Sx,f as hx,g as yx,h as Lx,i as vx,j as Zx,k as bx,l as gx,m as ux,n as Tx,o as jx,p as Fx,q as Wx,r as kx,s as wx,t as zx,u as Bx,v as Dx,w as Ex,x as Gx,y as Mx,z as Nx}from"./chunk-KSEP7AUF.js";import"./chunk-ORIDWL3T.js";import{a as s,b as n,c as l,d as S,e as h,f as y,g as L,h as v,i as Z,j as b,k as g,l as u,m as T,n as j,o as F,p as W,q as k,r as w,s as z,t as B,u as D,v as E,w as G}from"./chunk-QB3NL7VQ.js";import"./chunk-BIGH6D34.js";import"./chunk-ELQN62PQ.js";import{a as If,b as Jf,c as Kf,d as Qf}from"./chunk-FZNEWOC5.js";import{a as Rf}from"./chunk-4CZZZCFB.js";import{a as Uf,b as Xf,c as Yf,d as _f,e as $f,f as ox,g as rx,h as ex,i as tx,j as mx,k as px,l as ax,m as fx,n as xx,o as ix,p as dx}from"./chunk-47DG7I7M.js";import{a as Wo,b as ko,c as wo,d as zo,e as Po,f as qp,g as Ap,h as $p,i as oa,j as ra,k as ea,l as ta,m as ma,n as pa,o as aa,p as fa,q as xa,r as ia}from"./chunk-CGHGVX4T.js";import{a as Fo,c as Lm,d as vm,e as Zm,f as sp,g as np,h as up,i as Tp,k as jp,l as Fp,m as Wp,n as kp,o as wp,p as zp,q as Bp,r as Dp,s as Ep,t as Gp,u as Mp,v as Np,w as Pp,y as Vp}from"./chunk-EA52VY4B.js";import{a as Bo,b as Do,c as Eo,d as Go,e as Mo,f as No,g as Oo}from"./chunk-PCFF4LLO.js";import{a as so,b as no}from"./chunk-Q2YDBMVY.js";import{c as vp,d as Zp,e as bp,f as gp}from"./chunk-BCFFS3FP.js";import"./chunk-VSFULLND.js";import"./chunk-2HSR5XDQ.js";import{b as Ho,k as Yo}from"./chunk-G5IJBJ4E.js";import{a as Ao,b as Co,c as Io,d as Jo,e as Ko,f as Qo,g as Ro,h as Uo,i as Xo}from"./chunk-BQRMYLYD.js";import{B as xo,C as io,D as co,a as C,b as H,c as I,d as J,e as K,f as Q,h as R,j as U,l as X,m as Y,n as _,o as $,p as oo,q as ro,u as eo,v as to,w as mo,x as po,y as ao,z as fo}from"./chunk-GPCSX3M6.js";import{b as xp}from"./chunk-WBQ5TNRZ.js";import{a as da,b as ca,c as sa,d as na,e as la}from"./chunk-K3NNXZIJ.js";import{a as Cp,b as Hp,c as Ip,d as Jp,e as Kp,f as Qp,g as Rp,h as Up,i as Xp,j as Yp,l as _p}from"./chunk-LI43BZQN.js";import{a as pp,b as ap,c as fp,d as ip,e as dp,f as cp}from"./chunk-YQS7CGXE.js";import{A as te,B as me,C as pe,D as ae,E as fe,F as Se,G as he,H as ye,I as Le,J as ve,K as Ze,L as be,M as ge,N as ue,b as Br,c as Dr,d as Er,e as Gr,f as Mr,g as Nr,h as Or,i as Pr,j as Vr,k as qr,l as Ar,m as Cr,n as Hr,o as Ir,p as Jr,q as Kr,r as Qr,s as Rr,t as Ur,u as Xr,v as Yr,w as _r,x as $r,y as oe,z as ee}from"./chunk-STVEILJJ.js";import{c as gr,d as ur,e as Tr,f as jr,g as Fr,h as Wr,i as kr,j as wr,u as zr,z as re}from"./chunk-KP6DLLJO.js";import{c as o,d as r,h as e,i as t,k as m,l as p,m as a,n as f,o as x,p as i,q as d,r as c}from"./chunk-6FGXC4T6.js";import{a as Vo,b as qo}from"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import{a as xe,b as ie,c as de,d as ce,e as se,f as ne,g as le}from"./chunk-UUOPT2N4.js";import{b as br}from"./chunk-EVYHPR3J.js";import{a as Sa,b as ha,c as ya,d as La,e as va,f as Za,g as ba,h as ga,i as ua,j as Ta,k as ja,l as Fa,m as Wa,n as ka,o as wa,p as za}from"./chunk-6XFXPIVB.js";import{$ as gt,A as Ue,Aa as Ut,B as Xe,Ba as Xt,C as Ye,Ca as Yt,D as _e,Da as _t,E as $e,Ea as $t,F as ot,Fa as om,G as rt,Ga as rm,H as et,Ha as em,I as tt,Ia as tm,J as mt,Ja as mm,K as pt,Ka as pm,L as at,La as am,M as ft,Ma as fm,N as xt,Na as xm,O as it,Oa as im,P as dt,Pa as dm,Q as ct,Qa as cm,R as st,Ra as sm,S as nt,Sa as nm,T as lt,Ta as lm,U as St,Ua as Sm,V as ht,Va as hm,W as yt,X as Lt,Y as vt,Z as Zt,_ as bt,aa as ut,b as Te,ba as Tt,c as je,ca as jt,d as Fe,da as Ft,e as We,ea as Wt,f as ke,fa as kt,g as we,ga as wt,h as ze,ha as zt,i as Be,ia as Bt,j as De,ja as Dt,k as Ee,ka as Et,l as Ge,la as Gt,m as Me,ma as Mt,n as Ne,na as Nt,o as Oe,oa as Ot,p as Pe,pa as Pt,q as Ve,qa as Vt,r as qe,ra as qt,s as Ae,sa as At,t as Ce,ta as Ct,u as He,ua as Ht,v as Ie,va as It,w as Je,wa as Jt,x as Ke,xa as Kt,y as Qe,ya as Qt,z as Re,za as Rt}from"./chunk-VUJXR5K5.js";import{a as Ba,b as Da,c as Ia,d as Ja,e as Ka,f as Qa}from"./chunk-ZZO4CKRU.js";import{a as Ea,b as Ga,c as Ma,d as Na,e as Oa,f as Pa,g as Va,h as qa,i as Aa,j as Ca,k as Ha}from"./chunk-NVVLLWIM.js";import{a as Xm,c as Ym,d as _m,e as $m,f as op,g as rp}from"./chunk-2PFNNGTV.js";import"./chunk-VMXSE3EC.js";import{a as Ra,b as Ua,c as Xa,d as Ya,e as _a,f as $a,g as of,h as rf,i as ef,j as tf,k as mf}from"./chunk-YNX3Q3CL.js";import{a as bm,b as gm,c as um,d as Tm,e as jm,f as Fm,g as Wm,h as km,i as wm,j as zm,k as Bm,l as Dm,m as Em,n as Gm,o as Mm,p as Nm,q as Om,r as ep,s as tp,t as mp}from"./chunk-2XMG3NJS.js";import{a as ym}from"./chunk-7GYFZKK7.js";import{a as Pm,b as Vm,c as qm,d as Am,e as Cm,f as Hm,g as Im,h as Jm,i as Km,j as Qm,k as Rm,l as Um}from"./chunk-QGIYILYI.js";import{a as pf,b as af,c as ff,d as xf}from"./chunk-WQ3WMMZD.js";import{h as lp,i as Sp,j as hp,k as yp,l as Lp}from"./chunk-D2PATZCC.js";import{e as M,f as N,g as O,h as P,i as V,j as q,m as A}from"./chunk-4QLJUQSJ.js";import{a as _o,b as $o,c as or,d as rr,g as er,h as tr,i as mr,j as pr}from"./chunk-7WRQ2UAN.js";import{A as Nf,B as Of,C as Pf,D as Vf,E as qf,a as df,b as cf,c as sf,d as nf,e as lf,f as Sf,g as hf,h as yf,i as Lf,j as vf,k as Zf,l as bf,m as gf,n as uf,o as Tf,p as jf,q as Ff,r as Wf,s as kf,t as wf,u as zf,v as Bf,w as Df,x as Ef,y as Gf,z as Mf}from"./chunk-IPWUDOV5.js";import{a as Op}from"./chunk-BH53MBAZ.js";import{a as ar,b as fr,c as xr,d as ir,e as dr,f as cr,g as sr,h as nr,i as lr,j as Sr,k as hr,l as yr,m as Lr,n as vr,o as Zr}from"./chunk-XRP4JJXL.js";import{a as Af,b as Cf,c as Hf}from"./chunk-7QF6YTEZ.js";import{a as lo,b as So,c as ho,d as yo,e as Lo,f as vo,g as Zo,h as bo,i as go,j as uo,k as To,l as jo}from"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";export{pp as ACTOR_TYPE,Wo as AspectRatio,Va as AudioClipSchema,ef as AudioItemSchema,Or as BOX_TYPE,Qf as BRIDGE_READY_EVENT,Te as BoundaryRicochet3DCoordinator,je as BoundaryRicochetCoordinator,Hr as CONE_TYPE,bm as CUTSCENE_BEHAVIOR_KEY,Ur as CYLINDER_TYPE,Xa as CameraKeyframeSchema,Ep as CameraManager,jp as CameraPipeline,$a as CameraShotSchema,Gp as CameraWrapper,Dx as ColorJsonSchema,vp as ConstructionGrid,Fe as CooldownBehavior,gm as CutsceneCameraBehavior,Ya as CutsceneCameraSchema,mf as CutsceneDefinitionSchema,of as CutsceneEventSchema,mp as CutscenePreviewController,Ua as CutsceneSceneSchema,tf as CutsceneTrackSchema,I as DEFAULT_SNAP_SETTINGS,ee as DISK_TYPE,We as Destructible3DBehavior,ke as DestructibleMesh,_a as DollyPathSchema,Lx as EntityJsonSchema,sx as EntitySchema,so as EntityThumbnailCache,Vo as EventEmitterDelegate,rf as EventItemSchema,ip as FOG_TYPE,we as FirstPersonBehavior,ze as FirstPersonEvent,Be as FirstPersonFSM,kp as FirstPersonPerspective,Ge as FirstPersonPresentation,De as FirstPersonShooterCoordinator,Ee as FirstPersonState,Wp as Fixed2DPerspective,c as Fn,Me as FractureOptions,$p as Game,Yo as GameBridge,Vx as GameConfigJsonSchema,Px as GameDeviceConfigJsonSchema,Bx as GameInputConfigSchema,zx as GameInputPlayerConfigSchema,Qa as Howl,Ma as InstrumentDefinitionSchema,Ga as InstrumentEffectSchema,Ea as InstrumentPresetSchema,wp as IsometricPerspective,Ne as Jumper2DBehavior,Oe as Jumper2DEvent,Pe as Jumper2DFSM,Ve as Jumper2DState,qe as Jumper3DBehavior,Ae as Jumper3DEvent,Ce as Jumper3DFSM,He as Jumper3DState,Zx as KeyboardMappingSchema,be as LIGHT_TYPE,Rp as LINE_TYPE,hx as LineEntityDataSchema,wx as MouseConfigSchema,bx as MouseMappingSchema,Ie as MultidirectionalSpaceShooterCoordinator,Pa as NoteClipSchema,da as PARTICLE_SYSTEM_TYPE,_r as PILL_TYPE,pe as PLANE_TYPE,Kr as PYRAMID_TYPE,Je as ParticleEmitterBehavior,Tp as Perspectives,Ke as Platformer2DBehavior,Qe as Platformer2DEvent,Re as Platformer2DFSM,Ue as Platformer2DState,Xe as Platformer3DBehavior,Ye as Platformer3DEvent,_e as Platformer3DFSM,$e as Platformer3DState,Le as RECT_TYPE,ba as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ga as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,ua as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,Ta as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,ja as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,Fa as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,sp as RenderBundleManager,np as RenderStrategyManager,Ox as ResolutionInputSchema,ot as Ricochet2DBehavior,rt as Ricochet2DEvent,et as Ricochet2DFSM,tt as Ricochet2DState,mt as Ricochet3DBehavior,pt as Ricochet3DEvent,at as Ricochet3DFSM,ft as Ricochet3DState,Sa as RuntimeBoundary2DBehavior,ha as RuntimeDynamicCircleBody2DBehavior,ya as RuntimeGoalZone2DBehavior,La as RuntimePlayerInput2DBehavior,va as RuntimeRicochet2DBehavior,Za as RuntimeTriggerRegion2DBehavior,xe as SELECTION_BOUNDS_MARGIN,ie as SELECTION_THIN_AXIS_FRACTION,ce as SELECTION_THIN_AXIS_MAX,de as SELECTION_THIN_AXIS_MIN,qr as SPHERE_TYPE,Jp as SPRITE_TYPE,ta as STAGE_STATE_CHANGE,Ra as SceneTransitionSchema,xt as ScreenVisibilityBehavior,it as ScreenVisibilityFSM,dt as ScreenWrapBehavior,ct as ScreenWrapEvent,st as ScreenWrapFSM,nt as ScreenWrapState,Bp as SecondPersonPerspective,lt as Shooter2DBehavior,xp as SimulationBody,qa as SongClipSchema,Ha as SongDefinitionSchema,Ca as SongLoopSchema,Na as SongNoteSchema,Oa as SongTrackSchema,yx as SpriteEntityDataSchema,Mx as StageAssetLoaderConfigSchema,mx as StageBodyKind,px as StageBoundaryDim,Nx as StageConfigJsonSchema,ax as StageEventType,Gx as StageGLTFAssetLoaderConfigSchema,vx as StageJsonSchema,Ap as StageManager,fx as StageRicochetDim,xx as StageRicochetReflection,nx as StageSchema,ix as StageTopDownPlane,Cp as TEXT_TYPE,C as TRANSFORM_TOOLS,lx as TextEntityDataSchema,Fp as ThirdPersonPerspective,St as ThrusterBehavior,ht as ThrusterEvent,yt as ThrusterFSM,Lt as ThrusterState,Aa as TimeSignatureSchema,vt as TopDownMovementBehavior,zp as TopDownPerspective,Zt as TopDownShooterCoordinator,gp as TransformGizmo,$o as VEC2_ONE,_o as VEC2_ZERO,rr as VEC3_ONE,or as VEC3_ZERO,Ex as Vec3ComponentsSchema,cx as Vector2Schema,Sx as Vector3TupleSchema,Tx as VirtualTouchButtonConfigSchema,Fx as VirtualTouchButtonsConfigSchema,kx as VirtualTouchConfigSchema,jx as VirtualTouchJoystickConfigSchema,Wx as VirtualTouchJoysticksConfigSchema,ux as VirtualTouchPositionSchema,gx as VirtualTouchStyleSchema,bt as WorldBoundary2DBehavior,gt as WorldBoundary2DEvent,ut as WorldBoundary2DFSM,Tt as WorldBoundary2DState,jt as WorldBoundary3DBehavior,Ft as WorldBoundary3DEvent,Wt as WorldBoundary3DFSM,kt as WorldBoundary3DState,Se as ZONE_TYPE,ap as ZylemActor,Pr as ZylemBox,Ir as ZylemCone,Xr as ZylemCylinder,te as ZylemDisk,dp as ZylemFog,Rf as ZylemGameElement,ge as ZylemLight,Xp as ZylemLine,ca as ZylemParticleSystem,$r as ZylemPill,ae as ZylemPlane,Qr as ZylemPyramid,ve as ZylemRect,Ar as ZylemSphere,Kp as ZylemSprite,Hp as ZylemText,he as ZylemZone,u as abs,km as activeShot,Jf as announceBridgeReady,Kf as applySwatchesToSelection,Op as applyTransformChanges,g as asin,b as atan,Qm as audibleTrackIds,Pm as beatsPerBar,qm as beatsToSeconds,Wa as bindRuntimeDynamicCircleBody2DHandle,gr as boxCollision,Br as boxMesh,Xf as buildBoxCollider,_f as buildCapsuleCollider,ox as buildConvexHullCollider,$f as buildCylinderCollider,ex as buildHeightfieldCollider,Uf as buildRuntimeBody,Yf as buildSphereCollider,rx as buildTrimeshCollider,tx as bundleRuntimeCollision,Sf as callFunc,Mm as cameraTracks,L as clamp,A as clearGlobalSubscriptions,Um as clipsAt,Zp as closestAxisValue,wt as computeWorldBoundary2DHits,zt as computeWorldBoundary3DHits,Tr as coneCollision,Er as coneMesh,Z as cos,zr as create,fp as createActor,s as createBackgroundShader,Vr as createBox,Mp as createCamera,Jr as createCone,na as createCooldownIcon,Om as createCutscenePlayer,Yr as createCylinder,me as createDisk,re as createEntity,_p as createEntityFactory,Bt as createFirstPersonInputComponent,Dt as createFirstPersonMovementComponent,Et as createFirstPersonStateComponent,cp as createFog,aa as createFollowTarget,oa as createGame,N as createGlobal,Xm as createInstrument,Gt as createJumpConfig2D,Mt as createJumpConfig3D,Nt as createJumpInput2D,Ot as createJumpInput3D,Pt as createJumpState2D,Vt as createJumpState3D,ue as createLight,Yp as createLine,m as createNodeMaterialFromTSL,sa as createParticleSystem,Dp as createPerspective,qt as createPhysicsBodyComponent,oe as createPill,fe as createPlane,fa as createPlatformFollow,At as createPlatformer2DInputComponent,Ct as createPlatformer2DMovementComponent,Ht as createPlatformer2DStateComponent,It as createPlatformer3DInputComponent,Jt as createPlatformer3DMovementComponent,Kt as createPlatformer3DStateComponent,Rr as createPyramid,Ze as createRect,Qt as createShooter2DStateComponent,dx as createSimulation,op as createSongPlayer,Cr as createSphere,Qp as createSprite,Vp as createStage,tp as createStageCutsceneHost,xa as createStrategyPan,Ip as createText,Rt as createThrusterInputComponent,Ut as createThrusterMovementComponent,Xt as createThrusterStateComponent,Yt as createTopDownMovementComponent,_t as createTopDownMovementInputComponent,$t as createTopDownMovementStateComponent,om as createTransformComponent,Tf as createTransformStore,Sp as createVariable,ye as createZone,ym as crossfadeTransitionShader,Nm as cutsceneLength,Fr as cylinderCollision,Mr as cylinderMesh,Jm as dbToGain,J as debugState,Oo as defaultTouchControls,rm as defineBehavior,Uo as degreesToRadians,lf as delay,la as destroy,pa as dispatchStageState,zm as dollyPointAt,B as dot,um as easeValue,ka as emitRuntimeGoal,wa as emitRuntimeRicochet,za as emitRuntimeTriggerRegionEnter,Ja as encodeWav,Ka as encodeWavBlob,_m as ensureAudio,ea as entitySpawner,no as entityThumbnailCache,Io as eulerToQuaternion,Dm as evaluateCameraPose,Em as evaluateCutscene,T as exp,hf as fadeOpacity,em as fireCooldown,tm as fireShooter2DIfRequested,d as float,w as floor,Co as focusEntity,z as fract,Km as gainToDb,Po as gameConfig,rp as getActiveSongPlayer,mm as getCooldown,pm as getCooldownStore,ko as getDisplayAspect,am as getEntityFacingAngle2D,O as getGlobal,q as getGlobals,io as getHoveredEntity,ao as getHoveredEntityId,Ef as getPosition,wo as getPresetResolution,Zr as getRotation,xo as getSelectedEntity,_ as getSelectedEntityId,oo as getSelectedEntityIds,eo as getSnapSettings,hp as getVariable,Gf as getVelocity,If as getZylemBridge,pf as globalChange,af as globalChanges,fm as hasAnyWorldBoundary2DHit,xm as hasAnyWorldBoundary3DHit,ma as initStageStateDispatcher,bp as intersectPlane,$m as isAudioReady,t as isGLSLShader,Zm as isManagedRenderEntity,Y as isPickMode,e as isTSLShader,H as isTransformTool,Fo as isWebGPUSupported,Gm as itemsBetween,Go as joystickBaseSvg,Mo as joystickThumbSvg,D as length,jm as lerpPose,Tm as lerpVec3,Ym as loadTone,W as max,ne as measureObjectSelectionBounds,jo as mergeInputConfigs,Hm as midiToFrequency,Im as midiToNoteName,k as min,h as mix,G as mod,jf as move,cf as moveBy,Df as moveForwardXY,sf as moveTo,Ff as moveX,wf as moveXY,zf as moveXZ,Wf as moveY,kf as moveZ,S as normalize,er as normalizeVec2,tr as normalizeVec3,o as objectVertexShader,P as onGlobalChange,V as onGlobalChanges,Lf as onPress,vf as onRelease,yp as onVariableChange,Lp as onVariableChanges,br as packCollisionGroups,se as padSelectionBounds,bf as parallel,zo as parseResolution,im as particleEffect,dm as particlePresets,Up as pickZylemLine,Wr as pillCollision,Nr as pillMesh,Da as pingPongBeep,kr as planeCollision,l as positionWorld,n as positionWorldDirection,j as pow,wm as previousShot,jr as pyramidCollision,Gr as pyramidMesh,Jo as quaternionToEuler,Xo as radiansToDegrees,cm as registerCooldown,K as registerDebugEntityResolver,Ao as registerEntityFocusContext,Ia as renderSong,gf as repeat,uf as repeatForever,sm as resetCooldown,df as resetEntityOpacity,Bf as resetVelocity,nm as resolveAim2D,Eo as resolveButtonAccent,Q as resolveDebugEntity,Lm as resolveRenderCategory,le as resolveSelectionBounds,Do as resolveTouchTheme,Ba as ricochetSound,nf as rotateBy,xr as rotateEuler,ar as rotateInDirection,dr as rotateX,ir as rotateY,fr as rotateYEuler,cr as rotateZ,Bm as sampleDollyPath,Fm as sceneAt,Rm as scheduleSong,Hf as screenCenterLookDeltas,Cf as screenCenterLookTargets,Am as secondsToBeats,Zf as sequence,po as setAddType,ia as setCameraFeed,ep as setCutsceneTransitionShaders,U as setDebugTool,M as setGlobal,mo as setGridVisible,fo as setHoveredEntityId,R as setPaused,X as setPickMode,Mf as setPosition,Nf as setPositionX,Of as setPositionY,Pf as setPositionZ,Lr as setRotation,vr as setRotationDegrees,Sr as setRotationDegreesX,nr as setRotationDegreesY,yr as setRotationDegreesZ,lr as setRotationX,sr as setRotationY,hr as setRotationZ,co as setSelectedEntity,$ as setSelectedEntityId,ro as setSelectedEntityIds,to as setSnapSettings,up as setStageFrameProfilerEnabled,lp as setVariable,Af as shortestAngleDelta,Wm as shotAt,v as sin,y as smoothstep,Ro as snapScale,Ko as snapToIncrement,Qo as snapVec3,Vm as songLengthBeats,Cm as songLengthSeconds,ur as sphereCollision,Dr as sphereMesh,Np as stageConfig,qp as stageState,r as standardShader,F as step,Ho as streamLevel,ra as streamLevelOnStage,yf as throttle,lm as tickCooldowns,f as time,mr as toThreeVector2,pr as toThreeVector3,No as touchButtonSvg,Bo as touchThemes,p as uniform,Sm as updateBoundaryRicochet,lo as useArrowsForAxes,ho as useArrowsForDirections,So as useArrowsForSecondaryAxes,hm as useBehavior,vo as useIJKLForAxes,Zo as useIJKLForDirections,uo as useMouse,bo as useMouseLook,go as useScreenCenterLook,To as useVirtualControls,Lo as useWASDForAxes,yo as useWASDForDirections,vm as usesManagedRenderPath,a as uv,ff as variableChange,xf as variableChanges,E as vec2,x as vec3,i as vec4,Pp as vessel,qf as wrapAround3D,Vf as wrapAroundXY,wr as zoneCollision,qo as zylemEventBus};
1
+ import{A as Ox,B as Px,C as Vx,a as cx,b as sx,c as nx,d as lx,e as Sx,f as hx,g as yx,h as Lx,i as vx,j as Zx,k as bx,l as gx,m as ux,n as Tx,o as jx,p as Fx,q as Wx,r as kx,s as wx,t as zx,u as Bx,v as Dx,w as Ex,x as Gx,y as Mx,z as Nx}from"./chunk-KSEP7AUF.js";import"./chunk-ORIDWL3T.js";import{a as s,b as n,c as l,d as S,e as h,f as y,g as L,h as v,i as Z,j as b,k as g,l as u,m as T,n as j,o as F,p as W,q as k,r as w,s as z,t as B,u as D,v as E,w as G}from"./chunk-QB3NL7VQ.js";import"./chunk-BIGH6D34.js";import"./chunk-ELQN62PQ.js";import{a as If,b as Jf,c as Kf,d as Qf}from"./chunk-FZNEWOC5.js";import{a as Rf}from"./chunk-4CZZZCFB.js";import{a as Uf,b as Xf,c as Yf,d as _f,e as $f,f as ox,g as rx,h as ex,i as tx,j as mx,k as px,l as ax,m as fx,n as xx,o as ix,p as dx}from"./chunk-47DG7I7M.js";import{a as Wo,b as ko,c as wo,d as zo,e as Po,f as qp,g as Ap,h as $p,i as oa,j as ra,k as ea,l as ta,m as ma,n as pa,o as aa,p as fa,q as xa,r as ia}from"./chunk-2IJLXFWY.js";import{a as Fo,c as Lm,d as vm,e as Zm,f as sp,g as np,h as up,i as Tp,k as jp,l as Fp,m as Wp,n as kp,o as wp,p as zp,q as Bp,r as Dp,s as Ep,t as Gp,u as Mp,v as Np,w as Pp,y as Vp}from"./chunk-NK4IXK5V.js";import{a as Bo,b as Do,c as Eo,d as Go,e as Mo,f as No,g as Oo}from"./chunk-PCFF4LLO.js";import{a as so,b as no}from"./chunk-OCQ7A5IK.js";import{c as vp,d as Zp,e as bp,f as gp}from"./chunk-47HAZZWF.js";import"./chunk-VSFULLND.js";import"./chunk-2HSR5XDQ.js";import{e as Ho,n as Yo}from"./chunk-3CLQWJ2I.js";import{a as Ao,b as Co,c as Io,d as Jo,e as Ko,f as Qo,g as Ro,h as Uo,i as Xo}from"./chunk-BQRMYLYD.js";import{B as xo,C as io,D as co,a as C,b as H,c as I,d as J,e as K,f as Q,h as R,j as U,l as X,m as Y,n as _,o as $,p as oo,q as ro,u as eo,v as to,w as mo,x as po,y as ao,z as fo}from"./chunk-GPCSX3M6.js";import{b as xp}from"./chunk-WBQ5TNRZ.js";import{a as da,b as ca,c as sa,d as na,e as la}from"./chunk-K3NNXZIJ.js";import{a as Cp,b as Hp,c as Ip,d as Jp,e as Kp,f as Qp,g as Rp,h as Up,i as Xp,j as Yp,l as _p}from"./chunk-LI43BZQN.js";import{a as pp,b as ap,c as fp,d as ip,e as dp,f as cp}from"./chunk-YQS7CGXE.js";import{A as te,B as me,C as pe,D as ae,E as fe,F as Se,G as he,H as ye,I as Le,J as ve,K as Ze,L as be,M as ge,N as ue,b as Br,c as Dr,d as Er,e as Gr,f as Mr,g as Nr,h as Or,i as Pr,j as Vr,k as qr,l as Ar,m as Cr,n as Hr,o as Ir,p as Jr,q as Kr,r as Qr,s as Rr,t as Ur,u as Xr,v as Yr,w as _r,x as $r,y as oe,z as ee}from"./chunk-STVEILJJ.js";import{c as gr,d as ur,e as Tr,f as jr,g as Fr,h as Wr,i as kr,j as wr,u as zr,z as re}from"./chunk-KP6DLLJO.js";import{c as o,d as r,h as e,i as t,k as m,l as p,m as a,n as f,o as x,p as i,q as d,r as c}from"./chunk-6FGXC4T6.js";import{a as Vo,b as qo}from"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import{a as xe,b as ie,c as de,d as ce,e as se,f as ne,g as le}from"./chunk-UUOPT2N4.js";import{b as br}from"./chunk-EVYHPR3J.js";import{a as Sa,b as ha,c as ya,d as La,e as va,f as Za,g as ba,h as ga,i as ua,j as Ta,k as ja,l as Fa,m as Wa,n as ka,o as wa,p as za}from"./chunk-6XFXPIVB.js";import{$ as gt,A as Ue,Aa as Ut,B as Xe,Ba as Xt,C as Ye,Ca as Yt,D as _e,Da as _t,E as $e,Ea as $t,F as ot,Fa as om,G as rt,Ga as rm,H as et,Ha as em,I as tt,Ia as tm,J as mt,Ja as mm,K as pt,Ka as pm,L as at,La as am,M as ft,Ma as fm,N as xt,Na as xm,O as it,Oa as im,P as dt,Pa as dm,Q as ct,Qa as cm,R as st,Ra as sm,S as nt,Sa as nm,T as lt,Ta as lm,U as St,Ua as Sm,V as ht,Va as hm,W as yt,X as Lt,Y as vt,Z as Zt,_ as bt,aa as ut,b as Te,ba as Tt,c as je,ca as jt,d as Fe,da as Ft,e as We,ea as Wt,f as ke,fa as kt,g as we,ga as wt,h as ze,ha as zt,i as Be,ia as Bt,j as De,ja as Dt,k as Ee,ka as Et,l as Ge,la as Gt,m as Me,ma as Mt,n as Ne,na as Nt,o as Oe,oa as Ot,p as Pe,pa as Pt,q as Ve,qa as Vt,r as qe,ra as qt,s as Ae,sa as At,t as Ce,ta as Ct,u as He,ua as Ht,v as Ie,va as It,w as Je,wa as Jt,x as Ke,xa as Kt,y as Qe,ya as Qt,z as Re,za as Rt}from"./chunk-VUJXR5K5.js";import{a as Ba,b as Da,c as Ia,d as Ja,e as Ka,f as Qa}from"./chunk-ZZO4CKRU.js";import{a as Ea,b as Ga,c as Ma,d as Na,e as Oa,f as Pa,g as Va,h as qa,i as Aa,j as Ca,k as Ha}from"./chunk-NVVLLWIM.js";import{a as Xm,c as Ym,d as _m,e as $m,f as op,g as rp}from"./chunk-2PFNNGTV.js";import"./chunk-VMXSE3EC.js";import{a as Ra,b as Ua,c as Xa,d as Ya,e as _a,f as $a,g as of,h as rf,i as ef,j as tf,k as mf}from"./chunk-YNX3Q3CL.js";import{a as bm,b as gm,c as um,d as Tm,e as jm,f as Fm,g as Wm,h as km,i as wm,j as zm,k as Bm,l as Dm,m as Em,n as Gm,o as Mm,p as Nm,q as Om,r as ep,s as tp,t as mp}from"./chunk-2XMG3NJS.js";import{a as ym}from"./chunk-7GYFZKK7.js";import{a as Pm,b as Vm,c as qm,d as Am,e as Cm,f as Hm,g as Im,h as Jm,i as Km,j as Qm,k as Rm,l as Um}from"./chunk-QGIYILYI.js";import{a as pf,b as af,c as ff,d as xf}from"./chunk-WQ3WMMZD.js";import{h as lp,i as Sp,j as hp,k as yp,l as Lp}from"./chunk-D2PATZCC.js";import{e as M,f as N,g as O,h as P,i as V,j as q,m as A}from"./chunk-4QLJUQSJ.js";import{a as _o,b as $o,c as or,d as rr,g as er,h as tr,i as mr,j as pr}from"./chunk-7WRQ2UAN.js";import{A as Nf,B as Of,C as Pf,D as Vf,E as qf,a as df,b as cf,c as sf,d as nf,e as lf,f as Sf,g as hf,h as yf,i as Lf,j as vf,k as Zf,l as bf,m as gf,n as uf,o as Tf,p as jf,q as Ff,r as Wf,s as kf,t as wf,u as zf,v as Bf,w as Df,x as Ef,y as Gf,z as Mf}from"./chunk-IPWUDOV5.js";import{a as Op}from"./chunk-BH53MBAZ.js";import{a as ar,b as fr,c as xr,d as ir,e as dr,f as cr,g as sr,h as nr,i as lr,j as Sr,k as hr,l as yr,m as Lr,n as vr,o as Zr}from"./chunk-XRP4JJXL.js";import{a as Af,b as Cf,c as Hf}from"./chunk-7QF6YTEZ.js";import{a as lo,b as So,c as ho,d as yo,e as Lo,f as vo,g as Zo,h as bo,i as go,j as uo,k as To,l as jo}from"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";export{pp as ACTOR_TYPE,Wo as AspectRatio,Va as AudioClipSchema,ef as AudioItemSchema,Or as BOX_TYPE,Qf as BRIDGE_READY_EVENT,Te as BoundaryRicochet3DCoordinator,je as BoundaryRicochetCoordinator,Hr as CONE_TYPE,bm as CUTSCENE_BEHAVIOR_KEY,Ur as CYLINDER_TYPE,Xa as CameraKeyframeSchema,Ep as CameraManager,jp as CameraPipeline,$a as CameraShotSchema,Gp as CameraWrapper,Dx as ColorJsonSchema,vp as ConstructionGrid,Fe as CooldownBehavior,gm as CutsceneCameraBehavior,Ya as CutsceneCameraSchema,mf as CutsceneDefinitionSchema,of as CutsceneEventSchema,mp as CutscenePreviewController,Ua as CutsceneSceneSchema,tf as CutsceneTrackSchema,I as DEFAULT_SNAP_SETTINGS,ee as DISK_TYPE,We as Destructible3DBehavior,ke as DestructibleMesh,_a as DollyPathSchema,Lx as EntityJsonSchema,sx as EntitySchema,so as EntityThumbnailCache,Vo as EventEmitterDelegate,rf as EventItemSchema,ip as FOG_TYPE,we as FirstPersonBehavior,ze as FirstPersonEvent,Be as FirstPersonFSM,kp as FirstPersonPerspective,Ge as FirstPersonPresentation,De as FirstPersonShooterCoordinator,Ee as FirstPersonState,Wp as Fixed2DPerspective,c as Fn,Me as FractureOptions,$p as Game,Yo as GameBridge,Vx as GameConfigJsonSchema,Px as GameDeviceConfigJsonSchema,Bx as GameInputConfigSchema,zx as GameInputPlayerConfigSchema,Qa as Howl,Ma as InstrumentDefinitionSchema,Ga as InstrumentEffectSchema,Ea as InstrumentPresetSchema,wp as IsometricPerspective,Ne as Jumper2DBehavior,Oe as Jumper2DEvent,Pe as Jumper2DFSM,Ve as Jumper2DState,qe as Jumper3DBehavior,Ae as Jumper3DEvent,Ce as Jumper3DFSM,He as Jumper3DState,Zx as KeyboardMappingSchema,be as LIGHT_TYPE,Rp as LINE_TYPE,hx as LineEntityDataSchema,wx as MouseConfigSchema,bx as MouseMappingSchema,Ie as MultidirectionalSpaceShooterCoordinator,Pa as NoteClipSchema,da as PARTICLE_SYSTEM_TYPE,_r as PILL_TYPE,pe as PLANE_TYPE,Kr as PYRAMID_TYPE,Je as ParticleEmitterBehavior,Tp as Perspectives,Ke as Platformer2DBehavior,Qe as Platformer2DEvent,Re as Platformer2DFSM,Ue as Platformer2DState,Xe as Platformer3DBehavior,Ye as Platformer3DEvent,_e as Platformer3DFSM,$e as Platformer3DState,Le as RECT_TYPE,ba as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ga as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,ua as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,Ta as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,ja as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,Fa as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,sp as RenderBundleManager,np as RenderStrategyManager,Ox as ResolutionInputSchema,ot as Ricochet2DBehavior,rt as Ricochet2DEvent,et as Ricochet2DFSM,tt as Ricochet2DState,mt as Ricochet3DBehavior,pt as Ricochet3DEvent,at as Ricochet3DFSM,ft as Ricochet3DState,Sa as RuntimeBoundary2DBehavior,ha as RuntimeDynamicCircleBody2DBehavior,ya as RuntimeGoalZone2DBehavior,La as RuntimePlayerInput2DBehavior,va as RuntimeRicochet2DBehavior,Za as RuntimeTriggerRegion2DBehavior,xe as SELECTION_BOUNDS_MARGIN,ie as SELECTION_THIN_AXIS_FRACTION,ce as SELECTION_THIN_AXIS_MAX,de as SELECTION_THIN_AXIS_MIN,qr as SPHERE_TYPE,Jp as SPRITE_TYPE,ta as STAGE_STATE_CHANGE,Ra as SceneTransitionSchema,xt as ScreenVisibilityBehavior,it as ScreenVisibilityFSM,dt as ScreenWrapBehavior,ct as ScreenWrapEvent,st as ScreenWrapFSM,nt as ScreenWrapState,Bp as SecondPersonPerspective,lt as Shooter2DBehavior,xp as SimulationBody,qa as SongClipSchema,Ha as SongDefinitionSchema,Ca as SongLoopSchema,Na as SongNoteSchema,Oa as SongTrackSchema,yx as SpriteEntityDataSchema,Mx as StageAssetLoaderConfigSchema,mx as StageBodyKind,px as StageBoundaryDim,Nx as StageConfigJsonSchema,ax as StageEventType,Gx as StageGLTFAssetLoaderConfigSchema,vx as StageJsonSchema,Ap as StageManager,fx as StageRicochetDim,xx as StageRicochetReflection,nx as StageSchema,ix as StageTopDownPlane,Cp as TEXT_TYPE,C as TRANSFORM_TOOLS,lx as TextEntityDataSchema,Fp as ThirdPersonPerspective,St as ThrusterBehavior,ht as ThrusterEvent,yt as ThrusterFSM,Lt as ThrusterState,Aa as TimeSignatureSchema,vt as TopDownMovementBehavior,zp as TopDownPerspective,Zt as TopDownShooterCoordinator,gp as TransformGizmo,$o as VEC2_ONE,_o as VEC2_ZERO,rr as VEC3_ONE,or as VEC3_ZERO,Ex as Vec3ComponentsSchema,cx as Vector2Schema,Sx as Vector3TupleSchema,Tx as VirtualTouchButtonConfigSchema,Fx as VirtualTouchButtonsConfigSchema,kx as VirtualTouchConfigSchema,jx as VirtualTouchJoystickConfigSchema,Wx as VirtualTouchJoysticksConfigSchema,ux as VirtualTouchPositionSchema,gx as VirtualTouchStyleSchema,bt as WorldBoundary2DBehavior,gt as WorldBoundary2DEvent,ut as WorldBoundary2DFSM,Tt as WorldBoundary2DState,jt as WorldBoundary3DBehavior,Ft as WorldBoundary3DEvent,Wt as WorldBoundary3DFSM,kt as WorldBoundary3DState,Se as ZONE_TYPE,ap as ZylemActor,Pr as ZylemBox,Ir as ZylemCone,Xr as ZylemCylinder,te as ZylemDisk,dp as ZylemFog,Rf as ZylemGameElement,ge as ZylemLight,Xp as ZylemLine,ca as ZylemParticleSystem,$r as ZylemPill,ae as ZylemPlane,Qr as ZylemPyramid,ve as ZylemRect,Ar as ZylemSphere,Kp as ZylemSprite,Hp as ZylemText,he as ZylemZone,u as abs,km as activeShot,Jf as announceBridgeReady,Kf as applySwatchesToSelection,Op as applyTransformChanges,g as asin,b as atan,Qm as audibleTrackIds,Pm as beatsPerBar,qm as beatsToSeconds,Wa as bindRuntimeDynamicCircleBody2DHandle,gr as boxCollision,Br as boxMesh,Xf as buildBoxCollider,_f as buildCapsuleCollider,ox as buildConvexHullCollider,$f as buildCylinderCollider,ex as buildHeightfieldCollider,Uf as buildRuntimeBody,Yf as buildSphereCollider,rx as buildTrimeshCollider,tx as bundleRuntimeCollision,Sf as callFunc,Mm as cameraTracks,L as clamp,A as clearGlobalSubscriptions,Um as clipsAt,Zp as closestAxisValue,wt as computeWorldBoundary2DHits,zt as computeWorldBoundary3DHits,Tr as coneCollision,Er as coneMesh,Z as cos,zr as create,fp as createActor,s as createBackgroundShader,Vr as createBox,Mp as createCamera,Jr as createCone,na as createCooldownIcon,Om as createCutscenePlayer,Yr as createCylinder,me as createDisk,re as createEntity,_p as createEntityFactory,Bt as createFirstPersonInputComponent,Dt as createFirstPersonMovementComponent,Et as createFirstPersonStateComponent,cp as createFog,aa as createFollowTarget,oa as createGame,N as createGlobal,Xm as createInstrument,Gt as createJumpConfig2D,Mt as createJumpConfig3D,Nt as createJumpInput2D,Ot as createJumpInput3D,Pt as createJumpState2D,Vt as createJumpState3D,ue as createLight,Yp as createLine,m as createNodeMaterialFromTSL,sa as createParticleSystem,Dp as createPerspective,qt as createPhysicsBodyComponent,oe as createPill,fe as createPlane,fa as createPlatformFollow,At as createPlatformer2DInputComponent,Ct as createPlatformer2DMovementComponent,Ht as createPlatformer2DStateComponent,It as createPlatformer3DInputComponent,Jt as createPlatformer3DMovementComponent,Kt as createPlatformer3DStateComponent,Rr as createPyramid,Ze as createRect,Qt as createShooter2DStateComponent,dx as createSimulation,op as createSongPlayer,Cr as createSphere,Qp as createSprite,Vp as createStage,tp as createStageCutsceneHost,xa as createStrategyPan,Ip as createText,Rt as createThrusterInputComponent,Ut as createThrusterMovementComponent,Xt as createThrusterStateComponent,Yt as createTopDownMovementComponent,_t as createTopDownMovementInputComponent,$t as createTopDownMovementStateComponent,om as createTransformComponent,Tf as createTransformStore,Sp as createVariable,ye as createZone,ym as crossfadeTransitionShader,Nm as cutsceneLength,Fr as cylinderCollision,Mr as cylinderMesh,Jm as dbToGain,J as debugState,Oo as defaultTouchControls,rm as defineBehavior,Uo as degreesToRadians,lf as delay,la as destroy,pa as dispatchStageState,zm as dollyPointAt,B as dot,um as easeValue,ka as emitRuntimeGoal,wa as emitRuntimeRicochet,za as emitRuntimeTriggerRegionEnter,Ja as encodeWav,Ka as encodeWavBlob,_m as ensureAudio,ea as entitySpawner,no as entityThumbnailCache,Io as eulerToQuaternion,Dm as evaluateCameraPose,Em as evaluateCutscene,T as exp,hf as fadeOpacity,em as fireCooldown,tm as fireShooter2DIfRequested,d as float,w as floor,Co as focusEntity,z as fract,Km as gainToDb,Po as gameConfig,rp as getActiveSongPlayer,mm as getCooldown,pm as getCooldownStore,ko as getDisplayAspect,am as getEntityFacingAngle2D,O as getGlobal,q as getGlobals,io as getHoveredEntity,ao as getHoveredEntityId,Ef as getPosition,wo as getPresetResolution,Zr as getRotation,xo as getSelectedEntity,_ as getSelectedEntityId,oo as getSelectedEntityIds,eo as getSnapSettings,hp as getVariable,Gf as getVelocity,If as getZylemBridge,pf as globalChange,af as globalChanges,fm as hasAnyWorldBoundary2DHit,xm as hasAnyWorldBoundary3DHit,ma as initStageStateDispatcher,bp as intersectPlane,$m as isAudioReady,t as isGLSLShader,Zm as isManagedRenderEntity,Y as isPickMode,e as isTSLShader,H as isTransformTool,Fo as isWebGPUSupported,Gm as itemsBetween,Go as joystickBaseSvg,Mo as joystickThumbSvg,D as length,jm as lerpPose,Tm as lerpVec3,Ym as loadTone,W as max,ne as measureObjectSelectionBounds,jo as mergeInputConfigs,Hm as midiToFrequency,Im as midiToNoteName,k as min,h as mix,G as mod,jf as move,cf as moveBy,Df as moveForwardXY,sf as moveTo,Ff as moveX,wf as moveXY,zf as moveXZ,Wf as moveY,kf as moveZ,S as normalize,er as normalizeVec2,tr as normalizeVec3,o as objectVertexShader,P as onGlobalChange,V as onGlobalChanges,Lf as onPress,vf as onRelease,yp as onVariableChange,Lp as onVariableChanges,br as packCollisionGroups,se as padSelectionBounds,bf as parallel,zo as parseResolution,im as particleEffect,dm as particlePresets,Up as pickZylemLine,Wr as pillCollision,Nr as pillMesh,Da as pingPongBeep,kr as planeCollision,l as positionWorld,n as positionWorldDirection,j as pow,wm as previousShot,jr as pyramidCollision,Gr as pyramidMesh,Jo as quaternionToEuler,Xo as radiansToDegrees,cm as registerCooldown,K as registerDebugEntityResolver,Ao as registerEntityFocusContext,Ia as renderSong,gf as repeat,uf as repeatForever,sm as resetCooldown,df as resetEntityOpacity,Bf as resetVelocity,nm as resolveAim2D,Eo as resolveButtonAccent,Q as resolveDebugEntity,Lm as resolveRenderCategory,le as resolveSelectionBounds,Do as resolveTouchTheme,Ba as ricochetSound,nf as rotateBy,xr as rotateEuler,ar as rotateInDirection,dr as rotateX,ir as rotateY,fr as rotateYEuler,cr as rotateZ,Bm as sampleDollyPath,Fm as sceneAt,Rm as scheduleSong,Hf as screenCenterLookDeltas,Cf as screenCenterLookTargets,Am as secondsToBeats,Zf as sequence,po as setAddType,ia as setCameraFeed,ep as setCutsceneTransitionShaders,U as setDebugTool,M as setGlobal,mo as setGridVisible,fo as setHoveredEntityId,R as setPaused,X as setPickMode,Mf as setPosition,Nf as setPositionX,Of as setPositionY,Pf as setPositionZ,Lr as setRotation,vr as setRotationDegrees,Sr as setRotationDegreesX,nr as setRotationDegreesY,yr as setRotationDegreesZ,lr as setRotationX,sr as setRotationY,hr as setRotationZ,co as setSelectedEntity,$ as setSelectedEntityId,ro as setSelectedEntityIds,to as setSnapSettings,up as setStageFrameProfilerEnabled,lp as setVariable,Af as shortestAngleDelta,Wm as shotAt,v as sin,y as smoothstep,Ro as snapScale,Ko as snapToIncrement,Qo as snapVec3,Vm as songLengthBeats,Cm as songLengthSeconds,ur as sphereCollision,Dr as sphereMesh,Np as stageConfig,qp as stageState,r as standardShader,F as step,Ho as streamLevel,ra as streamLevelOnStage,yf as throttle,lm as tickCooldowns,f as time,mr as toThreeVector2,pr as toThreeVector3,No as touchButtonSvg,Bo as touchThemes,p as uniform,Sm as updateBoundaryRicochet,lo as useArrowsForAxes,ho as useArrowsForDirections,So as useArrowsForSecondaryAxes,hm as useBehavior,vo as useIJKLForAxes,Zo as useIJKLForDirections,uo as useMouse,bo as useMouseLook,go as useScreenCenterLook,To as useVirtualControls,Lo as useWASDForAxes,yo as useWASDForDirections,vm as usesManagedRenderPath,a as uv,ff as variableChange,xf as variableChanges,E as vec2,x as vec3,i as vec4,Pp as vessel,qf as wrapAround3D,Vf as wrapAroundXY,wr as zoneCollision,qo as zylemEventBus};