@combos-fun/plugin-renderer-3d 0.1.26 → 0.1.28

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.
@@ -1 +1 @@
1
- "use strict";var e=require("tslib"),t=require("@combos-fun/engine"),r=require("three"),o=require("@combos-fun/inspector-decorator"),s=require("three/addons/loaders/KTX2Loader.js");const i="combosGameObjectId",n="combosTransform3D";function a(e){return!!e?.userData?.[n]}function c(e,t){e.traverse(e=>{e.userData[i]=t})}function p(e){let t=e;for(;t;){const e=t.userData?.[i];if("number"==typeof e)return e;t=t.parent}}function d(e){if(!e)return!0;const t=e.parent;return!t||t===e.scene}function h(e){return{positionX:e.positionX??0,positionY:e.positionY??0,positionZ:e.positionZ??0,rotationX:e.rotationX??0,rotationY:e.rotationY??0,rotationZ:e.rotationZ??0,scaleX:e.scaleX??1,scaleY:e.scaleY??1,scaleZ:e.scaleZ??1}}function l(e){const t=h(e);return[t.positionX,t.positionY,t.positionZ,t.rotationX,t.rotationY,t.rotationZ,t.scaleX,t.scaleY,t.scaleZ].join(",")}function m(e,t){const r=h(e);t.positionX=r.positionX,t.positionY=r.positionY,t.positionZ=r.positionZ,t.rotationX=r.rotationX,t.rotationY=r.rotationY,t.rotationZ=r.rotationZ,t.scaleX=r.scaleX,t.scaleY=r.scaleY,t.scaleZ=r.scaleZ}function u(e){const t=h(e);return 0===t.positionX&&0===t.positionY&&0===t.positionZ&&0===t.rotationX&&0===t.rotationY&&0===t.rotationZ&&1===t.scaleX&&1===t.scaleY&&1===t.scaleZ}function g(e,t){u(t)&&!u(e)&&m(e,t)}const f={none:r.NoToneMapping,aces:r.ACESFilmicToneMapping,linear:r.LinearToneMapping,reinhard:r.ReinhardToneMapping,cineon:r.CineonToneMapping},y=new r.Vector3,b=new r.Euler;class C{constructor(e){this.mixers=new Map,this.models=new Map,this.nodes=new Map,this.defaultLights=[];const{canvas:t,container:o,width:s,height:i,antialias:n=!0,backgroundColor:a=0,backgroundAlpha:c=1}=e;this.scene=new r.Scene,this.shadows=!!e.shadows,this.camera=new r.PerspectiveCamera(75,s/i,.1,1e3),this.camera.position.z=5,this.fallbackCamera=this.camera;const p=e.pixelRatio??1;this.width=s,this.height=i,this.pixelRatio=p;const d={antialias:n,powerPreference:e.powerPreference??"high-performance"};t&&(d.canvas=t),c<1&&(d.alpha=!0),this.renderer=new r.WebGLRenderer(d),this.renderer.setPixelRatio(1),this.renderer.setSize(Math.max(1,Math.round(s*p)),Math.max(1,Math.round(i*p)),!1),this.renderer.domElement.style.width="",this.renderer.domElement.style.height="",this.renderer.setClearColor(a,c),this.renderer.toneMapping=f[e.toneMapping??"aces"]??r.ACESFilmicToneMapping,this.renderer.toneMappingExposure=e.toneMappingExposure??1,this.anisotropy=function(e){const t=e.capabilities,r=t?.getMaxAnisotropy?.()??0;return r>1?Math.min(8,r):1}(this.renderer);const h=e.softShadows??p<2,l=e.shadowMapSize??(h?1024:512);this.shadows&&(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=h?r.PCFSoftShadowMap:r.PCFShadowMap),!t&&o&&o.appendChild(this.renderer.domElement);const m=new r.AmbientLight(16777215,e.ambientIntensity??.6);this.scene.add(m),this.defaultLights.push(m);const u=new r.DirectionalLight(16777215,e.directionalIntensity??.8);if(u.position.set(5,10,7.5),this.shadows&&(u.castShadow=!0,u.shadow.mapSize.set(l,l)),this.scene.add(u),this.defaultLights.push(u),!1!==e.hemisphereLight){const t="object"==typeof e.hemisphereLight?e.hemisphereLight:{},o=new r.HemisphereLight(t.skyColor??16777215,t.groundColor??4473924,t.intensity??.35);this.scene.add(o),this.defaultLights.push(o)}if(e.fog){const t="object"==typeof e.fog?e.fog:{};this.scene.fog=new r.Fog(t.color??a,t.near??8,t.far??40)}this.clock=new r.Clock}update(e){const t=this.clock.getDelta();if(!e?.skipDraw){for(const e of this.mixers.values())e.update(t);this.renderer.render(this.scene,this.camera)}}setPixelRatio(e){e>0&&e!==this.pixelRatio&&(this.pixelRatio=e)}presentBuffer(e,t){if(!(e>=1&&t>=1))return;this.renderer.setDrawingBufferSize(e,t,1);const r=this.renderer.domElement;r.width===e&&r.height===t||(r.width=e,r.height=t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.fallbackCamera!==this.camera&&(this.fallbackCamera.aspect=e/t,this.fallbackCamera.updateProjectionMatrix())}configureTexture(e){!e?.isTexture||this.anisotropy<=1||e.anisotropy!==this.anisotropy&&(e.anisotropy=this.anisotropy,e.needsUpdate=!0)}configureObject(e){!e||this.anisotropy<=1||e.traverse(e=>{const t=e;if(!t.isMesh||!t.material)return;const r=Array.isArray(t.material)?t.material:[t.material];for(const e of r)v(e,e=>this.configureTexture(e))})}hasTransform3DRoot(e){return a(this.nodes.get(e))}applyModelShadows(e){this.shadows&&e.traverse(e=>{const t=e;t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0)})}attachParsedModel(e,t,o,s){if(c(t,e),this.applyModelShadows(t),this.models.set(e,t),this.attachVisual(e,t,s),o&&o.length>0){const s=new r.AnimationMixer(t);this.mixers.set(e,s),t.userData.animations=o}return t}object3DFor(e){return this.nodes.get(e)}attachObject3D(e,t,r){const o=this.nodes.get(e);o&&o!==t&&(this.rehomeRegisteredChildren(o),o.parent?.remove(o)),this.nodes.set(e,t);const s=this.findParentNode(r);t.parent!==s&&s.add(t),r&&this.adoptChildGameObjects(r,t)}attachVisual(e,t,r){c(t,e),this.configureObject(t);const o=this.nodes.get(e);a(o)&&o!==t?t.parent!==o&&o.add(t):this.attachObject3D(e,t,r)}detachVisual(e,t){const r=this.nodes.get(e);return a(r)&&r!==t?(t.parent?.remove(t),t):r===t?this.detachObject3D(e):(t.parent?.remove(t),t)}detachObject3D(e){const t=this.nodes.get(e);if(t)return this.rehomeRegisteredChildren(t),t.parent?.remove(t),this.nodes.delete(e),t}reparentGameObject(e){const t=this.nodes.get(e.id);if(!t)return;const r=this.findParentNode(e);t.parent!==r&&r.add(t)}findParentNode(e){if(!e||d(e))return this.scene;let t=e.parent;for(;t&&t!==e.scene;){const e=this.nodes.get(t.id);if(e)return e;t=t.parent}return this.scene}adoptChildGameObjects(e,t){const r=e.children;if(r)for(const e of r){if(!e)continue;const r=this.nodes.get(e.id);r&&r.parent!==t&&t.add(r)}}ensureTransformRoot(e,t){const o=this.nodes.get(e.id);if(a(o))return this.applyTransformPose(o,t),o;const s=new r.Group;if(s.name=e.name,s.userData[n]=!0,c(s,e.id),o&&o!==s){(function(e){const t=h(e);return 0===t.positionX&&0===t.positionY&&0===t.positionZ&&0===t.rotationX&&0===t.rotationY&&0===t.rotationZ&&1===t.scaleX&&1===t.scaleY&&1===t.scaleZ})(t)&&(t.positionX=o.position.x,t.positionY=o.position.y,t.positionZ=o.position.z,t.rotationX=o.rotation.x,t.rotationY=o.rotation.y,t.rotationZ=o.rotation.z,t.scaleX=o.scale.x,t.scaleY=o.scale.y,t.scaleZ=o.scale.z);(o.parent||this.scene).add(s),s.add(o),o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),this.nodes.set(e.id,s),this.adoptChildGameObjects(e,s)}else this.attachObject3D(e.id,s,e);return this.applyTransformPose(s,t),s}applyTransform3D(e,t){const r=this.ensureTransformRoot(e,t);return this.applyTransformPose(r,t),r.updateWorldMatrix(!0,!1),r.getWorldPosition(y),t.worldPositionX=y.x,t.worldPositionY=y.y,t.worldPositionZ=y.z,b.setFromRotationMatrix(r.matrixWorld),t.worldRotationX=b.x,t.worldRotationY=b.y,t.worldRotationZ=b.z,r}applyTransformPose(e,t){const r=h(t);e.position.set(r.positionX,r.positionY,r.positionZ),e.rotation.set(r.rotationX,r.rotationY,r.rotationZ),e.scale.set(r.scaleX,r.scaleY,r.scaleZ)}removeDefaultLights(){if(this.defaultLights.length){for(const e of this.defaultLights)e.parent?.remove(e),e.dispose?.();this.defaultLights=[]}}setActiveCamera(e){const t=this.camera;this.camera=e,t&&(e.aspect=t.aspect),e.updateProjectionMatrix()}restoreFallbackCamera(){this.camera!==this.fallbackCamera&&this.setActiveCamera(this.fallbackCamera)}rehomeRegisteredChildren(e){for(const t of[...e.children]){const e=t.userData?.[i];"number"==typeof e&&this.nodes.get(e)===t&&this.scene.add(t)}}playAnimation(e,t,r){const o=this.mixers.get(e),s=this.models.get(e);if(!o||!s)return;o.stopAllAction();const i=s.userData.animations;if(i&&i[t]){const e=o.clipAction(i[t]);e.timeScale=r,e.play()}}stopAnimation(e){const t=this.mixers.get(e);t&&t.stopAllAction()}removeModel(e){const t=this.models.get(e);t&&(this.detachVisual(e,t),t.traverse(e=>{const t=e;if(t.geometry&&t.geometry.dispose(),t.material){(Array.isArray(t.material)?t.material:[t.material]).forEach(e=>e.dispose())}}),this.models.delete(e));const r=this.mixers.get(e);r&&(r.stopAllAction(),this.mixers.delete(e))}resize(e,t){this.width=e,this.height=t,this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.fallbackCamera!==this.camera&&(this.fallbackCamera.aspect=e/t,this.fallbackCamera.updateProjectionMatrix()),this.renderer.setSize(e,t,!1)}destroy(){for(const e of this.models.keys())this.removeModel(e);this.removeDefaultLights(),this.renderer.dispose(),this.renderer.domElement.remove(),this.nodes.clear(),this.scene=null,this.camera=null,this.fallbackCamera=null,this.renderer=null,this.clock=null}}const x=["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","lightMap","metalnessMap","normalMap","roughnessMap"];function v(e,t){const r=e;for(const e of x){const o=r[e];o?.isTexture&&t(o)}}class w{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this,t.threeContext=this.rendererSystem.threeContext,this.renderers.push(t)}componentChanged(e){for(const r of e)for(const e of this.renderers){const o=e.observerInfo[r.componentName];if(!o)continue;if(r.type===t.OBSERVER_TYPE.ADD||r.type===t.OBSERVER_TYPE.REMOVE){try{e.componentChanged(r)}catch(e){console.error(`gameObject: ${r.gameObject.name}, ${r.componentName} error.`,r,e)}continue}if(o.findIndex(e=>"string"==typeof e&&"string"==typeof r.prop?e===r.prop:JSON.stringify(e)===JSON.stringify(r.prop))>-1)try{e.componentChanged(r)}catch(e){console.error(`gameObject: ${r.gameObject?.name}, ${r.componentName} componentChanged error.`,r,e)}}}update(e){for(const t of e.components)for(const r of this.renderers){if(r.observerInfo[t.name])try{r.rendererUpdate(e)}catch(r){console.info(`gameObject: ${e.name}, ${t.name} update error`,r)}}}}class D extends t.Component{constructor(){super(...arguments),this.positionX=0,this.positionY=0,this.positionZ=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.scaleX=1,this.scaleY=1,this.scaleZ=1,this.worldPositionX=0,this.worldPositionY=0,this.worldPositionZ=0,this.worldRotationX=0,this.worldRotationY=0,this.worldRotationZ=0}static{this.componentName="Transform3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionX",description:"Local X position.",editor:"number-stepper"})],D.prototype,"positionX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionY",description:"Local Y position.",editor:"number-stepper"})],D.prototype,"positionY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionZ",description:"Local Z position.",editor:"number-stepper"})],D.prototype,"positionZ",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationX",description:"Rotation around X in radians.",editor:"number-stepper"})],D.prototype,"rotationX",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationY",description:"Rotation around Y in radians.",editor:"number-stepper"})],D.prototype,"rotationY",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationZ",description:"Rotation around Z in radians.",editor:"number-stepper"})],D.prototype,"rotationZ",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleX",description:"Scale on X.",editor:"number-stepper"})],D.prototype,"scaleX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleY",description:"Scale on Y.",editor:"number-stepper"})],D.prototype,"scaleY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleZ",description:"Scale on Z.",editor:"number-stepper"})],D.prototype,"scaleZ",void 0);let R=class extends t.System{constructor(){super(...arguments),this.name="Renderer3DSystem",this.adaptive=null,this.pauseWhenHidden=!0,this.resolution=1,this.resizeObserver=null}static{this.systemName="Renderer3DSystem"}init(e){const r=e||{},o=r.width||750,s=r.height||1334,i=t.resolveRenderQuality(r,{adaptivePixelRatio:!1});this.resolution=i.pixelRatio,this.pauseWhenHidden=i.pauseWhenHidden,this.adaptive=new t.AdaptivePixelRatio({pixelRatio:i.pixelRatio,ceiling:i.pixelRatioCeiling,enabled:i.adaptivePixelRatio}),this.threeContext=new C({canvas:r.canvas,container:r.container,width:o,height:s,antialias:i.antialias,pixelRatio:i.pixelRatio,powerPreference:i.powerPreference,softShadows:r.softShadows,shadowMapSize:r.shadowMapSize,backgroundColor:r.backgroundColor,backgroundAlpha:r.backgroundAlpha,fog:r.fog,hemisphereLight:r.hemisphereLight,shadows:r.shadows,toneMapping:r.toneMapping,toneMappingExposure:r.toneMappingExposure,ambientIntensity:r.ambientIntensity,directionalIntensity:r.directionalIntensity}),this.game.canvas=this.threeContext.renderer.domElement,this.unregisterMetrics=this.game.diagnostics.register(function(e,r){let o=null,s=!0,i=!1,n={calls:0,triangles:0};const a={drawCalls:{supported:!0,coverage:"all passes including shadows within renderer.render"},canvasDrawOps:{supported:!1,reason:"backend-not-applicable"},triangles:{supported:!0},textures:{supported:!0},geometries:{supported:!0},programs:{supported:!0},gpuMs:{supported:!1,reason:"timer-query-unavailable"}};return{id:r,dimension:"3d",backend:"webgl",canvas:e.domElement,capabilities:a,start(r={}){i||(i=!0,o=r.gpuTiming?new t.WebGLGpuTimer(e.getContext()):null,a.gpuMs={supported:!!o?.supported,reason:o?.supported?void 0:r.gpuTiming?"timer-query-unavailable":"disabled-by-config"})},stop(){o?.clear(),o=null,i=!1},beginFrame(){s=e.info.autoReset,s&&e.info.reset(),e.info.autoReset=!1,n={calls:e.info.render.calls,triangles:e.info.render.triangles},o?.begin()},endFrame:()=>(e.info.autoReset=s,{drawCalls:e.info.render.calls-n.calls,triangles:e.info.render.triangles-n.triangles,canvasDrawOps:null,gpuMs:o?.end()??null}),resources:()=>({textures:e.info.memory.textures,geometries:e.info.memory.geometries,programs:e.info.programs?.length??0,bufferWidth:e.domElement.width,bufferHeight:e.domElement.height})}}(this.threeContext.renderer,"three-0")),this.observeCanvas(this.game.canvas),this.rendererManager=new w({game:this.game,rendererSystem:this})}update(e){const t=this.componentObserver.clear();for(const e of t)this.handleHierarchyChange(e);for(const e of this.game.gameObjects){const t=e.getComponent(D);t&&this.threeContext.applyTransform3D(e,t),this.rendererManager.update(e)}}handleHierarchyChange(e){"GameObject"===e.componentName&&(e.type!==t.OBSERVER_TYPE.CHANGE&&e.type!==t.OBSERVER_TYPE.ADD||(this.ensureTransform3D(e.gameObject),e.gameObject.parent&&this.ensureTransform3D(e.gameObject.parent),this.threeContext?.reparentGameObject(e.gameObject)))}ensureTransform3D(e){if(!e||e.destroyed||e===e.scene)return;let t=e.getComponent(D);(t||(t=new D,e.addComponent(t)))&&this.threeContext?.ensureTransformRoot(e,t)}lateUpdate(e){if(!this.threeContext)return;if(t.shouldPauseRendering(this.pauseWhenHidden))return void this.threeContext.update({skipDraw:!0});const r=this.adaptive?.sample(e?.deltaTime??0);null!=r&&(this.resolution=r,this.threeContext.pixelRatio=r,this.applyDisplay()),this.game.diagnostics.measureRender("three-0",()=>this.threeContext.update())}resize(e,t){this.applyDisplay()}observeCanvas(e){this.resizeObserver?.disconnect(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>this.applyDisplay()),this.resizeObserver.observe(e)),this.applyDisplay()}applyDisplay(){const e=this.threeContext?.renderer?.domElement;if(!e||"function"!=typeof e.getBoundingClientRect)return;const r=e.getBoundingClientRect(),o=t.displayBufferSize(r,this.resolution);if(!o)return;const s=e.width,i=e.height;if(s===o.bufferWidth&&i===o.bufferHeight){const e=o.bufferWidth/o.bufferHeight;if(Math.abs(this.threeContext.camera.aspect-e)<1e-6)return}this.threeContext.presentBuffer(o.bufferWidth,o.bufferHeight)}onDestroy(){this.unregisterMetrics?.(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.threeContext?.destroy(),this.threeContext=null}};R=e.__decorate([t.decorators.componentObserver({GameObject:["parent"]})],R);var O=R;Object.assign(O,{packageName:"@combos-fun/plugin-renderer-3d",packageVersion:"0.1.26"});class _ extends t.System{constructor(e){super(e),this.asyncIdMap={};const t=this.constructor;this.observerInfo=t.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}const S=new Set(["positionX","positionY","positionZ","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"]);let M=class extends _{constructor(){super(...arguments),this.name="Transform3DSystem"}static{this.systemName="Transform3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("GameObject"===e.componentName)return this.ensureOn(e.gameObject),e.gameObject.parent&&this.ensureOn(e.gameObject.parent),void this.threeContext.reparentGameObject(e.gameObject);"Transform3D"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.threeContext.ensureTransformRoot(e.gameObject,e.component):e.type===t.OBSERVER_TYPE.REMOVE?this.threeContext.detachObject3D(e.gameObject.id):S.has(e.prop?.prop?.[0])&&this.threeContext.applyTransform3D(e.gameObject,e.component))}rendererUpdate(e){const t=e.getComponent(D);t&&this.threeContext.applyTransform3D(e,t)}ensureOn(e){if(!e||e.destroyed||e===e.scene)return;let t=e.getComponent(D);(t||(t=new D,e.addComponent(t)))&&this.threeContext.ensureTransformRoot(e,t)}};M=e.__decorate([t.decorators.componentObserver({Transform3D:["positionX","positionY","positionZ","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"],GameObject:["parent"]})],M);var T=M;class E extends t.Component{constructor(){super(...arguments),this.visible=!0,this.opacity=1,this.renderOrder=0,this.sortableChildren=!1}static{this.componentName="Render3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"boolean",group:"Render3D",label:"visible",description:"Whether this object is drawn.",editor:"toggle"})],E.prototype,"visible",void 0),e.__decorate([o.Field({type:"number",step:.01,min:0,max:1,group:"Render3D",label:"opacity",description:"Opacity from 0 to 1.",editor:"number-slider"})],E.prototype,"opacity",void 0),e.__decorate([o.Field({type:"number",step:1,group:"Render3D",label:"renderOrder",description:"Draw order; higher values render on top.",editor:"number-stepper"})],E.prototype,"renderOrder",void 0),e.__decorate([o.Field({type:"boolean",group:"Render3D",label:"sortableChildren",description:"When on, children are sorted by their render order before drawing.",editor:"toggle"})],E.prototype,"sortableChildren",void 0);let j=class extends _{constructor(){super(...arguments),this.name="Render3DSystem"}static{this.systemName="Render3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Render3D"===e.componentName){if(e.type===t.OBSERVER_TYPE.REMOVE){const t=this.threeContext.object3DFor(e.gameObject.id);return void(t&&this.apply(t,{visible:!0,opacity:1,renderOrder:0,sortableChildren:!1}))}this.applyTo(e.gameObject,e.component)}}rendererUpdate(e){const t=e.getComponent(E);t&&this.applyTo(e,t)}applyTo(e,t){const r=this.threeContext.object3DFor(e.id);r&&(this.apply(r,t),t.sortableChildren&&this.sortChildren(e,r))}apply(e,t){e.visible=t.visible,e.traverse(e=>{e.renderOrder=t.renderOrder;const r=e;if(!r.isMesh||!r.material)return;const o=Array.isArray(r.material)?r.material:[r.material];for(const e of o){const r=e;"number"==typeof r.opacity&&(r.opacity=t.opacity,r.transparent=t.opacity<1)}})}sortChildren(e,t){const r=e.children?.map(e=>{if(!e)return null;const r=this.threeContext.object3DFor(e.id);if(!r||r.parent!==t)return null;const o=e.getComponent(E);return{node:r,order:o?.renderOrder??0}}).filter(e=>!!e).sort((e,t)=>e.order-t.order);if(r?.length)for(const e of r)t.add(e.node)}};j=e.__decorate([t.decorators.componentObserver({Render3D:["visible","opacity","renderOrder","sortableChildren"]})],j);var A=j;class Y extends t.Component{constructor(){super(...arguments),this.fov=75,this.near=.1,this.far=1e3,this.active=!0,this.lookAt=!1,this.lookAtX=0,this.lookAtY=0,this.lookAtZ=0}static{this.componentName="Camera3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"number",step:1,group:"Camera3D",label:"fov",description:"Vertical field of view in degrees.",editor:"number-stepper"})],Y.prototype,"fov",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Camera3D",label:"near",description:"Near clipping plane.",editor:"number-stepper"})],Y.prototype,"near",void 0),e.__decorate([o.Field({type:"number",step:1,group:"Camera3D",label:"far",description:"Far clipping plane.",editor:"number-stepper"})],Y.prototype,"far",void 0),e.__decorate([o.Field({type:"boolean",group:"Camera3D",label:"active",description:"Use this camera for rendering.",editor:"toggle"})],Y.prototype,"active",void 0),e.__decorate([o.Field({type:"boolean",group:"Camera3D",label:"lookAt",description:"Point the camera at lookAtX/Y/Z each frame.",editor:"toggle"})],Y.prototype,"lookAt",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtX",description:"World-space look-at target on X.",editor:"number-stepper"})],Y.prototype,"lookAtX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtY",description:"World-space look-at target on Y.",editor:"number-stepper"})],Y.prototype,"lookAtY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtZ",description:"World-space look-at target on Z.",editor:"number-stepper"})],Y.prototype,"lookAtZ",void 0);let L=class extends _{constructor(){super(...arguments),this.name="Camera3DSystem",this.cameras=new Map}static{this.systemName="Camera3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Camera3D"!==e.componentName)return;const r=e.component;e.type===t.OBSERVER_TYPE.ADD?this.mount(e.gameObject,r):e.type===t.OBSERVER_TYPE.REMOVE?this.unmount(e.gameObject.id):this.sync(e.gameObject,r)}rendererUpdate(e){const t=e.getComponent(Y),r=this.cameras.get(e.id);t&&r&&t.lookAt&&r.lookAt(t.lookAtX,t.lookAtY,t.lookAtZ)}mount(e,t){this.ensureTransform(e);const o=new r.PerspectiveCamera(t.fov,this.threeContext.camera.aspect,t.near,t.far);this.threeContext.attachVisual(e.id,o,e),this.cameras.set(e.id,o),this.sync(e,t)}sync(e,t){const r=this.cameras.get(e.id);r&&(r.fov=t.fov,r.near=t.near,r.far=t.far,r.updateProjectionMatrix(),t.active?this.threeContext.setActiveCamera(r):this.threeContext.camera===r&&this.activateAnother(e.id))}unmount(e){const t=this.cameras.get(e);t&&(this.threeContext.detachVisual(e,t),this.cameras.delete(e),this.threeContext.camera===t&&this.activateAnother(e))}activateAnother(e){for(const[t,r]of this.cameras){if(t===e)continue;const o=this.game.gameObjects.find(e=>e.id===t),s=o?.getComponent(Y);if(s?.active)return void this.threeContext.setActiveCamera(r)}this.threeContext.restoreFallbackCamera()}ensureTransform(e){if(!e||e.destroyed)return;let t=e.getComponent(D);if(!t)return t=new D,t.positionZ=5,void e.addComponent(t);u(t)&&(t.positionZ=5)}onDestroy(){for(const[e]of this.cameras)this.unmount(e);this.cameras.clear()}};L=e.__decorate([t.decorators.componentObserver({Camera3D:["fov","near","far","active","lookAt","lookAtX","lookAtY","lookAtZ"]})],L);var k=L;class P extends t.Component{constructor(){super(...arguments),this.type="directional",this.color=16777215,this.intensity=1,this.castShadow=!1,this.skyColor=16777215,this.groundColor=4473924,this.distance=0,this.decay=2,this.angle=Math.PI/3,this.penumbra=0}static{this.componentName="Light3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"string",group:"Light3D",label:"type",description:"Light kind.",editor:"enum",enumOptions:["ambient","directional","hemisphere","point","spot"]})],P.prototype,"type",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"color",description:"Light color (hex).",editor:"number-stepper"})],P.prototype,"color",void 0),e.__decorate([o.Field({type:"number",step:.05,group:"Light3D",label:"intensity",description:"Light intensity.",editor:"number-stepper"})],P.prototype,"intensity",void 0),e.__decorate([o.Field({type:"boolean",group:"Light3D",label:"castShadow",description:"Whether this light casts shadows.",editor:"toggle"})],P.prototype,"castShadow",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"skyColor",description:"Hemisphere sky color (hex).",editor:"number-stepper"})],P.prototype,"skyColor",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"groundColor",description:"Hemisphere ground color (hex).",editor:"number-stepper"})],P.prototype,"groundColor",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Light3D",label:"distance",description:"Range for point and spot lights. 0 means no limit.",editor:"number-stepper"})],P.prototype,"distance",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Light3D",label:"decay",description:"Intensity falloff for point and spot lights.",editor:"number-stepper"})],P.prototype,"decay",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Light3D",label:"angle",description:"Spot light cone angle in radians.",editor:"number-stepper"})],P.prototype,"angle",void 0),e.__decorate([o.Field({type:"number",step:.01,min:0,max:1,group:"Light3D",label:"penumbra",description:"Spot light soft edge (0–1).",editor:"number-slider"})],P.prototype,"penumbra",void 0);let X=class extends _{constructor(){super(...arguments),this.name="Light3DSystem",this.lights=new Map}static{this.systemName="Light3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Light3D"!==e.componentName)return;const r=e.component;e.type===t.OBSERVER_TYPE.ADD?this.mount(e.gameObject,r):e.type===t.OBSERVER_TYPE.REMOVE?this.unmount(e.gameObject.id):"type"===e.prop?.prop?.[0]?(this.unmount(e.gameObject.id),this.mount(e.gameObject,r)):this.sync(e.gameObject.id,r)}rendererUpdate(e){}mount(e,t){this.ensureTransform(e),0===this.lights.size&&this.threeContext.removeDefaultLights();const r=this.createLight(t);this.threeContext.attachVisual(e.id,r,e),this.lights.set(e.id,r),this.sync(e.id,t)}createLight(e){switch(e.type){case"ambient":return new r.AmbientLight(e.color,e.intensity);case"hemisphere":return new r.HemisphereLight(e.skyColor,e.groundColor,e.intensity);case"point":return new r.PointLight(e.color,e.intensity,e.distance,e.decay);case"spot":return new r.SpotLight(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);default:return new r.DirectionalLight(e.color,e.intensity)}}sync(e,t){const o=this.lights.get(e);o&&("color"in o&&o.color&&o.color.set(t.color),o.intensity=t.intensity,o instanceof r.HemisphereLight&&(o.color.set(t.skyColor),o.groundColor.set(t.groundColor)),(o instanceof r.PointLight||o instanceof r.SpotLight)&&(o.distance=t.distance,o.decay=t.decay),o instanceof r.SpotLight&&(o.angle=t.angle,o.penumbra=t.penumbra),"castShadow"in o&&(o.castShadow=!(!t.castShadow||!this.threeContext.shadows)))}unmount(e){const t=this.lights.get(e);t&&(this.threeContext.detachVisual(e,t),t.dispose?.(),this.lights.delete(e))}ensureTransform(e){e&&!e.destroyed&&(e.getComponent(D)||e.addComponent(new D))}onDestroy(){for(const[e]of this.lights)this.unmount(e);this.lights.clear()}};X=e.__decorate([t.decorators.componentObserver({Light3D:["type","color","intensity","castShadow","skyColor","groundColor","distance","decay","angle","penumbra"]})],X);var Z=X;const F=["WEBGL_compressed_texture_astc","EXT_texture_compression_bptc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_etc"];let I=null,B=null;function V(e){return F.some(t=>e.extensions.has(t))}function N(e){return I||(I=new s.KTX2Loader,I.setTranscoderPath("https://unpkg.com/three@0.172.0/examples/jsm/libs/basis/")),e&&B!==e&&(I.detectSupport(e),B=e),I}async function G(e,t){if(!V(t))return null;try{const o=await N(t).loadAsync(e),s=o;return s?.isCompressedTexture&&s.format!==r.RGBAFormat?o:(o?.dispose(),null)}catch{return null}}async function z(e){const r=String(e??"").trim();if(!r)throw new Error("resource name is required; register it with resource.addResource");const o=await t.resource.getResource(r);if(!o||!o.name)throw new Error(`Unknown resource "${r}"; register it with resource.addResource first`);return o}function W(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?e:null}async function U(e){let t=e;if("function"==typeof createImageBitmap)try{t=await createImageBitmap(e)}catch{t=e}const o=new r.Texture(t);if(o.colorSpace=r.SRGBColorSpace,o.needsUpdate=!0,"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=t,r=o.dispose.bind(o);o.dispose=()=>{r();try{e.close()}catch{}}}return o}async function H(e,r){if(!r)return null;const o=function(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const t=e;return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}return null}(e.data?.image);if(!o)return null;const s=t.compressedTextureUrl(e.src?.image),i=URL.createObjectURL(new Blob([o]));try{const e=await G(i,r);if(e)return e}finally{URL.revokeObjectURL(i)}return s?G(s,r):null}async function $(e,r){const o=await H(e,r);if(o)return o;const s=W(e.data?.image);if(s)return U(s);const i=t.imageFallbackUrl(e.src?.image);if(i)try{return U(await(n=i,new Promise((e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=()=>t(new Error(`Failed to load image ${n}`)),r.src=n})))}catch{}var n;throw new Error(`Resource "${e.name}" has no image data; use RESOURCE_TYPE.IMAGE with src.image.url`)}exports.COMBOS_GAME_OBJECT_ID=i,exports.COMBOS_TRANSFORM3D=n,exports.Camera3D=Y,exports.Camera3DSystem=k,exports.Light3D=P,exports.Light3DSystem=Z,exports.Render3D=E,exports.Render3DSystem=A,exports.Renderer3D=_,exports.Renderer3DManager=w,exports.Renderer3DSystem=O,exports.ThreeContext=C,exports.Transform3D=D,exports.Transform3DSystem=T,exports.VisualPoseBridge=class{constructor(){this.lastVisual="",this.lastRoot=""}sync(e,t){if(!t)return!0;if(""===this.lastVisual&&""===this.lastRoot)return g(e,t),this.lastVisual=l(e),this.lastRoot=l(t),!1;const r=l(e),o=l(t);return r!==this.lastVisual&&o===this.lastRoot&&m(e,t),this.lastVisual=l(e),this.lastRoot=l(t),!1}},exports.copyPose=m,exports.ensureKtx2Loader=N,exports.gameObjectIdFromIntersection=function(e){return p(e?.object)},exports.gameObjectIdFromObject3D=p,exports.has3DChildGameObjects=function(e){return(e?.children?.length??0)>0},exports.is3DSceneParent=d,exports.isIdentityPose=u,exports.isTransform3DRoot=a,exports.loadThreeKtx2=G,exports.poseKeyOf=l,exports.readPose=h,exports.rendererSupportsCompressedTexture=V,exports.requireNamedResource=z,exports.seedTransform3D=g,exports.tagObject3D=c,exports.textureFromNamedImage=async function(e,t){return $(await z(e),t)},exports.textureFromResourceImage=function(e){const t=W(e.data?.image);if(!t)throw new Error(`Resource "${e.name}" has no image data; use RESOURCE_TYPE.IMAGE with src.image.url`);const o=new r.Texture(t);return o.colorSpace=r.SRGBColorSpace,o.needsUpdate=!0,o},exports.textureFromResourceImageAsync=$;
1
+ "use strict";var e=require("tslib"),t=require("@combos-fun/engine"),r=require("three"),o=require("@combos-fun/inspector-decorator"),s=require("three/addons/loaders/KTX2Loader.js");const i="combosGameObjectId",n="combosTransform3D";function a(e){return!!e?.userData?.[n]}function c(e,t){e.traverse(e=>{e.userData[i]=t})}function p(e){let t=e;for(;t;){const e=t.userData?.[i];if("number"==typeof e)return e;t=t.parent}}function d(e){if(!e)return!0;const t=e.parent;return!t||t===e.scene}function h(e){return{positionX:e.positionX??0,positionY:e.positionY??0,positionZ:e.positionZ??0,rotationX:e.rotationX??0,rotationY:e.rotationY??0,rotationZ:e.rotationZ??0,scaleX:e.scaleX??1,scaleY:e.scaleY??1,scaleZ:e.scaleZ??1}}function l(e){const t=h(e);return[t.positionX,t.positionY,t.positionZ,t.rotationX,t.rotationY,t.rotationZ,t.scaleX,t.scaleY,t.scaleZ].join(",")}function m(e,t){const r=h(e);t.positionX=r.positionX,t.positionY=r.positionY,t.positionZ=r.positionZ,t.rotationX=r.rotationX,t.rotationY=r.rotationY,t.rotationZ=r.rotationZ,t.scaleX=r.scaleX,t.scaleY=r.scaleY,t.scaleZ=r.scaleZ}function u(e){const t=h(e);return 0===t.positionX&&0===t.positionY&&0===t.positionZ&&0===t.rotationX&&0===t.rotationY&&0===t.rotationZ&&1===t.scaleX&&1===t.scaleY&&1===t.scaleZ}function g(e,t){u(t)&&!u(e)&&m(e,t)}const f={none:r.NoToneMapping,aces:r.ACESFilmicToneMapping,linear:r.LinearToneMapping,reinhard:r.ReinhardToneMapping,cineon:r.CineonToneMapping},y=new r.Vector3,b=new r.Euler;class C{constructor(e){this.mixers=new Map,this.models=new Map,this.nodes=new Map,this.defaultLights=[];const{canvas:t,container:o,width:s,height:i,antialias:n=!0,backgroundColor:a=0,backgroundAlpha:c=1}=e;this.scene=new r.Scene,this.shadows=!!e.shadows,this.camera=new r.PerspectiveCamera(75,s/i,.1,1e3),this.camera.position.z=5,this.fallbackCamera=this.camera;const p=e.pixelRatio??1;this.width=s,this.height=i,this.pixelRatio=p;const d={antialias:n,powerPreference:e.powerPreference??"high-performance"};t&&(d.canvas=t),c<1&&(d.alpha=!0),this.renderer=new r.WebGLRenderer(d),this.renderer.setPixelRatio(1),this.renderer.setSize(Math.max(1,Math.round(s*p)),Math.max(1,Math.round(i*p)),!1),this.renderer.domElement.style.width="",this.renderer.domElement.style.height="",this.renderer.setClearColor(a,c),this.renderer.toneMapping=f[e.toneMapping??"aces"]??r.ACESFilmicToneMapping,this.renderer.toneMappingExposure=e.toneMappingExposure??1,this.anisotropy=function(e){const t=e.capabilities,r=t?.getMaxAnisotropy?.()??0;return r>1?Math.min(8,r):1}(this.renderer);const h=e.softShadows??p<2,l=e.shadowMapSize??(h?1024:512);this.shadows&&(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=h?r.PCFSoftShadowMap:r.PCFShadowMap),!t&&o&&o.appendChild(this.renderer.domElement);const m=new r.AmbientLight(16777215,e.ambientIntensity??.6);this.scene.add(m),this.defaultLights.push(m);const u=new r.DirectionalLight(16777215,e.directionalIntensity??.8);if(u.position.set(5,10,7.5),this.shadows&&(u.castShadow=!0,u.shadow.mapSize.set(l,l)),this.scene.add(u),this.defaultLights.push(u),!1!==e.hemisphereLight){const t="object"==typeof e.hemisphereLight?e.hemisphereLight:{},o=new r.HemisphereLight(t.skyColor??16777215,t.groundColor??4473924,t.intensity??.35);this.scene.add(o),this.defaultLights.push(o)}if(e.fog){const t="object"==typeof e.fog?e.fog:{};this.scene.fog=new r.Fog(t.color??a,t.near??8,t.far??40)}this.clock=new r.Clock}update(e){const t=this.clock.getDelta();if(!e?.skipDraw){for(const e of this.mixers.values())e.update(t);this.renderer.render(this.scene,this.camera)}}setPixelRatio(e){e>0&&e!==this.pixelRatio&&(this.pixelRatio=e)}presentBuffer(e,t){if(!(e>=1&&t>=1))return;this.renderer.setDrawingBufferSize(e,t,1);const r=this.renderer.domElement;r.width===e&&r.height===t||(r.width=e,r.height=t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.fallbackCamera!==this.camera&&(this.fallbackCamera.aspect=e/t,this.fallbackCamera.updateProjectionMatrix())}configureTexture(e){!e?.isTexture||this.anisotropy<=1||e.anisotropy!==this.anisotropy&&(e.anisotropy=this.anisotropy,e.needsUpdate=!0)}configureObject(e){!e||this.anisotropy<=1||e.traverse(e=>{const t=e;if(!t.isMesh||!t.material)return;const r=Array.isArray(t.material)?t.material:[t.material];for(const e of r)v(e,e=>this.configureTexture(e))})}hasTransform3DRoot(e){return a(this.nodes.get(e))}applyModelShadows(e){this.shadows&&e.traverse(e=>{const t=e;t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0)})}attachParsedModel(e,t,o,s){if(c(t,e),this.applyModelShadows(t),this.models.set(e,t),this.attachVisual(e,t,s),o&&o.length>0){const s=new r.AnimationMixer(t);this.mixers.set(e,s),t.userData.animations=o}return t}object3DFor(e){return this.nodes.get(e)}attachObject3D(e,t,r){const o=this.nodes.get(e);o&&o!==t&&(this.rehomeRegisteredChildren(o),o.parent?.remove(o)),this.nodes.set(e,t);const s=this.findParentNode(r);t.parent!==s&&s.add(t),r&&this.adoptChildGameObjects(r,t)}attachVisual(e,t,r){c(t,e),this.configureObject(t);const o=this.nodes.get(e);a(o)&&o!==t?t.parent!==o&&o.add(t):this.attachObject3D(e,t,r)}detachVisual(e,t){const r=this.nodes.get(e);return a(r)&&r!==t?(t.parent?.remove(t),t):r===t?this.detachObject3D(e):(t.parent?.remove(t),t)}detachObject3D(e){const t=this.nodes.get(e);if(t)return this.rehomeRegisteredChildren(t),t.parent?.remove(t),this.nodes.delete(e),t}reparentGameObject(e){const t=this.nodes.get(e.id);if(!t)return;const r=this.findParentNode(e);t.parent!==r&&r.add(t)}findParentNode(e){if(!e||d(e))return this.scene;let t=e.parent;for(;t&&t!==e.scene;){const e=this.nodes.get(t.id);if(e)return e;t=t.parent}return this.scene}adoptChildGameObjects(e,t){const r=e.children;if(r)for(const e of r){if(!e)continue;const r=this.nodes.get(e.id);r&&r.parent!==t&&t.add(r)}}ensureTransformRoot(e,t){const o=this.nodes.get(e.id);if(a(o))return this.applyTransformPose(o,t),o;const s=new r.Group;if(s.name=e.name,s.userData[n]=!0,c(s,e.id),o&&o!==s){(function(e){const t=h(e);return 0===t.positionX&&0===t.positionY&&0===t.positionZ&&0===t.rotationX&&0===t.rotationY&&0===t.rotationZ&&1===t.scaleX&&1===t.scaleY&&1===t.scaleZ})(t)&&(t.positionX=o.position.x,t.positionY=o.position.y,t.positionZ=o.position.z,t.rotationX=o.rotation.x,t.rotationY=o.rotation.y,t.rotationZ=o.rotation.z,t.scaleX=o.scale.x,t.scaleY=o.scale.y,t.scaleZ=o.scale.z);(o.parent||this.scene).add(s),s.add(o),o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),this.nodes.set(e.id,s),this.adoptChildGameObjects(e,s)}else this.attachObject3D(e.id,s,e);return this.applyTransformPose(s,t),s}applyTransform3D(e,t){const r=this.ensureTransformRoot(e,t);return this.applyTransformPose(r,t),r.updateWorldMatrix(!0,!1),r.getWorldPosition(y),t.worldPositionX=y.x,t.worldPositionY=y.y,t.worldPositionZ=y.z,b.setFromRotationMatrix(r.matrixWorld),t.worldRotationX=b.x,t.worldRotationY=b.y,t.worldRotationZ=b.z,r}applyTransformPose(e,t){const r=h(t);e.position.set(r.positionX,r.positionY,r.positionZ),e.rotation.set(r.rotationX,r.rotationY,r.rotationZ),e.scale.set(r.scaleX,r.scaleY,r.scaleZ)}removeDefaultLights(){if(this.defaultLights.length){for(const e of this.defaultLights)e.parent?.remove(e),e.dispose?.();this.defaultLights=[]}}setActiveCamera(e){const t=this.camera;this.camera=e,t&&(e.aspect=t.aspect),e.updateProjectionMatrix()}restoreFallbackCamera(){this.camera!==this.fallbackCamera&&this.setActiveCamera(this.fallbackCamera)}rehomeRegisteredChildren(e){for(const t of[...e.children]){const e=t.userData?.[i];"number"==typeof e&&this.nodes.get(e)===t&&this.scene.add(t)}}playAnimation(e,t,r){const o=this.mixers.get(e),s=this.models.get(e);if(!o||!s)return;o.stopAllAction();const i=s.userData.animations;if(i&&i[t]){const e=o.clipAction(i[t]);e.timeScale=r,e.play()}}stopAnimation(e){const t=this.mixers.get(e);t&&t.stopAllAction()}removeModel(e){const t=this.models.get(e);t&&(this.detachVisual(e,t),t.traverse(e=>{const t=e;if(t.geometry&&t.geometry.dispose(),t.material){(Array.isArray(t.material)?t.material:[t.material]).forEach(e=>e.dispose())}}),this.models.delete(e));const r=this.mixers.get(e);r&&(r.stopAllAction(),this.mixers.delete(e))}resize(e,t){this.width=e,this.height=t,this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.fallbackCamera!==this.camera&&(this.fallbackCamera.aspect=e/t,this.fallbackCamera.updateProjectionMatrix()),this.renderer.setSize(e,t,!1)}destroy(){for(const e of this.models.keys())this.removeModel(e);this.removeDefaultLights(),this.renderer.dispose(),this.renderer.domElement.remove(),this.nodes.clear(),this.scene=null,this.camera=null,this.fallbackCamera=null,this.renderer=null,this.clock=null}}const x=["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","lightMap","metalnessMap","normalMap","roughnessMap"];function v(e,t){const r=e;for(const e of x){const o=r[e];o?.isTexture&&t(o)}}class w{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this,t.threeContext=this.rendererSystem.threeContext,this.renderers.push(t)}componentChanged(e){for(const r of e)for(const e of this.renderers){const o=e.observerInfo[r.componentName];if(!o)continue;if(r.type===t.OBSERVER_TYPE.ADD||r.type===t.OBSERVER_TYPE.REMOVE){try{e.componentChanged(r)}catch(e){console.error(`gameObject: ${r.gameObject.name}, ${r.componentName} error.`,r,e)}continue}if(o.findIndex(e=>"string"==typeof e&&"string"==typeof r.prop?e===r.prop:JSON.stringify(e)===JSON.stringify(r.prop))>-1)try{e.componentChanged(r)}catch(e){console.error(`gameObject: ${r.gameObject?.name}, ${r.componentName} componentChanged error.`,r,e)}}}update(e){for(const t of e.components)for(const r of this.renderers){if(r.observerInfo[t.name])try{r.rendererUpdate(e)}catch(r){console.info(`gameObject: ${e.name}, ${t.name} update error`,r)}}}}class D extends t.Component{constructor(){super(...arguments),this.positionX=0,this.positionY=0,this.positionZ=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.scaleX=1,this.scaleY=1,this.scaleZ=1,this.worldPositionX=0,this.worldPositionY=0,this.worldPositionZ=0,this.worldRotationX=0,this.worldRotationY=0,this.worldRotationZ=0}static{this.componentName="Transform3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionX",description:"Local X position.",editor:"number-stepper"})],D.prototype,"positionX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionY",description:"Local Y position.",editor:"number-stepper"})],D.prototype,"positionY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"positionZ",description:"Local Z position.",editor:"number-stepper"})],D.prototype,"positionZ",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationX",description:"Rotation around X in radians.",editor:"number-stepper"})],D.prototype,"rotationX",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationY",description:"Rotation around Y in radians.",editor:"number-stepper"})],D.prototype,"rotationY",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Transform3D",label:"rotationZ",description:"Rotation around Z in radians.",editor:"number-stepper"})],D.prototype,"rotationZ",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleX",description:"Scale on X.",editor:"number-stepper"})],D.prototype,"scaleX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleY",description:"Scale on Y.",editor:"number-stepper"})],D.prototype,"scaleY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Transform3D",label:"scaleZ",description:"Scale on Z.",editor:"number-stepper"})],D.prototype,"scaleZ",void 0);let R=class extends t.System{constructor(){super(...arguments),this.name="Renderer3DSystem",this.adaptive=null,this.pauseWhenHidden=!0,this.resolution=1,this.resizeObserver=null}static{this.systemName="Renderer3DSystem"}init(e){const r=e||{},o=r.width||750,s=r.height||1334,i=t.resolveRenderQuality(r,{adaptivePixelRatio:!1});this.resolution=i.pixelRatio,this.pauseWhenHidden=i.pauseWhenHidden,this.adaptive=new t.AdaptivePixelRatio({pixelRatio:i.pixelRatio,ceiling:i.pixelRatioCeiling,enabled:i.adaptivePixelRatio}),this.threeContext=new C({canvas:r.canvas,container:r.container,width:o,height:s,antialias:i.antialias,pixelRatio:i.pixelRatio,powerPreference:i.powerPreference,softShadows:r.softShadows,shadowMapSize:r.shadowMapSize,backgroundColor:r.backgroundColor,backgroundAlpha:r.backgroundAlpha,fog:r.fog,hemisphereLight:r.hemisphereLight,shadows:r.shadows,toneMapping:r.toneMapping,toneMappingExposure:r.toneMappingExposure,ambientIntensity:r.ambientIntensity,directionalIntensity:r.directionalIntensity}),this.game.canvas=this.threeContext.renderer.domElement,this.unregisterMetrics=this.game.diagnostics.register(function(e,r){let o=null,s=!0,i=!1,n={calls:0,triangles:0};const a={drawCalls:{supported:!0,coverage:"all passes including shadows within renderer.render"},canvasDrawOps:{supported:!1,reason:"backend-not-applicable"},triangles:{supported:!0},textures:{supported:!0},geometries:{supported:!0},programs:{supported:!0},gpuMs:{supported:!1,reason:"timer-query-unavailable"}};return{id:r,dimension:"3d",backend:"webgl",canvas:e.domElement,capabilities:a,start(r={}){i||(i=!0,o=r.gpuTiming?new t.WebGLGpuTimer(e.getContext()):null,a.gpuMs={supported:!!o?.supported,reason:o?.supported?void 0:r.gpuTiming?"timer-query-unavailable":"disabled-by-config"})},stop(){o?.clear(),o=null,i=!1},beginFrame(){s=e.info.autoReset,s&&e.info.reset(),e.info.autoReset=!1,n={calls:e.info.render.calls,triangles:e.info.render.triangles},o?.begin()},endFrame:()=>(e.info.autoReset=s,{drawCalls:e.info.render.calls-n.calls,triangles:e.info.render.triangles-n.triangles,canvasDrawOps:null,gpuMs:o?.end()??null}),resources:()=>({textures:e.info.memory.textures,geometries:e.info.memory.geometries,programs:e.info.programs?.length??0,bufferWidth:e.domElement.width,bufferHeight:e.domElement.height})}}(this.threeContext.renderer,"three-0")),this.observeCanvas(this.game.canvas),this.rendererManager=new w({game:this.game,rendererSystem:this})}update(e){const t=this.componentObserver.clear();for(const e of t)this.handleHierarchyChange(e);for(const e of this.game.gameObjects){const t=e.getComponent(D);t&&this.threeContext.applyTransform3D(e,t),this.rendererManager.update(e)}}handleHierarchyChange(e){"GameObject"===e.componentName&&(e.type!==t.OBSERVER_TYPE.CHANGE&&e.type!==t.OBSERVER_TYPE.ADD||(this.ensureTransform3D(e.gameObject),e.gameObject.parent&&this.ensureTransform3D(e.gameObject.parent),this.threeContext?.reparentGameObject(e.gameObject)))}ensureTransform3D(e){if(!e||e.destroyed||e===e.scene)return;let t=e.getComponent(D);(t||(t=new D,e.addComponent(t)))&&this.threeContext?.ensureTransformRoot(e,t)}lateUpdate(e){if(!this.threeContext)return;if(t.shouldPauseRendering(this.pauseWhenHidden))return void this.threeContext.update({skipDraw:!0});const r=this.adaptive?.sample(e?.deltaTime??0);null!=r&&(this.resolution=r,this.threeContext.pixelRatio=r,this.applyDisplay()),this.game.diagnostics.measureRender("three-0",()=>this.threeContext.update())}resize(e,t){this.applyDisplay()}observeCanvas(e){this.resizeObserver?.disconnect(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>this.applyDisplay()),this.resizeObserver.observe(e)),this.applyDisplay()}applyDisplay(){const e=this.threeContext?.renderer?.domElement;if(!e||"function"!=typeof e.getBoundingClientRect)return;const r=e.getBoundingClientRect(),o=t.displayBufferSize(r,this.resolution);if(!o)return;const s=e.width,i=e.height;if(s===o.bufferWidth&&i===o.bufferHeight){const e=o.bufferWidth/o.bufferHeight;if(Math.abs(this.threeContext.camera.aspect-e)<1e-6)return}this.threeContext.presentBuffer(o.bufferWidth,o.bufferHeight)}onDestroy(){this.unregisterMetrics?.(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.threeContext?.destroy(),this.threeContext=null}};R=e.__decorate([t.decorators.componentObserver({GameObject:["parent"]})],R);var O=R;Object.assign(O,{packageName:"@combos-fun/plugin-renderer-3d",packageVersion:"0.1.28"});class _ extends t.System{constructor(e){super(e),this.asyncIdMap={};const t=this.constructor;this.observerInfo=t.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}const S=new Set(["positionX","positionY","positionZ","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"]);let M=class extends _{constructor(){super(...arguments),this.name="Transform3DSystem"}static{this.systemName="Transform3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("GameObject"===e.componentName)return this.ensureOn(e.gameObject),e.gameObject.parent&&this.ensureOn(e.gameObject.parent),void this.threeContext.reparentGameObject(e.gameObject);"Transform3D"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.threeContext.ensureTransformRoot(e.gameObject,e.component):e.type===t.OBSERVER_TYPE.REMOVE?this.threeContext.detachObject3D(e.gameObject.id):S.has(e.prop?.prop?.[0])&&this.threeContext.applyTransform3D(e.gameObject,e.component))}rendererUpdate(e){const t=e.getComponent(D);t&&this.threeContext.applyTransform3D(e,t)}ensureOn(e){if(!e||e.destroyed||e===e.scene)return;let t=e.getComponent(D);(t||(t=new D,e.addComponent(t)))&&this.threeContext.ensureTransformRoot(e,t)}};M=e.__decorate([t.decorators.componentObserver({Transform3D:["positionX","positionY","positionZ","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"],GameObject:["parent"]})],M);var T=M;class E extends t.Component{constructor(){super(...arguments),this.visible=!0,this.opacity=1,this.renderOrder=0,this.sortableChildren=!1}static{this.componentName="Render3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"boolean",group:"Render3D",label:"visible",description:"Whether this object is drawn.",editor:"toggle"})],E.prototype,"visible",void 0),e.__decorate([o.Field({type:"number",step:.01,min:0,max:1,group:"Render3D",label:"opacity",description:"Opacity from 0 to 1.",editor:"number-slider"})],E.prototype,"opacity",void 0),e.__decorate([o.Field({type:"number",step:1,group:"Render3D",label:"renderOrder",description:"Draw order; higher values render on top.",editor:"number-stepper"})],E.prototype,"renderOrder",void 0),e.__decorate([o.Field({type:"boolean",group:"Render3D",label:"sortableChildren",description:"When on, children are sorted by their render order before drawing.",editor:"toggle"})],E.prototype,"sortableChildren",void 0);let j=class extends _{constructor(){super(...arguments),this.name="Render3DSystem"}static{this.systemName="Render3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Render3D"===e.componentName){if(e.type===t.OBSERVER_TYPE.REMOVE){const t=this.threeContext.object3DFor(e.gameObject.id);return void(t&&this.apply(t,{visible:!0,opacity:1,renderOrder:0,sortableChildren:!1}))}this.applyTo(e.gameObject,e.component)}}rendererUpdate(e){const t=e.getComponent(E);t&&this.applyTo(e,t)}applyTo(e,t){const r=this.threeContext.object3DFor(e.id);r&&(this.apply(r,t),t.sortableChildren&&this.sortChildren(e,r))}apply(e,t){e.visible=t.visible,e.traverse(e=>{e.renderOrder=t.renderOrder;const r=e;if(!r.isMesh||!r.material)return;const o=Array.isArray(r.material)?r.material:[r.material];for(const e of o){const r=e;"number"==typeof r.opacity&&(r.opacity=t.opacity,r.transparent=t.opacity<1)}})}sortChildren(e,t){const r=e.children?.map(e=>{if(!e)return null;const r=this.threeContext.object3DFor(e.id);if(!r||r.parent!==t)return null;const o=e.getComponent(E);return{node:r,order:o?.renderOrder??0}}).filter(e=>!!e).sort((e,t)=>e.order-t.order);if(r?.length)for(const e of r)t.add(e.node)}};j=e.__decorate([t.decorators.componentObserver({Render3D:["visible","opacity","renderOrder","sortableChildren"]})],j);var A=j;class Y extends t.Component{constructor(){super(...arguments),this.fov=75,this.near=.1,this.far=1e3,this.active=!0,this.lookAt=!1,this.lookAtX=0,this.lookAtY=0,this.lookAtZ=0}static{this.componentName="Camera3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"number",step:1,group:"Camera3D",label:"fov",description:"Vertical field of view in degrees.",editor:"number-stepper"})],Y.prototype,"fov",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Camera3D",label:"near",description:"Near clipping plane.",editor:"number-stepper"})],Y.prototype,"near",void 0),e.__decorate([o.Field({type:"number",step:1,group:"Camera3D",label:"far",description:"Far clipping plane.",editor:"number-stepper"})],Y.prototype,"far",void 0),e.__decorate([o.Field({type:"boolean",group:"Camera3D",label:"active",description:"Use this camera for rendering.",editor:"toggle"})],Y.prototype,"active",void 0),e.__decorate([o.Field({type:"boolean",group:"Camera3D",label:"lookAt",description:"Point the camera at lookAtX/Y/Z each frame.",editor:"toggle"})],Y.prototype,"lookAt",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtX",description:"World-space look-at target on X.",editor:"number-stepper"})],Y.prototype,"lookAtX",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtY",description:"World-space look-at target on Y.",editor:"number-stepper"})],Y.prototype,"lookAtY",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Camera3D",label:"lookAtZ",description:"World-space look-at target on Z.",editor:"number-stepper"})],Y.prototype,"lookAtZ",void 0);let L=class extends _{constructor(){super(...arguments),this.name="Camera3DSystem",this.cameras=new Map}static{this.systemName="Camera3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Camera3D"!==e.componentName)return;const r=e.component;e.type===t.OBSERVER_TYPE.ADD?this.mount(e.gameObject,r):e.type===t.OBSERVER_TYPE.REMOVE?this.unmount(e.gameObject.id):this.sync(e.gameObject,r)}rendererUpdate(e){const t=e.getComponent(Y),r=this.cameras.get(e.id);t&&r&&t.lookAt&&r.lookAt(t.lookAtX,t.lookAtY,t.lookAtZ)}mount(e,t){this.ensureTransform(e);const o=new r.PerspectiveCamera(t.fov,this.threeContext.camera.aspect,t.near,t.far);this.threeContext.attachVisual(e.id,o,e),this.cameras.set(e.id,o),this.sync(e,t)}sync(e,t){const r=this.cameras.get(e.id);r&&(r.fov=t.fov,r.near=t.near,r.far=t.far,r.updateProjectionMatrix(),t.active?this.threeContext.setActiveCamera(r):this.threeContext.camera===r&&this.activateAnother(e.id))}unmount(e){const t=this.cameras.get(e);t&&(this.threeContext.detachVisual(e,t),this.cameras.delete(e),this.threeContext.camera===t&&this.activateAnother(e))}activateAnother(e){for(const[t,r]of this.cameras){if(t===e)continue;const o=this.game.gameObjects.find(e=>e.id===t),s=o?.getComponent(Y);if(s?.active)return void this.threeContext.setActiveCamera(r)}this.threeContext.restoreFallbackCamera()}ensureTransform(e){if(!e||e.destroyed)return;let t=e.getComponent(D);if(!t)return t=new D,t.positionZ=5,void e.addComponent(t);u(t)&&(t.positionZ=5)}onDestroy(){for(const[e]of this.cameras)this.unmount(e);this.cameras.clear()}};L=e.__decorate([t.decorators.componentObserver({Camera3D:["fov","near","far","active","lookAt","lookAtX","lookAtY","lookAtZ"]})],L);var k=L;class P extends t.Component{constructor(){super(...arguments),this.type="directional",this.color=16777215,this.intensity=1,this.castShadow=!1,this.skyColor=16777215,this.groundColor=4473924,this.distance=0,this.decay=2,this.angle=Math.PI/3,this.penumbra=0}static{this.componentName="Light3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([o.Field({type:"string",group:"Light3D",label:"type",description:"Light kind.",editor:"enum",enumOptions:["ambient","directional","hemisphere","point","spot"]})],P.prototype,"type",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"color",description:"Light color (hex).",editor:"number-stepper"})],P.prototype,"color",void 0),e.__decorate([o.Field({type:"number",step:.05,group:"Light3D",label:"intensity",description:"Light intensity.",editor:"number-stepper"})],P.prototype,"intensity",void 0),e.__decorate([o.Field({type:"boolean",group:"Light3D",label:"castShadow",description:"Whether this light casts shadows.",editor:"toggle"})],P.prototype,"castShadow",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"skyColor",description:"Hemisphere sky color (hex).",editor:"number-stepper"})],P.prototype,"skyColor",void 0),e.__decorate([o.Field({type:"number",group:"Light3D",label:"groundColor",description:"Hemisphere ground color (hex).",editor:"number-stepper"})],P.prototype,"groundColor",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Light3D",label:"distance",description:"Range for point and spot lights. 0 means no limit.",editor:"number-stepper"})],P.prototype,"distance",void 0),e.__decorate([o.Field({type:"number",step:.1,group:"Light3D",label:"decay",description:"Intensity falloff for point and spot lights.",editor:"number-stepper"})],P.prototype,"decay",void 0),e.__decorate([o.Field({type:"number",step:.01,group:"Light3D",label:"angle",description:"Spot light cone angle in radians.",editor:"number-stepper"})],P.prototype,"angle",void 0),e.__decorate([o.Field({type:"number",step:.01,min:0,max:1,group:"Light3D",label:"penumbra",description:"Spot light soft edge (0–1).",editor:"number-slider"})],P.prototype,"penumbra",void 0);let X=class extends _{constructor(){super(...arguments),this.name="Light3DSystem",this.lights=new Map}static{this.systemName="Light3DSystem"}init(){this.game.getSystem("Renderer3DSystem").rendererManager.register(this)}componentChanged(e){if("Light3D"!==e.componentName)return;const r=e.component;e.type===t.OBSERVER_TYPE.ADD?this.mount(e.gameObject,r):e.type===t.OBSERVER_TYPE.REMOVE?this.unmount(e.gameObject.id):"type"===e.prop?.prop?.[0]?(this.unmount(e.gameObject.id),this.mount(e.gameObject,r)):this.sync(e.gameObject.id,r)}rendererUpdate(e){}mount(e,t){this.ensureTransform(e),0===this.lights.size&&this.threeContext.removeDefaultLights();const r=this.createLight(t);this.threeContext.attachVisual(e.id,r,e),this.lights.set(e.id,r),this.sync(e.id,t)}createLight(e){switch(e.type){case"ambient":return new r.AmbientLight(e.color,e.intensity);case"hemisphere":return new r.HemisphereLight(e.skyColor,e.groundColor,e.intensity);case"point":return new r.PointLight(e.color,e.intensity,e.distance,e.decay);case"spot":return new r.SpotLight(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);default:return new r.DirectionalLight(e.color,e.intensity)}}sync(e,t){const o=this.lights.get(e);o&&("color"in o&&o.color&&o.color.set(t.color),o.intensity=t.intensity,o instanceof r.HemisphereLight&&(o.color.set(t.skyColor),o.groundColor.set(t.groundColor)),(o instanceof r.PointLight||o instanceof r.SpotLight)&&(o.distance=t.distance,o.decay=t.decay),o instanceof r.SpotLight&&(o.angle=t.angle,o.penumbra=t.penumbra),"castShadow"in o&&(o.castShadow=!(!t.castShadow||!this.threeContext.shadows)))}unmount(e){const t=this.lights.get(e);t&&(this.threeContext.detachVisual(e,t),t.dispose?.(),this.lights.delete(e))}ensureTransform(e){e&&!e.destroyed&&(e.getComponent(D)||e.addComponent(new D))}onDestroy(){for(const[e]of this.lights)this.unmount(e);this.lights.clear()}};X=e.__decorate([t.decorators.componentObserver({Light3D:["type","color","intensity","castShadow","skyColor","groundColor","distance","decay","angle","penumbra"]})],X);var Z=X;const F=["WEBGL_compressed_texture_astc","EXT_texture_compression_bptc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_etc"];let I=null,B=null;function V(e){return F.some(t=>e.extensions.has(t))}function N(e){return I||(I=new s.KTX2Loader,I.setTranscoderPath("https://unpkg.com/three@0.172.0/examples/jsm/libs/basis/")),e&&B!==e&&(I.detectSupport(e),B=e),I}async function G(e,t){if(!V(t))return null;try{const o=await N(t).loadAsync(e),s=o;return s?.isCompressedTexture&&s.format!==r.RGBAFormat?o:(o?.dispose(),null)}catch{return null}}async function z(e){const r=String(e??"").trim();if(!r)throw new Error("resource name is required; register it with resource.addResource");const o=await t.resource.getResource(r);if(!o||!o.name)throw new Error(`Unknown resource "${r}"; register it with resource.addResource first`);return o}function W(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?e:null}async function U(e){let t=e;if("function"==typeof createImageBitmap)try{t=await createImageBitmap(e)}catch{t=e}const o=new r.Texture(t);if(o.colorSpace=r.SRGBColorSpace,o.needsUpdate=!0,"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=t,r=o.dispose.bind(o);o.dispose=()=>{r();try{e.close()}catch{}}}return o}async function H(e,r){if(!r)return null;const o=function(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const t=e;return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}return null}(e.data?.image);if(!o)return null;const s=t.compressedTextureUrl(e.src?.image),i=URL.createObjectURL(new Blob([o]));try{const e=await G(i,r);if(e)return e}finally{URL.revokeObjectURL(i)}return s?G(s,r):null}async function $(e,r){const o=await H(e,r);if(o)return o;const s=W(e.data?.image);if(s)return U(s);const i=t.imageFallbackUrl(e.src?.image);if(i)try{return U(await(n=i,new Promise((e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=()=>t(new Error(`Failed to load image ${n}`)),r.src=n})))}catch{}var n;throw new Error(`Resource "${e.name}" has no image data; use RESOURCE_TYPE.IMAGE with src.image.url`)}exports.COMBOS_GAME_OBJECT_ID=i,exports.COMBOS_TRANSFORM3D=n,exports.Camera3D=Y,exports.Camera3DSystem=k,exports.Light3D=P,exports.Light3DSystem=Z,exports.Render3D=E,exports.Render3DSystem=A,exports.Renderer3D=_,exports.Renderer3DManager=w,exports.Renderer3DSystem=O,exports.ThreeContext=C,exports.Transform3D=D,exports.Transform3DSystem=T,exports.VisualPoseBridge=class{constructor(){this.lastVisual="",this.lastRoot=""}sync(e,t){if(!t)return!0;if(""===this.lastVisual&&""===this.lastRoot)return g(e,t),this.lastVisual=l(e),this.lastRoot=l(t),!1;const r=l(e),o=l(t);return r!==this.lastVisual&&o===this.lastRoot&&m(e,t),this.lastVisual=l(e),this.lastRoot=l(t),!1}},exports.copyPose=m,exports.ensureKtx2Loader=N,exports.gameObjectIdFromIntersection=function(e){return p(e?.object)},exports.gameObjectIdFromObject3D=p,exports.has3DChildGameObjects=function(e){return(e?.children?.length??0)>0},exports.is3DSceneParent=d,exports.isIdentityPose=u,exports.isTransform3DRoot=a,exports.loadThreeKtx2=G,exports.poseKeyOf=l,exports.readPose=h,exports.rendererSupportsCompressedTexture=V,exports.requireNamedResource=z,exports.seedTransform3D=g,exports.tagObject3D=c,exports.textureFromNamedImage=async function(e,t){return $(await z(e),t)},exports.textureFromResourceImage=function(e){const t=W(e.data?.image);if(!t)throw new Error(`Resource "${e.name}" has no image data; use RESOURCE_TYPE.IMAGE with src.image.url`);const o=new r.Texture(t);return o.colorSpace=r.SRGBColorSpace,o.needsUpdate=!0,o},exports.textureFromResourceImageAsync=$;
@@ -925,7 +925,7 @@ var Renderer3DSystem$1 = Renderer3DSystem;
925
925
  /** Auto-generated by scripts/build-package.mjs — do not edit. */
926
926
  Object.assign(Renderer3DSystem$1, {
927
927
  packageName: "@combos-fun/plugin-renderer-3d",
928
- packageVersion: "0.1.26",
928
+ packageVersion: "0.1.28",
929
929
  });
930
930
 
931
931
  class Renderer3D extends System {