@hology/core 0.0.204 → 0.0.206

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.
Files changed (38) hide show
  1. package/dist/config/project-config.d.ts +4 -0
  2. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +28 -1
  3. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  4. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  5. package/dist/gameplay/index.d.ts +1 -0
  6. package/dist/gameplay/index.js +1 -1
  7. package/dist/gameplay/initiate.d.ts +4 -0
  8. package/dist/gameplay/services/asset-loader.d.ts +3 -0
  9. package/dist/gameplay/services/asset-loader.js +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -1
  12. package/dist/rendering.d.ts +2 -0
  13. package/dist/rendering.js +1 -1
  14. package/dist/scene/asset-resource-loader.js +1 -1
  15. package/dist/scene/custom-param-deserialize.d.ts +1 -0
  16. package/dist/scene/custom-param-deserialize.js +1 -1
  17. package/dist/scene/custom-param-runtime-types.d.ts +3 -1
  18. package/dist/scene/custom-param-runtime-types.js +1 -1
  19. package/dist/scene/landscape/landscape.js +1 -1
  20. package/dist/scene/materializer.d.ts +16 -3
  21. package/dist/scene/materializer.js +1 -1
  22. package/dist/scene/model.d.ts +18 -2
  23. package/dist/scene/model.js +1 -1
  24. package/dist/scene/objects/data-asset.d.ts +10 -0
  25. package/dist/scene/objects/data-asset.js +4 -0
  26. package/dist/shader/parameter.d.ts +64 -3
  27. package/dist/shader/parameter.js +1 -1
  28. package/dist/test/data-asset-definition.test.d.ts +2 -0
  29. package/dist/test/data-asset-definition.test.js +4 -0
  30. package/dist/test/parameter-definition.test.d.ts +2 -0
  31. package/dist/test/parameter-definition.test.js +4 -0
  32. package/dist/test/prefab-instance-params.test.d.ts +2 -0
  33. package/dist/test/prefab-instance-params.test.js +4 -0
  34. package/dist/utils/collections.d.ts +1 -0
  35. package/dist/utils/collections.js +1 -1
  36. package/dist/utils/type.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/tsconfig.tsbuildinfo +1 -1
package/dist/rendering.js CHANGED
@@ -1,4 +1,4 @@
1
- var e;import{__decorate as t,__metadata as s}from"tslib";import*as i from"three";import{Color as a,Material as n,Matrix4 as r,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as p,WebGLRenderTarget as d,Texture as u,Euler as c,MeshStandardMaterial as m}from"three";import{CopyShader as f,EffectComposer as g,FXAAShader as M,GammaCorrectionShader as v,LUTPass as P,RenderPass as b,ShaderPass as y,VRButton as T}from"three-stdlib";import{CSMShader as w,CSMUtil as x}from"./csm.js";import{colorToNormal as S,float as C,NodeShaderMaterial as R,standardMaterial as O,uniformFloat as U,uniformVec3 as E,toonMaterial as A,lambertMaterial as F,normalize as G,rgb as B,rgba as D,transformed as I,varying as L,varyingAttributes as V,varyingTransformed as _,vec4 as W,BooleanExpression as j,select as N,ifDefApply as q,uniformSampler2d as k,RgbaNode as H,mix as z,attributes as $,uniformVec2 as X}from"three-shader-graph";import{Reflector as Y}from"three-stdlib";import{BokehPass as K,OutputPass as Q}from"three/examples/jsm/Addons.js";import{CSM as J}from"three/examples/jsm/csm/CSM.js";import{RectAreaLightUniformsLib as Z}from"three/examples/jsm/lights/RectAreaLightUniformsLib.js";import ee from"three/examples/jsm/libs/stats.module.js";import{GTAOPass as te}from"three/examples/jsm/postprocessing/GTAOPass.js";import{Service as se}from"typedi";import{depthUniformName as ie,farUniformName as ae,nearUniformName as ne,resolutionUniformName as re,sceneNormalUniformName as oe,screenUV as le,supportsDepthTextureExtension as he}from"./shader-nodes/depth.js";import{elapsedTimeUniformName as pe}from"./shader-nodes/time.js";import{aoMapUniformName as de,sceneMapUniformName as ue}from"./shader-nodes/scene-sample.js";import{DepthPass as ce}from"./utils/three/depth-pass.js";import{GPUStatsPanel as me}from"./utils/three/gpu-stats-panel.js";import{OutlinePass as fe}from"./utils/three/outline-pass.js";import{findFirstVisibleObject as ge,traverseVisibleStop as Me}from"./utils/three/traverse.js";import{clamp as ve}from"./utils/math.js";import{ColorPass as Pe}from"./rendering/color-pass.js";import{PostProcessEffectPass as be,PostProcessEffectRegistration as ye,postProcessEffectStages as Te,sanitizePostProcessEffectPriority as we,sanitizePostProcessEffectStage as xe}from"./rendering/post-process-effect.js";import{SSRPass as Se}from"./rendering/ssr/SSRPass.js";import{SSRShader as Ce}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as Re}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as Oe}from"./rendering/outline-effect.js";import{UnrealBloomPass as Ue}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as Ee}from"./shader-nodes/depth.js";import{packDepthToRGBA as Ae}from"three-shader-graph";import{FogVolumeObject as Fe}from"./rendering/fog/fog-volume-object";import{ParallaxStandardMaterial as Ge}from"./shader/builtin/standard-shader.js";import{parallaxOcclusionMapping as Be}from"./shader-nodes/pom.js";import{FullScreenQuad as De}from"three-stdlib";import{edgeDepthEffect as Ie}from"./shader-nodes/effects";import{decalDiscard as Le}from"./shader-nodes/decal.js";import{Pass as Ve}from"three/examples/jsm/Addons.js";import{BatchedMesh2 as _e}from"./scene/batched-mesh-2.js";import{applyUvTiling as We}from"./shader/uv-nodes.js";x.patchSetupMaterial();const je=document.createElement("div");je.style.position="absolute",je.style.left="50%",je.style.top="50%",je.style.color="black",je.style.zIndex="999";(new i.Layers).set(9);const Ne=new i.MeshBasicMaterial({color:"black"}),qe=new i.MeshDepthMaterial;var ke;qe.depthPacking=i.RGBADepthPacking,qe.blending=i.NoBlending,qe.side=i.DoubleSide,function(e){e[e.opaque=0]="opaque",e[e.transparent=1]="transparent"}(ke||(ke={}));const He=(()=>{const e=new Uint8Array([255,255,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),ze=(()=>{const e=new Uint8Array([0,0,0,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),$e=(()=>{const e=new Uint8Array([128,128,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),Xe=new R({color:C(0),position:W(C(0))});Xe.visible=!1;const Ye=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let Ke=0,Qe=null;const Je=new Map;function Ze(){return null==Qe&&(Qe=new IntersectionObserver(e=>{for(const t of e){const e=Je.get(t.target);e&&e(t.isIntersecting)}},{threshold:0})),Qe}let et=e=class{get fpsCap(){return this._fpsCap}set fpsCap(e){const t=null!=e&&Number.isFinite(e)&&e>0?e:null;t!==this._fpsCap&&(this._fpsCap=t,this.fpsCapRevision++)}setPaused(e){this.paused=e}resizeRender(){if(!this.running)return;const e=this.container.clientWidth,t=this.container.clientHeight;this.previousClientWith===e&&this.previousClientHeight===t||0!==e&&0!==t&&(this.previousClientWith=e,this.previousClientHeight=t,this.camera instanceof l&&(this.camera.aspect=e/t,this.camera.updateProjectionMatrix()),this.renderer.setPixelRatio(Math.min(this.maxPixelRatio,window.devicePixelRatio)*this.resolutionScale),this.renderer.setSize(e,t),this.composer.setPixelRatio(this.renderer.getPixelRatio()),this.composer.setSize(e,t),this.dofPass.setSize(e*this.renderer.getPixelRatio(),t*this.renderer.getPixelRatio()),this.fxaaPass.setSize(e*this.renderer.getPixelRatio(),t*this.renderer.getPixelRatio()),this.fxaaPass.uniforms.resolution.value.set(1/(e*this.renderer.getPixelRatio()),1/(t*this.renderer.getPixelRatio())),this.createGRenderTarget(),this.phasedRenderPass.gRenderTarget=this.gRenderTarget,this.bloomPass.emissiveTexture=this.gRenderTarget.textures[1],this.ssrPass.setSize(this.gRenderTarget.width,this.gRenderTarget.height),this.ssrPass.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),this.aoPass.setSize(this.gRenderTarget.width,this.gRenderTarget.height),this.aoPass.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),this.sceneColorRenderTarget.dispose(),this.sceneColorRenderTarget=this.createSceneColorRenderTarget(this.renderer,this.container),this.copyPass.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass.material.uniformsNeedUpdate=!0)}addPostProcessVolume(e){if(0===this.postProcessVolumes.length)this.postProcessVolumes.push(e);else{let t=!1;for(let s=0;s<this.postProcessVolumes.length;s++)if(e.priority<this.postProcessVolumes[s].priority){this.postProcessVolumes.splice(s,0,e),t=!0;break}t||this.postProcessVolumes.push(e)}}removePostProcessVolume(e){const t=this.postProcessVolumes.indexOf(e);t>-1&&this.postProcessVolumes.splice(t,1)}addPostProcessEffect(e,t={}){const s={id:++this.postProcessEffectId,pass:new be(e),priority:we(t.priority),stage:xe(t.stage)};return s.pass.enabled=t.enabled??!0,this.postProcessEffects.push(s),this.refreshPostProcessEffectPassOrder(),new ye(this,s)}removePostProcessEffectEntry(e){const t=e,s=this.postProcessEffects.indexOf(t);-1!==s&&(this.postProcessEffects.splice(s,1),this.composer.removePass(t.pass),t.pass.dispose())}refreshPostProcessEffectPassOrder(){for(const e of this.postProcessEffects)this.composer.removePass(e.pass);for(const e of Te){const t=this.getPostProcessEffectStageAnchorPass(e),s=null!=t?this.composer.passes.indexOf(t):this.composer.passes.length,i=this.postProcessEffects.filter(t=>t.stage===e).sort(it);for(let e=0;e<i.length;e++)this.composer.insertPass(i[e].pass,s+e)}}getPostProcessEffectStageAnchorPass(e){switch(e){case"beforeFog":return this.volumetricFogPass;case"beforeDepthOfField":return this.dofPass;case"beforeColorAdjustment":return this.colorPass;case"beforeOutline":return this.outlinePass;case"beforeAntiAliasing":return this.fxaaPass;case"beforeLut":return this.lutPass;case"beforeOutput":return this.outputPass}}constructor(t,s={}){this.container=t,this.options=s,this.isIntersecting=!1,this.windowVisible=!0,this.running=!0,this.paused=!1,this._fpsCap=null,this.fpsCapRevision=0,this.postProcessVolumes=[],this.postProcessSettings={},this.baseToneMapping=i.NoToneMapping,this.baseToneMappingExposure=1,this.csmUpdateInvervals=this.options.shadows?.cascadeUpdateIntervals,this._id=Ke++,this.postProcessEffectId=0,this.postProcessEffects=[],this.postProcessEffectResolution=new i.Vector2(1,1),this.postProcessEffectUniformState={aoEnabled:!1,aoTexture:null,cameraFar:void 0,cameraNear:void 0,depthTexture:new u,normalTexture:new u,resolution:this.postProcessEffectResolution,simulationTime:0},this.fquadCopy=new De(new p(f)),this.fquadCopyOpaque=new De(new R({outputs:[k("tSceneColor",new u).sample(V.uv),W(k("tDepthTexture",new i.DepthTexture(1,1)).sample(V.uv).r)]})),this.simulationTime=0,this.simulationTimeScale=1,this.lightProbeIntensity=2,this.fquadBlendAO=(()=>{const e=W(1),t=new R({outputs:[k("tAO",new u).sample(le),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new De(t)})(),this.resolutionScale=1,this.maxPixelRatio=Ye?1:window.devicePixelRatio,this.onResize=()=>{if(this.resizeRender(),!this.paused)try{this.render()}catch(e){}},this.onVisiblityChane=()=>{this.windowVisible=!document.hidden},this.isDepthTextureExtensionSupported=!0,this.onLoopCallbacks=[],this.stats=new ee,this._showStats=!0,this.gbufferMaterialCache=new Map,this.gbufferDepthPrepassMaterialCache=new Map,this.tbufferMaterialCache=new Map,this.depthPrepassMaterialCache=new WeakMap,this.depthPrepassCachedMaterials=new Map,this.depthPrepassCachedVisibility=[],this.gBufferCachedMaterials=new Map,this.gBufferCachedVisibility=[],this._initiatedMaterialTextures=new Set,this._initiatedTextures=new Set,this.compileInProgress=!1,this.pmremGeneratorResults=new WeakMap,this.insetHeight=200,this.insetWidth=this.insetHeight*(16/9),this.insetOffsetY=250,this.insetMargin=10,this.maxInsetCameras=4,this.overlayCameras=new Set,this.prevClearColor=new a,this.hadBloom=!1,this.bloomStoredMaterials={},this.bloomHidden=[],this._customDepthMaterialCache=new WeakMap,null!=s.maxPixelRatio&&(this.maxPixelRatio=s.maxPixelRatio),this.resolutionScale=s.resolutionScale??1,this.fpsCap=s.fpsCap,e.activeView=this,Z.init(),window.renderer=this.renderer=window.renderer??new i.WebGLRenderer({antialias:!1,powerPreference:"high-performance"});new i.MeshStandardMaterial({color:"#ccc"});this.scene=new i.Scene,this.scene.matrixWorldAutoUpdate=!0,this.scene.updateMatrixWorld=function(e){const t=this.children;for(let s=0,i=t.length;s<i;s++){t[s].updateMatrixWorld(e)}}.bind(this.scene),this.renderer.setPixelRatio(Math.min(this.maxPixelRatio,window.devicePixelRatio)*this.resolutionScale),this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.xr.enabled=this.options.enableXR??!1,!0===this.options.enableXR&&document.body.appendChild(T.createButton(this.renderer));const n=new Oe(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=n,this.createGRenderTarget(),this.composer=new g(this.renderer,function(e,t){const s=new i.WebGLRenderTarget(Math.max(1,e),Math.max(1,t),{minFilter:i.LinearFilter,magFilter:i.LinearFilter,format:i.RGBAFormat,type:i.HalfFloatType});return s.texture.name="EffectComposer.rt1",s.texture.generateMipmaps=!1,s}(t.clientWidth,t.clientHeight)),this.composer.setPixelRatio(this.renderer.getPixelRatio()),this.composer.setSize(t.clientWidth,t.clientHeight);var r=(t.clientWidth||1)/(t.clientHeight||1);const o=new i.PerspectiveCamera(45,r,.5,800);o.layers.enable(19),this.setCamera(o),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=i.PCFSoftShadowMap,this.renderer.shadowMap.autoUpdate=s.shadows?.autoUpdate??!1,this.renderer.outputColorSpace=i.SRGBColorSpace,this.renderer.toneMapping=i.NoToneMapping,this.renderer.toneMappingExposure=1,this.baseToneMapping=this.renderer.toneMapping,this.baseToneMappingExposure=this.renderer.toneMappingExposure,this.renderer.gammaFactor=1.4,x.renderingView=this,this.isDepthTextureExtensionSupported=he(this.renderer),t.replaceChildren(this.renderer.domElement),this.setupEventListeners(),this.aoMaskDepthRenderTarget=e.createAOMaskDepthRenderTarget(this.renderer,this.container),this.sceneColorRenderTarget=this.createSceneColorRenderTarget(this.renderer,this.container);const l=new i.Vector2(t.clientWidth,t.clientHeight),h=(new b(this.scene,this.camera),new y(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const d=new Ue(l,1.5,.4,.85);d.threshold=1,d.strength=.9,d.radius=.5,this.bloomPass=d;const c=new te(this.scene,this.camera,this.gRenderTarget.width,this.gRenderTarget.height,{});c.normalRenderTarget?.dispose(),c.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),c.output=te.OUTPUT.Off,c.enabled=!1,this.aoPass=c,this.fquadBlendAO.material.uniforms.tAO.value=c.pdRenderTarget.texture,Ce.fragmentShader=Ce.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Se({renderer:this.renderer,scene:this.scene,camera:this.camera,width:this.gRenderTarget.width,height:this.gRenderTarget.height,groundReflector:null,selects:[],normalTexture:this.gRenderTarget.textures[2],depthTexture:this.gRenderTarget.depthTexture});m.output=Se.OUTPUT.Default,m.blur=!0,m.fresnel=!1,m.distanceAttenuation=!0,m.maxDistance=50,m.selective=!0,m.bouncing=!1,m.opacity=.4,m.enabled=!1!==this.options?.reflection?.enabled,this.ssrPass=m,!1!==this.options.ao?.enabled&&this.composer.addPass(c);const w=new Tt((e,t,s,i,a)=>{this.aoPass.enabled&&(this.initResolutionUniform(this.fquadBlendAO.material),this.renderer.setRenderTarget(this.gRenderTarget),this.fquadBlendAO.render(this.renderer),this.renderer.setRenderTarget(null))});this.composer.addPass(w);const S=new Tt((e,t,s,i,a)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(ke.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(S),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new yt(this.scene,this.camera,this.gRenderTarget),this.composer.addPass(this.phasedRenderPass),this.composer.addPass(d),d.emissiveTexture=this.gRenderTarget.textures[1],this.renderer.info.autoReset=!1,this.volumetricFogPass=new Re(l),this.composer.addPass(this.volumetricFogPass),this.volumetricFogPass.enabled=!0,this.dofPass=new K(this.scene,this.camera,{focus:1,aperture:.025,maxblur:.01}),this.dofPass.enabled=!1,this.composer.addPass(this.dofPass);const C=new Pe;this.composer.addPass(C),this.colorPass=C,C.vignetteEnabled=!1,this.outlinePass=new fe(new i.Vector2(t.clientWidth,t.clientHeight),this.scene,this.camera),this.outlinePass.edgeGlow=0,this.outlinePass.edgeThickness=1.5,this.outlinePass.edgeStrength=5,this.outlinePass.clear=!1,this.outlinePass.enabled=!1,this.composer.addPass(this.outlinePass);const O=new y(M);O.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(O),this.fxaaPass=O,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new y(v).clear=!1,this.fixStatsStyle(),this.lutPass=new P({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const U=new y(f,"prevtexture");U.enabled=!0,U.needsSwap=!1,U.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],U.renderToScreen=!0;const E=new Q;!function(e){const t=e.material;if(t.dithering=!0,t.fragmentShader.includes("<dithering_fragment>"))return;const s="#include <colorspace_pars_fragment>";if(!t.fragmentShader.includes(s))return;t.fragmentShader=t.fragmentShader.replace(s,`${s}\n #include <common>\n #include <dithering_pars_fragment>`);const i=t.fragmentShader.lastIndexOf("}");i<0||(t.fragmentShader=`${t.fragmentShader.slice(0,i)}\n #include <dithering_fragment>\n${t.fragmentShader.slice(i)}`,t.needsUpdate=!0)}(E),this.outputPass=E,this.composer.addPass(E)}fixStatsStyle(){const e=this.stats.dom;e.style.position="absolute";const t=e.getElementsByTagName("canvas");for(let e=0;e<t.length;e++)t.item(e).style.display="inline-block"}setEnableOutlines(e){this.outlinePass.enabled=e,this.fxaaPass.enabled=e}setCamera(e){if(this.camera=e,this.composer.passes.forEach(t=>{t instanceof b?t.camera=e:t instanceof fe?t.renderCamera=e:(t instanceof ce||t instanceof te)&&(t.camera=e)}),this.ssrPass&&(this.ssrPass.camera=e),this.aoPass&&(this.aoPass.camera=e),this.phasedRenderPass&&(this.phasedRenderPass.camera=e),null==this.csm){if(this.csm=new J({maxFar:80,lightFar:250,lightMargin:20,cascades:Ye?2:3,shadowMapSize:2048*(Ye?.5:1),lightDirection:new i.Vector3(.5,-1,-.6).normalize(),lightIntensity:.5*Math.PI,camera:this.camera,parent:this.scene,mode:"practical"}),null!=this.csmUpdateInvervals){this.csmCascadeLastUpdate=new Array(this.csm.lights.length).fill(0);for(const e of this.csm.lights)e.shadow.autoUpdate=!1}this.csm&&Array.isArray(this.csm.lights),this.csm.fade=!0,h.lights_fragment_begin=w.lights_fragment_begin}else this.csm.camera=this.camera,this.camera;this.csm.updateFrustums()}setSelectedObjects(e){if(null==this.outlinePass)return;const t=new Map;for(const s of e)t.set(s.uuid,s);for(const s of e)s.traverse(e=>{e.uuid!==s.uuid&&t.has(e.uuid)&&t.delete(e.uuid)});this.outlinePass.selectedObjects=Array.from(t.values())}static createDepthRenderTarget(e,t,s){const a=Math.max(1,Math.floor(t.clientWidth*s)),n=Math.max(1,Math.floor(t.clientHeight*s)),r=new i.WebGLRenderTarget(a,n);return r.texture.minFilter=i.NearestFilter,r.texture.magFilter=i.NearestFilter,r.texture.generateMipmaps=!1,r.stencilBuffer=!1,r.depthTexture=new i.DepthTexture(a,n),r.depthTexture.type=i.UnsignedShortType,r.depthTexture.minFilter=i.NearestFilter,r.depthTexture.magFilter=i.NearestFilter,r}static createAOMaskDepthRenderTarget(e,t){const s=Math.max(1,t.clientWidth*e.getPixelRatio()),a=Math.max(1,t.clientHeight*e.getPixelRatio()),n=new i.DepthTexture(s,a);n.type=i.UnsignedInt248Type,n.minFilter=i.NearestFilter,n.magFilter=i.NearestFilter;const r=new i.WebGLRenderTarget(s,a,{type:i.HalfFloatType,depthTexture:n});return r.texture.minFilter=i.NearestFilter,r.texture.magFilter=i.NearestFilter,r.texture.generateMipmaps=!1,r.stencilBuffer=!1,r}createSceneColorRenderTarget(e,t){const s=this.gRenderTarget.width,a=this.gRenderTarget.height,n=new i.WebGLRenderTarget(s,a,{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return n.texture.minFilter=i.LinearFilter,n.texture.magFilter=i.LinearFilter,n.texture.generateMipmaps=!1,n.textures[1].minFilter=i.NearestFilter,n.textures[1].magFilter=i.NearestFilter,n}createGRenderTarget(){const e=this.container;null!=this.gRenderTarget&&this.gRenderTarget.dispose();const t=Math.max(1,e.clientWidth*this.renderer.getPixelRatio()),s=Math.max(1,e.clientHeight*this.renderer.getPixelRatio()),a=new i.DepthTexture(t,s);a.type=i.UnsignedIntType,a.minFilter=i.NearestFilter,a.magFilter=i.NearestFilter,this.gRenderTarget=new d(t,s,{count:3,samples:this.options?.msaa??(Ye?void 0:2),minFilter:i.NearestFilter,magFilter:i.NearestFilter,type:i.HalfFloatType,format:i.RGBAFormat,depthTexture:a}),this.gRenderTarget.texture.generateMipmaps=!1,this.gRenderTarget.stencilBuffer=!1}setupEventListeners(){window.addEventListener("resize",this.onResize),window.addEventListener("orientationchange",this.onResize),document.addEventListener("visibilitychange",this.onVisiblityChane)}stop(e=!0){this.running=!1,this.lightVolume?.shTexture.dispose(),window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),document.removeEventListener("visibilitychange",this.onVisiblityChane),this.onLoopCallbacks=[],e&&this.renderer.dispose(),this.gRenderTarget.dispose(),this.aoMaskDepthRenderTarget.dispose(),this.sceneColorRenderTarget.dispose(),this.csm.dispose();for(const e of this.postProcessEffects)this.composer.removePass(e.pass),e.pass.dispose();this.postProcessEffects.length=0,this.container.replaceChildren();Ze().unobserve(this.container),Je.delete(this.container),this.volumetricFogPass.dispose(),x.clearSceneCache(this.scene)}onLoop(e){this.onLoopCallbacks.push(e)}removeOnLoop(e){const t=this.onLoopCallbacks.findIndex(t=>t===e);t>=0&&this.onLoopCallbacks.splice(t,1)}set showStats(e){this._showStats=e,this._showStats&&!this.container.contains(this.stats.dom)?this.container.appendChild(this.stats.dom):!this._showStats&&this.container.contains(this.stats.dom)&&this.container.removeChild(this.stats.dom)}get showStats(){return this._showStats}applyEnvMap(e){if(null!=this.scene.environment&&(e instanceof R&&(null==e.envMap||e.userData.useSceneEnv)&&(e.userData.useSceneEnv=!0,null==e.uniforms.envMap&&(e.uniforms.envMap={value:this.scene.environment},e.uniformsNeedUpdate=!0,e.uniforms.envMapRotation={value:gt(this.scene.environmentRotation,this.scene.environment,new i.Matrix3)}),null==e.uniforms.envMapIntensity&&(e.uniforms.envMapIntensity={value:1},e.uniformsNeedUpdate=!0),e.uniforms.envMap.value=this.scene.environment,e.uniforms.envMapIntensity.value=this.scene.environmentIntensity,e.envMap=this.scene.environment),e instanceof R||e instanceof i.MeshStandardMaterial)){const t=this.gbufferMaterialCache.get(e);null==t||this.gbufferMaterialCache.has(t)||this.applyEnvMap(t)}}setupCsm(e){if(e instanceof i.Mesh||e instanceof i.SkinnedMesh)if(e.material instanceof Array)for(const t of e.material)this.csm.setupMaterial(t);else this.csm.setupMaterial(e.material)}updateMaterialProperties(e,t){(e instanceof i.MeshBasicMaterial||e instanceof m||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)&&(null!=t.uniforms.color&&t.uniforms.color.value.setFromColor(e.color),null!=t.uniforms.opacity&&(t.uniforms.opacity.value=e.opacity),null!=t.uniforms.map&&(t.uniforms.map.value=e.map),null!=t.uniforms.alphaMap&&(t.uniforms.alphaMap.value=e.alphaMap),null!=t.uniforms.lightMap&&(t.uniforms.lightMap.value=e.lightMap,t.uniforms.lightMapIntensity.value=e.lightMapIntensity),null!=t.uniforms.aoMap&&(t.uniforms.aoMap.value=e.aoMap,t.uniforms.aoMapIntensity.value=e.aoMapIntensity),null!=t.uniforms.alphaTest&&(t.uniforms.alphaTest.value=e.alphaTest)),(e instanceof m||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)&&(t.uniforms.normalMap&&(t.uniforms.normalMap.value=e.normalMap,t.uniforms.normalScale.value=e.normalScale.x),t.uniforms.emissiveMap&&(t.uniforms.emissiveMap.value=e.emissiveMap,t.uniforms.emissive.value.setFromColor(e.emissive),t.uniforms.emissiveIntensity.value=e.emissiveIntensity)),e instanceof m&&(null!=t.uniforms.roughnessMap&&(t.uniforms.roughnessMap.value=e.roughnessMap),null!=t.uniforms.metalnessMap&&(t.uniforms.metalnessMap.value=e.metalnessMap),null!=t.uniforms.roughness&&(t.uniforms.roughness.value=e.roughness),null!=t.uniforms.metalness&&(t.uniforms.metalness.value=e.metalness)),e instanceof i.MeshPhysicalMaterial&&(t.uniforms.sheenColor&&t.uniforms.sheenColor.value.setFromColor(e.sheenColor).multiplyScalar(e.sheen),t.uniforms.sheenColorMap&&(t.uniforms.sheenColorMap.value=e.sheenColorMap),t.uniforms.sheenRoughness&&(t.uniforms.sheenRoughness.value=e.sheenRoughness),t.uniforms.sheenRoughnessMap&&(t.uniforms.sheenRoughnessMap.value=e.sheenRoughnessMap)),e instanceof Ge&&(t.uniforms.heightMap.value=e.heightMap,t.uniforms.heightScale.value=e.heightScale),this.updateMaterialCommonProperties(e,t)}updateUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s){const t=i[e],a=s[e].value;null!=t&&t.value!==a&&"receiveShadow"!==e&&!1===wt.includes(e)&&(t.value=a)}this.updateMaterialCommonProperties(e,t)}inheritCustomUniformBindings(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s)null==i[e]&&("receiveShadow"===e||wt.includes(e)||xt.includes(e)||(i[e]={value:s[e].value}))}updateMaterialCommonProperties(e,t){t.alphaTest=e.alphaTest,t.side=e.side,t.depthTest=e.depthTest,t.blending=e.blending,t.colorWrite=e.colorWrite,t.premultipliedAlpha=e.premultipliedAlpha,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t.visible=e.visible}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of wt){const t=i[e],a=s[e];null!=a&&null!=t&&(t.value=a.value)}}createGBufferMaterial(e,t,s=!1){const a=t===ke.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let n=a.get(e);if(!0===e.userData.isGBufferMaterial)return e;if(null==n){let s=V.uv;if(e instanceof Ge&&null!=e.heightMap){const t=U("heightScale",e.heightScale??1);s=Be(s,k("heightMap",e.heightMap),t)}let o=_.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??$e,i=U("useNormalMap",null!=e.normalMap?1:0),a=U("normalScale",e.normalScale?.x??1),n=S(k("normalMap",t).sample(We(s,e.normalMap)),a);o=z(_.normal,n,i)}else e instanceof R&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=q("DOUBLE_SIDED",o,e=>N(new j("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?C(0):C(1);if(e instanceof i.MeshStandardMaterial){const t=U("roughness",e.roughness??1),i=e.roughnessMap??He,a=U("useRoughnessMap",null!=e.roughnessMap?1:0),n=k("roughnessMap",i).sample(We(s,e.roughnessMap)).g.multiply(t);l=z(t,n,a)}else e instanceof R&&null!=e.outputRoughness&&(l=e.outputRoughness);let h=null;if((e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial)&&null!=e.lightMap){const t=e.lightMap,i=U("useLightMap",null!=e.lightMap?1:0),a=U("lightMapIntensity",e.lightMapIntensity??1),n=k("lightMap",t).sample(s).rgb.multiplyScalar(a);h=z(B(0),n,i)}let d=C(0);if(e instanceof i.MeshStandardMaterial){const t=U("metalness",e.metalness??0),i=e.metalnessMap??ze,a=U("useMetalnessMap",null!=e.metalnessMap?1:0),n=k("metalnessMap",i).sample(We(s,e.metalnessMap)).b.multiply(t);d=z(t,n,a)}else e instanceof R&&e.outputRoughness;let u=null,c=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){const t=e.aoMap??He,i=U("useAoMap",null!=e.aoMap?1:0);c=U("aoMapIntensity",e.aoMapIntensity??1);const a=k("aoMap",t).sample(We(s,e.aoMap)).r;u=z(C(1),a,i)}else e instanceof R&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){if(null!=e.alphaMap){const t=e.alphaMap;g=k("alphaMap",t).sample(We(s,e.alphaMap)).r}g=g.multiply(f)}else e instanceof R&&null!=e.outputOpacity&&(g=e.outputOpacity);let M=D(0,1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){let t=E("color",(new i.Vector3).setFromColor(e.color));const a=e.map??He,n=U("useAlbedoMap",null!=e.map?1:0),r=k("map",a).sample(We(s,e.map)),o=r.multiply(D(t,1)),l=D(t,1);M=z(l,o,n),e.vertexColors&&(M=M.multiply(W(L($.color.rgb),1)));const h=z(C(1),r.w,n);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let P=B(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=E("emissive",(new i.Vector3).setFromColor(e.emissive)),a=U("emissiveIntensity",e.emissiveIntensity),n=e.emissiveMap??ze,r=U("useEmissiveMap",null!=e.emissiveMap?1:0),o=k("emissiveMap",n).sample(We(s,e.emissiveMap)).rgb.multiply(t);P=z(t,o,r),P=P.multiplyScalar(a)}else e instanceof R&&null!=e.outputEmissive&&(P=e.outputEmissive);let b=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(b=E("sheenColor",(new i.Vector3).setFromColor(e.sheenColor).multiplyScalar(e.sheen)),e.sheen>0&&null!=e.sheenColorMap)){const t=k("sheenColorMap",e.sheenColorMap).sample(s).rgb;b=b.multiply(t)}let y=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(y=U("sheenRoughness",e.sheenRoughness),e.sheen>0&&null!=e.sheenRoughnessMap)){const t=k("sheenRoughnessMap",e.sheenRoughnessMap).sample(s).r;y=y.multiply(t)}let T=null;if(e instanceof i.MeshPhysicalMaterial&&e.anisotropy>0&&(T=U("anisotropy",e.anisotropy),e.anisotropy>0&&null!=e.anisotropyMap)){const t=k("anisotropyMap",e.anisotropyMap).sample(s).r;T=T.multiply(t)}let w=null;if(e instanceof i.MeshPhysicalMaterial&&e.anisotropy>0){const t=e.anisotropyRotation??0;w=X("anisotropyDirection",new i.Vector2(Math.cos(t),Math.sin(t)))}const x=e instanceof p&&null!=e.uniforms[ie],I=e instanceof p&&null!=e.uniforms[ue],H=e instanceof p&&null!=e.uniforms[de],Y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,K=U("alphaTest",e.alphaTest);let Q,J=e.alphaTest>0?g.lt(K):Y&&t===ke.opaque?g.lt(.8):null;!0===e.userData.isDecal&&(J=J?J.or(Le):Le),Q=Y?W(0,0,0,0):(r=o,G(r).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const Z=e instanceof R?e.outputPosition:void 0,ee=e instanceof R?e.outputTransform:void 0;let te,se=D("black",1);if(e instanceof R&&null!=e.outputColor)se=e.outputColor;else if(e instanceof i.MeshStandardMaterial)se=O({color:M,metalness:d,roughness:l,emissive:P.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:c,bakedLight:h,sheenColor:b,sheenRoughness:y,anisotropy:T,anisotropyDirection:w});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)se=F({color:M.rgb,ambientOcclusion:u,ambientOcclusionIntensity:c});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??B("black");null!=u&&(t=t.multiplyScalar(u.subtract(1).multiply(c).add(1))),e=e.add(t),se=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(se=A({color:M,emissive:P.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:c,bakedLight:h}));(e instanceof R||e instanceof i.MeshStandardMaterial)&&(te=e.envMap);let ae=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(ae=e.fog);let ne=D(se.rgb,g);ae&&(ne=new FogNode(ne));let re=!0;if(t===ke.opaque?(re&&(re=!x&&!I&&!H),re&&(re=!Y)):t===ke.transparent&&re&&(re=Y||x||I||H),!re)return n=Xe,a.set(e,n),n;n=new R({transform:ee,position:null==ee?Z:void 0,outputs:[ne,P.rgba(t===ke.opaque?K:v?1:0),Q],opacity:g,outputEncoding:!1,fog:ae,transparent:e.transparent,lights:!0,envMap:te,alphaTest:e.alphaTest,discard:J}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=n.uniforms.envMapIntensity&&(n.uniforms.envMapIntensity.value=e.envMapIntensity),"alphaMap"in e&&null!=e.alphaMap&&(n.alphaMap=e.alphaMap),(e instanceof R||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(n),e instanceof R&&(Object.assign(n.defines,e.defines),null!=n.uniforms[de]&&(n.uniforms[de].value=this.aoPass.pdRenderTarget.texture,n.defines.USE_SSAO_MAP="")),n.userData.mrtOutputs=3,n.forceSinglePass=e.forceSinglePass,n.side=e.side,n.blending=e.blending,Y?(n.depthWrite=!e.transparent,n.depthTest=e.depthTest,n.colorWrite=t===ke.transparent):(n.depthWrite=e.depthWrite,n.depthTest=e.depthTest),n.visible=e.visible,n.alphaTest=e.alphaTest,n.alphaHash=e.alphaHash,n.vertexColors=e.vertexColors,n.premultipliedAlpha=e.premultipliedAlpha,n.toneMapped=e.toneMapped,n.blendAlpha=e.blendAlpha,n.blendColor=e.blendColor,n.polygonOffset=e.polygonOffset,n.polygonOffsetFactor=e.polygonOffsetFactor,n.polygonOffsetUnits=e.polygonOffsetUnits,n.blending=e.blending,n.wireframe=e.wireframe??!1,n.userData.isGBufferMaterial=!0,n.visible=re,Object.assign(n.userData,e.userData),n.visible&&(this.csm.setupMaterial(n),e instanceof p&&this.inheritCustomUniformBindings(e,n)),a.set(e,n)}var r;return n.visible&&(e instanceof p?this.updateUniformValues(e,n):this.updateMaterialProperties(e,n)),this.initLightVolumeUniform(n),n}isDepthPrepassEnabled(){return!0===this.options.depthPrepass?.enabled}usesSceneFeedbackUniforms(e){return e instanceof p&&(null!=e.uniforms[ie]||null!=e.uniforms[ue]||null!=e.uniforms[de])}isDepthPrepassEligibleMaterial(e){return null!=e&&(!1!==e.visible&&!1!==e.depthTest&&!1!==e.depthWrite&&(!e.transparent&&e.blending!==i.AdditiveBlending&&(!this.usesSceneFeedbackUniforms(e)&&(e instanceof R||e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshBasicMaterial))))}isDepthPrepassEligibleMesh(e){return!!this.isDepthPrepassEnabled()&&((e instanceof i.InstancedMesh||e instanceof _e)&&(!Array.isArray(e.material)&&this.isDepthPrepassEligibleMaterial(e.material)))}createDepthPrepassMaterial(e){if(!this.isDepthPrepassEligibleMaterial(e))return null;let t=this.depthPrepassMaterialCache.get(e);if(null==t){let s,a=C(1);e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial?(a=U("opacity",e.opacity??1),null!=e.map&&(a=a.multiply(k("map",e.map).sample(V.uv).a)),null!=e.alphaMap&&(a=a.multiply(k("alphaMap",e.alphaMap).sample(V.uv).r))):e instanceof R&&(a=e.outputOpacity??C(1)),null!=e.alphaTest&&e.alphaTest>0&&(s=a.lt(e.alphaTest));const n=e instanceof R?e.outputPosition:void 0,r=e instanceof R?e.outputTransform:void 0;t=new R({outputs:[D(0,0),D(0,0),D(0,0)],opacity:a,transform:r,position:null==r?n:void 0,discard:s,lights:!1,fog:!1,outputEncoding:!1,transparent:!1,alphaTest:e.alphaTest}),t.depthWrite=!0,t.depthTest=e.depthTest,t.colorWrite=!1,t.transparent=!1,t.blending=i.NoBlending,t.lights=!1,t.fog=!1,t.toneMapped=!1,t.side=e.side,t.alphaTest=e.alphaTest,t.visible=e.visible,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t.onBeforeCompile=()=>{},t.customProgramCacheKey=()=>`depth-prepass:${e.id}:${e.version}:${e.alphaTest}:${e.side}`;for(const e of wt)delete t.uniforms[e];for(const e of xt)delete t.uniforms[e];delete t.uniforms.receiveShadow,this.depthPrepassMaterialCache.set(e,t)}return e instanceof R?this.updateUniformValues(e,t):this.updateMaterialProperties(e,t),t.depthWrite=!0,t.depthTest=e.depthTest,t.colorWrite=!1,t.transparent=!1,t.blending=i.NoBlending,t.visible=e.visible,t.alphaTest=e.alphaTest,t.side=e.side,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t}applyDepthPrepassMaterials(){const e=this.depthPrepassCachedMaterials,t=this.depthPrepassCachedVisibility;e.clear(),t.length=0,Me(this.scene,s=>{if(Pt(s))return t.push(s),s.visible=!1,!1;if(!(s instanceof o))return;if(e.set(s,s.material),!this.isDepthPrepassEligibleMesh(s))return t.push(s),void(s.visible=!1);const i=this.createDepthPrepassMaterial(s.material);if(null==i)return t.push(s),void(s.visible=!1);s.material=i,s.visible=!0})}unapplyDepthPrepassMaterials(){this.depthPrepassCachedMaterials.forEach((e,t)=>{t.material=e}),this.depthPrepassCachedVisibility.forEach(e=>{e.visible=!0})}renderDepthPrepass(){if(!this.isDepthPrepassEnabled())return;this.applyDepthPrepassMaterials();const e=this.scene.matrixWorldAutoUpdate,t=this.scene.matrixAutoUpdate,s=this.renderer.shadowMap.autoUpdate;this.renderer.shadowMap.autoUpdate=!1,this.scene.matrixWorldAutoUpdate=!1,this.scene.matrixAutoUpdate=!1,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clearDepth();try{this.renderer.render(this.scene,this.camera)}catch(e){console.warn("Depth prepass render failed",e)}this.unapplyDepthPrepassMaterials(),this.renderer.shadowMap.autoUpdate=s,this.scene.matrixWorldAutoUpdate=e,this.scene.matrixAutoUpdate=t}updateCsm(){const e=this.csmUpdateInvervals;if(this.renderer.shadowMap.autoUpdate&&null!=this.csmCascadeLastUpdate&&Array.isArray(e)){const t=performance.now();for(let s=0;s<this.csm.lights.length;++s){const i=e[s]??e[e.length-1]??16;(t-this.csmCascadeLastUpdate[s]>=i||0===s)&&this.csm.lights[s].shadow&&(this.csm.lights[s].shadow.needsUpdate=!0,this.csmCascadeLastUpdate[s]=t)}}this.csm.update()}loop(t,s=!1){const a=this.stats,n=a.addPanel(new ee.Panel("Calls","#83f","#002")),l=a.addPanel(new ee.Panel("Triangles","#c32","#002"));let h;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(h=new me(this.renderer.getContext()),a.addPanel(h)),this.showStats=s;let p=10,d=1e3;const u=()=>{const e=this.renderer.info.render.calls;e>p&&(p=e,setTimeout(()=>p=10,5e3)),n.update(e,p);const t=this.renderer.info.render.triangles;t>d&&(d=t,setTimeout(()=>d=1e3,5e3)),l.update(t,d)};performance.now();i.Ray.prototype.intersectTriangle;this.resizeRender();const c=[],m=[],f=[];let g=0;const M=new r,v=new r;let P=0;let b=this.paused,y=!1,T=0,w=null,x=this.fpsCapRevision;const S=()=>{this.running&&!0!==this.options.enableXR&&requestAnimationFrame(U)},C=()=>{e.activeView=this,y&&(y=!1,requestAnimationFrame(()=>U(T)))},O=Ze();Je.set(this.container,e=>{this.isIntersecting=e,e&&C()}),O.observe(this.container),this.container.addEventListener("pointerdown",()=>{C()},{capture:!0});const U=s=>{y=!1;const n=this.renderer.getContext();if(!this.running||null===this.container.offsetParent||this.paused&&n.drawingBufferHeight>1)return y=!0,T=s,setTimeout(()=>{y&&U(s)},500),void(this.paused&&(b=!0));if(this.renderer.domElement.parentElement!==this.container){if(e.activeView!==this&&null!==e.activeView)return y=!0,void(T=s);this.container.replaceChildren(this.renderer.domElement),this.resizeRender()}if(!0!==this.options.enableXR){x!==this.fpsCapRevision&&(x=this.fpsCapRevision,w=null);const e=this.fpsCap;if(null!=e){const t=1e3/e;if(null!=w){const e=s-w;if(e<t)return void S();w=s-e%t}else w=s}else w=s}this.applyPostProcessSettings(),this.renderer.autoClear=!1,this.renderer.setViewport(0,0,this.container.clientWidth,this.container.clientHeight),a.begin(),this.showStats&&h?.startQuery(),this.ssrPass.gpuPanel=h;let r=(s*=.001)-g;if(g=s,b&&(r=.016,b=!1),M.copy(this.camera.matrixWorld),r>1){let e=r;for(;e>.05;)t(tt),e-=tt;t(e)}else t(r);this.onLoopCallbacks.forEach(e=>e(r)),this.paused||(this.simulationTime+=r*this.simulationTimeScale);const l=this.simulationTime;this.camera?.updateMatrixWorld(),v.copy(this.camera.matrixWorld),s-P>.08&&!v.equals(M)&&(this.renderer.shadowMap.needsUpdate=!0,P=s),this.updateCsm();let p=!1;c.length=0,m.length=0,f.length=0;const d=at;rt.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),d.setFromProjectionMatrix(rt);let C=!1,O=!1,E=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Fe&&(C=!0),e instanceof o&&this.initCustomDepthMaterial(e),(e instanceof o||e instanceof i.Sprite)&&(this.initResolutionUniform(e.material),this.initNormalUniform(e.material),this.initShadowUniform(e,e.material),this.initLightVolumeUniform(e.material),null!=this.scene.environment&&function(e,t){if(Array.isArray(e.material))for(const s of e.material)t(s);else null!=e.material&&t(e.material)}(e,e=>this.applyEnvMap(e)),!0===e.material?.userData?.hasBloom&&(p=!0)),(e instanceof o||e instanceof i.Sprite)&&e.visible&&(e.material?.userData?.water||e.material?.uniforms&&null!=e.material?.uniforms[ie])&&isObjectInFrustum(e,d)?(this.initDepthUniform(e.material),O=!0):e instanceof Y&&(e.visible=!1,m.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[de]&&isObjectInFrustum(e,d)&&e.material instanceof R&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ue]&&isObjectInFrustum(e,d)&&(f.push(e),e.material.uniforms[ue].value=this.sceneColorRenderTarget.texture,E=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[pe])e.material.uniforms[pe].value=l;else if(e instanceof o&&Array.isArray(e.material))for(const t of e.material)t.uniforms&&null!=t.uniforms[pe]&&(t.uniforms[pe].value=l)}),this.bloomPass.enabled=p,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderDepthPrepass(),this.renderScene(ke.opaque),this.aoPass.output=te.OUTPUT.Off,(O||E)&&(this.fquadCopyOpaque.material.uniforms.tSceneColor.value=this.gRenderTarget.textures[0],this.fquadCopyOpaque.material.uniforms.tDepthTexture.value=this.gRenderTarget.depthTexture,this.initResolutionUniform(this.fquadCopyOpaque.material),this.renderer.setRenderTarget(this.sceneColorRenderTarget),this.renderer.clear(),this.fquadCopyOpaque.render(this.renderer),this.renderer.setRenderTarget(this.gRenderTarget)),f.length,c.forEach(e=>e.visible=!0),m.forEach(e=>e.visible=!0),f.forEach(e=>e.visible=!0),this.aoPass.enabled,this.ssrPass&&(this.ssrPass.elapsedTime=s),this.volumetricFogPass&&C?(this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene),this.volumetricFogPass.enabled=!0):this.volumetricFogPass&&(this.volumetricFogPass.enabled=!1),this.updatePostProcessEffectUniforms(l);try{!this.paused&&this.running&&(this.render(r),this.showStats&&h?.endQuery(),this.showStats&&u(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}a.end(),this.csm?.update(),S()};!0===this.options.enableXR?this.renderer.setAnimationLoop(U):requestAnimationFrame(U)}applyGBufferMaterials(e){const t=this.gBufferCachedMaterials,s=this.gBufferCachedVisibility;t.clear(),s.length=0;Me(this.scene,i=>{if(Pt(i))return s.push(i),i.visible=!1,!1;if(i instanceof o){t.set(i,i.material);let a=!1;if(Array.isArray(i.material)){i.material=i.material.slice();for(let t=0;t<i.material.length;t++)i.material[t]=this.createGBufferMaterial(i.material[t],e,e===ke.opaque&&this.isDepthPrepassEligibleMesh(i)),a||(a=i.material[t].visible),this.initShadowUniform(i,i.material[t])}else i.material=this.createGBufferMaterial(i.material,e,e===ke.opaque&&this.isDepthPrepassEligibleMesh(i)),a||(a=i.material.visible),this.initShadowUniform(i,i.material);a?i.visible=!0:null!=i.children&&0!=i.children.length||(s.push(i),i.visible=!1)}})}unapplyGBufferMaterials(){this.gBufferCachedMaterials.forEach((e,t)=>{t.material=e}),this.gBufferCachedVisibility.forEach((e,t)=>{e.visible=!0,e.updateMatrixWorld(!0)})}initTextures(e=this.scene){e.traverse(e=>{if(e instanceof o)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)this._initMaterialTextures(e.material[t]);else this._initMaterialTextures(e.material)})}_initMaterialTextures(e){if(!this._initiatedMaterialTextures.has(e))if(this._initiatedMaterialTextures.add(e),e instanceof p){for(const[t,s]of Object.entries(e.uniforms))if(s.value instanceof u){if(this._initiatedTextures.has(s.value))continue;this.renderer.initTexture(s.value),this._initiatedTextures.add(s.value)}}else for(const[t,s]of Object.entries(e))if(s instanceof u){if(this._initiatedTextures.has(s))continue;this.renderer.initTexture(s),this._initiatedTextures.add(s)}}async compileAsync(e=this.scene){if(this.compileInProgress)return;this.renderer.setRenderTarget(this.gRenderTarget),this.compileInProgress=!0,this.applyGBufferMaterials(ke.opaque),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(ke.transparent),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.isDepthPrepassEnabled()&&(this.renderer.setRenderTarget(this.gRenderTarget),this.applyDepthPrepassMaterials(),await this.renderer.compileAsync(e,this.camera),this.unapplyDepthPrepassMaterials()),e===this.scene&&(this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.compileAsync(this.fquadBlendAO.mesh,this.fquadBlendAO.camera),this.renderer.setRenderTarget(this.sceneColorRenderTarget),this.renderer.compileAsync(this.fquadCopyOpaque.mesh,this.fquadCopyOpaque.camera));const t=this.csm.lights[0]?.shadow.camera;null!=t&&(this.applyDepthMaterial(),await this.renderer.compileAsync(e,t),this.unapplyDepthMaterial()),this.compileInProgress=!1,this.renderer.setRenderTarget(null)}applyDepthMaterial(){const e=this.gBufferCachedMaterials;e.clear(),this.scene.traverse(t=>{(t.isMesh||t.isPoints||t.isLine||t.isSprite)&&(this.initCustomDepthMaterial(t),e.set(t,t.material),t.castShadow?null!=t.customDepthMaterial?t.material=t.customDepthMaterial:t.material=Ct:t.material=null)})}unapplyDepthMaterial(){this.gBufferCachedMaterials.forEach((e,t)=>{t.material=e})}renderScene(e){if(!this.running||this.paused)return;if(this.compileInProgress)return void console.error("Compile in progress, skipping render");this.applyGBufferMaterials(e);const t=this.scene.matrixWorldAutoUpdate,s=this.scene.matrixAutoUpdate,i=this.renderer.shadowMap.autoUpdate;e!==ke.opaque&&(this.renderer.shadowMap.autoUpdate=!1,this.scene.matrixWorldAutoUpdate=!1,this.scene.matrixAutoUpdate=!1);try{this.renderer.render(this.scene,this.camera)}catch(e){console.warn("Render failed",e)}e===ke.opaque&&this.gBufferCachedMaterials.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof p&&this.updateLightUniformValues(t.material,e)}),this.unapplyGBufferMaterials(),this.renderer.shadowMap.autoUpdate=i,this.scene.matrixWorldAutoUpdate=t,this.scene.matrixAutoUpdate=s}getEnvTexture(e){null==this.pmremGenerator&&(this.pmremGenerator=new i.PMREMGenerator(this.renderer),this.pmremGenerator.compileEquirectangularShader());let t=this.pmremGeneratorResults.get(e);return null==t&&(t=this.pmremGenerator.fromEquirectangular(e).texture,this.pmremGeneratorResults.set(e,t)),t.colorSpace=i.SRGBColorSpace,t}applyPostProcessSettings(){if(0==this.postProcessVolumes.length)return this.lutPass.enabled=!1,this.colorPass.enabled=!1,this.dofPass.enabled=!1,this.renderer.toneMapping=this.baseToneMapping,void(this.renderer.toneMappingExposure=this.baseToneMappingExposure);!function(e,t=i.NoToneMapping,s=1){e.tonemapMapping=t,e.tonemapExposure=s,e.envIntensity=1,e.envTexture=void 0,e.vignetteIntensity=0,e.colorTint=e.colorTint??new i.Color("white"),e.colorTint.set("white"),e.colorTintIntensity=0,e.depthFocus=void 0,e.depthAperture=void 0,e.depthMaxBlur=void 0,e.temperature=6500,e.temperatureTint=0,e.globalSaturation=ot(e.globalSaturation,1,1,1),e.globalContrast=ot(e.globalContrast,1,1,1),e.globalGamma=ot(e.globalGamma,1,1,1),e.globalGain=ot(e.globalGain,1,1,1),e.globalOffset=ot(e.globalOffset,0,0,0),e.shadowsSaturation=ot(e.shadowsSaturation,1,1,1),e.shadowsContrast=ot(e.shadowsContrast,1,1,1),e.shadowsGamma=ot(e.shadowsGamma,1,1,1),e.shadowsGain=ot(e.shadowsGain,1,1,1),e.shadowsOffset=ot(e.shadowsOffset,0,0,0),e.shadowsMax=.09,e.midtonesSaturation=ot(e.midtonesSaturation,1,1,1),e.midtonesContrast=ot(e.midtonesContrast,1,1,1),e.midtonesGamma=ot(e.midtonesGamma,1,1,1),e.midtonesGain=ot(e.midtonesGain,1,1,1),e.midtonesOffset=ot(e.midtonesOffset,0,0,0),e.highlightsSaturation=ot(e.highlightsSaturation,1,1,1),e.highlightsContrast=ot(e.highlightsContrast,1,1,1),e.highlightsGamma=ot(e.highlightsGamma,1,1,1),e.highlightsGain=ot(e.highlightsGain,1,1,1),e.highlightsOffset=ot(e.highlightsOffset,0,0,0),e.highlightsMin=.5,e.lut=void 0,e.lutIntensity=0}(this.postProcessSettings,this.baseToneMapping,this.baseToneMappingExposure);const e=this.postProcessSettings;let t,s=!1;if(null==this.camera)return;const a=this.camera.getWorldPosition(dt);let n=[];for(const r of this.postProcessVolumes){if(!st(r.object))continue;let o=r.blendWeight??1;const l=r.distanceToPoint(a);l>r.blendRadius||(r.blendRadius>0&&(o*=ve(1-l/r.blendRadius,0,1)),o>1&&(o=1),o>0&&(n.push(r),void 0!==r.settings.tonemapMapping&&(e.tonemapMapping=r.settings.tonemapMapping),void 0!==r.settings.tonemapExposure&&(e.tonemapExposure=i.MathUtils.lerp(e.tonemapExposure,r.settings.tonemapExposure,o)),void 0!==r.settings.envTexture&&(e.envTexture=r.settings.envTexture),void 0!==r.settings.envIntensity&&(e.envIntensity=i.MathUtils.lerp(e.envIntensity,r.settings.envIntensity,o)),void 0!==r.settings.vignetteIntensity&&(e.vignetteIntensity=i.MathUtils.lerp(e.vignetteIntensity,r.settings.vignetteIntensity,o)),void 0!==r.settings.colorTint&&void 0!==r.settings.colorTintIntensity&&r.settings.colorTintIntensity>0&&(e.colorTint=e.colorTint.lerp(r.settings.colorTint,o)),void 0!==r.settings.colorTintIntensity&&(e.colorTintIntensity=i.MathUtils.lerp(e.colorTintIntensity,r.settings.colorTintIntensity,o)),void 0!==r.settings.depthFocus&&(s=!0,e.depthFocus=void 0!==e.depthFocus?i.MathUtils.lerp(e.depthFocus,r.settings.depthFocus,o):r.settings.depthFocus),void 0!==r.settings.depthAperture&&(s=!0,e.depthAperture=void 0!==e.depthAperture?i.MathUtils.lerp(e.depthAperture,r.settings.depthAperture,o):r.settings.depthAperture),void 0!==r.settings.depthMaxBlur&&(s=!0,e.depthMaxBlur=void 0!==e.depthMaxBlur?i.MathUtils.lerp(e.depthMaxBlur,r.settings.depthMaxBlur,o):r.settings.depthMaxBlur),void 0!==r.settings.temperature&&(e.temperature=i.MathUtils.lerp(e.temperature,r.settings.temperature,o)),void 0!==r.settings.temperatureTint&&(e.temperatureTint=i.MathUtils.lerp(e.temperatureTint,r.settings.temperatureTint,o)),void 0!==r.settings.globalSaturation&&e.globalSaturation.lerp(r.settings.globalSaturation,o),void 0!==r.settings.globalContrast&&e.globalContrast.lerp(r.settings.globalContrast,o),void 0!==r.settings.globalGamma&&e.globalGamma.lerp(r.settings.globalGamma,o),void 0!==r.settings.globalGain&&e.globalGain.lerp(r.settings.globalGain,o),void 0!==r.settings.globalOffset&&e.globalOffset.lerp(r.settings.globalOffset,o),void 0!==r.settings.shadowsSaturation&&e.shadowsSaturation.lerp(r.settings.shadowsSaturation,o),void 0!==r.settings.shadowsContrast&&e.shadowsContrast.lerp(r.settings.shadowsContrast,o),void 0!==r.settings.shadowsGamma&&e.shadowsGamma.lerp(r.settings.shadowsGamma,o),void 0!==r.settings.shadowsGain&&e.shadowsGain.lerp(r.settings.shadowsGain,o),void 0!==r.settings.shadowsOffset&&e.shadowsOffset.lerp(r.settings.shadowsOffset,o),void 0!==r.settings.shadowsMax&&(e.shadowsMax=i.MathUtils.lerp(e.shadowsMax,r.settings.shadowsMax,o)),void 0!==r.settings.midtonesSaturation&&e.midtonesSaturation.lerp(r.settings.midtonesSaturation,o),void 0!==r.settings.midtonesContrast&&e.midtonesContrast.lerp(r.settings.midtonesContrast,o),void 0!==r.settings.midtonesGamma&&e.midtonesGamma.lerp(r.settings.midtonesGamma,o),void 0!==r.settings.midtonesGain&&e.midtonesGain.lerp(r.settings.midtonesGain,o),void 0!==r.settings.midtonesOffset&&e.midtonesOffset.lerp(r.settings.midtonesOffset,o),void 0!==r.settings.highlightsSaturation&&e.highlightsSaturation.lerp(r.settings.highlightsSaturation,o),void 0!==r.settings.highlightsContrast&&e.highlightsContrast.lerp(r.settings.highlightsContrast,o),void 0!==r.settings.highlightsGamma&&e.highlightsGamma.lerp(r.settings.highlightsGamma,o),void 0!==r.settings.highlightsGain&&e.highlightsGain.lerp(r.settings.highlightsGain,o),void 0!==r.settings.highlightsOffset&&e.highlightsOffset.lerp(r.settings.highlightsOffset,o),void 0!==r.settings.highlightsMin&&(e.highlightsMin=i.MathUtils.lerp(e.highlightsMin,r.settings.highlightsMin,o)),void 0!==r.settings.lut&&(t=r.settings.lut),void 0!==r.settings.lutIntensity&&(e.lutIntensity=i.MathUtils.lerp(e.lutIntensity,r.settings.lutIntensity,o))))}if(0===n.length)return this.lutPass.enabled=!1,this.colorPass.enabled=!1,this.dofPass.enabled=!1,this.renderer.toneMapping=this.baseToneMapping,void(this.renderer.toneMappingExposure=this.baseToneMappingExposure);const r=e.vignetteIntensity>pt,o=(h=e.temperature,p=e.temperatureTint,!ht(h,6500)||!ht(p,0));var h,p;const d=(u=e.colorTint,e.colorTintIntensity>pt&&(!ht(u.r,1)||!ht(u.g,1)||!ht(u.b,1)));var u;const c=!(lt((m=e).globalSaturation,1,1,1)&&lt(m.globalContrast,1,1,1)&&lt(m.globalGamma,1,1,1)&&lt(m.globalGain,1,1,1)&&lt(m.globalOffset,0,0,0)&&lt(m.shadowsSaturation,1,1,1)&&lt(m.shadowsContrast,1,1,1)&&lt(m.shadowsGamma,1,1,1)&&lt(m.shadowsGain,1,1,1)&&lt(m.shadowsOffset,0,0,0)&&lt(m.midtonesSaturation,1,1,1)&&lt(m.midtonesContrast,1,1,1)&&lt(m.midtonesGamma,1,1,1)&&lt(m.midtonesGain,1,1,1)&&lt(m.midtonesOffset,0,0,0)&&lt(m.highlightsSaturation,1,1,1)&&lt(m.highlightsContrast,1,1,1)&&lt(m.highlightsGamma,1,1,1)&&lt(m.highlightsGain,1,1,1)&&lt(m.highlightsOffset,0,0,0));var m;const f=o||d||c||r,g=f&&e.tonemapMapping!==i.NoToneMapping,M=null!=t&&e.lutIntensity>pt;f?(this.renderer.toneMapping=i.NoToneMapping,this.renderer.toneMappingExposure=1):(this.renderer.toneMapping=e.tonemapMapping,this.renderer.toneMappingExposure=e.tonemapExposure),null!=e.envTexture&&(this.scene.environment=this.getEnvTexture(e.envTexture)),this.scene.environmentIntensity=e.envIntensity,f?(this.colorPass.whiteBalanceEnabled=o,this.colorPass.whiteBalanceScale=o?function(e,t,s){const i=function(e){const t=ve(e,1e3,4e4)/100,s=t<=66?1:ve(1.292936186062745*Math.pow(t-60,-.1332047592),0,1),i=ve(t<=66?.3900815787690196*Math.log(t)-.6318414437886275:1.129890860895294*Math.pow(t-60,-.0755148492),0,1),a=t>=66?1:t<=19?0:ve(.5432067891101962*Math.log(t-10)-1.19625408914,0,1);return ct.set(s,i,a)}(t),a=1+.2*ve(s,-1,1),n=i.x,r=i.y*a,o=i.z,l=Math.max(r,1e-4);return e.set(1/Math.max(n/l,1e-4),1/Math.max(r/l,1e-4),1/Math.max(o/l,1e-4)),e}(ut,e.temperature,e.temperatureTint):ut.set(1,1,1),this.colorPass.vignetteIntensity=e.vignetteIntensity,this.colorPass.vignetteEnabled=r,this.colorPass.colorTintEnabled=d,this.colorPass.colorTint=e.colorTint,this.colorPass.colorTintIntensity=e.colorTintIntensity,this.colorPass.colorGradingEnabled=c,this.colorPass.toneMapping=e.tonemapMapping,this.colorPass.toneMappingEnabled=g,this.colorPass.toneMappingExposure=e.tonemapExposure,this.colorPass.globalSaturation=e.globalSaturation,this.colorPass.globalContrast=e.globalContrast,this.colorPass.globalGamma=e.globalGamma,this.colorPass.globalGain=e.globalGain,this.colorPass.globalOffset=e.globalOffset,this.colorPass.shadowsSaturation=e.shadowsSaturation,this.colorPass.shadowsContrast=e.shadowsContrast,this.colorPass.shadowsGamma=e.shadowsGamma,this.colorPass.shadowsGain=e.shadowsGain,this.colorPass.shadowsOffset=e.shadowsOffset,this.colorPass.shadowsMax=e.shadowsMax,this.colorPass.midtonesSaturation=e.midtonesSaturation,this.colorPass.midtonesContrast=e.midtonesContrast,this.colorPass.midtonesGamma=e.midtonesGamma,this.colorPass.midtonesGain=e.midtonesGain,this.colorPass.midtonesOffset=e.midtonesOffset,this.colorPass.highlightsSaturation=e.highlightsSaturation,this.colorPass.highlightsContrast=e.highlightsContrast,this.colorPass.highlightsGamma=e.highlightsGamma,this.colorPass.highlightsGain=e.highlightsGain,this.colorPass.highlightsOffset=e.highlightsOffset,this.colorPass.highlightsMin=e.highlightsMin,this.colorPass.enabled=!0):this.colorPass.enabled=!1,s&&this.camera instanceof l?(this.dofPass.enabled=!0,void 0!==e.depthFocus&&(this.dofPass.uniforms.focus.value=e.depthFocus),void 0!==e.depthAperture&&(this.dofPass.uniforms.aperture.value=e.depthAperture),void 0!==e.depthMaxBlur&&(this.dofPass.uniforms.maxblur.value=e.depthMaxBlur)):this.dofPass.enabled=!1,this.lutPass.enabled=M,M&&(null!=t&&(t.flipY=!0,t.generateMipmaps=!1),this.lutPass.lut=t,this.lutPass.intensity=e.lutIntensity)}updatePostProcessEffectUniforms(e){if(0===this.postProcessEffects.length)return;const t=this.postProcessEffectUniformState;t.aoEnabled=this.aoPass.enabled,t.aoTexture=this.aoPass.enabled?this.aoPass.pdRenderTarget.texture:null,this.camera instanceof l?(t.cameraNear=this.camera.near,t.cameraFar=this.camera.far):(t.cameraNear=void 0,t.cameraFar=void 0),t.depthTexture=this.sceneColorRenderTarget.textures[1],t.normalTexture=this.gRenderTarget.textures[2],t.resolution.set(this.gRenderTarget.width,this.gRenderTarget.height),t.simulationTime=e;for(const e of this.postProcessEffects)e.pass.updateUniformState(t)}renderOverlay(){if(!this.running)return;if(0===this.overlayCameras.size)return;const e=Array.from(this.overlayCameras.values()).slice(0,this.maxInsetCameras),t=this.previousClientWith/2,s=e.length*this.insetWidth+(e.length-1)*this.insetMargin;for(let i=0;i<e.length;i++)this.renderer.clearDepth(),this.renderer.setViewport(t-s/2+this.insetWidth*i+this.insetMargin*i,this.insetOffsetY,this.insetWidth,this.insetHeight),this.renderer.render(this.scene,e[i])}addOverlayCamera(e){this.overlayCameras.add(e)}clearOverlayCameras(){this.overlayCameras.clear()}removeOverlayCamera(e){this.overlayCameras.delete(e)}render(e){if(0===this.composer.renderTarget1.width||0===this.composer.renderTarget1.height)return;if(0===this.composer.renderTarget2.width||0===this.composer.renderTarget2.height)return;let t=!1;if(this.ssrPass.enabled&&!1!==this.options?.reflection?.enabled){const e=this.ssrPass.selects??[];e.length=0,this.scene.traverseVisible(t=>{t instanceof o&&!0===t.material.userData?.reflective&&isObjectInFrustum(t,at)&&e.push(t)}),this.ssrPass.selects=e,0==e.length&&(this.ssrPass.enabled=!1),t=!0}this.options.bloom,this.composer.render(e),this.scene.matrixWorldAutoUpdate=!0,this.scene.matrixAutoUpdate=!0,t&&(this.ssrPass.enabled=!0)}hasBloom(){return null!=ge(this.scene,e=>e instanceof o&&!0===e.material?.userData?.hasBloom)}darkenNonBloomed(e){if((e instanceof o||e instanceof i.Sprite||e instanceof i.Line)&&e.visible&&(null==e.material.userData||!0!==e.material.userData.hasBloom)){if(e.material?.id===Ne.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Ne:(e.visible=!1,this.bloomHidden.push(e))}else"TransformControlsPlane"!==e.type&&"TransformControlsGizmo"!==e.type||(e.visible=!1,this.bloomHidden.push(e))}restoreMaterial(e){this.bloomStoredMaterials[e.uuid]&&(e.material=this.bloomStoredMaterials[e.uuid],delete this.bloomStoredMaterials[e.uuid],e.visible=!0)}initDepthUniform(e){e instanceof p&&(e.uniforms[ie].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[ne]&&(e.uniforms[ne].value=this.camera.near),null!=e.uniforms[ae]&&(e.uniforms[ae].value=this.camera.far)))}initNormalUniform(e){e instanceof p&&null!=e.uniforms[oe]&&(e.uniforms[oe].value=this.gRenderTarget.textures[2])}initShadowUniform(e,t){t instanceof R&&(t.uniforms.receiveShadow?t.uniforms.receiveShadow.value=e.receiveShadow:t.uniforms.receiveShadow={value:e.receiveShadow})}initLightVolumeUniform(e){e instanceof R&&(null!=this.lightVolume?null==e.uniforms.uSH?(e.defines.USE_LIGHT_PROBE_VOLUME="",e.uniforms.gridOrigin={value:this.lightVolume.gridOrigin},e.uniforms.gridSize={value:this.lightVolume.gridSize},e.uniforms.gridRes={value:this.lightVolume.gridResolution},e.uniforms.giIntensity={value:this.lightProbeIntensity},e.uniforms.uSH={value:this.lightVolume.shTexture},e.uniformsNeedUpdate=!0,e.needsUpdate=!0):e.uniforms.giIntensity.value=this.lightProbeIntensity:null!=e.uniforms.uSH&&(delete e.defines.USE_LIGHT_PROBE_VOLUME,delete e.uniforms.gridOrigin,delete e.uniforms.gridSize,delete e.uniforms.gridRes,delete e.uniforms.giIntensity,delete e.uniforms.uSH,e.uniformsNeedUpdate=!0,e.needsUpdate=!0))}initResolutionUniform(e){e instanceof p&&null!=e.uniforms[re]&&e.uniforms[re].value.set(this.gRenderTarget.width,this.gRenderTarget.height)}initAoUniform(e){if(this.aoPass.enabled){e.uniforms[de].value=this.aoPass.pdRenderTarget.texture,null==e.defines.USE_SSAO_MAP&&(e.defines.USE_SSAO_MAP="",e.needsUpdate=!0),e.defines.USE_SSAO_MAP="";const t=this.tbufferMaterialCache.get(e);null!=t&&this.initAoUniform(t)}else if(null!=e.defines.USE_SSAO_MAP){delete e.defines.USE_SSAO_MAP,e.needsUpdate=!0;const t=this.tbufferMaterialCache.get(e);null!=t&&this.initAoUniform(t)}}initCustomDepthMaterial(e){if(null!=e.customDepthMaterial||!e.castShadow)return;const t=e.material;if(!(t instanceof R&&!t.transparent&&t.depthWrite&&t.alphaTest>0))return;let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Ae(Ee);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new R({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}};et.activeView=null,et=e=t([se(),s("design:paramtypes",[HTMLElement,Object])],et);export{et as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const tt=.05;function st(e){let t=e;for(;t;){if(!1===t.visible)return!1;t=t.parent}return!0}function it(e,t){return e.priority!==t.priority?e.priority-t.priority:e.id-t.id}te.prototype.overrideVisibility=function(){const e=this.scene,t=this._visibilityCache;e.traverse(function(e){if(t.set(e,e.visible),(e.isPoints||e.isLine||e.isTransformControls||e.isSprite)&&(e.visible=!1),null!=e.material){let t=!1,s=!1;if(Array.isArray(e.material)){for(const s of e.material)if(null!=s.alphaTest&&s.alphaTest>0){t=!0;break}}else null!=e.material.alphaTest&&e.material.alphaTest>0?t=!0:!0===e.material.userData.isDecal&&(s=!0);s&&(e.visible=!1)}})};const at=new i.Frustum,nt=new i.Box3,rt=new i.Matrix4;export function isObjectInFrustum(e,t){const s=nt.setFromObject(e);return t.intersectsBox(s)}function ot(e,t,s,a){return null==e?new i.Vector3(t,s,a):e.set(t,s,a)}function lt(e,t,s,i){return null!=e&&ht(e.x,t)&&ht(e.y,s)&&ht(e.z,i)}function ht(e,t,s=pt){return Math.abs(e-t)<=s}const pt=1e-4,dt=new i.Vector3,ut=new i.Vector3(1,1,1),ct=new i.Vector3(1,1,1);const mt=new r,ft=new c;function gt(e,t,s=new i.Matrix3){return ft.copy(e),ft.x*=-1,ft.y*=-1,ft.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(ft.y*=-1,ft.z*=-1),s.setFromMatrix4(mt.makeRotationFromEuler(ft))}const Mt=new R({outputs:[W(0,0,0,0),W(0,0,0,0),D(B("white"),Ie(4))],transparent:!0}),vt=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});Mt.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),vt);function Pt(e){return e instanceof i.Sprite||e.isPoints||e.isLine||e.isLineSegments2||e.isTransformControls||e.isTransformControlsGizmo||e instanceof o&&bt(e,e.material)}function bt(e,t){return null==t||(Array.isArray(t)?t.some(t=>bt(e,t)):t instanceof i.RawShaderMaterial||t instanceof i.ShaderMaterial&&!(t instanceof R))}class yt extends Ve{constructor(e,t,s){super(),this.scene=e,this.camera=t,this.gRenderTarget=s,this.cachedVisibility=[],this.toRender=[],this.needsSwap=!1}render(e,t,s,i,a){const n=e.autoClear;e.autoClear=!1;const r=this.scene.matrixWorldAutoUpdate,l=this.scene.matrixAutoUpdate,h=e.shadowMap.autoUpdate;this.scene.matrixAutoUpdate=!1,e.shadowMap.autoUpdate=!1;const p=s.depthTexture;s.depthTexture=this.gRenderTarget.depthTexture,e.setRenderTarget(s),this.cachedVisibility.length=0;let d=0,u=this.toRender;if(u.length=0,this.scene.traverseVisible(e=>{const t=Pt(e);e instanceof o&&!t?(this.cachedVisibility.push(e),e.visible=!1):t&&(d++,u.push(e))}),d>0)for(const t of u)e.render(t,this.camera);this.cachedVisibility.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=n,s.depthTexture=p,this.scene.matrixWorldAutoUpdate=r,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class Tt extends Ve{constructor(e){super(),this.fn=e}render(e,t,s,i,a){this.fn(e,t,s,i,a)}}const wt=["ambientLightColor","cameraNear","directionalLightShadows","directionalLights","directionalShadowMap","directionalShadowMatrix","fogColor","fogDensity","fogFar","fogNear","hemisphereLights","lightProbe","ltc_1","ltc_2","pointLightShadows","pointLights","pointShadowMap","pointShadowMatrix","rectAreaLights","shadowFar","spotLightMap","spotLightMatrix","spotLightShadows","spotLights","spotShadowMap"],xt=["directionalShadowMap","directionalShadowMatrix","pointLightShadows","pointShadowMap","pointShadowMatrix","spotLightShadows","spotShadowMap"],St=E("fogColor");export class FogNode extends H{constructor(e,t=St){super(),this.source=e,this.fogColor=t}compile(e){const t=e.variable(),s=e.get(this.source.rgb),i=e.get(this.source.a),a=e.get(this.fogColor),n=e.get(U("fogFar")),r=e.get(U("fogNear")),o=e.get(U("fogDensity")),l=e.get(L(I.mvPosition.z));return{pars:"\n ",chunk:`\n #ifdef FOG_EXP2\n float fogFactor_${t} = 1.0 - exp( - ${o} * ${o} * ${l} * ${l} );\n #else\n float fogFactor_${t} = smoothstep( ${r}, ${n}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${a}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}const Ct=new i.MeshDepthMaterial({depthPacking:i.RGBADepthPacking});/*
1
+ var e;import{__decorate as t,__metadata as s}from"tslib";import*as i from"three";import{Color as a,Material as n,Matrix4 as r,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as p,WebGLRenderTarget as d,Texture as u,Euler as c,MeshStandardMaterial as m}from"three";import{CopyShader as f,EffectComposer as g,FXAAShader as M,GammaCorrectionShader as v,LUTPass as P,RenderPass as b,ShaderPass as y,VRButton as w}from"three-stdlib";import{CSMShader as T,CSMUtil as x}from"./csm.js";import{colorToNormal as S,float as C,NodeShaderMaterial as R,standardMaterial as O,uniformFloat as E,uniformVec3 as U,toonMaterial as A,lambertMaterial as F,normalize as G,rgb as D,rgba as B,transformed as I,varying as L,varyingAttributes as V,varyingTransformed as _,vec4 as W,BooleanExpression as j,select as N,ifDefApply as q,uniformSampler2d as k,RgbaNode as H,mix as z,attributes as $,uniformVec2 as X}from"three-shader-graph";import{Reflector as Y}from"three-stdlib";import{BokehPass as K,OutputPass as Q}from"three/examples/jsm/Addons.js";import{CSM as J}from"three/examples/jsm/csm/CSM.js";import{RectAreaLightUniformsLib as Z}from"three/examples/jsm/lights/RectAreaLightUniformsLib.js";import ee from"three/examples/jsm/libs/stats.module.js";import{GTAOPass as te}from"three/examples/jsm/postprocessing/GTAOPass.js";import{Service as se}from"typedi";import{depthUniformName as ie,farUniformName as ae,nearUniformName as ne,resolutionUniformName as re,sceneNormalUniformName as oe,screenUV as le,supportsDepthTextureExtension as he}from"./shader-nodes/depth.js";import{elapsedTimeUniformName as pe}from"./shader-nodes/time.js";import{aoMapUniformName as de,sceneMapUniformName as ue}from"./shader-nodes/scene-sample.js";import{DepthPass as ce}from"./utils/three/depth-pass.js";import{GPUStatsPanel as me}from"./utils/three/gpu-stats-panel.js";import{OutlinePass as fe}from"./utils/three/outline-pass.js";import{findFirstVisibleObject as ge,traverseVisibleStop as Me}from"./utils/three/traverse.js";import{clamp as ve}from"./utils/math.js";import{ColorPass as Pe}from"./rendering/color-pass.js";import{PostProcessEffectPass as be,PostProcessEffectRegistration as ye,postProcessEffectStages as we,sanitizePostProcessEffectPriority as Te,sanitizePostProcessEffectStage as xe}from"./rendering/post-process-effect.js";import{SSRPass as Se}from"./rendering/ssr/SSRPass.js";import{SSRShader as Ce}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as Re}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as Oe}from"./rendering/outline-effect.js";import{UnrealBloomPass as Ee}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as Ue}from"./shader-nodes/depth.js";import{packDepthToRGBA as Ae}from"three-shader-graph";import{FogVolumeObject as Fe}from"./rendering/fog/fog-volume-object";import{ParallaxStandardMaterial as Ge}from"./shader/builtin/standard-shader.js";import{parallaxOcclusionMapping as De}from"./shader-nodes/pom.js";import{FullScreenQuad as Be}from"three-stdlib";import{edgeDepthEffect as Ie}from"./shader-nodes/effects";import{decalDiscard as Le}from"./shader-nodes/decal.js";import{Pass as Ve}from"three/examples/jsm/Addons.js";import{BatchedMesh2 as _e}from"./scene/batched-mesh-2.js";import{applyUvTiling as We}from"./shader/uv-nodes.js";x.patchSetupMaterial();const je=document.createElement("div");je.style.position="absolute",je.style.left="50%",je.style.top="50%",je.style.color="black",je.style.zIndex="999";(new i.Layers).set(9);const Ne=new i.MeshBasicMaterial({color:"black"}),qe=new i.MeshDepthMaterial;var ke;qe.depthPacking=i.RGBADepthPacking,qe.blending=i.NoBlending,qe.side=i.DoubleSide,function(e){e[e.opaque=0]="opaque",e[e.transparent=1]="transparent"}(ke||(ke={}));const He=(()=>{const e=new Uint8Array([255,255,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),ze=(()=>{const e=new Uint8Array([0,0,0,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),$e=(()=>{const e=new Uint8Array([128,128,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),Xe=new R({color:C(0),position:W(C(0))});Xe.visible=!1;const Ye=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let Ke=0,Qe=null;const Je=new Map;function Ze(){return null==Qe&&(Qe=new IntersectionObserver(e=>{for(const t of e){const e=Je.get(t.target);e&&e(t.isIntersecting)}},{threshold:0})),Qe}let et=e=class{get fpsCap(){return this._fpsCap}set fpsCap(e){const t=null!=e&&Number.isFinite(e)&&e>0?e:null;t!==this._fpsCap&&(this._fpsCap=t,this.fpsCapRevision++)}setPaused(e){this.paused=e}resizeRender(){if(!this.running)return;const e=this.container.clientWidth,t=this.container.clientHeight;this.previousClientWith===e&&this.previousClientHeight===t||0!==e&&0!==t&&(this.previousClientWith=e,this.previousClientHeight=t,this.camera instanceof l&&(this.camera.aspect=e/t,this.camera.updateProjectionMatrix()),this.renderer.setPixelRatio(Math.min(this.maxPixelRatio,window.devicePixelRatio)*this.resolutionScale),this.renderer.setSize(e,t),this.composer.setPixelRatio(this.renderer.getPixelRatio()),this.composer.setSize(e,t),this.dofPass.setSize(e*this.renderer.getPixelRatio(),t*this.renderer.getPixelRatio()),this.fxaaPass.setSize(e*this.renderer.getPixelRatio(),t*this.renderer.getPixelRatio()),this.fxaaPass.uniforms.resolution.value.set(1/(e*this.renderer.getPixelRatio()),1/(t*this.renderer.getPixelRatio())),this.createGRenderTarget(),this.phasedRenderPass.gRenderTarget=this.gRenderTarget,this.bloomPass.emissiveTexture=this.gRenderTarget.textures[1],this.ssrPass.setSize(this.gRenderTarget.width,this.gRenderTarget.height),this.ssrPass.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),this.aoPass.setSize(this.gRenderTarget.width,this.gRenderTarget.height),this.aoPass.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),this.sceneColorRenderTarget.dispose(),this.sceneColorRenderTarget=this.createSceneColorRenderTarget(this.renderer,this.container),this.copyPass.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass.material.uniformsNeedUpdate=!0)}addPostProcessVolume(e){if(0===this.postProcessVolumes.length)this.postProcessVolumes.push(e);else{let t=!1;for(let s=0;s<this.postProcessVolumes.length;s++)if(e.priority<this.postProcessVolumes[s].priority){this.postProcessVolumes.splice(s,0,e),t=!0;break}t||this.postProcessVolumes.push(e)}}removePostProcessVolume(e){const t=this.postProcessVolumes.indexOf(e);t>-1&&this.postProcessVolumes.splice(t,1)}addPostProcessEffect(e,t={}){const s={id:++this.postProcessEffectId,pass:new be(e),priority:Te(t.priority),stage:xe(t.stage)};return s.pass.enabled=t.enabled??!0,this.postProcessEffects.push(s),this.refreshPostProcessEffectPassOrder(),new ye(this,s)}removePostProcessEffectEntry(e){const t=e,s=this.postProcessEffects.indexOf(t);-1!==s&&(this.postProcessEffects.splice(s,1),this.composer.removePass(t.pass),t.pass.dispose())}refreshPostProcessEffectPassOrder(){for(const e of this.postProcessEffects)this.composer.removePass(e.pass);for(const e of we){const t=this.getPostProcessEffectStageAnchorPass(e),s=null!=t?this.composer.passes.indexOf(t):this.composer.passes.length,i=this.postProcessEffects.filter(t=>t.stage===e).sort(it);for(let e=0;e<i.length;e++)this.composer.insertPass(i[e].pass,s+e)}}getPostProcessEffectStageAnchorPass(e){switch(e){case"beforeFog":return this.volumetricFogPass;case"beforeDepthOfField":return this.dofPass;case"beforeColorAdjustment":return this.colorPass;case"beforeOutline":return this.outlinePass;case"beforeAntiAliasing":return this.fxaaPass;case"beforeLut":return this.lutPass;case"beforeOutput":return this.outputPass}}constructor(t,s={}){this.container=t,this.options=s,this.isIntersecting=!1,this.windowVisible=!0,this.running=!0,this.paused=!1,this._fpsCap=null,this.fpsCapRevision=0,this.postProcessVolumes=[],this.postProcessSettings={},this.baseToneMapping=i.NoToneMapping,this.baseToneMappingExposure=1,this.csmUpdateInvervals=this.options.shadows?.cascadeUpdateIntervals,this._id=Ke++,this.postProcessEffectId=0,this.postProcessEffects=[],this.postProcessEffectResolution=new i.Vector2(1,1),this.postProcessEffectUniformState={aoEnabled:!1,aoTexture:null,cameraFar:void 0,cameraNear:void 0,depthTexture:new u,normalTexture:new u,resolution:this.postProcessEffectResolution,simulationTime:0},this.fquadCopy=new Be(new p(f)),this.fquadCopyOpaque=new Be(new R({outputs:[k("tSceneColor",new u).sample(V.uv),W(k("tDepthTexture",new i.DepthTexture(1,1)).sample(V.uv).r)]})),this.simulationTime=0,this.simulationTimeScale=1,this.lightProbeIntensity=2,this.fquadBlendAO=(()=>{const e=W(1),t=new R({outputs:[k("tAO",new u).sample(le),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Be(t)})(),this.resolutionScale=1,this.maxPixelRatio=Ye?1:window.devicePixelRatio,this.onResize=()=>{if(this.resizeRender(),!this.paused)try{this.render()}catch(e){}},this.onVisiblityChane=()=>{this.windowVisible=!document.hidden},this.isDepthTextureExtensionSupported=!0,this.onLoopCallbacks=[],this.stats=new ee,this._showStats=!1,this.gbufferMaterialCache=new Map,this.gbufferDepthPrepassMaterialCache=new Map,this.tbufferMaterialCache=new Map,this.depthPrepassMaterialCache=new WeakMap,this.depthPrepassCachedMaterials=new Map,this.depthPrepassCachedVisibility=[],this.gBufferCachedMaterials=new Map,this.gBufferCachedVisibility=[],this._initiatedMaterialTextures=new Set,this._initiatedTextures=new Set,this.compileInProgress=!1,this.pmremGeneratorResults=new WeakMap,this.insetHeight=200,this.insetWidth=this.insetHeight*(16/9),this.insetOffsetY=250,this.insetMargin=10,this.maxInsetCameras=4,this.overlayCameras=new Set,this.prevClearColor=new a,this.hadBloom=!1,this.bloomStoredMaterials={},this.bloomHidden=[],this._customDepthMaterialCache=new WeakMap,null!=s.maxPixelRatio&&(this.maxPixelRatio=s.maxPixelRatio),this.resolutionScale=s.resolutionScale??1,this.fpsCap=s.fpsCap,e.activeView=this,Z.init(),window.renderer=this.renderer=window.renderer??new i.WebGLRenderer({antialias:!1,powerPreference:"high-performance"});new i.MeshStandardMaterial({color:"#ccc"});this.scene=new i.Scene,this.scene.matrixWorldAutoUpdate=!0,this.scene.updateMatrixWorld=function(e){const t=this.children;for(let s=0,i=t.length;s<i;s++){t[s].updateMatrixWorld(e)}}.bind(this.scene),this.renderer.setPixelRatio(Math.min(this.maxPixelRatio,window.devicePixelRatio)*this.resolutionScale),this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.xr.enabled=this.options.enableXR??!1,!0===this.options.enableXR&&document.body.appendChild(w.createButton(this.renderer));const n=new Oe(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=n,this.createGRenderTarget(),this.composer=new g(this.renderer,function(e,t){const s=new i.WebGLRenderTarget(Math.max(1,e),Math.max(1,t),{minFilter:i.LinearFilter,magFilter:i.LinearFilter,format:i.RGBAFormat,type:i.HalfFloatType});return s.texture.name="EffectComposer.rt1",s.texture.generateMipmaps=!1,s}(t.clientWidth,t.clientHeight)),this.composer.setPixelRatio(this.renderer.getPixelRatio()),this.composer.setSize(t.clientWidth,t.clientHeight);var r=(t.clientWidth||1)/(t.clientHeight||1);const o=new i.PerspectiveCamera(45,r,.5,800);o.layers.enable(19),this.setCamera(o),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=i.PCFSoftShadowMap,this.renderer.shadowMap.autoUpdate=s.shadows?.autoUpdate??!1,this.renderer.outputColorSpace=i.SRGBColorSpace,this.renderer.toneMapping=i.NoToneMapping,this.renderer.toneMappingExposure=1,this.baseToneMapping=this.renderer.toneMapping,this.baseToneMappingExposure=this.renderer.toneMappingExposure,this.renderer.gammaFactor=1.4,x.renderingView=this,this.isDepthTextureExtensionSupported=he(this.renderer),this.attachRendererDomElement(),this.setupEventListeners(),this.aoMaskDepthRenderTarget=e.createAOMaskDepthRenderTarget(this.renderer,this.container),this.sceneColorRenderTarget=this.createSceneColorRenderTarget(this.renderer,this.container);const l=new i.Vector2(t.clientWidth,t.clientHeight),h=(new b(this.scene,this.camera),new y(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const d=new Ee(l,1.5,.4,.85);d.threshold=1,d.strength=.9,d.radius=.5,this.bloomPass=d;const c=new te(this.scene,this.camera,this.gRenderTarget.width,this.gRenderTarget.height,{});c.normalRenderTarget?.dispose(),c.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),c.output=te.OUTPUT.Off,c.enabled=!1,this.aoPass=c,this.fquadBlendAO.material.uniforms.tAO.value=c.pdRenderTarget.texture,Ce.fragmentShader=Ce.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Se({renderer:this.renderer,scene:this.scene,camera:this.camera,width:this.gRenderTarget.width,height:this.gRenderTarget.height,groundReflector:null,selects:[],normalTexture:this.gRenderTarget.textures[2],depthTexture:this.gRenderTarget.depthTexture});m.output=Se.OUTPUT.Default,m.blur=!0,m.fresnel=!1,m.distanceAttenuation=!0,m.maxDistance=50,m.selective=!0,m.bouncing=!1,m.opacity=.4,m.enabled=!1!==this.options?.reflection?.enabled,this.ssrPass=m,!1!==this.options.ao?.enabled&&this.composer.addPass(c);const T=new wt((e,t,s,i,a)=>{this.aoPass.enabled&&(this.initResolutionUniform(this.fquadBlendAO.material),this.renderer.setRenderTarget(this.gRenderTarget),this.fquadBlendAO.render(this.renderer),this.renderer.setRenderTarget(null))});this.composer.addPass(T);const S=new wt((e,t,s,i,a)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(ke.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(S),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new yt(this.scene,this.camera,this.gRenderTarget),this.composer.addPass(this.phasedRenderPass),this.composer.addPass(d),d.emissiveTexture=this.gRenderTarget.textures[1],this.renderer.info.autoReset=!1,this.volumetricFogPass=new Re(l),this.composer.addPass(this.volumetricFogPass),this.volumetricFogPass.enabled=!0,this.dofPass=new K(this.scene,this.camera,{focus:1,aperture:.025,maxblur:.01}),this.dofPass.enabled=!1,this.composer.addPass(this.dofPass);const C=new Pe;this.composer.addPass(C),this.colorPass=C,C.vignetteEnabled=!1,this.outlinePass=new fe(new i.Vector2(t.clientWidth,t.clientHeight),this.scene,this.camera),this.outlinePass.edgeGlow=0,this.outlinePass.edgeThickness=1.5,this.outlinePass.edgeStrength=5,this.outlinePass.clear=!1,this.outlinePass.enabled=!1,this.composer.addPass(this.outlinePass);const O=new y(M);O.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(O),this.fxaaPass=O,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new y(v).clear=!1,this.fixStatsStyle(),this.lutPass=new P({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const E=new y(f,"prevtexture");E.enabled=!0,E.needsSwap=!1,E.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],E.renderToScreen=!0;const U=new Q;!function(e){const t=e.material;if(t.dithering=!0,t.fragmentShader.includes("<dithering_fragment>"))return;const s="#include <colorspace_pars_fragment>";if(!t.fragmentShader.includes(s))return;t.fragmentShader=t.fragmentShader.replace(s,`${s}\n #include <common>\n #include <dithering_pars_fragment>`);const i=t.fragmentShader.lastIndexOf("}");i<0||(t.fragmentShader=`${t.fragmentShader.slice(0,i)}\n #include <dithering_fragment>\n${t.fragmentShader.slice(i)}`,t.needsUpdate=!0)}(U),this.outputPass=U,this.composer.addPass(U)}fixStatsStyle(){const e=this.stats.dom;e.style.position="absolute";const t=e.getElementsByTagName("canvas");for(let e=0;e<t.length;e++)t.item(e).style.display="inline-block"}setEnableOutlines(e){this.outlinePass.enabled=e,this.fxaaPass.enabled=e}setCamera(e){if(this.camera=e,this.composer.passes.forEach(t=>{t instanceof b?t.camera=e:t instanceof fe?t.renderCamera=e:(t instanceof ce||t instanceof te)&&(t.camera=e)}),this.ssrPass&&(this.ssrPass.camera=e),this.aoPass&&(this.aoPass.camera=e),this.phasedRenderPass&&(this.phasedRenderPass.camera=e),null==this.csm){if(this.csm=new J({maxFar:80,lightFar:250,lightMargin:20,cascades:Ye?2:3,shadowMapSize:2048*(Ye?.5:1),lightDirection:new i.Vector3(.5,-1,-.6).normalize(),lightIntensity:.5*Math.PI,camera:this.camera,parent:this.scene,mode:"practical"}),null!=this.csmUpdateInvervals){this.csmCascadeLastUpdate=new Array(this.csm.lights.length).fill(0);for(const e of this.csm.lights)e.shadow.autoUpdate=!1}this.csm&&Array.isArray(this.csm.lights),this.csm.fade=!0,h.lights_fragment_begin=T.lights_fragment_begin}else this.csm.camera=this.camera,this.camera;this.csm.updateFrustums()}setSelectedObjects(e){if(null==this.outlinePass)return;const t=new Map;for(const s of e)t.set(s.uuid,s);for(const s of e)s.traverse(e=>{e.uuid!==s.uuid&&t.has(e.uuid)&&t.delete(e.uuid)});this.outlinePass.selectedObjects=Array.from(t.values())}static createDepthRenderTarget(e,t,s){const a=Math.max(1,Math.floor(t.clientWidth*s)),n=Math.max(1,Math.floor(t.clientHeight*s)),r=new i.WebGLRenderTarget(a,n);return r.texture.minFilter=i.NearestFilter,r.texture.magFilter=i.NearestFilter,r.texture.generateMipmaps=!1,r.stencilBuffer=!1,r.depthTexture=new i.DepthTexture(a,n),r.depthTexture.type=i.UnsignedShortType,r.depthTexture.minFilter=i.NearestFilter,r.depthTexture.magFilter=i.NearestFilter,r}static createAOMaskDepthRenderTarget(e,t){const s=Math.max(1,t.clientWidth*e.getPixelRatio()),a=Math.max(1,t.clientHeight*e.getPixelRatio()),n=new i.DepthTexture(s,a);n.type=i.UnsignedInt248Type,n.minFilter=i.NearestFilter,n.magFilter=i.NearestFilter;const r=new i.WebGLRenderTarget(s,a,{type:i.HalfFloatType,depthTexture:n});return r.texture.minFilter=i.NearestFilter,r.texture.magFilter=i.NearestFilter,r.texture.generateMipmaps=!1,r.stencilBuffer=!1,r}createSceneColorRenderTarget(e,t){const s=this.gRenderTarget.width,a=this.gRenderTarget.height,n=new i.WebGLRenderTarget(s,a,{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return n.texture.minFilter=i.LinearFilter,n.texture.magFilter=i.LinearFilter,n.texture.generateMipmaps=!1,n.textures[1].minFilter=i.NearestFilter,n.textures[1].magFilter=i.NearestFilter,n}createGRenderTarget(){const e=this.container;null!=this.gRenderTarget&&this.gRenderTarget.dispose();const t=Math.max(1,e.clientWidth*this.renderer.getPixelRatio()),s=Math.max(1,e.clientHeight*this.renderer.getPixelRatio()),a=new i.DepthTexture(t,s);a.type=i.UnsignedIntType,a.minFilter=i.NearestFilter,a.magFilter=i.NearestFilter,this.gRenderTarget=new d(t,s,{count:3,samples:this.options?.msaa??(Ye?void 0:2),minFilter:i.NearestFilter,magFilter:i.NearestFilter,type:i.HalfFloatType,format:i.RGBAFormat,depthTexture:a}),this.gRenderTarget.texture.generateMipmaps=!1,this.gRenderTarget.stencilBuffer=!1}setupEventListeners(){window.addEventListener("resize",this.onResize),window.addEventListener("orientationchange",this.onResize),document.addEventListener("visibilitychange",this.onVisiblityChane)}stop(e=!0){this.running=!1,this.lightVolume?.shTexture.dispose(),window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),document.removeEventListener("visibilitychange",this.onVisiblityChane),this.onLoopCallbacks=[],e&&this.renderer.dispose(),this.gRenderTarget.dispose(),this.aoMaskDepthRenderTarget.dispose(),this.sceneColorRenderTarget.dispose(),this.csm.dispose();for(const e of this.postProcessEffects)this.composer.removePass(e.pass),e.pass.dispose();this.postProcessEffects.length=0,this.detachOwnedDomElements();Ze().unobserve(this.container),Je.delete(this.container),this.volumetricFogPass.dispose(),x.clearSceneCache(this.scene)}onLoop(e){this.onLoopCallbacks.push(e)}removeOnLoop(e){const t=this.onLoopCallbacks.findIndex(t=>t===e);t>=0&&this.onLoopCallbacks.splice(t,1)}set showStats(e){this._showStats=e,this._showStats&&this.stats.dom.parentElement!==this.container?this.container.appendChild(this.stats.dom):this._showStats||this.stats.dom.parentElement!==this.container||this.container.removeChild(this.stats.dom)}get showStats(){return this._showStats}attachRendererDomElement(){const e=this.renderer.domElement;e.parentElement===this.container&&e===this.container.firstChild||this.container.insertBefore(e,this.container.firstChild),this._showStats&&this.stats.dom.parentElement!==this.container&&this.container.appendChild(this.stats.dom)}detachOwnedDomElements(){this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement),this.stats.dom.parentElement===this.container&&this.container.removeChild(this.stats.dom)}applyEnvMap(e){if(null!=this.scene.environment&&(e instanceof R&&(null==e.envMap||e.userData.useSceneEnv)&&(e.userData.useSceneEnv=!0,null==e.uniforms.envMap&&(e.uniforms.envMap={value:this.scene.environment},e.uniformsNeedUpdate=!0,e.uniforms.envMapRotation={value:gt(this.scene.environmentRotation,this.scene.environment,new i.Matrix3)}),null==e.uniforms.envMapIntensity&&(e.uniforms.envMapIntensity={value:1},e.uniformsNeedUpdate=!0),e.uniforms.envMap.value=this.scene.environment,e.uniforms.envMapIntensity.value=this.scene.environmentIntensity,e.envMap=this.scene.environment),e instanceof R||e instanceof i.MeshStandardMaterial)){const t=this.gbufferMaterialCache.get(e);null==t||this.gbufferMaterialCache.has(t)||this.applyEnvMap(t)}}setupCsm(e){if(e instanceof i.Mesh||e instanceof i.SkinnedMesh)if(e.material instanceof Array)for(const t of e.material)this.csm.setupMaterial(t);else this.csm.setupMaterial(e.material)}updateMaterialProperties(e,t){(e instanceof i.MeshBasicMaterial||e instanceof m||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)&&(null!=t.uniforms.color&&t.uniforms.color.value.setFromColor(e.color),null!=t.uniforms.opacity&&(t.uniforms.opacity.value=e.opacity),null!=t.uniforms.map&&(t.uniforms.map.value=e.map),null!=t.uniforms.alphaMap&&(t.uniforms.alphaMap.value=e.alphaMap),null!=t.uniforms.lightMap&&(t.uniforms.lightMap.value=e.lightMap,t.uniforms.lightMapIntensity.value=e.lightMapIntensity),null!=t.uniforms.aoMap&&(t.uniforms.aoMap.value=e.aoMap,t.uniforms.aoMapIntensity.value=e.aoMapIntensity),null!=t.uniforms.alphaTest&&(t.uniforms.alphaTest.value=e.alphaTest)),(e instanceof m||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)&&(t.uniforms.normalMap&&(t.uniforms.normalMap.value=e.normalMap,t.uniforms.normalScale.value=e.normalScale.x),t.uniforms.emissiveMap&&(t.uniforms.emissiveMap.value=e.emissiveMap,t.uniforms.emissive.value.setFromColor(e.emissive),t.uniforms.emissiveIntensity.value=e.emissiveIntensity)),e instanceof m&&(null!=t.uniforms.roughnessMap&&(t.uniforms.roughnessMap.value=e.roughnessMap),null!=t.uniforms.metalnessMap&&(t.uniforms.metalnessMap.value=e.metalnessMap),null!=t.uniforms.roughness&&(t.uniforms.roughness.value=e.roughness),null!=t.uniforms.metalness&&(t.uniforms.metalness.value=e.metalness)),e instanceof i.MeshPhysicalMaterial&&(t.uniforms.sheenColor&&t.uniforms.sheenColor.value.setFromColor(e.sheenColor).multiplyScalar(e.sheen),t.uniforms.sheenColorMap&&(t.uniforms.sheenColorMap.value=e.sheenColorMap),t.uniforms.sheenRoughness&&(t.uniforms.sheenRoughness.value=e.sheenRoughness),t.uniforms.sheenRoughnessMap&&(t.uniforms.sheenRoughnessMap.value=e.sheenRoughnessMap)),e instanceof Ge&&(t.uniforms.heightMap.value=e.heightMap,t.uniforms.heightScale.value=e.heightScale),this.updateMaterialCommonProperties(e,t)}updateUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s){const t=i[e],a=s[e].value;null!=t&&t.value!==a&&"receiveShadow"!==e&&!1===Tt.includes(e)&&(t.value=a)}this.updateMaterialCommonProperties(e,t)}inheritCustomUniformBindings(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s)null==i[e]&&("receiveShadow"===e||Tt.includes(e)||xt.includes(e)||(i[e]={value:s[e].value}))}updateMaterialCommonProperties(e,t){t.alphaTest=e.alphaTest,t.side=e.side,t.depthTest=e.depthTest,t.blending=e.blending,t.colorWrite=e.colorWrite,t.premultipliedAlpha=e.premultipliedAlpha,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t.visible=e.visible}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of Tt){const t=i[e],a=s[e];null!=a&&null!=t&&(t.value=a.value)}}createGBufferMaterial(e,t,s=!1){const a=t===ke.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let n=a.get(e);if(!0===e.userData.isGBufferMaterial)return e;if(null==n){let s=V.uv;if(e instanceof Ge&&null!=e.heightMap){const t=E("heightScale",e.heightScale??1);s=De(s,k("heightMap",e.heightMap),t)}let o=_.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??$e,i=E("useNormalMap",null!=e.normalMap?1:0),a=E("normalScale",e.normalScale?.x??1),n=S(k("normalMap",t).sample(We(s,e.normalMap)),a);o=z(_.normal,n,i)}else e instanceof R&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=q("DOUBLE_SIDED",o,e=>N(new j("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?C(0):C(1);if(e instanceof i.MeshStandardMaterial){const t=E("roughness",e.roughness??1),i=e.roughnessMap??He,a=E("useRoughnessMap",null!=e.roughnessMap?1:0),n=k("roughnessMap",i).sample(We(s,e.roughnessMap)).g.multiply(t);l=z(t,n,a)}else e instanceof R&&null!=e.outputRoughness&&(l=e.outputRoughness);let h=null;if((e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial)&&null!=e.lightMap){const t=e.lightMap,i=E("useLightMap",null!=e.lightMap?1:0),a=E("lightMapIntensity",e.lightMapIntensity??1),n=k("lightMap",t).sample(s).rgb.multiplyScalar(a);h=z(D(0),n,i)}let d=C(0);if(e instanceof i.MeshStandardMaterial){const t=E("metalness",e.metalness??0),i=e.metalnessMap??ze,a=E("useMetalnessMap",null!=e.metalnessMap?1:0),n=k("metalnessMap",i).sample(We(s,e.metalnessMap)).b.multiply(t);d=z(t,n,a)}else e instanceof R&&e.outputRoughness;let u=null,c=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){const t=e.aoMap??He,i=E("useAoMap",null!=e.aoMap?1:0);c=E("aoMapIntensity",e.aoMapIntensity??1);const a=k("aoMap",t).sample(We(s,e.aoMap)).r;u=z(C(1),a,i)}else e instanceof R&&e.outputRoughness;const f=E("opacity",e.opacity??1);let g=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){if(null!=e.alphaMap){const t=e.alphaMap;g=k("alphaMap",t).sample(We(s,e.alphaMap)).r}g=g.multiply(f)}else e instanceof R&&null!=e.outputOpacity&&(g=e.outputOpacity);let M=B(0,1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){let t=U("color",(new i.Vector3).setFromColor(e.color));const a=e.map??He,n=E("useAlbedoMap",null!=e.map?1:0),r=k("map",a).sample(We(s,e.map)),o=r.multiply(B(t,1)),l=B(t,1);M=z(l,o,n),e.vertexColors&&(M=M.multiply(W(L($.color.rgb),1)));const h=z(C(1),r.w,n);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let P=D(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=U("emissive",(new i.Vector3).setFromColor(e.emissive)),a=E("emissiveIntensity",e.emissiveIntensity),n=e.emissiveMap??ze,r=E("useEmissiveMap",null!=e.emissiveMap?1:0),o=k("emissiveMap",n).sample(We(s,e.emissiveMap)).rgb.multiply(t);P=z(t,o,r),P=P.multiplyScalar(a)}else e instanceof R&&null!=e.outputEmissive&&(P=e.outputEmissive);let b=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(b=U("sheenColor",(new i.Vector3).setFromColor(e.sheenColor).multiplyScalar(e.sheen)),e.sheen>0&&null!=e.sheenColorMap)){const t=k("sheenColorMap",e.sheenColorMap).sample(s).rgb;b=b.multiply(t)}let y=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(y=E("sheenRoughness",e.sheenRoughness),e.sheen>0&&null!=e.sheenRoughnessMap)){const t=k("sheenRoughnessMap",e.sheenRoughnessMap).sample(s).r;y=y.multiply(t)}let w=null;if(e instanceof i.MeshPhysicalMaterial&&e.anisotropy>0&&(w=E("anisotropy",e.anisotropy),e.anisotropy>0&&null!=e.anisotropyMap)){const t=k("anisotropyMap",e.anisotropyMap).sample(s).r;w=w.multiply(t)}let T=null;if(e instanceof i.MeshPhysicalMaterial&&e.anisotropy>0){const t=e.anisotropyRotation??0;T=X("anisotropyDirection",new i.Vector2(Math.cos(t),Math.sin(t)))}const x=e instanceof p&&null!=e.uniforms[ie],I=e instanceof p&&null!=e.uniforms[ue],H=e instanceof p&&null!=e.uniforms[de],Y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,K=E("alphaTest",e.alphaTest);let Q,J=e.alphaTest>0?g.lt(K):Y&&t===ke.opaque?g.lt(.8):null;!0===e.userData.isDecal&&(J=J?J.or(Le):Le),Q=Y?W(0,0,0,0):(r=o,G(r).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const Z=e instanceof R?e.outputPosition:void 0,ee=e instanceof R?e.outputTransform:void 0;let te,se=B("black",1);if(e instanceof R&&null!=e.outputColor)se=e.outputColor;else if(e instanceof i.MeshStandardMaterial)se=O({color:M,metalness:d,roughness:l,emissive:P.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:c,bakedLight:h,sheenColor:b,sheenRoughness:y,anisotropy:w,anisotropyDirection:T});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)se=F({color:M.rgb,ambientOcclusion:u,ambientOcclusionIntensity:c});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??D("black");null!=u&&(t=t.multiplyScalar(u.subtract(1).multiply(c).add(1))),e=e.add(t),se=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(se=A({color:M,emissive:P.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:c,bakedLight:h}));(e instanceof R||e instanceof i.MeshStandardMaterial)&&(te=e.envMap);let ae=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(ae=e.fog);let ne=B(se.rgb,g);ae&&(ne=new FogNode(ne));let re=!0;if(t===ke.opaque?(re&&(re=!x&&!I&&!H),re&&(re=!Y)):t===ke.transparent&&re&&(re=Y||x||I||H),!re)return n=Xe,a.set(e,n),n;n=new R({transform:ee,position:null==ee?Z:void 0,outputs:[ne,P.rgba(t===ke.opaque?K:v?1:0),Q],opacity:g,outputEncoding:!1,fog:ae,transparent:e.transparent,lights:!0,envMap:te,alphaTest:e.alphaTest,discard:J}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=n.uniforms.envMapIntensity&&(n.uniforms.envMapIntensity.value=e.envMapIntensity),"alphaMap"in e&&null!=e.alphaMap&&(n.alphaMap=e.alphaMap),(e instanceof R||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(n),e instanceof R&&(Object.assign(n.defines,e.defines),null!=n.uniforms[de]&&(n.uniforms[de].value=this.aoPass.pdRenderTarget.texture,n.defines.USE_SSAO_MAP="")),n.userData.mrtOutputs=3,n.forceSinglePass=e.forceSinglePass,n.side=e.side,n.blending=e.blending,Y?(n.depthWrite=!e.transparent,n.depthTest=e.depthTest,n.colorWrite=t===ke.transparent):(n.depthWrite=e.depthWrite,n.depthTest=e.depthTest),n.visible=e.visible,n.alphaTest=e.alphaTest,n.alphaHash=e.alphaHash,n.vertexColors=e.vertexColors,n.premultipliedAlpha=e.premultipliedAlpha,n.toneMapped=e.toneMapped,n.blendAlpha=e.blendAlpha,n.blendColor=e.blendColor,n.polygonOffset=e.polygonOffset,n.polygonOffsetFactor=e.polygonOffsetFactor,n.polygonOffsetUnits=e.polygonOffsetUnits,n.blending=e.blending,n.wireframe=e.wireframe??!1,n.userData.isGBufferMaterial=!0,n.visible=re,Object.assign(n.userData,e.userData),n.visible&&(this.csm.setupMaterial(n),e instanceof p&&this.inheritCustomUniformBindings(e,n)),a.set(e,n)}var r;return n.visible&&(e instanceof p?this.updateUniformValues(e,n):this.updateMaterialProperties(e,n)),this.initLightVolumeUniform(n),n}isDepthPrepassEnabled(){return!0===this.options.depthPrepass?.enabled}usesSceneFeedbackUniforms(e){return e instanceof p&&(null!=e.uniforms[ie]||null!=e.uniforms[ue]||null!=e.uniforms[de])}isDepthPrepassEligibleMaterial(e){return null!=e&&(!1!==e.visible&&!1!==e.depthTest&&!1!==e.depthWrite&&(!e.transparent&&e.blending!==i.AdditiveBlending&&(!this.usesSceneFeedbackUniforms(e)&&(e instanceof R||e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshBasicMaterial))))}isDepthPrepassEligibleMesh(e){return!!this.isDepthPrepassEnabled()&&((e instanceof i.InstancedMesh||e instanceof _e)&&(!Array.isArray(e.material)&&this.isDepthPrepassEligibleMaterial(e.material)))}createDepthPrepassMaterial(e){if(!this.isDepthPrepassEligibleMaterial(e))return null;let t=this.depthPrepassMaterialCache.get(e);if(null==t){let s,a=C(1);e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial?(a=E("opacity",e.opacity??1),null!=e.map&&(a=a.multiply(k("map",e.map).sample(V.uv).a)),null!=e.alphaMap&&(a=a.multiply(k("alphaMap",e.alphaMap).sample(V.uv).r))):e instanceof R&&(a=e.outputOpacity??C(1)),null!=e.alphaTest&&e.alphaTest>0&&(s=a.lt(e.alphaTest));const n=e instanceof R?e.outputPosition:void 0,r=e instanceof R?e.outputTransform:void 0;t=new R({outputs:[B(0,0),B(0,0),B(0,0)],opacity:a,transform:r,position:null==r?n:void 0,discard:s,lights:!1,fog:!1,outputEncoding:!1,transparent:!1,alphaTest:e.alphaTest}),t.depthWrite=!0,t.depthTest=e.depthTest,t.colorWrite=!1,t.transparent=!1,t.blending=i.NoBlending,t.lights=!1,t.fog=!1,t.toneMapped=!1,t.side=e.side,t.alphaTest=e.alphaTest,t.visible=e.visible,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t.onBeforeCompile=()=>{},t.customProgramCacheKey=()=>`depth-prepass:${e.id}:${e.version}:${e.alphaTest}:${e.side}`;for(const e of Tt)delete t.uniforms[e];for(const e of xt)delete t.uniforms[e];delete t.uniforms.receiveShadow,this.depthPrepassMaterialCache.set(e,t)}return e instanceof R?this.updateUniformValues(e,t):this.updateMaterialProperties(e,t),t.depthWrite=!0,t.depthTest=e.depthTest,t.colorWrite=!1,t.transparent=!1,t.blending=i.NoBlending,t.visible=e.visible,t.alphaTest=e.alphaTest,t.side=e.side,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t}applyDepthPrepassMaterials(){const e=this.depthPrepassCachedMaterials,t=this.depthPrepassCachedVisibility;e.clear(),t.length=0,Me(this.scene,s=>{if(Pt(s))return t.push(s),s.visible=!1,!1;if(!(s instanceof o))return;if(e.set(s,s.material),!this.isDepthPrepassEligibleMesh(s))return t.push(s),void(s.visible=!1);const i=this.createDepthPrepassMaterial(s.material);if(null==i)return t.push(s),void(s.visible=!1);s.material=i,s.visible=!0})}unapplyDepthPrepassMaterials(){this.depthPrepassCachedMaterials.forEach((e,t)=>{t.material=e}),this.depthPrepassCachedVisibility.forEach(e=>{e.visible=!0})}renderDepthPrepass(){if(!this.isDepthPrepassEnabled())return;this.applyDepthPrepassMaterials();const e=this.scene.matrixWorldAutoUpdate,t=this.scene.matrixAutoUpdate,s=this.renderer.shadowMap.autoUpdate;this.renderer.shadowMap.autoUpdate=!1,this.scene.matrixWorldAutoUpdate=!1,this.scene.matrixAutoUpdate=!1,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clearDepth();try{this.renderer.render(this.scene,this.camera)}catch(e){console.warn("Depth prepass render failed",e)}this.unapplyDepthPrepassMaterials(),this.renderer.shadowMap.autoUpdate=s,this.scene.matrixWorldAutoUpdate=e,this.scene.matrixAutoUpdate=t}updateCsm(){const e=this.csmUpdateInvervals;if(this.renderer.shadowMap.autoUpdate&&null!=this.csmCascadeLastUpdate&&Array.isArray(e)){const t=performance.now();for(let s=0;s<this.csm.lights.length;++s){const i=e[s]??e[e.length-1]??16;(t-this.csmCascadeLastUpdate[s]>=i||0===s)&&this.csm.lights[s].shadow&&(this.csm.lights[s].shadow.needsUpdate=!0,this.csmCascadeLastUpdate[s]=t)}}this.csm.update()}loop(t,s=!1){const a=this.stats,n=a.addPanel(new ee.Panel("Calls","#83f","#002")),l=a.addPanel(new ee.Panel("Triangles","#c32","#002"));let h;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(h=new me(this.renderer.getContext()),a.addPanel(h)),this.showStats=s;let p=10,d=1e3;const u=()=>{const e=this.renderer.info.render.calls;e>p&&(p=e,setTimeout(()=>p=10,5e3)),n.update(e,p);const t=this.renderer.info.render.triangles;t>d&&(d=t,setTimeout(()=>d=1e3,5e3)),l.update(t,d)};performance.now();i.Ray.prototype.intersectTriangle;this.resizeRender();const c=[],m=[],f=[];let g=0;const M=new r,v=new r;let P=0;let b=this.paused,y=!1,w=0,T=null,x=this.fpsCapRevision;const S=()=>{this.running&&!0!==this.options.enableXR&&requestAnimationFrame(E)},C=()=>{e.activeView=this,y&&(y=!1,requestAnimationFrame(()=>E(w)))},O=Ze();Je.set(this.container,e=>{this.isIntersecting=e,e&&C()}),O.observe(this.container),this.container.addEventListener("pointerdown",()=>{C()},{capture:!0});const E=s=>{y=!1;const n=this.renderer.getContext();if(!this.running||null===this.container.offsetParent||this.paused&&n.drawingBufferHeight>1)return y=!0,w=s,setTimeout(()=>{y&&E(s)},500),void(this.paused&&(b=!0));if(this.renderer.domElement.parentElement!==this.container){if(e.activeView!==this&&null!==e.activeView)return y=!0,void(w=s);this.attachRendererDomElement(),this.resizeRender()}if(!0!==this.options.enableXR){x!==this.fpsCapRevision&&(x=this.fpsCapRevision,T=null);const e=this.fpsCap;if(null!=e){const t=1e3/e;if(null!=T){const e=s-T;if(e<t)return void S();T=s-e%t}else T=s}else T=s}this.applyPostProcessSettings(),this.renderer.autoClear=!1,this.renderer.setViewport(0,0,this.container.clientWidth,this.container.clientHeight),a.begin(),this.showStats&&h?.startQuery(),this.ssrPass.gpuPanel=h;let r=(s*=.001)-g;if(g=s,b&&(r=.016,b=!1),M.copy(this.camera.matrixWorld),r>1){let e=r;for(;e>.05;)t(tt),e-=tt;t(e)}else t(r);this.onLoopCallbacks.forEach(e=>e(r)),this.paused||(this.simulationTime+=r*this.simulationTimeScale);const l=this.simulationTime;this.camera?.updateMatrixWorld(),v.copy(this.camera.matrixWorld),s-P>.08&&!v.equals(M)&&(this.renderer.shadowMap.needsUpdate=!0,P=s),this.updateCsm();let p=!1;c.length=0,m.length=0,f.length=0;const d=at;rt.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),d.setFromProjectionMatrix(rt);let C=!1,O=!1,U=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Fe&&(C=!0),e instanceof o&&this.initCustomDepthMaterial(e),(e instanceof o||e instanceof i.Sprite)&&(this.initResolutionUniform(e.material),this.initNormalUniform(e.material),this.initShadowUniform(e,e.material),this.initLightVolumeUniform(e.material),null!=this.scene.environment&&function(e,t){if(Array.isArray(e.material))for(const s of e.material)t(s);else null!=e.material&&t(e.material)}(e,e=>this.applyEnvMap(e)),!0===e.material?.userData?.hasBloom&&(p=!0)),(e instanceof o||e instanceof i.Sprite)&&e.visible&&(e.material?.userData?.water||e.material?.uniforms&&null!=e.material?.uniforms[ie])&&isObjectInFrustum(e,d)?(this.initDepthUniform(e.material),O=!0):e instanceof Y&&(e.visible=!1,m.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[de]&&isObjectInFrustum(e,d)&&e.material instanceof R&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ue]&&isObjectInFrustum(e,d)&&(f.push(e),e.material.uniforms[ue].value=this.sceneColorRenderTarget.texture,U=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[pe])e.material.uniforms[pe].value=l;else if(e instanceof o&&Array.isArray(e.material))for(const t of e.material)t.uniforms&&null!=t.uniforms[pe]&&(t.uniforms[pe].value=l)}),this.bloomPass.enabled=p,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderDepthPrepass(),this.renderScene(ke.opaque),this.aoPass.output=te.OUTPUT.Off,(O||U)&&(this.fquadCopyOpaque.material.uniforms.tSceneColor.value=this.gRenderTarget.textures[0],this.fquadCopyOpaque.material.uniforms.tDepthTexture.value=this.gRenderTarget.depthTexture,this.initResolutionUniform(this.fquadCopyOpaque.material),this.renderer.setRenderTarget(this.sceneColorRenderTarget),this.renderer.clear(),this.fquadCopyOpaque.render(this.renderer),this.renderer.setRenderTarget(this.gRenderTarget)),f.length,c.forEach(e=>e.visible=!0),m.forEach(e=>e.visible=!0),f.forEach(e=>e.visible=!0),this.aoPass.enabled,this.ssrPass&&(this.ssrPass.elapsedTime=s),this.volumetricFogPass&&C?(this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene),this.volumetricFogPass.enabled=!0):this.volumetricFogPass&&(this.volumetricFogPass.enabled=!1),this.updatePostProcessEffectUniforms(l);try{!this.paused&&this.running&&(this.render(r),this.showStats&&h?.endQuery(),this.showStats&&u(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}a.end(),this.csm?.update(),S()};!0===this.options.enableXR?this.renderer.setAnimationLoop(E):requestAnimationFrame(E)}applyGBufferMaterials(e){const t=this.gBufferCachedMaterials,s=this.gBufferCachedVisibility;t.clear(),s.length=0;Me(this.scene,i=>{if(Pt(i))return s.push(i),i.visible=!1,!1;if(i instanceof o){t.set(i,i.material);let a=!1;if(Array.isArray(i.material)){i.material=i.material.slice();for(let t=0;t<i.material.length;t++)i.material[t]=this.createGBufferMaterial(i.material[t],e,e===ke.opaque&&this.isDepthPrepassEligibleMesh(i)),a||(a=i.material[t].visible),this.initShadowUniform(i,i.material[t])}else i.material=this.createGBufferMaterial(i.material,e,e===ke.opaque&&this.isDepthPrepassEligibleMesh(i)),a||(a=i.material.visible),this.initShadowUniform(i,i.material);a?i.visible=!0:null!=i.children&&0!=i.children.length||(s.push(i),i.visible=!1)}})}unapplyGBufferMaterials(){this.gBufferCachedMaterials.forEach((e,t)=>{t.material=e}),this.gBufferCachedVisibility.forEach((e,t)=>{e.visible=!0,e.updateMatrixWorld(!0)})}initTextures(e=this.scene){e.traverse(e=>{if(e instanceof o)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)this._initMaterialTextures(e.material[t]);else this._initMaterialTextures(e.material)})}_initMaterialTextures(e){if(!this._initiatedMaterialTextures.has(e))if(this._initiatedMaterialTextures.add(e),e instanceof p){for(const[t,s]of Object.entries(e.uniforms))if(s.value instanceof u){if(this._initiatedTextures.has(s.value))continue;this.renderer.initTexture(s.value),this._initiatedTextures.add(s.value)}}else for(const[t,s]of Object.entries(e))if(s instanceof u){if(this._initiatedTextures.has(s))continue;this.renderer.initTexture(s),this._initiatedTextures.add(s)}}async compileAsync(e=this.scene){if(this.compileInProgress)return;this.renderer.setRenderTarget(this.gRenderTarget),this.compileInProgress=!0,this.applyGBufferMaterials(ke.opaque),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(ke.transparent),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.isDepthPrepassEnabled()&&(this.renderer.setRenderTarget(this.gRenderTarget),this.applyDepthPrepassMaterials(),await this.renderer.compileAsync(e,this.camera),this.unapplyDepthPrepassMaterials()),e===this.scene&&(this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.compileAsync(this.fquadBlendAO.mesh,this.fquadBlendAO.camera),this.renderer.setRenderTarget(this.sceneColorRenderTarget),this.renderer.compileAsync(this.fquadCopyOpaque.mesh,this.fquadCopyOpaque.camera));const t=this.csm.lights[0]?.shadow.camera;null!=t&&(this.applyDepthMaterial(),await this.renderer.compileAsync(e,t),this.unapplyDepthMaterial()),this.compileInProgress=!1,this.renderer.setRenderTarget(null)}applyDepthMaterial(){const e=this.gBufferCachedMaterials;e.clear(),this.scene.traverse(t=>{(t.isMesh||t.isPoints||t.isLine||t.isSprite)&&(this.initCustomDepthMaterial(t),e.set(t,t.material),t.castShadow?null!=t.customDepthMaterial?t.material=t.customDepthMaterial:t.material=Ct:t.material=null)})}unapplyDepthMaterial(){this.gBufferCachedMaterials.forEach((e,t)=>{t.material=e})}renderScene(e){if(!this.running||this.paused)return;if(this.compileInProgress)return void console.error("Compile in progress, skipping render");this.applyGBufferMaterials(e);const t=this.scene.matrixWorldAutoUpdate,s=this.scene.matrixAutoUpdate,i=this.renderer.shadowMap.autoUpdate;e!==ke.opaque&&(this.renderer.shadowMap.autoUpdate=!1,this.scene.matrixWorldAutoUpdate=!1,this.scene.matrixAutoUpdate=!1);try{this.renderer.render(this.scene,this.camera)}catch(e){console.warn("Render failed",e)}e===ke.opaque&&this.gBufferCachedMaterials.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof p&&this.updateLightUniformValues(t.material,e)}),this.unapplyGBufferMaterials(),this.renderer.shadowMap.autoUpdate=i,this.scene.matrixWorldAutoUpdate=t,this.scene.matrixAutoUpdate=s}getEnvTexture(e){null==this.pmremGenerator&&(this.pmremGenerator=new i.PMREMGenerator(this.renderer),this.pmremGenerator.compileEquirectangularShader());let t=this.pmremGeneratorResults.get(e);return null==t&&(t=this.pmremGenerator.fromEquirectangular(e).texture,this.pmremGeneratorResults.set(e,t)),t.colorSpace=i.SRGBColorSpace,t}applyPostProcessSettings(){if(0==this.postProcessVolumes.length)return this.lutPass.enabled=!1,this.colorPass.enabled=!1,this.dofPass.enabled=!1,this.renderer.toneMapping=this.baseToneMapping,void(this.renderer.toneMappingExposure=this.baseToneMappingExposure);!function(e,t=i.NoToneMapping,s=1){e.tonemapMapping=t,e.tonemapExposure=s,e.envIntensity=1,e.envTexture=void 0,e.vignetteIntensity=0,e.colorTint=e.colorTint??new i.Color("white"),e.colorTint.set("white"),e.colorTintIntensity=0,e.depthFocus=void 0,e.depthAperture=void 0,e.depthMaxBlur=void 0,e.temperature=6500,e.temperatureTint=0,e.globalSaturation=ot(e.globalSaturation,1,1,1),e.globalContrast=ot(e.globalContrast,1,1,1),e.globalGamma=ot(e.globalGamma,1,1,1),e.globalGain=ot(e.globalGain,1,1,1),e.globalOffset=ot(e.globalOffset,0,0,0),e.shadowsSaturation=ot(e.shadowsSaturation,1,1,1),e.shadowsContrast=ot(e.shadowsContrast,1,1,1),e.shadowsGamma=ot(e.shadowsGamma,1,1,1),e.shadowsGain=ot(e.shadowsGain,1,1,1),e.shadowsOffset=ot(e.shadowsOffset,0,0,0),e.shadowsMax=.09,e.midtonesSaturation=ot(e.midtonesSaturation,1,1,1),e.midtonesContrast=ot(e.midtonesContrast,1,1,1),e.midtonesGamma=ot(e.midtonesGamma,1,1,1),e.midtonesGain=ot(e.midtonesGain,1,1,1),e.midtonesOffset=ot(e.midtonesOffset,0,0,0),e.highlightsSaturation=ot(e.highlightsSaturation,1,1,1),e.highlightsContrast=ot(e.highlightsContrast,1,1,1),e.highlightsGamma=ot(e.highlightsGamma,1,1,1),e.highlightsGain=ot(e.highlightsGain,1,1,1),e.highlightsOffset=ot(e.highlightsOffset,0,0,0),e.highlightsMin=.5,e.lut=void 0,e.lutIntensity=0}(this.postProcessSettings,this.baseToneMapping,this.baseToneMappingExposure);const e=this.postProcessSettings;let t,s=!1;if(null==this.camera)return;const a=this.camera.getWorldPosition(dt);let n=[];for(const r of this.postProcessVolumes){if(!st(r.object))continue;let o=r.blendWeight??1;const l=r.distanceToPoint(a);l>r.blendRadius||(r.blendRadius>0&&(o*=ve(1-l/r.blendRadius,0,1)),o>1&&(o=1),o>0&&(n.push(r),void 0!==r.settings.tonemapMapping&&(e.tonemapMapping=r.settings.tonemapMapping),void 0!==r.settings.tonemapExposure&&(e.tonemapExposure=i.MathUtils.lerp(e.tonemapExposure,r.settings.tonemapExposure,o)),void 0!==r.settings.envTexture&&(e.envTexture=r.settings.envTexture),void 0!==r.settings.envIntensity&&(e.envIntensity=i.MathUtils.lerp(e.envIntensity,r.settings.envIntensity,o)),void 0!==r.settings.vignetteIntensity&&(e.vignetteIntensity=i.MathUtils.lerp(e.vignetteIntensity,r.settings.vignetteIntensity,o)),void 0!==r.settings.colorTint&&void 0!==r.settings.colorTintIntensity&&r.settings.colorTintIntensity>0&&(e.colorTint=e.colorTint.lerp(r.settings.colorTint,o)),void 0!==r.settings.colorTintIntensity&&(e.colorTintIntensity=i.MathUtils.lerp(e.colorTintIntensity,r.settings.colorTintIntensity,o)),void 0!==r.settings.depthFocus&&(s=!0,e.depthFocus=void 0!==e.depthFocus?i.MathUtils.lerp(e.depthFocus,r.settings.depthFocus,o):r.settings.depthFocus),void 0!==r.settings.depthAperture&&(s=!0,e.depthAperture=void 0!==e.depthAperture?i.MathUtils.lerp(e.depthAperture,r.settings.depthAperture,o):r.settings.depthAperture),void 0!==r.settings.depthMaxBlur&&(s=!0,e.depthMaxBlur=void 0!==e.depthMaxBlur?i.MathUtils.lerp(e.depthMaxBlur,r.settings.depthMaxBlur,o):r.settings.depthMaxBlur),void 0!==r.settings.temperature&&(e.temperature=i.MathUtils.lerp(e.temperature,r.settings.temperature,o)),void 0!==r.settings.temperatureTint&&(e.temperatureTint=i.MathUtils.lerp(e.temperatureTint,r.settings.temperatureTint,o)),void 0!==r.settings.globalSaturation&&e.globalSaturation.lerp(r.settings.globalSaturation,o),void 0!==r.settings.globalContrast&&e.globalContrast.lerp(r.settings.globalContrast,o),void 0!==r.settings.globalGamma&&e.globalGamma.lerp(r.settings.globalGamma,o),void 0!==r.settings.globalGain&&e.globalGain.lerp(r.settings.globalGain,o),void 0!==r.settings.globalOffset&&e.globalOffset.lerp(r.settings.globalOffset,o),void 0!==r.settings.shadowsSaturation&&e.shadowsSaturation.lerp(r.settings.shadowsSaturation,o),void 0!==r.settings.shadowsContrast&&e.shadowsContrast.lerp(r.settings.shadowsContrast,o),void 0!==r.settings.shadowsGamma&&e.shadowsGamma.lerp(r.settings.shadowsGamma,o),void 0!==r.settings.shadowsGain&&e.shadowsGain.lerp(r.settings.shadowsGain,o),void 0!==r.settings.shadowsOffset&&e.shadowsOffset.lerp(r.settings.shadowsOffset,o),void 0!==r.settings.shadowsMax&&(e.shadowsMax=i.MathUtils.lerp(e.shadowsMax,r.settings.shadowsMax,o)),void 0!==r.settings.midtonesSaturation&&e.midtonesSaturation.lerp(r.settings.midtonesSaturation,o),void 0!==r.settings.midtonesContrast&&e.midtonesContrast.lerp(r.settings.midtonesContrast,o),void 0!==r.settings.midtonesGamma&&e.midtonesGamma.lerp(r.settings.midtonesGamma,o),void 0!==r.settings.midtonesGain&&e.midtonesGain.lerp(r.settings.midtonesGain,o),void 0!==r.settings.midtonesOffset&&e.midtonesOffset.lerp(r.settings.midtonesOffset,o),void 0!==r.settings.highlightsSaturation&&e.highlightsSaturation.lerp(r.settings.highlightsSaturation,o),void 0!==r.settings.highlightsContrast&&e.highlightsContrast.lerp(r.settings.highlightsContrast,o),void 0!==r.settings.highlightsGamma&&e.highlightsGamma.lerp(r.settings.highlightsGamma,o),void 0!==r.settings.highlightsGain&&e.highlightsGain.lerp(r.settings.highlightsGain,o),void 0!==r.settings.highlightsOffset&&e.highlightsOffset.lerp(r.settings.highlightsOffset,o),void 0!==r.settings.highlightsMin&&(e.highlightsMin=i.MathUtils.lerp(e.highlightsMin,r.settings.highlightsMin,o)),void 0!==r.settings.lut&&(t=r.settings.lut),void 0!==r.settings.lutIntensity&&(e.lutIntensity=i.MathUtils.lerp(e.lutIntensity,r.settings.lutIntensity,o))))}if(0===n.length)return this.lutPass.enabled=!1,this.colorPass.enabled=!1,this.dofPass.enabled=!1,this.renderer.toneMapping=this.baseToneMapping,void(this.renderer.toneMappingExposure=this.baseToneMappingExposure);const r=e.vignetteIntensity>pt,o=(h=e.temperature,p=e.temperatureTint,!ht(h,6500)||!ht(p,0));var h,p;const d=(u=e.colorTint,e.colorTintIntensity>pt&&(!ht(u.r,1)||!ht(u.g,1)||!ht(u.b,1)));var u;const c=!(lt((m=e).globalSaturation,1,1,1)&&lt(m.globalContrast,1,1,1)&&lt(m.globalGamma,1,1,1)&&lt(m.globalGain,1,1,1)&&lt(m.globalOffset,0,0,0)&&lt(m.shadowsSaturation,1,1,1)&&lt(m.shadowsContrast,1,1,1)&&lt(m.shadowsGamma,1,1,1)&&lt(m.shadowsGain,1,1,1)&&lt(m.shadowsOffset,0,0,0)&&lt(m.midtonesSaturation,1,1,1)&&lt(m.midtonesContrast,1,1,1)&&lt(m.midtonesGamma,1,1,1)&&lt(m.midtonesGain,1,1,1)&&lt(m.midtonesOffset,0,0,0)&&lt(m.highlightsSaturation,1,1,1)&&lt(m.highlightsContrast,1,1,1)&&lt(m.highlightsGamma,1,1,1)&&lt(m.highlightsGain,1,1,1)&&lt(m.highlightsOffset,0,0,0));var m;const f=o||d||c||r,g=f&&e.tonemapMapping!==i.NoToneMapping,M=null!=t&&e.lutIntensity>pt;f?(this.renderer.toneMapping=i.NoToneMapping,this.renderer.toneMappingExposure=1):(this.renderer.toneMapping=e.tonemapMapping,this.renderer.toneMappingExposure=e.tonemapExposure),null!=e.envTexture&&(this.scene.environment=this.getEnvTexture(e.envTexture)),this.scene.environmentIntensity=e.envIntensity,f?(this.colorPass.whiteBalanceEnabled=o,this.colorPass.whiteBalanceScale=o?function(e,t,s){const i=function(e){const t=ve(e,1e3,4e4)/100,s=t<=66?1:ve(1.292936186062745*Math.pow(t-60,-.1332047592),0,1),i=ve(t<=66?.3900815787690196*Math.log(t)-.6318414437886275:1.129890860895294*Math.pow(t-60,-.0755148492),0,1),a=t>=66?1:t<=19?0:ve(.5432067891101962*Math.log(t-10)-1.19625408914,0,1);return ct.set(s,i,a)}(t),a=1+.2*ve(s,-1,1),n=i.x,r=i.y*a,o=i.z,l=Math.max(r,1e-4);return e.set(1/Math.max(n/l,1e-4),1/Math.max(r/l,1e-4),1/Math.max(o/l,1e-4)),e}(ut,e.temperature,e.temperatureTint):ut.set(1,1,1),this.colorPass.vignetteIntensity=e.vignetteIntensity,this.colorPass.vignetteEnabled=r,this.colorPass.colorTintEnabled=d,this.colorPass.colorTint=e.colorTint,this.colorPass.colorTintIntensity=e.colorTintIntensity,this.colorPass.colorGradingEnabled=c,this.colorPass.toneMapping=e.tonemapMapping,this.colorPass.toneMappingEnabled=g,this.colorPass.toneMappingExposure=e.tonemapExposure,this.colorPass.globalSaturation=e.globalSaturation,this.colorPass.globalContrast=e.globalContrast,this.colorPass.globalGamma=e.globalGamma,this.colorPass.globalGain=e.globalGain,this.colorPass.globalOffset=e.globalOffset,this.colorPass.shadowsSaturation=e.shadowsSaturation,this.colorPass.shadowsContrast=e.shadowsContrast,this.colorPass.shadowsGamma=e.shadowsGamma,this.colorPass.shadowsGain=e.shadowsGain,this.colorPass.shadowsOffset=e.shadowsOffset,this.colorPass.shadowsMax=e.shadowsMax,this.colorPass.midtonesSaturation=e.midtonesSaturation,this.colorPass.midtonesContrast=e.midtonesContrast,this.colorPass.midtonesGamma=e.midtonesGamma,this.colorPass.midtonesGain=e.midtonesGain,this.colorPass.midtonesOffset=e.midtonesOffset,this.colorPass.highlightsSaturation=e.highlightsSaturation,this.colorPass.highlightsContrast=e.highlightsContrast,this.colorPass.highlightsGamma=e.highlightsGamma,this.colorPass.highlightsGain=e.highlightsGain,this.colorPass.highlightsOffset=e.highlightsOffset,this.colorPass.highlightsMin=e.highlightsMin,this.colorPass.enabled=!0):this.colorPass.enabled=!1,s&&this.camera instanceof l?(this.dofPass.enabled=!0,void 0!==e.depthFocus&&(this.dofPass.uniforms.focus.value=e.depthFocus),void 0!==e.depthAperture&&(this.dofPass.uniforms.aperture.value=e.depthAperture),void 0!==e.depthMaxBlur&&(this.dofPass.uniforms.maxblur.value=e.depthMaxBlur)):this.dofPass.enabled=!1,this.lutPass.enabled=M,M&&(null!=t&&(t.flipY=!0,t.generateMipmaps=!1),this.lutPass.lut=t,this.lutPass.intensity=e.lutIntensity)}updatePostProcessEffectUniforms(e){if(0===this.postProcessEffects.length)return;const t=this.postProcessEffectUniformState;t.aoEnabled=this.aoPass.enabled,t.aoTexture=this.aoPass.enabled?this.aoPass.pdRenderTarget.texture:null,this.camera instanceof l?(t.cameraNear=this.camera.near,t.cameraFar=this.camera.far):(t.cameraNear=void 0,t.cameraFar=void 0),t.depthTexture=this.sceneColorRenderTarget.textures[1],t.normalTexture=this.gRenderTarget.textures[2],t.resolution.set(this.gRenderTarget.width,this.gRenderTarget.height),t.simulationTime=e;for(const e of this.postProcessEffects)e.pass.updateUniformState(t)}renderOverlay(){if(!this.running)return;if(0===this.overlayCameras.size)return;const e=Array.from(this.overlayCameras.values()).slice(0,this.maxInsetCameras),t=this.previousClientWith/2,s=e.length*this.insetWidth+(e.length-1)*this.insetMargin;for(let i=0;i<e.length;i++)this.renderer.clearDepth(),this.renderer.setViewport(t-s/2+this.insetWidth*i+this.insetMargin*i,this.insetOffsetY,this.insetWidth,this.insetHeight),this.renderer.render(this.scene,e[i])}addOverlayCamera(e){this.overlayCameras.add(e)}clearOverlayCameras(){this.overlayCameras.clear()}removeOverlayCamera(e){this.overlayCameras.delete(e)}render(e){if(0===this.composer.renderTarget1.width||0===this.composer.renderTarget1.height)return;if(0===this.composer.renderTarget2.width||0===this.composer.renderTarget2.height)return;let t=!1;if(this.ssrPass.enabled&&!1!==this.options?.reflection?.enabled){const e=this.ssrPass.selects??[];e.length=0,this.scene.traverseVisible(t=>{t instanceof o&&!0===t.material.userData?.reflective&&isObjectInFrustum(t,at)&&e.push(t)}),this.ssrPass.selects=e,0==e.length&&(this.ssrPass.enabled=!1),t=!0}this.options.bloom,this.composer.render(e),this.scene.matrixWorldAutoUpdate=!0,this.scene.matrixAutoUpdate=!0,t&&(this.ssrPass.enabled=!0)}hasBloom(){return null!=ge(this.scene,e=>e instanceof o&&!0===e.material?.userData?.hasBloom)}darkenNonBloomed(e){if((e instanceof o||e instanceof i.Sprite||e instanceof i.Line)&&e.visible&&(null==e.material.userData||!0!==e.material.userData.hasBloom)){if(e.material?.id===Ne.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Ne:(e.visible=!1,this.bloomHidden.push(e))}else"TransformControlsPlane"!==e.type&&"TransformControlsGizmo"!==e.type||(e.visible=!1,this.bloomHidden.push(e))}restoreMaterial(e){this.bloomStoredMaterials[e.uuid]&&(e.material=this.bloomStoredMaterials[e.uuid],delete this.bloomStoredMaterials[e.uuid],e.visible=!0)}initDepthUniform(e){e instanceof p&&(e.uniforms[ie].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[ne]&&(e.uniforms[ne].value=this.camera.near),null!=e.uniforms[ae]&&(e.uniforms[ae].value=this.camera.far)))}initNormalUniform(e){e instanceof p&&null!=e.uniforms[oe]&&(e.uniforms[oe].value=this.gRenderTarget.textures[2])}initShadowUniform(e,t){t instanceof R&&(t.uniforms.receiveShadow?t.uniforms.receiveShadow.value=e.receiveShadow:t.uniforms.receiveShadow={value:e.receiveShadow})}initLightVolumeUniform(e){e instanceof R&&(null!=this.lightVolume?null==e.uniforms.uSH?(e.defines.USE_LIGHT_PROBE_VOLUME="",e.uniforms.gridOrigin={value:this.lightVolume.gridOrigin},e.uniforms.gridSize={value:this.lightVolume.gridSize},e.uniforms.gridRes={value:this.lightVolume.gridResolution},e.uniforms.giIntensity={value:this.lightProbeIntensity},e.uniforms.uSH={value:this.lightVolume.shTexture},e.uniformsNeedUpdate=!0,e.needsUpdate=!0):e.uniforms.giIntensity.value=this.lightProbeIntensity:null!=e.uniforms.uSH&&(delete e.defines.USE_LIGHT_PROBE_VOLUME,delete e.uniforms.gridOrigin,delete e.uniforms.gridSize,delete e.uniforms.gridRes,delete e.uniforms.giIntensity,delete e.uniforms.uSH,e.uniformsNeedUpdate=!0,e.needsUpdate=!0))}initResolutionUniform(e){e instanceof p&&null!=e.uniforms[re]&&e.uniforms[re].value.set(this.gRenderTarget.width,this.gRenderTarget.height)}initAoUniform(e){if(this.aoPass.enabled){e.uniforms[de].value=this.aoPass.pdRenderTarget.texture,null==e.defines.USE_SSAO_MAP&&(e.defines.USE_SSAO_MAP="",e.needsUpdate=!0),e.defines.USE_SSAO_MAP="";const t=this.tbufferMaterialCache.get(e);null!=t&&this.initAoUniform(t)}else if(null!=e.defines.USE_SSAO_MAP){delete e.defines.USE_SSAO_MAP,e.needsUpdate=!0;const t=this.tbufferMaterialCache.get(e);null!=t&&this.initAoUniform(t)}}initCustomDepthMaterial(e){if(null!=e.customDepthMaterial||!e.castShadow)return;const t=e.material;if(!(t instanceof R&&t.depthWrite&&t.alphaTest>0))return;let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Ae(Ue);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new R({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}};et.activeView=null,et=e=t([se(),s("design:paramtypes",[HTMLElement,Object])],et);export{et as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const tt=.05;function st(e){let t=e;for(;t;){if(!1===t.visible)return!1;t=t.parent}return!0}function it(e,t){return e.priority!==t.priority?e.priority-t.priority:e.id-t.id}te.prototype.overrideVisibility=function(){const e=this.scene,t=this._visibilityCache;e.traverse(function(e){if(t.set(e,e.visible),(e.isPoints||e.isLine||e.isTransformControls||e.isSprite)&&(e.visible=!1),null!=e.material){let t=!1,s=!1;if(Array.isArray(e.material)){for(const s of e.material)if(null!=s.alphaTest&&s.alphaTest>0){t=!0;break}}else null!=e.material.alphaTest&&e.material.alphaTest>0?t=!0:!0===e.material.userData.isDecal&&(s=!0);s&&(e.visible=!1)}})};const at=new i.Frustum,nt=new i.Box3,rt=new i.Matrix4;export function isObjectInFrustum(e,t){const s=nt.setFromObject(e);return t.intersectsBox(s)}function ot(e,t,s,a){return null==e?new i.Vector3(t,s,a):e.set(t,s,a)}function lt(e,t,s,i){return null!=e&&ht(e.x,t)&&ht(e.y,s)&&ht(e.z,i)}function ht(e,t,s=pt){return Math.abs(e-t)<=s}const pt=1e-4,dt=new i.Vector3,ut=new i.Vector3(1,1,1),ct=new i.Vector3(1,1,1);const mt=new r,ft=new c;function gt(e,t,s=new i.Matrix3){return ft.copy(e),ft.x*=-1,ft.y*=-1,ft.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(ft.y*=-1,ft.z*=-1),s.setFromMatrix4(mt.makeRotationFromEuler(ft))}const Mt=new R({outputs:[W(0,0,0,0),W(0,0,0,0),B(D("white"),Ie(4))],transparent:!0}),vt=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});Mt.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),vt);function Pt(e){return e instanceof i.Sprite||e.isPoints||e.isLine||e.isLineSegments2||e.isTransformControls||e.isTransformControlsGizmo||e instanceof o&&bt(e,e.material)}function bt(e,t){return null==t||(Array.isArray(t)?t.some(t=>bt(e,t)):t instanceof i.RawShaderMaterial||t instanceof i.ShaderMaterial&&!(t instanceof R))}class yt extends Ve{constructor(e,t,s){super(),this.scene=e,this.camera=t,this.gRenderTarget=s,this.cachedVisibility=[],this.toRender=[],this.needsSwap=!1}render(e,t,s,i,a){const n=e.autoClear;e.autoClear=!1;const r=this.scene.matrixWorldAutoUpdate,l=this.scene.matrixAutoUpdate,h=e.shadowMap.autoUpdate;this.scene.matrixAutoUpdate=!1,e.shadowMap.autoUpdate=!1;const p=s.depthTexture;s.depthTexture=this.gRenderTarget.depthTexture,e.setRenderTarget(s),this.cachedVisibility.length=0;let d=0,u=this.toRender;if(u.length=0,this.scene.traverseVisible(e=>{const t=Pt(e);e instanceof o&&!t?(this.cachedVisibility.push(e),e.visible=!1):t&&(d++,u.push(e))}),d>0)for(const t of u)e.render(t,this.camera);this.cachedVisibility.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=n,s.depthTexture=p,this.scene.matrixWorldAutoUpdate=r,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class wt extends Ve{constructor(e){super(),this.fn=e}render(e,t,s,i,a){this.fn(e,t,s,i,a)}}const Tt=["ambientLightColor","cameraNear","directionalLightShadows","directionalLights","directionalShadowMap","directionalShadowMatrix","fogColor","fogDensity","fogFar","fogNear","hemisphereLights","lightProbe","ltc_1","ltc_2","pointLightShadows","pointLights","pointShadowMap","pointShadowMatrix","rectAreaLights","shadowFar","spotLightMap","spotLightMatrix","spotLightShadows","spotLights","spotShadowMap"],xt=["directionalShadowMap","directionalShadowMatrix","pointLightShadows","pointShadowMap","pointShadowMatrix","spotLightShadows","spotShadowMap"],St=U("fogColor");export class FogNode extends H{constructor(e,t=St){super(),this.source=e,this.fogColor=t}compile(e){const t=e.variable(),s=e.get(this.source.rgb),i=e.get(this.source.a),a=e.get(this.fogColor),n=e.get(E("fogFar")),r=e.get(E("fogNear")),o=e.get(E("fogDensity")),l=e.get(L(I.mvPosition.z));return{pars:"\n ",chunk:`\n #ifdef FOG_EXP2\n float fogFactor_${t} = 1.0 - exp( - ${o} * ${o} * ${l} * ${l} );\n #else\n float fogFactor_${t} = smoothstep( ${r}, ${n}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${a}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}const Ct=new i.MeshDepthMaterial({depthPacking:i.RGBADepthPacking});/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{AudioLoader as e,BufferGeometry as t,Euler as s,Group as r,LoadingManager as a,Mesh as i,Object3D as n,Texture as o,TextureLoader as l,Vector3 as c}from"three";import{MTLLoader as h,OBJLoader as u,LUTCubeLoader as m}from"three-stdlib";import{cloneMesh as d}from"../utils/mesh.js";import{pathJoin as p}from"../utils/files.js";import{Subject as f,firstValueFrom as y}from"rxjs";import{BoxCollisionShape as g,CapsuleCollisionShape as w,CollisionShapeSource as x,CylinderCollisionShape as M,SphereCollisionShape as A}from"./collision/collision-shape.js";import{importCollisionShapes as b,isCollisionMesh as L}from"./collision/collision-shape-import.js";import*as _ from"three";import{iterateMaterials as v}from"../utils/materials.js";import{applyMaterial as S,getConvertedFbxToGlbAssignedMaterialTextureFlipY as C}from"./materializer.js";import{BufferGeometryUtils as T,DRACOLoader as P,EXRLoader as R,FBXLoader as k,GLTFLoader as K,KTX2Loader as I,TGALoader as W,UltraHDRLoader as B}from"three/examples/jsm/Addons.js";import{disposeScene as j}from"../utils/three/cleanup.js";(()=>{const e=new Uint8Array([255,0,0,255]),t=new _.DataTexture(e,1,1,_.RGBAFormat);t.needsUpdate=!0})();const D=new P;D.setDecoderConfig({type:"js"}),D.setDecoderPath("/assets/draco/");const F=["glb","gltf","fbx","obj"];export class AssetResourceLoader{onError(e){console.error(e)}constructor(){this.cache=new Map,this.textureCache=new Map,this.loadingManager=new a,this.glbLoader=new K(this.loadingManager).setDRACOLoader(D),this.fbxLoader=new k(this.loadingManager),this.objLoader=new u(this.loadingManager),this.textureLoader=new l(this.loadingManager),this.tgaLoader=new W(this.loadingManager),this.exrLoader=new R(this.loadingManager),this.cubeLoader=new m(this.loadingManager),this.hdrLoader=new B(this.loadingManager),this.ktx2Loader=new I(this.loadingManager),this._textureLoader=new _.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this._retrievedMeshes=[],this._retrievedTextures=[],this.makeReady=new f,this.ready=y(this.makeReady),this._texturePromises=new Map,this._arrayTexturesByFileKey=new Map,this._animationPromises=new Map,this._animationCache=new Map,this.asyncMeshResults=new Map,this.asyncAudioResults=new Map,this.collisionShapeCache=new Map,this.optimizedMeshes=new Set}initKtx2(e){this.initialisedKtx2=!0;null!=getElectronArg("windowId")||import.meta.url.includes(".vite")||import.meta.url.includes("hology/packages/core")?this.ktx2Loader.setTranscoderPath("/assets/basis/"):this.ktx2Loader.setTranscoderPath(new URL("../assets/basis/",import.meta.url).href),this.ktx2Loader.detectSupport(e),this.ktx2Loader.setWorkerLimit(6)}setDataDir(e){this.basePath=p(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=function(e){return E.get(e)}(e),s=getElectronArg("windowId");return null!=s||import.meta.url.includes(".vite")||import.meta.url.includes("hology/packages/core")?p(this.basePath,e)+(null!=s?`?windowId=${s}${null!=t?`&v=${t}`:""}`:""):new URL(p("..",this.basePath,e),import.meta.url).href}async getTexture(e){if(!e||!e.fileKey)return null;if("png"===e.fileFormat||e.fileFormat,this._texturePromises.has(e.id))return this._texturePromises.get(e.id);const t=this._getTexture(e).finally(()=>{this._texturePromises.delete(e.id)});return this._texturePromises.set(e.id,t),t}async _getTexture(e){if(null==e||null==e.fileKey)return null;if(await this.ready,this.textureCache.has(e.id)){const t=this.textureCache.get(e.id);if(null!=e.texture){const s=$(t,e);t.flipY!==s?(t.needsUpdate=!0,t.flipY=s):t.wrapS!==z(e.texture?.wrapS)?(t.needsUpdate=!0,t.wrapS=z(e.texture?.wrapS)):t.wrapT!==z(e.texture?.wrapT)&&(t.wrapT=z(e.texture?.wrapT),t.needsUpdate=!0)}const s=Y(O(e));t.colorSpace!==s&&(t.colorSpace=s,t.needsUpdate=!0)}else try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then(t=>(t.texture3D?t=t.texture3D:(t.wrapS=z(e.texture?.wrapS),t.wrapT=z(e.texture?.wrapT),t.flipY=$(t,e),t.colorSpace=Y(O(e))),this.textureCache.set(e.id,t),this._retrievedTextures.push(t),t))}catch(t){return console.warn("Failed to load texture "+e.name,t),null}const t=this.textureCache.get(e.id);return null!=t&&(t.userData.assetId=e.id),t}async getTextureArray(e){const t=e.texture?.textureArrayFileKey,s=e.texture?.textureArrayLayer;if(!t||null==s)return{texture:null,layerIndex:null};if(!this._arrayTexturesByFileKey.has(t)){const e=this._getTextureLoader(t);let s=await e.loadAsync(this.getUri(t));s instanceof o||(s=s.texture3D),this._arrayTexturesByFileKey.set(t,s),this._retrievedTextures.push(s)}return{texture:this._arrayTexturesByFileKey.get(t),layerIndex:s}}_getTextureLoader(e){return e?.toLowerCase().endsWith(".tga")?this.tgaLoader:e?.toLowerCase().endsWith(".ktx2")?this.ktx2Loader:e?.toLowerCase().endsWith(".exr")?this.exrLoader:e?.toLowerCase().endsWith(".cube")?this.cubeLoader:this.textureLoader}clearCache(e){this.clearCacheByAsset(e)}clearCacheByAsset(e){null!=e&&(this.clearCacheById(e.id),null!=e.fileKey&&(Array.from(this.cache.keys()).forEach(t=>{t.startsWith(e.fileKey)&&this.cache.delete(t)}),Array.from(this.asyncMeshResults.keys()).forEach(t=>{t.startsWith(e.fileKey)&&this.asyncMeshResults.delete(t)}),Array.from(this._animationCache.keys()).forEach(t=>{t.startsWith(e.fileKey+"|")&&this._animationCache.delete(t)}),Array.from(this._animationPromises.keys()).forEach(t=>{t.startsWith(e.fileKey+"|")&&this._animationPromises.delete(t)}),U(e.fileKey)),null!=e.materialLib&&U(e.materialLib))}clearCacheById(e){const t=Array.from(this.cache.values()).find(t=>t.scene.userData.assetId===e);t&&Array.from(this.cache.keys()).forEach(e=>{this.cache.get(e)===t&&this.cache.delete(e)}),this.textureCache.delete(e),this._texturePromises.delete(e),Array.from(this.collisionShapeCache.keys()).forEach(t=>{t.startsWith(e+"|")&&this.collisionShapeCache.delete(t)})}async getMesh(e,t){if(await this.ready,null==e)return console.error("No asset was provided"),{scene:new r,animations:[]};if(!F.includes(e.fileFormat?.toLowerCase()))return console.error("Unsupported mesh file format "+e.fileFormat,e),{scene:new r,animations:[]};const s=e.fileKey+(!0===t?.mergeGeomtries?"1":"0");if(!this.cache.has(s))try{this.asyncMeshResults.has(s)||this.asyncMeshResults.set(s,this.loadMesh(e).finally(()=>this.asyncMeshResults.delete(s))),this.cache.set(s,await this.asyncMeshResults.get(s))}catch(e){return this.onError(e),{scene:new r,animations:[]}}const a=this.cache.get(s).scene,n=this.computeCollisionShapes(e,a);!0===t?.mergeGeomtries&&this.optimizeDrawGroups(a);const o=d(a),l=this.cache.get(s).animations;o.traverse(e=>{e instanceof i&&e.material instanceof Array&&(e.material=e.material.slice())});const c=new AssetMeshInstance;c.add(o),c.collisionShapes=n,c.animations=l;const h=e.receiveShadow??!0,u=e.castShadow??!1;if(o.traverse(e=>{e.castShadow=u,e.receiveShadow=h}),!0===t?.rescale&&"number"==typeof e.mesh?.rescale&&c.scale.setScalar(e.mesh?.rescale),!0===t?.applyMaterials){const s=t?.materialResolver??this.materialProvider;if(null!=s)for(const t of e.materialAssignments??[])await S(c,t,s,void 0,{textureFlipY:C(e)});else console.warn(`applyMaterials was set to true for ${e.name} but no material resolver was provided.`)}return{scene:c,animations:l}}async getAudio(e){await this.ready;const t=e.fileKey;if(this.asyncAudioResults.has(t))return await this.asyncAudioResults.get(t);const s=this.audioLoader.loadAsync(this.getUri(e.fileKey)).finally(()=>{setTimeout(()=>{this.asyncAudioResults.delete(t)},1e3)});return this.asyncAudioResults.set(t,s),s}async getAnimationClip(e){if(null==e||null==e.fileKey||null==!e.anim?.clip)return console.warn("Asset or animation clip name is not defined",e),null;const t=e.anim.clip,s=e.fileKey+"|"+t;if(this._animationCache.has(s))return this._animationCache.get(s);if(this._animationPromises.has(s))return this._animationPromises.get(s);const r=(async()=>{try{const r=await this.getMesh(e),a=r.animations.find(e=>e.name===t);return null!=a&&this._animationCache.set(s,a),a}catch(e){return this.onError(e),null}finally{setTimeout(()=>this._animationPromises.delete(s),1e3)}})();return this._animationPromises.set(s,r),r}computeCollisionShapes(e,t){if(!0!==e.collisionDetection)return[];const s=e.id+"|"+(e.mesh?.collisions?.shapeType??"")+"|"+(e.mesh?.rescale??1)+"|"+JSON.stringify(e.mesh?.colliders??[]);if(!this.collisionShapeCache.has(s)){const r=e.mesh?.colliders??[],a=r.length>0?createAuthoredCollisionShapes(r,e.mesh?.rescale):b(t,e);this.collisionShapeCache.set(s,a)}return this.collisionShapeCache.get(s)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then(s=>(s.scene.traverse(e=>{e instanceof i&&e.material&&function(e){let t=e.material;if(null==t)return;Array.isArray(t)?e.material=t.map(J):e.material=J(t)}(e),L(e)?e.visible=!1:e instanceof i&&e.geometry instanceof t&&(e.geometry.hasAttribute("normal")||e.geometry.computeVertexNormals())}),this._retrievedMeshes.push(s.scene),s.scene=function(e,t){let s=!1;if(t.traverseVisible(e=>{X.test(e.name)&&(s=!0)}),!s)return t;const r=[],a=[t];for(;a.length>0;){const e=a.shift(),t=e.name.match(X);if(null!=t){const s=parseInt(t[1]);if(0!==s){console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`),r.push(e);continue}}a.push(...e.children)}for(const e of r)e.removeFromParent();return t}(0,s.scene),function(e){const t=V;V.length=0,e.traverse(e=>{(e instanceof _.Camera||e instanceof _.Light)&&t.push(e)}),t.forEach(e=>e.removeFromParent())}(s.scene),s.scene.userData.assetId=e.id,s))}optimizeDrawGroups(e){if(this.optimizedMeshes.has(e.uuid))return;this.optimizedMeshes.add(e.uuid),e.updateWorldMatrix(!0,!0);const s=[];e.traverse(e=>{e instanceof i&&!(e instanceof _.SkinnedMesh)&&e.geometry instanceof t&&Array.isArray(e.material)&&!L(e)&&s.push({mesh:e,geometry:e.geometry,materialArray:e.material,parent:e.parent})});for(const{mesh:t,geometry:r,materialArray:a,parent:n}of s){t.removeFromParent();for(let s=0;s<a.length;s++){const o=a[s],l=r.groups.filter(e=>e.materialIndex===s);if(0===l.length)continue;const c=this.extractGeometryGroups(r,l);c.groups.length>1&&T.mergeGroups(c);const h=new i(c,o);h.copy(t,!1),h.geometry=c,h.material=o,n?n.add(h):e.add(h)}r.dispose()}let r=!0,a=0,n=0;if(e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!L(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==n&&0!==n&&(r=!1),n=t}else(e instanceof _.SkinnedMesh||e instanceof _.Bone)&&(r=!1)}),a>1&&r){const s=new Map;e.traverse(r=>{if(r instanceof i&&r.geometry instanceof t&&!L(r)){if(Array.isArray(r.material))return;r.updateWorldMatrix(!0,!0);const t=r.material?.uuid||"default";s.has(t)||s.set(t,{material:r.material,geometries:[],objects:[]});const a=s.get(t),i=e.matrixWorld.clone().invert().multiply(r.matrixWorld);a.geometries.push(r.geometry.clone().applyMatrix4(i)),a.objects.push(r)}});for(const e of s.values())for(const t of e.objects)t.removeFromParent();for(const t of s.values()){let s;s=1===t.geometries.length?t.geometries[0]:T.mergeGeometries(t.geometries,!0),s.groups.length>1&&T.mergeGroups(s),e.add(new i(s,t.material))}}e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!L(e)){const t=e.geometry;!Array.isArray(e.material)&&t.groups.length>1&&T.mergeGroups(t)}})}extractGeometryGroups(e,s){const r=e.index;if(!r){const r=new t;let a=0;for(const e of s)a+=e.count;if(0===a)return r;for(const t in e.attributes){const i=e.attributes[t],n=i.itemSize,o=i.array,l=new(0,o.constructor)(a*n);let c=0;for(const e of s){const t=e.start*n,s=e.count*n;for(let e=0;e<s;e++)l[c+e]=o[t+e];c+=s}const h=new _.BufferAttribute(l,n,i.normalized);r.setAttribute(t,h)}return r.groups=[{start:0,count:a,materialIndex:0}],r}const a=[];for(const e of s)for(let t=0;t<e.count;t++){const s=r.getX(e.start+t);a.push(s)}if(0===a.length)return new t;const i=new Map,n=[];let o=0;for(const e of a)i.has(e)||(i.set(e,o),o++),n.push(i.get(e));if(0===n.length||0===i.size)return new t;const l=new t;for(const t in e.attributes){const s=e.attributes[t],r=s.itemSize,a=s.array,n=new(0,a.constructor)(i.size*r);for(const[e,t]of i)for(let s=0;s<r;s++)n[t*r+s]=a[e*r+s];const o=new _.BufferAttribute(n,r,s.normalized);l.setAttribute(t,o)}const c=new((n.length>0?Math.max(...n):0)>65535?Uint32Array:Uint16Array)(n.length);for(let e=0;e<n.length;e++)c[e]=n[e];return l.setIndex(new _.BufferAttribute(c,1)),l.groups=[{start:0,count:n.length,materialIndex:0}],l}async loadByAsset(e){this.fbxLoader;const t=this.getUri(e.fileKey);switch(e.fileFormat){case"glb":case"gltf":return this.glbLoader.loadAsync(t).then(e=>({scene:e.scene,animations:e.animations}));case"fbx":return this.fbxLoader.loadAsync(t).then(e=>({scene:e,animations:e.animations}));case"obj":if(null!=e.materialLib){const t=new h;t.materialOptions={normalizeRGB:!1};const s=await t.loadAsync(this.getUri(e.materialLib));this.objLoader.setMaterials(s)}return this.objLoader.loadAsync(t).then(e=>(G(e),e)).then(e=>({scene:e,animations:e.animations}))}}disposeAll(){this.cache.clear(),this._retrievedMeshes.forEach(e=>j(e)),this._retrievedTextures.forEach(e=>e.dispose()),this._retrievedMeshes.length=0,this._retrievedTextures.length=0}}const E=new Map;function U(e){E.set(e,(E.get(e)??0)+1)}function G(e){if(e instanceof i)for(const t of v(e.material))t instanceof _.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(G)}export class AssetMeshInstance extends n{}export function createAuthoredCollisionShapes(e,t=1){const r=null!=t&&0!==t?1/t:1;return e.map(e=>{let t;switch(e.type){case"box":t=new g((new c).fromArray(e.size).multiplyScalar(r));break;case"sphere":t=new A(e.radius*r);break;case"capsule":t=new w(e.length*r,e.radius*r);break;case"cylinder":t=new M(e.radius*r,e.radius*r,e.height*r,16,new s)}return t.source=x.custom,t.offset.fromArray(e.position??[0,0,0]).multiplyScalar(r),t.rotation.fromArray(e.rotation??[0,0,0,"XYZ"]),t})}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find(e=>e.startsWith(t));return s?.substring(t.length)}function z(e){switch(e){case"clamp":return _.ClampToEdgeWrapping;case"repeat":return _.RepeatWrapping;case"mirror":return _.MirroredRepeatWrapping}return _.RepeatWrapping}function $(e,t){const s=e;return!0!==s.isCompressedTexture&&!0!==s.isCompressedArrayTexture&&(t.texture?.flipY??!0)}function O(e){return e.texture?.colorSpace??function(e){if("exr"===e.fileFormat||e.fileKey?.toLowerCase().endsWith(".exr"))return"linear";const t=`${e.name} ${e.fileKey??""}`.toLowerCase();if(N.some(e=>t.includes(e)))return"linear";return"srgb"}(e)}function Y(e){return"linear"===e?_.LinearSRGBColorSpace:_.SRGBColorSpace}const N=["_normal","_nrm","_nor","_norm","_roughness","_rough","_metalness","_metallic","_metal","_ao","_ambient","_occlusion","_mask","_height","_disp","_displacement","_bump","_opacity"];new _.Matrix4;const V=[];const X=/_LOD(\d+)/;function J(e){let t=e instanceof _.MeshPhysicalMaterial&&0===e.sheen&&0===e.anisotropy;if("MeshLambertMaterial"===e.type||"MeshPhongMaterial"===e.type||t){let t={};(e instanceof _.MeshLambertMaterial||e instanceof _.MeshPhongMaterial||e instanceof _.MeshPhysicalMaterial)&&(t.color=e.color,t.map=e.map,t.bumpMap=e.bumpMap,t.bumpScale=e.bumpScale,t.lightMap=e.lightMap,t.lightMapIntensity=e.lightMapIntensity,t.aoMap=e.aoMap,t.aoMapIntensity=e.aoMapIntensity,t.emissiveMap=e.emissiveMap,t.alphaMap=e.alphaMap,t.envMap=e.envMap,t.envMapRotation=e.envMapRotation,t.wireframe=e.wireframe,t.wireframeLinewidth=e.wireframeLinewidth,t.fog=e.fog,t.opacity=e.opacity,t.transparent=e.transparent,t.side=e.side,t.depthTest=e.depthTest,t.depthWrite=e.depthWrite,t.alphaTest=e.alphaTest,t.displacementMap=e.displacementMap,t.displacementScale=e.displacementScale,t.displacementBias=e.displacementBias);const s=new _.MeshStandardMaterial(t);return s.userData={...e.userData??{}},s.name=e.name,s}return e}/*
1
+ import{AudioLoader as e,BufferGeometry as t,Euler as s,Group as r,LoadingManager as a,Mesh as i,Object3D as n,Texture as o,TextureLoader as l,Vector3 as c}from"three";import{MTLLoader as h,OBJLoader as u,LUTCubeLoader as m}from"three-stdlib";import{cloneMesh as d}from"../utils/mesh.js";import{pathJoin as p}from"../utils/files.js";import{Subject as f,firstValueFrom as y}from"rxjs";import{BoxCollisionShape as g,CapsuleCollisionShape as w,CollisionShapeSource as x,CylinderCollisionShape as M,SphereCollisionShape as A}from"./collision/collision-shape.js";import{importCollisionShapes as b,isCollisionMesh as L}from"./collision/collision-shape-import.js";import*as _ from"three";import{iterateMaterials as v}from"../utils/materials.js";import{applyMaterial as S,getConvertedFbxToGlbAssignedMaterialTextureFlipY as C}from"./materializer.js";import{BufferGeometryUtils as T,DRACOLoader as P,EXRLoader as R,FBXLoader as k,GLTFLoader as K,KTX2Loader as I,TGALoader as W,UltraHDRLoader as B}from"three/examples/jsm/Addons.js";import{disposeScene as j}from"../utils/three/cleanup.js";(()=>{const e=new Uint8Array([255,0,0,255]),t=new _.DataTexture(e,1,1,_.RGBAFormat);t.needsUpdate=!0})();const D=new P;D.setDecoderConfig({type:"js"}),D.setDecoderPath("/assets/draco/");const F=["glb","gltf","fbx","obj"];export class AssetResourceLoader{onError(e){console.error(e)}constructor(){this.cache=new Map,this.textureCache=new Map,this.loadingManager=new a,this.glbLoader=new K(this.loadingManager).setDRACOLoader(D),this.fbxLoader=new k(this.loadingManager),this.objLoader=new u(this.loadingManager),this.textureLoader=new l(this.loadingManager),this.tgaLoader=new W(this.loadingManager),this.exrLoader=new R(this.loadingManager),this.cubeLoader=new m(this.loadingManager),this.hdrLoader=new B(this.loadingManager),this.ktx2Loader=new I(this.loadingManager),this._textureLoader=new _.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this._retrievedMeshes=[],this._retrievedTextures=[],this.makeReady=new f,this.ready=y(this.makeReady),this._texturePromises=new Map,this._arrayTexturesByFileKey=new Map,this._animationPromises=new Map,this._animationCache=new Map,this.asyncMeshResults=new Map,this.asyncAudioResults=new Map,this.collisionShapeCache=new Map,this.optimizedMeshes=new Set}initKtx2(e){this.initialisedKtx2=!0;null!=getElectronArg("windowId")||import.meta.url.includes(".vite")||import.meta.url.includes("hology/packages/core")?this.ktx2Loader.setTranscoderPath("/assets/basis/"):this.ktx2Loader.setTranscoderPath(new URL("../assets/basis/",import.meta.url).href),this.ktx2Loader.detectSupport(e),this.ktx2Loader.setWorkerLimit(6)}setDataDir(e){this.basePath=p(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=function(e){return E.get(e)}(e),s=getElectronArg("windowId");return null!=s||import.meta.url.includes(".vite")||import.meta.url.includes("hology/packages/core")?p(this.basePath,e)+(null!=s?`?windowId=${s}${null!=t?`&v=${t}`:""}`:""):new URL(p("..",this.basePath,e),import.meta.url).href}async getTexture(e){if(!e||!e.fileKey)return null;if("png"===e.fileFormat||e.fileFormat,this._texturePromises.has(e.id))return this._texturePromises.get(e.id);const t=this._getTexture(e).finally(()=>{this._texturePromises.delete(e.id)});return this._texturePromises.set(e.id,t),t}async _getTexture(e){if(null==e||null==e.fileKey)return null;if(await this.ready,this.textureCache.has(e.id)){const t=this.textureCache.get(e.id);if(null!=e.texture){const s=$(t,e);t.flipY!==s?(t.needsUpdate=!0,t.flipY=s):t.wrapS!==z(e.texture?.wrapS)?(t.needsUpdate=!0,t.wrapS=z(e.texture?.wrapS)):t.wrapT!==z(e.texture?.wrapT)&&(t.wrapT=z(e.texture?.wrapT),t.needsUpdate=!0)}const s=Y(O(e));t.colorSpace!==s&&(t.colorSpace=s,t.needsUpdate=!0)}else try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then(t=>(t.texture3D?t=t.texture3D:(t.wrapS=z(e.texture?.wrapS),t.wrapT=z(e.texture?.wrapT),t.flipY=$(t,e),t.colorSpace=Y(O(e))),this.textureCache.set(e.id,t),this._retrievedTextures.push(t),t))}catch(t){return console.warn("Failed to load texture "+e.name,t),null}const t=this.textureCache.get(e.id);return null!=t&&(t.userData.assetId=e.id),t}async getTextureArray(e){const t=e.texture?.textureArrayFileKey,s=e.texture?.textureArrayLayer;if(!t||null==s)return{texture:null,layerIndex:null};if(!this._arrayTexturesByFileKey.has(t)){const e=this._getTextureLoader(t);let s=await e.loadAsync(this.getUri(t));s instanceof o||(s=s.texture3D),this._arrayTexturesByFileKey.set(t,s),this._retrievedTextures.push(s)}return{texture:this._arrayTexturesByFileKey.get(t),layerIndex:s}}_getTextureLoader(e){return e?.toLowerCase().endsWith(".tga")?this.tgaLoader:e?.toLowerCase().endsWith(".ktx2")?this.ktx2Loader:e?.toLowerCase().endsWith(".exr")?this.exrLoader:e?.toLowerCase().endsWith(".cube")?this.cubeLoader:this.textureLoader}clearCache(e){this.clearCacheByAsset(e)}clearCacheByAsset(e){null!=e&&(this.clearCacheById(e.id),null!=e.fileKey&&(Array.from(this.cache.keys()).forEach(t=>{t.startsWith(e.fileKey)&&this.cache.delete(t)}),Array.from(this.asyncMeshResults.keys()).forEach(t=>{t.startsWith(e.fileKey)&&this.asyncMeshResults.delete(t)}),Array.from(this._animationCache.keys()).forEach(t=>{t.startsWith(e.fileKey+"|")&&this._animationCache.delete(t)}),Array.from(this._animationPromises.keys()).forEach(t=>{t.startsWith(e.fileKey+"|")&&this._animationPromises.delete(t)}),U(e.fileKey)),null!=e.materialLib&&U(e.materialLib))}clearCacheById(e){const t=Array.from(this.cache.values()).find(t=>t.scene.userData.assetId===e);t&&Array.from(this.cache.keys()).forEach(e=>{this.cache.get(e)===t&&this.cache.delete(e)}),this.textureCache.delete(e),this._texturePromises.delete(e),Array.from(this.collisionShapeCache.keys()).forEach(t=>{t.startsWith(e+"|")&&this.collisionShapeCache.delete(t)})}async getMesh(e,t){if(await this.ready,null==e)return console.error("No asset was provided"),{scene:new r,animations:[]};if(!F.includes(e.fileFormat?.toLowerCase()))return console.error("Unsupported mesh file format "+e.fileFormat,e),{scene:new r,animations:[]};const s=e.fileKey+(!0===t?.mergeGeomtries?"1":"0");if(!this.cache.has(s))try{this.asyncMeshResults.has(s)||this.asyncMeshResults.set(s,this.loadMesh(e).finally(()=>this.asyncMeshResults.delete(s))),this.cache.set(s,await this.asyncMeshResults.get(s))}catch(e){return this.onError(e),{scene:new r,animations:[]}}const a=this.cache.get(s).scene,n=this.computeCollisionShapes(e,a);!0===t?.mergeGeomtries&&this.optimizeDrawGroups(a);const o=d(a),l=this.cache.get(s).animations;o.traverse(e=>{e instanceof i&&e.material instanceof Array&&(e.material=e.material.slice())});const c=new AssetMeshInstance;c.add(o),c.collisionShapes=n,c.animations=l;const h=e.receiveShadow??!0,u=e.castShadow??!1;if(o.traverse(e=>{e.castShadow=u,e.receiveShadow=h}),!0===t?.rescale&&"number"==typeof e.mesh?.rescale&&c.scale.setScalar(e.mesh?.rescale),!0===t?.applyMaterials){const s=t?.materialResolver??this.materialProvider;if(null!=s)for(const t of e.materialAssignments??[])await S(c,t,s,void 0,{textureFlipY:C(e)});else console.warn(`applyMaterials was set to true for ${e.name} but no material resolver was provided.`)}return{scene:c,animations:l}}async getAudio(e){await this.ready;const t=e.fileKey;if(this.asyncAudioResults.has(t))return await this.asyncAudioResults.get(t);const s=this.audioLoader.loadAsync(this.getUri(e.fileKey)).finally(()=>{setTimeout(()=>{this.asyncAudioResults.delete(t)},1e3)});return this.asyncAudioResults.set(t,s),s}async getAnimationClip(e){if(null==e||null==e.fileKey||null==e.anim?.clip)return console.warn("Asset or animation clip name is not defined",e),null;const t=e.anim.clip,s=e.fileKey+"|"+t;if(this._animationCache.has(s))return this._animationCache.get(s);if(this._animationPromises.has(s))return this._animationPromises.get(s);const r=(async()=>{try{const r=await this.getMesh(e),a=r.animations.find(e=>e.name===t);return null!=a&&this._animationCache.set(s,a),a}catch(e){return this.onError(e),null}finally{setTimeout(()=>this._animationPromises.delete(s),1e3)}})();return this._animationPromises.set(s,r),r}computeCollisionShapes(e,t){if(!0!==e.collisionDetection)return[];const s=e.id+"|"+(e.mesh?.collisions?.shapeType??"")+"|"+(e.mesh?.rescale??1)+"|"+JSON.stringify(e.mesh?.colliders??[]);if(!this.collisionShapeCache.has(s)){const r=e.mesh?.colliders??[],a=r.length>0?createAuthoredCollisionShapes(r,e.mesh?.rescale):b(t,e);this.collisionShapeCache.set(s,a)}return this.collisionShapeCache.get(s)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then(s=>(s.scene.traverse(e=>{e instanceof i&&e.material&&function(e){let t=e.material;if(null==t)return;Array.isArray(t)?e.material=t.map(J):e.material=J(t)}(e),L(e)?e.visible=!1:e instanceof i&&e.geometry instanceof t&&(e.geometry.hasAttribute("normal")||e.geometry.computeVertexNormals())}),this._retrievedMeshes.push(s.scene),s.scene=function(e,t){let s=!1;if(t.traverseVisible(e=>{X.test(e.name)&&(s=!0)}),!s)return t;const r=[],a=[t];for(;a.length>0;){const e=a.shift(),t=e.name.match(X);if(null!=t){const s=parseInt(t[1]);if(0!==s){console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`),r.push(e);continue}}a.push(...e.children)}for(const e of r)e.removeFromParent();return t}(0,s.scene),function(e){const t=V;V.length=0,e.traverse(e=>{(e instanceof _.Camera||e instanceof _.Light)&&t.push(e)}),t.forEach(e=>e.removeFromParent())}(s.scene),s.scene.userData.assetId=e.id,s))}optimizeDrawGroups(e){if(this.optimizedMeshes.has(e.uuid))return;this.optimizedMeshes.add(e.uuid),e.updateWorldMatrix(!0,!0);const s=[];e.traverse(e=>{e instanceof i&&!(e instanceof _.SkinnedMesh)&&e.geometry instanceof t&&Array.isArray(e.material)&&!L(e)&&s.push({mesh:e,geometry:e.geometry,materialArray:e.material,parent:e.parent})});for(const{mesh:t,geometry:r,materialArray:a,parent:n}of s){t.removeFromParent();for(let s=0;s<a.length;s++){const o=a[s],l=r.groups.filter(e=>e.materialIndex===s);if(0===l.length)continue;const c=this.extractGeometryGroups(r,l);c.groups.length>1&&T.mergeGroups(c);const h=new i(c,o);h.copy(t,!1),h.geometry=c,h.material=o,n?n.add(h):e.add(h)}r.dispose()}let r=!0,a=0,n=0;if(e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!L(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==n&&0!==n&&(r=!1),n=t}else(e instanceof _.SkinnedMesh||e instanceof _.Bone)&&(r=!1)}),a>1&&r){const s=new Map;e.traverse(r=>{if(r instanceof i&&r.geometry instanceof t&&!L(r)){if(Array.isArray(r.material))return;r.updateWorldMatrix(!0,!0);const t=r.material?.uuid||"default";s.has(t)||s.set(t,{material:r.material,geometries:[],objects:[]});const a=s.get(t),i=e.matrixWorld.clone().invert().multiply(r.matrixWorld);a.geometries.push(r.geometry.clone().applyMatrix4(i)),a.objects.push(r)}});for(const e of s.values())for(const t of e.objects)t.removeFromParent();for(const t of s.values()){let s;s=1===t.geometries.length?t.geometries[0]:T.mergeGeometries(t.geometries,!0),s.groups.length>1&&T.mergeGroups(s),e.add(new i(s,t.material))}}e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!L(e)){const t=e.geometry;!Array.isArray(e.material)&&t.groups.length>1&&T.mergeGroups(t)}})}extractGeometryGroups(e,s){const r=e.index;if(!r){const r=new t;let a=0;for(const e of s)a+=e.count;if(0===a)return r;for(const t in e.attributes){const i=e.attributes[t],n=i.itemSize,o=i.array,l=new(0,o.constructor)(a*n);let c=0;for(const e of s){const t=e.start*n,s=e.count*n;for(let e=0;e<s;e++)l[c+e]=o[t+e];c+=s}const h=new _.BufferAttribute(l,n,i.normalized);r.setAttribute(t,h)}return r.groups=[{start:0,count:a,materialIndex:0}],r}const a=[];for(const e of s)for(let t=0;t<e.count;t++){const s=r.getX(e.start+t);a.push(s)}if(0===a.length)return new t;const i=new Map,n=[];let o=0;for(const e of a)i.has(e)||(i.set(e,o),o++),n.push(i.get(e));if(0===n.length||0===i.size)return new t;const l=new t;for(const t in e.attributes){const s=e.attributes[t],r=s.itemSize,a=s.array,n=new(0,a.constructor)(i.size*r);for(const[e,t]of i)for(let s=0;s<r;s++)n[t*r+s]=a[e*r+s];const o=new _.BufferAttribute(n,r,s.normalized);l.setAttribute(t,o)}const c=new((n.length>0?Math.max(...n):0)>65535?Uint32Array:Uint16Array)(n.length);for(let e=0;e<n.length;e++)c[e]=n[e];return l.setIndex(new _.BufferAttribute(c,1)),l.groups=[{start:0,count:n.length,materialIndex:0}],l}async loadByAsset(e){this.fbxLoader;const t=this.getUri(e.fileKey);switch(e.fileFormat){case"glb":case"gltf":return this.glbLoader.loadAsync(t).then(e=>({scene:e.scene,animations:e.animations}));case"fbx":return this.fbxLoader.loadAsync(t).then(e=>({scene:e,animations:e.animations}));case"obj":if(null!=e.materialLib){const t=new h;t.materialOptions={normalizeRGB:!1};const s=await t.loadAsync(this.getUri(e.materialLib));this.objLoader.setMaterials(s)}return this.objLoader.loadAsync(t).then(e=>(G(e),e)).then(e=>({scene:e,animations:e.animations}))}}disposeAll(){this.cache.clear(),this._retrievedMeshes.forEach(e=>j(e)),this._retrievedTextures.forEach(e=>e.dispose()),this._retrievedMeshes.length=0,this._retrievedTextures.length=0}}const E=new Map;function U(e){E.set(e,(E.get(e)??0)+1)}function G(e){if(e instanceof i)for(const t of v(e.material))t instanceof _.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(G)}export class AssetMeshInstance extends n{}export function createAuthoredCollisionShapes(e,t=1){const r=null!=t&&0!==t?1/t:1;return e.map(e=>{let t;switch(e.type){case"box":t=new g((new c).fromArray(e.size).multiplyScalar(r));break;case"sphere":t=new A(e.radius*r);break;case"capsule":t=new w(e.length*r,e.radius*r);break;case"cylinder":t=new M(e.radius*r,e.radius*r,e.height*r,16,new s)}return t.source=x.custom,t.offset.fromArray(e.position??[0,0,0]).multiplyScalar(r),t.rotation.fromArray(e.rotation??[0,0,0,"XYZ"]),t})}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find(e=>e.startsWith(t));return s?.substring(t.length)}function z(e){switch(e){case"clamp":return _.ClampToEdgeWrapping;case"repeat":return _.RepeatWrapping;case"mirror":return _.MirroredRepeatWrapping}return _.RepeatWrapping}function $(e,t){const s=e;return!0!==s.isCompressedTexture&&!0!==s.isCompressedArrayTexture&&(t.texture?.flipY??!0)}function O(e){return e.texture?.colorSpace??function(e){if("exr"===e.fileFormat||e.fileKey?.toLowerCase().endsWith(".exr"))return"linear";const t=`${e.name} ${e.fileKey??""}`.toLowerCase();if(N.some(e=>t.includes(e)))return"linear";return"srgb"}(e)}function Y(e){return"linear"===e?_.LinearSRGBColorSpace:_.SRGBColorSpace}const N=["_normal","_nrm","_nor","_norm","_roughness","_rough","_metalness","_metallic","_metal","_ao","_ambient","_occlusion","_mask","_height","_disp","_displacement","_bump","_opacity"];new _.Matrix4;const V=[];const X=/_LOD(\d+)/;function J(e){let t=e instanceof _.MeshPhysicalMaterial&&0===e.sheen&&0===e.anisotropy;if("MeshLambertMaterial"===e.type||"MeshPhongMaterial"===e.type||t){let t={};(e instanceof _.MeshLambertMaterial||e instanceof _.MeshPhongMaterial||e instanceof _.MeshPhysicalMaterial)&&(t.color=e.color,t.map=e.map,t.bumpMap=e.bumpMap,t.bumpScale=e.bumpScale,t.lightMap=e.lightMap,t.lightMapIntensity=e.lightMapIntensity,t.aoMap=e.aoMap,t.aoMapIntensity=e.aoMapIntensity,t.emissiveMap=e.emissiveMap,t.alphaMap=e.alphaMap,t.envMap=e.envMap,t.envMapRotation=e.envMapRotation,t.wireframe=e.wireframe,t.wireframeLinewidth=e.wireframeLinewidth,t.fog=e.fog,t.opacity=e.opacity,t.transparent=e.transparent,t.side=e.side,t.depthTest=e.depthTest,t.depthWrite=e.depthWrite,t.alphaTest=e.alphaTest,t.displacementMap=e.displacementMap,t.displacementScale=e.displacementScale,t.displacementBias=e.displacementBias);const s=new _.MeshStandardMaterial(t);return s.userData={...e.userData??{}},s.name=e.name,s}return e}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -9,6 +9,7 @@ export interface CustomParamValueResolvers {
9
9
  visualEffect?: (value: unknown) => Promise<unknown> | unknown;
10
10
  prefab?: (value: unknown) => Promise<unknown> | unknown;
11
11
  prefabActor?: (value: unknown) => Promise<unknown> | unknown;
12
+ dataAsset?: (value: unknown) => Promise<unknown> | unknown;
12
13
  sequence?: (value: unknown) => Promise<unknown> | unknown;
13
14
  animationClip?: (value: unknown) => Promise<unknown> | unknown;
14
15
  }
@@ -1,4 +1,4 @@
1
- import{Color as e,Euler as a,Vector2 as r,Vector3 as u,Vector4 as l}from"three";import{Curve2 as t}from"../utils/curve.js";import{SerializedParamType as n}from"./model.js";export function customParamValueNeedsAsyncResolution(e){if(null==e||null==e.value||""===e.value)return!1;if(s(e))return e.value.some(a=>customParamValueNeedsAsyncResolution({type:e.element,value:a}));switch(e.type){case n.Texture:case n.Sampler2DNode:case n.Object3D:case n.Material:case n.AudioBuffer:case n.VisualEffect:case n.Prefab:case n.PrefabActor:case n.Sequence:case n.AnimationClip:return!0;default:return!1}}export function deserializeCustomParamValueSync(c,o={}){if(null==c||null==c.value||""===c.value)return c?.value??null;switch(c.type){case n.Array:return s(c)&&Array.isArray(c.value)?c.value.map(e=>deserializeCustomParamValueSync({type:c.element,value:e},o)):[];case n.Number:case n.FloatNode:return"string"==typeof c.value?parseFloat(c.value):c.value;case n.Boolean:case n.BooleanNode:case n.String:return c.value;case n.Vector2:case n.Vec2Node:return"object"==typeof c.value?Array.isArray(c.value)?(new r).fromArray(c.value):new r(c.value.x,c.value.y):null;case n.Vector3:case n.Vec3Node:return"object"==typeof c.value?Array.isArray(c.value)?(new u).fromArray(c.value):new u(c.value.x,c.value.y,c.value.z):null;case n.Vector4:case n.Vec4Node:return"object"==typeof c.value?Array.isArray(c.value)?(new l).fromArray(c.value):new l(c.value.x,c.value.y,c.value.z,c.value.w):null;case n.Color:case n.RgbNode:return new e(c.value);case n.Euler:return Array.isArray(c.value)?(new a).fromArray(c.value):c.value;case n.BaseActor:return o.actor?.(c.value)??c.value;case n.Curve:return t.decode(c.value);default:return c.value}}export async function deserializeCustomParamValue(e,a={}){if(null==e||null==e.value||""===e.value)return e?.value??null;if(!customParamValueNeedsAsyncResolution(e))return deserializeCustomParamValueSync(e,a);switch(e.type){case n.Array:return s(e)&&Array.isArray(e.value)?Promise.all(e.value.map(r=>deserializeCustomParamValue({type:e.element,value:r},a))):[];case n.Texture:return a.texture?.(e.value)??null;case n.Sampler2DNode:return a.sampler2DNode?.(e.value)??null;case n.Object3D:return a.object3D?.(e.value)??null;case n.Material:return a.material?.(e.value)??null;case n.AudioBuffer:return a.audioBuffer?.(e.value)??null;case n.VisualEffect:return a.visualEffect?.(e.value)??null;case n.Prefab:return a.prefab?.(e.value)??null;case n.PrefabActor:return a.prefabActor?.(e.value)??null;case n.Sequence:return a.sequence?.(e.value)??null;case n.AnimationClip:return a.animationClip?.(e.value)??null;default:return deserializeCustomParamValueSync(e,a)}}function s(e){return e.type===n.Array}/*
1
+ import{Color as e,Euler as a,Vector2 as r,Vector3 as u,Vector4 as t}from"three";import{getParameterDefinitionType as l,isParameterDefinitionAbstract as n}from"../shader/parameter.js";import{Curve2 as s}from"../utils/curve.js";import{SerializedParamType as c}from"./model.js";export function customParamValueNeedsAsyncResolution(e){if(null==e||null==e.value||""===e.value)return!1;if(o(e))return e.value.some(a=>customParamValueNeedsAsyncResolution(i(e,a)));switch(e.type){case c.Texture:case c.Sampler2DNode:case c.Object3D:case c.Material:case c.AudioBuffer:case c.VisualEffect:case c.Prefab:case c.PrefabActor:case c.DataAsset:case c.Sequence:case c.AnimationClip:return!0;case c.Struct:return Object.values(f(e.value)).some(e=>customParamValueNeedsAsyncResolution(e));default:return!1}}export function deserializeCustomParamValueSync(l,n={}){if(null==l||null==l.value||""===l.value)return l?.value??null;switch(l.type){case c.Array:return o(l)&&Array.isArray(l.value)?l.value.map(e=>deserializeCustomParamValueSync(i(l,e),n)):[];case c.Number:case c.FloatNode:return"string"==typeof l.value?parseFloat(l.value):l.value;case c.Boolean:case c.BooleanNode:case c.String:return l.value;case c.Vector2:case c.Vec2Node:return"object"==typeof l.value?Array.isArray(l.value)?(new r).fromArray(l.value):new r(l.value.x,l.value.y):null;case c.Vector3:case c.Vec3Node:return"object"==typeof l.value?Array.isArray(l.value)?(new u).fromArray(l.value):new u(l.value.x,l.value.y,l.value.z):null;case c.Vector4:case c.Vec4Node:return"object"==typeof l.value?Array.isArray(l.value)?(new t).fromArray(l.value):new t(l.value.x,l.value.y,l.value.z,l.value.w):null;case c.Color:case c.RgbNode:return new e(l.value);case c.Euler:return Array.isArray(l.value)?(new a).fromArray(l.value):l.value;case c.BaseActor:return n.actor?.(l.value)??l.value;case c.Curve:return s.decode(l.value);case c.Struct:return function(e,a){const r=m(e.value),u=v(r?.struct??e.struct);for(const[t,l]of Object.entries(r?.value??f(e.value)))u[t]=deserializeCustomParamValueSync(l,a);return u}(l,n);default:return l.value}}export async function deserializeCustomParamValue(e,a={}){if(null==e||null==e.value||""===e.value)return e?.value??null;if(!customParamValueNeedsAsyncResolution(e))return deserializeCustomParamValueSync(e,a);switch(e.type){case c.Array:return o(e)&&Array.isArray(e.value)?Promise.all(e.value.map(r=>deserializeCustomParamValue(i(e,r),a))):[];case c.Texture:return a.texture?.(e.value)??null;case c.Sampler2DNode:return a.sampler2DNode?.(e.value)??null;case c.Object3D:return a.object3D?.(e.value)??null;case c.Material:return a.material?.(e.value)??null;case c.AudioBuffer:return a.audioBuffer?.(e.value)??null;case c.VisualEffect:return a.visualEffect?.(e.value)??null;case c.Prefab:return a.prefab?.(e.value)??null;case c.PrefabActor:return a.prefabActor?.(e.value)??null;case c.DataAsset:return a.dataAsset?.(e.value)??null;case c.Sequence:return a.sequence?.(e.value)??null;case c.AnimationClip:return a.animationClip?.(e.value)??null;case c.Struct:return async function(e,a){const r=m(e.value),u=v(r?.struct??e.struct);for(const[t,l]of Object.entries(r?.value??f(e.value)))u[t]=await deserializeCustomParamValue(l,a);return u}(e,a);default:return deserializeCustomParamValueSync(e,a)}}function o(e){return e.type===c.Array}function i(e,a){const r=m(a);return{type:e.element,...null!=r?.struct||null!=e.elementStruct?{struct:r?.struct??e.elementStruct}:{},value:r?.value??a}}function v(e){const a=null!=e?l(e):void 0;if(null==a||n(e))return{};try{return new a}catch{return{}}}function f(e){const a=m(e);return null!=a?a.value:y(e)?e:null!=e&&"object"==typeof e&&y(e.params)?e.params:{}}function m(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.struct&&y(e.value)?e:null}function y(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&Object.values(e).every(e=>null!=e&&"object"==typeof e&&"type"in e)}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,8 +1,10 @@
1
- import type { ParameterType, PropertyParameter } from '../shader/parameter.js';
1
+ import { type ParameterType, type PropertyParameter } from '../shader/parameter.js';
2
2
  import { CustomParamValue, SerializedParamType } from './model.js';
3
3
  export interface RuntimeSerializedParamTypeHint {
4
4
  type: SerializedParamType;
5
5
  element?: SerializedParamType;
6
+ struct?: string;
7
+ elementStruct?: string;
6
8
  }
7
9
  export interface RuntimeParamConversionSkip {
8
10
  key: string;
@@ -1,4 +1,4 @@
1
- import{Color as e,Euler as r,Material as t,Object3D as n,Texture as o,Vector2 as u,Vector3 as a,Vector4 as l,AnimationClip as c}from"three";import{BooleanNode as i,FloatNode as s,RgbNode as f,Sampler2DNode as y,Texture2dLookupNode as p,Vec2Node as m,Vec3Node as d,Vec4Node as b}from"three-shader-graph";import{Curve2 as A}from"../utils/curve.js";import{SerializedParamType as g}from"./model.js";export const applyRuntimeParamTypeInference=!0;export function convertConfiguredParamsToRuntimeTypes(e,r={}){const t={},n=[],o=Object.entries(e),u=r.applyRuntimeParamTypeInference??true;if(0===o.length||!u)return u?{params:t,skipped:n}:{params:e,skipped:n};const a=getRuntimeParameterTypeHints(e,r);for(const[e,r]of o){if(!1===r.override){t[e]=r;continue}const o=a.get(e),u=null!=o?convertConfiguredParamValueToRuntimeType(r,o):r;null!=u?t[e]=u:n.push({key:e,sourceType:r.type,targetType:o.type})}return{params:t,skipped:n}}export function getRuntimeParameterTypeHints(e,r={}){const t=new Map,n=Object.keys(e).filter(r=>!1!==e[r]?.override);if(0===n.length)return t;const o=new Set(n),u=r.parameterTarget??function(e){if(null==e)return null;try{return new e}catch{return null}}(r.parameterType),a=function(e,r){if(null!=r.propertyParams)return r.propertyParams;if(null==r.extractPropertyParameters)return[];if(null!=r.parameterType)return v(r.parameterType,r.extractPropertyParameters);if(null!=e)return v(e.constructor,r.extractPropertyParameters);return[]}(u,r);for(const e of a){if(!o.has(e.name))continue;const n=S(e,r.toSerializedParamType);null!=n&&t.set(e.name,n);const a=inferRuntimeSerializedParamTypeHint(T(u,e.name))??inferRuntimeSerializedParamTypeHint(e.options.defaultValue);null!=a&&t.set(e.name,C(a,n))}if(null!=u)for(const e of n){const r=inferRuntimeSerializedParamTypeHint(T(u,e));if(null!=r){const n=t.get(e);t.set(e,C(r,n))}}return t}const N=new WeakMap,V=new WeakMap,P=Symbol("noCachedSerializedParamType");function v(e,r){let t=N.get(r);null==t&&(t=new WeakMap,N.set(r,t));const n=t.get(e);if(null!=n)return n;const o=function(e,r){try{return r(e)}catch{return[]}}(e,r);return t.set(e,o),o}function T(e,r){return null!=e?e[r]:void 0}function S(e,r){const t=function(e,r){if(null==e||null==r)return;const t=function(e,r){const t=V.get(r);if(null==t||!t.has(e))return P;const n=t.get(e);return null===n?void 0:n}(e,r);if(t!==P)return t;try{const t=r(e);return h(e,r,t),t}catch{return void h(e,r,void 0)}}(e.type,r);return!0===e.options.array?{type:g.Array,...null!=t?{element:t}:{}}:null!=t?{type:t}:void 0}function h(e,r,t){let n=V.get(r);null==n&&(n=new WeakMap,V.set(r,n)),n.set(e,t??null)}function C(e,r){return e.type!==g.Array?e:{type:g.Array,element:e.element??r?.element}}export function inferRuntimeSerializedParamTypeHint(N){if(null==N)return;if(Array.isArray(N)){const e=N.map(e=>inferRuntimeSerializedParamTypeHint(e)).find(e=>null!=e);return{type:g.Array,...null!=e&&e.type!==g.Array?{element:e.type}:{}}}switch(typeof N){case"number":return{type:g.Number};case"boolean":return{type:g.Boolean};case"string":return{type:g.String}}const V=function(e){const r=e;if(e instanceof s||"function"==typeof r?.isFloat||!0===r?.isFloat)return g.FloatNode;if(e instanceof i||"function"==typeof r?.isBool||!0===r?.isBool)return g.BooleanNode;if(e instanceof f||"function"==typeof r?.isRgb||!0===r?.isRgb)return g.RgbNode;if(e instanceof m||"function"==typeof r?.isVec2||!0===r?.isVec2)return g.Vec2Node;if(e instanceof d||"function"==typeof r?.isVec3||!0===r?.isVec3)return g.Vec3Node;if(e instanceof b||"function"==typeof r?.isVec4||!0===r?.isVec4)return g.Vec4Node;if(e instanceof y||e instanceof p||"function"==typeof r?.isSampler2D||!0===r?.isSampler2D)return g.Sampler2DNode;return}(N);return null!=V?{type:V}:N instanceof u?{type:g.Vector2}:N instanceof a?{type:g.Vector3}:N instanceof l?{type:g.Vector4}:N instanceof e?{type:g.Color}:N instanceof r?{type:g.Euler}:N instanceof o?{type:g.Texture}:N instanceof t?{type:g.Material}:N instanceof n?{type:g.Object3D}:"undefined"!=typeof AudioBuffer&&N instanceof AudioBuffer?{type:g.AudioBuffer}:L(N,"VisualEffect")?{type:g.VisualEffect}:L(N,"PrefabOf")?{type:g.PrefabActor}:L(N,"Prefab")?{type:g.Prefab}:N instanceof A?{type:g.Curve}:L(N,"ColorLayer")?{type:g.ColorLayer}:L(N,"MaskLayer")?{type:g.MaskLayer}:N instanceof c?{type:g.AnimationClip}:L(N,"Sequence")?{type:g.Sequence}:void 0}export function convertConfiguredParamValueToRuntimeType(e,r){if(null==e||null==r)return e;if(e.type===g.Array||r.type===g.Array)return function(e,r){if(r.type===g.Array){const t=w(e),n=r.element??(t?e.element:e.type);if(null==n)return t?e:null;const o=t?e.element:e.type,u=(t?Array.isArray(e.value)?e.value:[]:[e.value]).map(e=>x(e,o,n));return u.some(e=>e===R)?null:{...e,type:g.Array,element:n,value:u}}if(!w(e))return null;const t=Array.isArray(e.value)?e.value[0]:void 0;if(null==t)return null;const n=x(t,e.element,r.type);if(n===R)return null;return{...e,type:r.type,value:n}}(e,r);const t=x(e.value,e.type,r.type);return t===R?null:{...e,type:r.type,value:t}}function w(e){return e.type===g.Array}const R=Symbol("skippedParamValue");function x(e,r,t){if(function(e,r){if(e===r)return!0;const t=k(e);return null!=t&&t===k(r)}(r,t)&&function(e,r){switch(r){case g.Number:case g.FloatNode:return"number"==typeof e||"string"==typeof e&&Number.isFinite(parseFloat(e));case g.Boolean:case g.BooleanNode:return"boolean"==typeof e;case g.Vector2:case g.Vec2Node:return B(e,2);case g.Vector3:case g.Vec3Node:return B(e,3);case g.Vector4:case g.Vec4Node:return B(e,4);case g.Euler:return Array.isArray(e)&&e.length>=3&&null!=z(e,3);case g.Color:case g.RgbNode:return null!=D(e);case g.String:return"string"==typeof e;case g.Array:return Array.isArray(e);case g.Texture:case g.Sampler2DNode:case g.BaseActor:case g.Object3D:case g.Material:case g.AudioBuffer:case g.VisualEffect:case g.Prefab:case g.PrefabActor:case g.AnimationClip:case g.Sequence:return null==e||"string"==typeof e||"object"==typeof e;case g.Curve:case g.ColorLayer:case g.MaskLayer:return null!=e}return!0}(e,t))return e;switch(t){case g.Number:case g.FloatNode:{const r=j(e);return null!=r?r:R}case g.Boolean:case g.BooleanNode:{const r=function(e){if("boolean"==typeof e)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){const r=e.trim().toLowerCase();if(["true","1","yes","on"].includes(r))return!0;if(["false","0","no","off"].includes(r))return!1}return null}(e);return null!=r?r:R}case g.Vector2:case g.Vec2Node:return M(e,2,r)??R;case g.Vector3:case g.Vec3Node:return M(e,3,r)??R;case g.Vector4:case g.Vec4Node:return M(e,4,r)??R;case g.Color:case g.RgbNode:return function(e,r){if(r===g.Color||r===g.RgbNode)return"string"==typeof e||"number"==typeof e?e:F(e);return F(e)}(e,r)??R;case g.Euler:return function(e,r){if(Array.isArray(e)){const r=z(e,3);if(null==r)return null;const t="string"==typeof e[3]?e[3]:"XYZ";return[r[0],r[1],r[2],t]}const t=M(e,3,r);return null!=t?[t[0],t[1],t[2],"XYZ"]:null}(e,r)??R;case g.String:return"string"==typeof e?e:String(e);case g.Texture:case g.Sampler2DNode:case g.BaseActor:case g.Object3D:case g.Material:case g.AudioBuffer:case g.VisualEffect:case g.Curve:case g.ColorLayer:case g.MaskLayer:case g.Prefab:case g.PrefabActor:case g.AnimationClip:case g.Sequence:return R}return R}function B(e,r){if(Array.isArray(e))return e.length>=r&&null!=z(e,r);if(null!=e&&"object"==typeof e){const t=e;return["x","y","z","w"].slice(0,r).every(e=>null!=j(t[e]))}return!1}function k(e){switch(e){case g.Number:case g.FloatNode:return"number";case g.Boolean:case g.BooleanNode:return"boolean";case g.Vector2:case g.Vec2Node:return"vector2";case g.Vector3:case g.Vec3Node:return"vector3";case g.Vector4:case g.Vec4Node:return"vector4";case g.Color:case g.RgbNode:return"color";case g.Texture:case g.Sampler2DNode:return"texture";case g.Prefab:case g.PrefabActor:return"prefab"}}function j(e){if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e){const r=parseFloat(e);return Number.isFinite(r)?r:null}if("boolean"==typeof e)return e?1:0;if(Array.isArray(e))return j(e[0]);if(null!=e&&"object"==typeof e){const r=e;return j(r.x??r.r??r.value)}return null}function M(e,r,t){if(t===g.Color||t===g.RgbNode){const t=D(e);if(null!=t)return z(t.toArray(),r,4===r?1:0)}if(Array.isArray(e))return z(e,r);if("number"==typeof e||"string"==typeof e||"boolean"==typeof e){const t=j(e);return null!=t?new Array(r).fill(t):null}if(null!=e&&"object"==typeof e){const t=e,n=["x","y","z","w"].slice(0,r).map(e=>t[e]);if(n.some(e=>null!=e))return z(n,r);const o=["r","g","b","a"].slice(0,r).map(e=>t[e]);if(o.some(e=>null!=e))return z(o,r,4===r?1:0)}return null}function z(e,r,t=0){const n=[];for(let o=0;o<r;o++){const r=j(e[o]??t);if(null==r)return null;n.push(r)}return n}function F(e){const r=D(e);return null!=r?"#"+r.getHexString():null}function D(r){try{if(r instanceof e)return r.clone();if("string"==typeof r)return function(e){return/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e.trim())||/^(rgb|hsl)a?\(/i.test(e.trim())}(r)?new e(r):null;if("number"==typeof r)return Number.isInteger(r)&&r>=0?new e(r):null;if(Array.isArray(r)){const t=z(r,3);return null!=t?(new e).fromArray(t):null}if(null!=r&&"object"==typeof r){const t=r;if(null!=t.r||null!=t.g||null!=t.b){const r=z([t.r,t.g,t.b],3);return null!=r?(new e).fromArray(r):null}if(null!=t.x||null!=t.y||null!=t.z){const r=z([t.x,t.y,t.z],3);return null!=r?(new e).fromArray(r):null}}}catch{return null}return null}function L(e,r){return null!=e&&"object"==typeof e&&e.constructor?.name===r}/*
1
+ import{Color as e,Euler as r,Material as t,Object3D as n,Texture as u,Vector2 as o,Vector3 as a,Vector4 as c,AnimationClip as l}from"three";import{BooleanNode as i,FloatNode as s,RgbNode as f,Sampler2DNode as y,Texture2dLookupNode as p,Vec2Node as m,Vec3Node as d,Vec4Node as b}from"three-shader-graph";import{getParameterDefinitionId as A,getParameterDefinitionType as g,isParameterDefinitionStructAssignableTo as S}from"../shader/parameter.js";import{Curve2 as N}from"../utils/curve.js";import{SerializedParamType as V}from"./model.js";export const applyRuntimeParamTypeInference=!0;export function convertConfiguredParamsToRuntimeTypes(e,r={}){const t={},n=[],u=Object.entries(e),o=r.applyRuntimeParamTypeInference??true;if(0===u.length||!o)return o?{params:t,skipped:n}:{params:e,skipped:n};const a=getRuntimeParameterTypeHints(e,r);for(const[e,r]of u){if(!1===r.override){t[e]=r;continue}const u=a.get(e),o=null!=u?convertConfiguredParamValueToRuntimeType(r,u):r;null!=o?t[e]=o:n.push({key:e,sourceType:r.type,targetType:u.type})}return{params:t,skipped:n}}export function getRuntimeParameterTypeHints(e,r={}){const t=new Map,n=Object.keys(e).filter(r=>!1!==e[r]?.override);if(0===n.length)return t;const u=new Set(n),o=r.parameterTarget??function(e){if(null==e)return null;try{return new e}catch{return null}}(r.parameterType),a=function(e,r){if(null!=r.propertyParams)return r.propertyParams;if(null==r.extractPropertyParameters)return[];if(null!=r.parameterType)return h(r.parameterType,r.extractPropertyParameters);if(null!=e)return h(e.constructor,r.extractPropertyParameters);return[]}(o,r);for(const e of a){if(!u.has(e.name))continue;const n=R(e,r.toSerializedParamType);null!=n&&t.set(e.name,n);const a=inferRuntimeSerializedParamTypeHint(C(o,e.name))??inferRuntimeSerializedParamTypeHint(e.options.defaultValue);null!=a&&t.set(e.name,x(a,n))}if(null!=o)for(const e of n){const r=inferRuntimeSerializedParamTypeHint(C(o,e));if(null!=r){const n=t.get(e);t.set(e,x(r,n))}}return t}const v=new WeakMap,P=new WeakMap,T=Symbol("noCachedSerializedParamType");function h(e,r){let t=v.get(r);null==t&&(t=new WeakMap,v.set(r,t));const n=t.get(e);if(null!=n)return n;const u=function(e,r){try{return r(e)}catch{return[]}}(e,r);return t.set(e,u),u}function C(e,r){return null!=e?e[r]:void 0}function R(e,r){const t=function(e,r){if(null==e||null==r)return;const t=function(e,r){const t=P.get(r);if(null==t||!t.has(e))return T;const n=t.get(e);return null===n?void 0:n}(e,r);if(t!==T)return t;try{const t=r(e);return w(e,r,t),t}catch{return void w(e,r,void 0)}}(e.type,r),n=t===V.Struct?A(e.type):void 0;return!0===e.options.array?{type:V.Array,...null!=t?{element:t}:{},...null!=n?{elementStruct:n}:{}}:null!=t?{type:t,...null!=n?{struct:n}:{}}:void 0}function w(e,r,t){let n=P.get(r);null==n&&(n=new WeakMap,P.set(r,n)),n.set(e,t??null)}function x(e,r){return e.type!==V.Array?e:{type:V.Array,element:e.element??r?.element,elementStruct:e.elementStruct??r?.elementStruct}}export function inferRuntimeSerializedParamTypeHint(g){if(null==g)return;if(Array.isArray(g)){const e=g.map(e=>inferRuntimeSerializedParamTypeHint(e)).find(e=>null!=e);return{type:V.Array,...null!=e&&e.type!==V.Array?{element:e.type}:{},...null!=e?.struct?{elementStruct:e.struct}:{}}}switch(typeof g){case"number":return{type:V.Number};case"boolean":return{type:V.Boolean};case"string":return{type:V.String}}const S=function(e){const r=e;if(e instanceof s||"function"==typeof r?.isFloat||!0===r?.isFloat)return V.FloatNode;if(e instanceof i||"function"==typeof r?.isBool||!0===r?.isBool)return V.BooleanNode;if(e instanceof f||"function"==typeof r?.isRgb||!0===r?.isRgb)return V.RgbNode;if(e instanceof m||"function"==typeof r?.isVec2||!0===r?.isVec2)return V.Vec2Node;if(e instanceof d||"function"==typeof r?.isVec3||!0===r?.isVec3)return V.Vec3Node;if(e instanceof b||"function"==typeof r?.isVec4||!0===r?.isVec4)return V.Vec4Node;if(e instanceof y||e instanceof p||"function"==typeof r?.isSampler2D||!0===r?.isSampler2D)return V.Sampler2DNode;return}(g);if(null!=S)return{type:S};if(g instanceof o)return{type:V.Vector2};if(g instanceof a)return{type:V.Vector3};if(g instanceof c)return{type:V.Vector4};if(g instanceof e)return{type:V.Color};if(g instanceof r)return{type:V.Euler};if(g instanceof u)return{type:V.Texture};if(g instanceof t)return{type:V.Material};if(g instanceof n)return{type:V.Object3D};if("undefined"!=typeof AudioBuffer&&g instanceof AudioBuffer)return{type:V.AudioBuffer};if(W(g,"VisualEffect"))return{type:V.VisualEffect};if(W(g,"PrefabOf"))return{type:V.PrefabActor};if(W(g,"Prefab"))return{type:V.Prefab};if(W(g,"DataAssetRef"))return{type:V.DataAsset};if(g instanceof N)return{type:V.Curve};if(W(g,"ColorLayer"))return{type:V.ColorLayer};if(W(g,"MaskLayer"))return{type:V.MaskLayer};if(g instanceof l)return{type:V.AnimationClip};if(W(g,"Sequence"))return{type:V.Sequence};const v=A(g.constructor);return null!=v?{type:V.Struct,struct:v}:void 0}export function convertConfiguredParamValueToRuntimeType(e,r){if(null==e||null==r)return e;if(e.type===V.Array||r.type===V.Array)return function(e,r){if(r.type===V.Array){const t=B(e),n=r.element??(t?e.element:e.type);if(null==n)return t?e:null;const u=t?e.element:e.type,o=(t?Array.isArray(e.value)?e.value:[]:[e.value]).map(e=>M(e,u,n));return o.some(e=>e===D)?null:{...e,type:V.Array,element:n,...k(e,r),value:o}}if(!B(e))return null;const t=Array.isArray(e.value)?e.value[0]:void 0;if(null==t)return null;const n=M(t,e.element,r.type);if(n===D)return null;return{...e,type:r.type,...j(e,r),value:n}}(e,r);const t=M(e.value,e.type,r.type);return t===D?null:{...e,type:r.type,...j(e,r),value:t}}function B(e){return e.type===V.Array}function j(e,r){if(r.type!==V.Struct&&e.type!==V.Struct)return{};const t=function(e,r){if(null==r)return e;if(null==e)return r;if(e===r||S(e,r))return e;const t=g(e),n=g(r);if(null==t||null==n)return e;return r}(e.type===V.Struct?e.struct:void 0,r.struct);return null!=t?{struct:t}:{}}function k(e,r){if(r.type!==V.Array)return{};const t=B(e)?e.elementStruct:void 0,n=r.elementStruct??t;return null!=n?{elementStruct:n}:{}}const D=Symbol("skippedParamValue");function M(e,r,t){if(function(e,r){if(e===r)return!0;const t=F(e);return null!=t&&t===F(r)}(r,t)&&function(e,r){switch(r){case V.Number:case V.FloatNode:return"number"==typeof e||"string"==typeof e&&Number.isFinite(parseFloat(e));case V.Boolean:case V.BooleanNode:return"boolean"==typeof e;case V.Vector2:case V.Vec2Node:return z(e,2);case V.Vector3:case V.Vec3Node:return z(e,3);case V.Vector4:case V.Vec4Node:return z(e,4);case V.Euler:return Array.isArray(e)&&e.length>=3&&null!=E(e,3);case V.Color:case V.RgbNode:return null!=q(e);case V.String:return"string"==typeof e;case V.Array:return Array.isArray(e);case V.Texture:case V.Sampler2DNode:case V.BaseActor:case V.Object3D:case V.Material:case V.AudioBuffer:case V.VisualEffect:case V.Prefab:case V.PrefabActor:case V.DataAsset:case V.AnimationClip:case V.Sequence:return null==e||"string"==typeof e||"object"==typeof e;case V.Struct:return null!=e&&"object"==typeof e&&!Array.isArray(e);case V.Curve:case V.ColorLayer:case V.MaskLayer:return null!=e}return!0}(e,t))return e;switch(t){case V.Number:case V.FloatNode:{const r=L(e);return null!=r?r:D}case V.Boolean:case V.BooleanNode:{const r=function(e){if("boolean"==typeof e)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){const r=e.trim().toLowerCase();if(["true","1","yes","on"].includes(r))return!0;if(["false","0","no","off"].includes(r))return!1}return null}(e);return null!=r?r:D}case V.Vector2:case V.Vec2Node:return H(e,2,r)??D;case V.Vector3:case V.Vec3Node:return H(e,3,r)??D;case V.Vector4:case V.Vec4Node:return H(e,4,r)??D;case V.Color:case V.RgbNode:return function(e,r){if(r===V.Color||r===V.RgbNode)return"string"==typeof e||"number"==typeof e?e:O(e);return O(e)}(e,r)??D;case V.Euler:return function(e,r){if(Array.isArray(e)){const r=E(e,3);if(null==r)return null;const t="string"==typeof e[3]?e[3]:"XYZ";return[r[0],r[1],r[2],t]}const t=H(e,3,r);return null!=t?[t[0],t[1],t[2],"XYZ"]:null}(e,r)??D;case V.String:return"string"==typeof e?e:String(e);case V.Texture:case V.Sampler2DNode:case V.BaseActor:case V.Object3D:case V.Material:case V.AudioBuffer:case V.VisualEffect:case V.Curve:case V.ColorLayer:case V.MaskLayer:case V.Prefab:case V.PrefabActor:case V.DataAsset:case V.AnimationClip:case V.Sequence:case V.Struct:return D}return D}function z(e,r){if(Array.isArray(e))return e.length>=r&&null!=E(e,r);if(null!=e&&"object"==typeof e){const t=e;return["x","y","z","w"].slice(0,r).every(e=>null!=L(t[e]))}return!1}function F(e){switch(e){case V.Number:case V.FloatNode:return"number";case V.Boolean:case V.BooleanNode:return"boolean";case V.Vector2:case V.Vec2Node:return"vector2";case V.Vector3:case V.Vec3Node:return"vector3";case V.Vector4:case V.Vec4Node:return"vector4";case V.Color:case V.RgbNode:return"color";case V.Texture:case V.Sampler2DNode:return"texture";case V.Prefab:case V.PrefabActor:return"prefab";case V.DataAsset:return"dataAsset";case V.Struct:return"struct"}}function L(e){if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e){const r=parseFloat(e);return Number.isFinite(r)?r:null}if("boolean"==typeof e)return e?1:0;if(Array.isArray(e))return L(e[0]);if(null!=e&&"object"==typeof e){const r=e;return L(r.x??r.r??r.value)}return null}function H(e,r,t){if(t===V.Color||t===V.RgbNode){const t=q(e);if(null!=t)return E(t.toArray(),r,4===r?1:0)}if(Array.isArray(e))return E(e,r);if("number"==typeof e||"string"==typeof e||"boolean"==typeof e){const t=L(e);return null!=t?new Array(r).fill(t):null}if(null!=e&&"object"==typeof e){const t=e,n=["x","y","z","w"].slice(0,r).map(e=>t[e]);if(n.some(e=>null!=e))return E(n,r);const u=["r","g","b","a"].slice(0,r).map(e=>t[e]);if(u.some(e=>null!=e))return E(u,r,4===r?1:0)}return null}function E(e,r,t=0){const n=[];for(let u=0;u<r;u++){const r=L(e[u]??t);if(null==r)return null;n.push(r)}return n}function O(e){const r=q(e);return null!=r?"#"+r.getHexString():null}function q(r){try{if(r instanceof e)return r.clone();if("string"==typeof r)return function(e){return/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e.trim())||/^(rgb|hsl)a?\(/i.test(e.trim())}(r)?new e(r):null;if("number"==typeof r)return Number.isInteger(r)&&r>=0?new e(r):null;if(Array.isArray(r)){const t=E(r,3);return null!=t?(new e).fromArray(t):null}if(null!=r&&"object"==typeof r){const t=r;if(null!=t.r||null!=t.g||null!=t.b){const r=E([t.r,t.g,t.b],3);return null!=r?(new e).fromArray(r):null}if(null!=t.x||null!=t.y||null!=t.z){const r=E([t.x,t.y,t.z],3);return null!=r?(new e).fromArray(r):null}}}catch{return null}return null}function W(e,r){return null!=e&&"object"==typeof e&&e.constructor?.name===r}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{Group as e,Mesh as a}from"three";import{Color as r}from"three";import{varyingAttributes as t,float as n,mod as o,dot as c,vec2 as s,step as i,fract as l,mix as p,rgb as d,NodeShaderMaterial as u,rgba as f,standardMaterial as m,attributeFloat as x,RgbNode as S,varying as h}from"three-shader-graph";import{mixColorsByLayer as L,select as g}from"../../shader-nodes/index.js";export function initLandscape(e){e.sections.y,e.sectionSize,e.sections.x,e.sectionSize;return new LandscapeGroup}export function createLandscapeDefaultMaterial(e=!0,a=1){const S=t.uv.multiplyScalar(a),g=n(10),w=n(7),y=o(c(s(1,1),i(s(.5,.5),l(S.multiplyScalar(g)))),n(2)),v=o(c(s(1,1),i(s(.5,.5),l(S.multiplyScalar(w.multiply(g))))),n(2)),D=p(d("#"+new r(4473924).convertLinearToSRGB().getHexString()),d("#"+new r(5592405).convertLinearToSRGB().getHexString()),y),G=p(D,D.addScalar(n(.1)),v),M=L({layerColors:[f(G).rgb,...["#f3cc91","#e9a135","#f4a4a6","#ef767a","#e6373d","#55DDE0","#33658A","#2F4858"].map(e=>"#"+new r(e).convertLinearToSRGB().getHexString()).map(e=>d(e)).reverse()],enableNoise:!1}),B=x("hole"),H=new u({color:m({color:e?M:G}),discard:h(B).gt(.5)});return H.color=new r("#aaaaaa"),H.name="Default",H}export const defaultLandscapeMaterial=createLandscapeDefaultMaterial();export class LandscapeMesh extends a{}export class LandscapeGroup extends e{get sections(){return this.children.filter(e=>e instanceof LandscapeMesh)}}/*
1
+ import{Group as e,Mesh as a}from"three";import{Color as r}from"three";import{varyingAttributes as t,float as n,mod as o,dot as c,vec2 as s,step as i,fract as l,mix as p,rgb as d,NodeShaderMaterial as u,rgba as f,standardMaterial as m,attributeFloat as x,RgbNode as S,varying as h}from"three-shader-graph";import{mixColorsByLayer as L,select as g}from"../../shader-nodes/index.js";export function initLandscape(e){e.sections.y,e.sectionSize,e.sections.x,e.sectionSize;return new LandscapeGroup}export function createLandscapeDefaultMaterial(e=!0,a=1){const S=t.uv.multiplyScalar(a),g=n(10),w=n(7),y=o(c(s(1,1),i(s(.5,.5),l(S.multiplyScalar(g)))),n(2)),v=o(c(s(1,1),i(s(.5,.5),l(S.multiplyScalar(w.multiply(g))))),n(2)),D=p(d("#"+new r(4473924).convertLinearToSRGB().getHexString()),d("#"+new r(5592405).convertLinearToSRGB().getHexString()),y),G=p(D,D.addScalar(n(.1)),v),M=L({layerColors:[f(G).rgb,...["#f3cc91","#e9a135","#f4a4a6","#ef767a","#e6373d","#55DDE0","#33658A","#2F4858"].map(e=>"#"+new r(e).convertLinearToSRGB().getHexString()).map(e=>d(e)).reverse()],enableNoise:!1}),B=x("hole"),H=new u({color:m({color:e?M:G,specular:!1}),discard:h(B).gt(.5)});return H.color=new r("#aaaaaa"),H.name="Default",H}export const defaultLandscapeMaterial=createLandscapeDefaultMaterial();export class LandscapeMesh extends a{}export class LandscapeGroup extends e{get sections(){return this.children.filter(e=>e instanceof LandscapeMesh)}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -2,6 +2,7 @@ import { Subject } from "rxjs";
2
2
  import * as THREE from "three";
3
3
  import { Euler, Material, Object3D, Scene, Vector3 } from "three";
4
4
  import { ContainerInstance } from 'typedi';
5
+ import { DataAssetRef } from './objects/data-asset.js';
5
6
  import { GameComponent } from '../game-component/game-component.js';
6
7
  import { BaseActor } from '../gameplay/actors/actor.js';
7
8
  import { ActorComponent } from '../gameplay/actors/component.js';
@@ -504,9 +505,21 @@ export declare function prepareShapeParameters(paramsSource: {
504
505
  }, assetProvider?: AssetsProvider, assetManagerService?: AssetResourceLoader): Promise<{
505
506
  [key: string]: unknown;
506
507
  }>;
507
- export declare function toSerializedParamType(type: Type<any>): SerializedParamType;
508
- export declare function prepareCustomParams<T>(propertyParams: PropertyParameter[], previous: Record<string, CustomParamValue>, defaults?: Record<string, unknown>): Record<string, CustomParamValue>;
509
- export declare function prepareCustomParamsFromType<T>(type: Type<T>, previous: Record<string, CustomParamValue>, diContainer?: ContainerInstance): Record<string, CustomParamValue>;
508
+ export declare function materializeDataAssetRef<T = unknown>(value: unknown, assetsService: AssetsProvider, assetManagerService: AssetResourceLoader, actors?: Map<SceneObjectId, BaseActor>, renderingView?: RenderingView, shaders?: ShaderImpl[], actorProvider?: ActorProvider, prefabResolver?: (prefabInstanceId: string) => string | null): Promise<DataAssetRef<T> | null>;
509
+ export declare function toSerializedParamType(type: ParameterType): SerializedParamType;
510
+ export type PrepareCustomParamsOptions = {
511
+ treatAllAsOptional?: boolean;
512
+ missingOverrideDefaultsToOverride?: boolean;
513
+ };
514
+ export type CustomParamTypeInfo = {
515
+ type: SerializedParamType;
516
+ element?: SerializedParamType;
517
+ struct?: string;
518
+ elementStruct?: string;
519
+ };
520
+ export declare function getCustomParamTypeInfo(param: PropertyParameter): CustomParamTypeInfo;
521
+ export declare function prepareCustomParams<T>(propertyParams: PropertyParameter[], previous: Record<string, CustomParamValue>, defaults?: Record<string, unknown>, options?: PrepareCustomParamsOptions): Record<string, CustomParamValue>;
522
+ export declare function prepareCustomParamsFromType<T>(type: Type<T>, previous: Record<string, CustomParamValue>, diContainer?: ContainerInstance, options?: PrepareCustomParamsOptions): Record<string, CustomParamValue>;
510
523
  /**
511
524
  * Returns a serialized version of a custom parameter's value.
512
525
  * Returns undefined if