@hology/core 0.0.191 → 0.0.193

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 (64) hide show
  1. package/dist/effects/sequence/sequence-actor.d.ts +4 -0
  2. package/dist/effects/sequence/sequence-actor.js +1 -1
  3. package/dist/effects/sequence/sequence-data.d.ts +5 -0
  4. package/dist/effects/sequence/sequence-data.js +1 -1
  5. package/dist/effects/sequence/sequence-player.d.ts +3 -0
  6. package/dist/effects/sequence/sequence-player.js +1 -1
  7. package/dist/effects/vfx/behaviours.d.ts +7 -0
  8. package/dist/effects/vfx/behaviours.js +1 -1
  9. package/dist/effects/vfx/index.d.ts +2 -0
  10. package/dist/effects/vfx/index.js +1 -1
  11. package/dist/effects/vfx/initializsers.d.ts +6 -4
  12. package/dist/effects/vfx/initializsers.js +1 -1
  13. package/dist/effects/vfx/vfx-actor.d.ts +10 -1
  14. package/dist/effects/vfx/vfx-actor.js +1 -1
  15. package/dist/effects/vfx/vfx-asset.d.ts +12 -0
  16. package/dist/effects/vfx/vfx-asset.js +1 -1
  17. package/dist/effects/vfx/vfx-binding-runtime.d.ts +42 -0
  18. package/dist/effects/vfx/vfx-binding-runtime.js +4 -0
  19. package/dist/effects/vfx/vfx-defs.d.ts +58 -3
  20. package/dist/effects/vfx/vfx-defs.js +1 -1
  21. package/dist/effects/vfx/vfx-input-runtime.d.ts +17 -0
  22. package/dist/effects/vfx/vfx-input-runtime.js +4 -0
  23. package/dist/effects/vfx/vfx-materializer.d.ts +2 -1
  24. package/dist/effects/vfx/vfx-materializer.js +1 -1
  25. package/dist/effects/vfx/vfx-param.d.ts +3 -1
  26. package/dist/effects/vfx/vfx-param.js +1 -1
  27. package/dist/effects/vfx/vfx-service.d.ts +6 -2
  28. package/dist/effects/vfx/vfx-service.js +1 -1
  29. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
  30. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  31. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  32. package/dist/gameplay/services/asset-loader.d.ts +3 -0
  33. package/dist/gameplay/services/asset-loader.js +1 -1
  34. package/dist/gameplay/services/physics/physics-system.js +1 -1
  35. package/dist/gameplay/services/render.d.ts +12 -0
  36. package/dist/gameplay/services/render.js +1 -1
  37. package/dist/rendering.d.ts +2 -0
  38. package/dist/rendering.js +1 -1
  39. package/dist/scene/asset-resource-loader.d.ts +1 -0
  40. package/dist/scene/asset-resource-loader.js +1 -1
  41. package/dist/scene/collision/collision-shape-import.js +1 -1
  42. package/dist/scene/collision/collision-shape.d.ts +5 -4
  43. package/dist/scene/collision/collision-shape.js +1 -1
  44. package/dist/scene/materializer.d.ts +4 -0
  45. package/dist/scene/materializer.js +1 -1
  46. package/dist/scene/model.d.ts +53 -2
  47. package/dist/scene/storage/storage.d.ts +6 -1
  48. package/dist/scene/storage/storage.js +1 -1
  49. package/dist/shader/builtin/decal-standard-shader.d.ts +1 -1
  50. package/dist/shader/builtin/lambert-shader.js +1 -1
  51. package/dist/shader/builtin/standard-shader.d.ts +8 -6
  52. package/dist/shader/builtin/standard-shader.js +1 -1
  53. package/dist/shader/builtin/toon-shader.js +1 -1
  54. package/dist/shader/parameter.d.ts +6 -0
  55. package/dist/shader-nodes/time.d.ts +1 -0
  56. package/dist/shader-nodes/time.js +1 -1
  57. package/dist/test/collision-shape-import.test.d.ts +2 -0
  58. package/dist/test/collision-shape-import.test.js +4 -0
  59. package/dist/test/vfx-input-bindings.test.d.ts +2 -0
  60. package/dist/test/vfx-input-bindings.test.js +4 -0
  61. package/dist/utils/obb-utils.d.ts +12 -0
  62. package/dist/utils/obb-utils.js +4 -0
  63. package/package.json +2 -2
  64. 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 r,Matrix4 as n,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as u,WebGLRenderTarget as d,Texture as c,Euler as p,MeshStandardMaterial as m}from"three";import{CopyShader as f,EffectComposer as g,FXAAShader as M,GammaCorrectionShader as v,LUTPass as T,RenderPass as y,ShaderPass as b,VRButton as w}from"three-stdlib";import{CSMShader as x,CSMUtil as P}from"./csm.js";import{colorToNormal as S,float as R,NodeShaderMaterial as C,standardMaterial as A,uniformFloat as U,uniformVec3 as F,toonMaterial as I,lambertMaterial as B,normalize as O,rgb as E,rgba as D,transformed as L,varying as V,varyingAttributes as _,varyingTransformed as j,vec4 as G,BooleanExpression as W,select as q,ifDefApply as k,uniformSampler2d as N,RgbaNode as H,mix as z,attributes as $}from"three-shader-graph";import{Reflector as X}from"three-stdlib";import{BokehPass as Y,OutputPass as Q}from"three/examples/jsm/Addons.js";import{CSM as K}from"three/examples/jsm/csm/CSM.js";import{RectAreaLightUniformsLib as J}from"three/examples/jsm/lights/RectAreaLightUniformsLib.js";import Z from"three/examples/jsm/libs/stats.module.js";import{GTAOPass as ee}from"three/examples/jsm/postprocessing/GTAOPass.js";import{Service as te}from"typedi";import{depthUniformName as se,farUniformName as ie,nearUniformName as ae,resolutionUniformName as re,sceneNormalUniformName as ne,screenUV as oe,supportsDepthTextureExtension as le}from"./shader-nodes/depth.js";import{elapsedTimeUniformName as he}from"./shader-nodes/time.js";import{aoMapUniformName as ue,sceneMapUniformName as de}from"./shader-nodes/scene-sample.js";import{DepthPass as ce}from"./utils/three/depth-pass.js";import{GPUStatsPanel as pe}from"./utils/three/gpu-stats-panel.js";import{OutlinePass as me}from"./utils/three/outline-pass.js";import{findFirstVisibleObject as fe,traverseVisibleStop as ge}from"./utils/three/traverse.js";import{clamp as Me}from"./utils/math.js";import{ColorPass as ve}from"./rendering/color-pass.js";import{SSRPass as Te}from"./rendering/ssr/SSRPass.js";import{SSRShader as ye}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as be}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as we}from"./rendering/outline-effect.js";import{UnrealBloomPass as xe}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as Pe}from"./shader-nodes/depth.js";import{packDepthToRGBA as Se}from"three-shader-graph";import{FogVolumeObject as Re}from"./rendering/fog/fog-volume-object";import{ParallaxStandardMaterial as Ce}from"./shader/builtin/standard-shader.js";import{parallaxOcclusionMapping as Ae}from"./shader-nodes/pom.js";import{FullScreenQuad as Ue}from"three-stdlib";import{edgeDepthEffect as Fe}from"./shader-nodes/effects";import{decalDiscard as Ie}from"./shader-nodes/decal.js";import{Pass as Be}from"three/examples/jsm/Addons.js";P.patchSetupMaterial();const Oe=document.createElement("div");Oe.style.position="absolute",Oe.style.left="50%",Oe.style.top="50%",Oe.style.color="black",Oe.style.zIndex="999";(new i.Layers).set(9);const Ee=new i.MeshBasicMaterial({color:"black"}),De=new i.MeshDepthMaterial;var Le;De.depthPacking=i.RGBADepthPacking,De.blending=i.NoBlending,De.side=i.DoubleSide,function(e){e[e.opaque=0]="opaque",e[e.transparent=1]="transparent"}(Le||(Le={}));const Ve=(()=>{const e=new Uint8Array([255,255,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),_e=(()=>{const e=new Uint8Array([0,0,0,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),je=(()=>{const e=new Uint8Array([128,128,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),Ge=new C({color:R(0),position:G(R(0))});Ge.visible=!1;const We=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let qe=0,ke=null;const Ne=new Map;function He(){return null==ke&&(ke=new IntersectionObserver(e=>{for(const t of e){const e=Ne.get(t.target);e&&e(t.isIntersecting)}},{threshold:0})),ke}let ze=e=class{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.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)}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.postProcessVolumes=[],this.postProcessSettings={},this.csmUpdateInvervals=this.options.shadows?.cascadeUpdateIntervals,this._id=qe++,this.fquadCopy=new Ue(new u(f)),this.fquadCopyOpaque=new Ue(new C({outputs:[N("tSceneColor",new c).sample(_.uv),G(N("tDepthTexture",new i.DepthTexture(1,1)).sample(_.uv).r)]})),this.lightProbeIntensity=2,this.fquadBlendAO=(()=>{const e=G(1),t=new C({outputs:[N("tAO",new c).sample(oe),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Ue(t)})(),this.resolutionScale=1,this.maxPixelRatio=We?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 Z,this._showStats=!0,this.gbufferMaterialCache=new Map,this.tbufferMaterialCache=new Map,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,e.activeView=this,J.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 r=new we(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=r,this.createGRenderTarget(),this.composer=new g(this.renderer),this.composer.setSize(t.clientWidth,t.clientHeight);var n=(t.clientWidth||1)/(t.clientHeight||1);const o=new i.PerspectiveCamera(45,n,.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.renderer.gammaFactor=1.4,P.renderingView=this,this.isDepthTextureExtensionSupported=le(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 y(this.scene,this.camera),new b(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const d=new xe(l,1.5,.4,.85);d.threshold=1,d.strength=.9,d.radius=.5,this.bloomPass=d;const p=new ee(this.scene,this.camera,this.gRenderTarget.width,this.gRenderTarget.height,{});p.normalRenderTarget?.dispose(),p.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),p.output=ee.OUTPUT.Off,p.enabled=!1,this.aoPass=p,this.fquadBlendAO.material.uniforms.tAO.value=p.pdRenderTarget.texture,ye.fragmentShader=ye.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Te({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=Te.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(p);const x=new ot((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(x);const S=new ot((e,t,s,i,a)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(Le.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(S),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new nt(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 be(l),this.composer.addPass(this.volumetricFogPass),this.volumetricFogPass.enabled=!0,this.dofPass=new Y(this.scene,this.camera,{focus:1,aperture:.025,maxblur:.01}),this.dofPass.enabled=!1,this.composer.addPass(this.dofPass);const R=new ve;this.composer.addPass(R),this.colorPass=R,R.vignetteEnabled=!1,this.outlinePass=new me(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 A=new b(M);A.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(A),this.fxaaPass=A,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new b(v).clear=!1,this.fixStatsStyle(),this.lutPass=new T({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const U=new b(f,"prevtexture");U.enabled=!0,U.needsSwap=!1,U.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],U.renderToScreen=!0;const F=new Q;this.composer.addPass(F)}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 y?t.camera=e:t instanceof me?t.renderCamera=e:(t instanceof ce||t instanceof ee)&&(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 K({maxFar:100,lightFar:250,lightMargin:20,cascades:We?2:4,shadowMapSize:2048*(We?.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=x.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)),r=Math.max(1,Math.floor(t.clientHeight*s)),n=new i.WebGLRenderTarget(a,r);return n.texture.minFilter=i.NearestFilter,n.texture.magFilter=i.NearestFilter,n.texture.generateMipmaps=!1,n.stencilBuffer=!1,n.depthTexture=new i.DepthTexture(a,r),n.depthTexture.type=i.UnsignedShortType,n.depthTexture.minFilter=i.NearestFilter,n.depthTexture.magFilter=i.NearestFilter,n}static createAOMaskDepthRenderTarget(e,t){const s=Math.max(1,t.clientWidth*e.getPixelRatio()),a=Math.max(1,t.clientHeight*e.getPixelRatio()),r=new i.DepthTexture(s,a);r.type=i.UnsignedInt248Type,r.minFilter=i.NearestFilter,r.magFilter=i.NearestFilter;const n=new i.WebGLRenderTarget(s,a,{type:i.HalfFloatType,depthTexture:r});return n.texture.minFilter=i.NearestFilter,n.texture.magFilter=i.NearestFilter,n.texture.generateMipmaps=!1,n.stencilBuffer=!1,n}createSceneColorRenderTarget(e,t){const s=this.gRenderTarget.width,a=this.gRenderTarget.height,r=new i.WebGLRenderTarget(s,a,{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return r.texture.minFilter=i.LinearFilter,r.texture.magFilter=i.LinearFilter,r.texture.generateMipmaps=!1,r.textures[1].minFilter=i.NearestFilter,r.textures[1].magFilter=i.NearestFilter,r}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: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(),this.container.replaceChildren();He().unobserve(this.container),Ne.delete(this.container),this.volumetricFogPass.dispose(),P.clearSceneCache(this.scene)}onLoop(e){this.onLoopCallbacks.push(e)}removeOnLoop(e){const t=this.onLoopCallbacks.find(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 C&&(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:tt(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 C||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)&&(t.uniforms.color.value.setFromColor(e.color),t.uniforms.opacity.value=e.opacity,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&&(t.uniforms.roughnessMap.value=e.roughnessMap,t.uniforms.metalnessMap.value=e.metalnessMap,t.uniforms.roughness.value=e.roughness,t.uniforms.metalness.value=e.metalness),e instanceof Ce&&(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===lt.includes(e)&&(t.value=a)}this.updateMaterialCommonProperties(e,t)}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}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of lt){const t=i[e],a=s[e];null!=a&&null!=t&&(t.value=a.value)}}createGBufferMaterial(e,t){const s=t===Le.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let a=s.get(e);if(!0===e.userData.isGBufferMaterial)return e;if(null==a){let n=_.uv;if(e instanceof Ce&&null!=e.heightMap){const t=U("heightScale",e.heightScale??1);n=Ae(n,N("heightMap",e.heightMap),t)}let o=j.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??je,s=U("useNormalMap",null!=e.normalMap?1:0),i=U("normalScale",e.normalScale?.x??1),a=S(N("normalMap",t).sample(n),i);o=z(j.normal,a,s)}else e instanceof C&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=k("DOUBLE_SIDED",o,e=>q(new W("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?R(0):R(1);if(e instanceof i.MeshStandardMaterial){const t=U("roughness",e.roughness??1),s=e.roughnessMap??Ve,i=U("useRoughnessMap",null!=e.roughnessMap?1:0),a=N("roughnessMap",s).sample(n).g.multiply(t);l=z(t,a,i)}else e instanceof C&&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,s=U("useLightMap",null!=e.lightMap?1:0),i=U("lightMapIntensity",e.lightMapIntensity??1),a=N("lightMap",t).sample(n).rgb.multiplyScalar(i);h=z(E(0),a,s)}let d=R(0);if(e instanceof i.MeshStandardMaterial){const t=U("metalness",e.metalness??0),s=e.metalnessMap??_e,i=U("useMetalnessMap",null!=e.metalnessMap?1:0),a=N("metalnessMap",s).sample(n).b.multiply(t);d=z(t,a,i)}else e instanceof C&&e.outputRoughness;let c=null,p=R(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??Ve,s=U("useAoMap",null!=e.aoMap?1:0);p=U("aoMapIntensity",e.aoMapIntensity??1);const i=N("aoMap",t).sample(n).r;c=z(R(1),i,s)}else e instanceof C&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=R(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=N("alphaMap",t).sample(n).r}g=g.multiply(f)}else e instanceof C&&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=F("color",(new i.Vector3).setFromColor(e.color));const s=e.map??Ve,a=U("useAlbedoMap",null!=e.map?1:0),r=N("map",s).sample(n),o=r.multiply(D(t,1)),l=D(t,1);M=z(l,o,a),e.vertexColors&&(M=M.multiply(G(V($.color.rgb),1)));const h=z(R(1),r.w,a);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let T=E(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=F("emissive",(new i.Vector3).setFromColor(e.emissive)),s=U("emissiveIntensity",e.emissiveIntensity),a=e.emissiveMap??_e,r=U("useEmissiveMap",null!=e.emissiveMap?1:0),o=N("emissiveMap",a).sample(n).rgb.multiply(t);T=z(t,o,r),T=T.multiplyScalar(s)}else e instanceof C&&null!=e.outputEmissive&&(T=e.outputEmissive);const y=e instanceof u&&null!=e.uniforms[se],b=e instanceof u&&null!=e.uniforms[de],w=e instanceof u&&null!=e.uniforms[ue],x=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,P=U("alphaTest",e.alphaTest);let L,H=e.alphaTest>0?g.lt(P):x&&t===Le.opaque?g.lt(.8):null;!0===e.userData.isDecal&&(H=H?H.or(Ie):Ie),L=x?G(0,0,0,0):(r=o,O(r).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const X=e instanceof C?e.outputPosition:void 0,Y=e instanceof C?e.outputTransform:void 0;let Q,K=D("black",1);if(e instanceof C&&null!=e.outputColor)K=e.outputColor;else if(e instanceof i.MeshStandardMaterial)K=A({color:M,metalness:d,roughness:l,emissive:T.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)K=B({color:M.rgb,ambientOcclusion:c,ambientOcclusionIntensity:p});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??E("black");null!=c&&(t=t.multiplyScalar(c.subtract(1).multiply(p).add(1))),e=e.add(t),K=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(K=I({color:M,emissive:T.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h}));(e instanceof C||e instanceof i.MeshStandardMaterial)&&(Q=e.envMap);let J=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(J=e.fog);let Z=D(K.rgb,g);J&&(Z=new FogNode(Z));let ee=!0;if(t===Le.opaque?(ee&&(ee=!y&&!b&&!w),ee&&(ee=!x)):t===Le.transparent&&ee&&(ee=x||y||b||w),!ee)return a=Ge,s.set(e,a),a;a=new C({transform:Y,position:null==Y?X:void 0,outputs:[Z,T.rgba(t===Le.opaque?P:v?1:0),L],opacity:g,outputEncoding:!1,fog:J,transparent:e.transparent,lights:!0,envMap:Q,discard:H}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=a.uniforms.envMapIntensity&&(a.uniforms.envMapIntensity.value=e.envMapIntensity),"alphaMap"in e&&null!=e.alphaMap&&(a.alphaMap=e.alphaMap),(e instanceof C||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(a),e instanceof C&&(Object.assign(a.defines,e.defines),null!=a.uniforms[ue]&&(a.uniforms[ue].value=this.aoPass.pdRenderTarget.texture,a.defines.USE_SSAO_MAP="")),a.userData.mrtOutputs=3,a.forceSinglePass=e.forceSinglePass,a.side=e.side,a.blending=e.blending,x?(a.depthWrite=!e.transparent,a.depthTest=e.depthTest,a.colorWrite=t===Le.transparent):(a.depthWrite=e.depthWrite,a.depthTest=e.depthTest),a.visible=e.visible,a.alphaTest=e.alphaTest,a.alphaHash=e.alphaHash,a.vertexColors=e.vertexColors,a.premultipliedAlpha=e.premultipliedAlpha,a.toneMapped=e.toneMapped,a.blendAlpha=e.blendAlpha,a.blendColor=e.blendColor,a.polygonOffset=e.polygonOffset,a.polygonOffsetFactor=e.polygonOffsetFactor,a.polygonOffsetUnits=e.polygonOffsetUnits,a.blending=e.blending,a.wireframe=e.wireframe??!1,a.userData.isGBufferMaterial=!0,a.visible=ee,Object.assign(a.userData,e.userData),a.visible&&(this.csm.setupMaterial(a),e instanceof u&&Object.assign(a.uniforms,e.uniforms)),s.set(e,a)}var r;return a.visible&&(e instanceof u?this.updateUniformValues(e,a):this.updateMaterialProperties(e,a)),this.initLightVolumeUniform(a),a}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;if((t-this.csmCascadeLastUpdate[s]>=i||0===s)&&this.csm.lights[s].shadow){this.csm.lights[s].shadow.needsUpdate=!0,this.csmCascadeLastUpdate[s]=t;break}}}this.csm.update()}loop(t,s=!1){const a=this.stats,r=a.addPanel(new Z.Panel("Calls","#83f","#002")),l=a.addPanel(new Z.Panel("Triangles","#c32","#002"));let h;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(h=new pe(this.renderer.getContext()),a.addPanel(h)),this.showStats=s;let u=10,d=1e3;const c=()=>{const e=this.renderer.info.render.calls;e>u&&(u=e,setTimeout(()=>u=10,5e3)),r.update(e,u);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 p=[],m=[],f=[];let g=0;const M=new n,v=new n;let T=0;let y=this.paused,b=!1,w=0;const x=()=>{e.activeView=this,b&&(b=!1,requestAnimationFrame(()=>S(w)))},P=He();Ne.set(this.container,e=>{this.isIntersecting=e,e&&x()}),P.observe(this.container),this.container.addEventListener("pointerdown",()=>{x()},{capture:!0});const S=s=>{b=!1;const r=this.renderer.getContext();if(!this.running||null===this.container.offsetParent||this.paused&&r.drawingBufferHeight>1)return b=!0,w=s,setTimeout(()=>{b&&S(s)},500),void(this.paused&&(y=!0));if(this.renderer.domElement.parentElement!==this.container){if(e.activeView!==this&&null!==e.activeView)return b=!0,void(w=s);this.container.replaceChildren(this.renderer.domElement),this.resizeRender()}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 n=(s*=.001)-g;if(g=s,y&&(n=.016,y=!1),M.copy(this.camera.matrixWorld),n>1){let e=n;for(;e>.05;)t($e),e-=$e;t(e)}else t(n);this.onLoopCallbacks.forEach(e=>e(n)),this.camera?.updateMatrixWorld(),v.copy(this.camera.matrixWorld),s-T>.08&&!v.equals(M)&&(this.renderer.shadowMap.needsUpdate=!0,T=s),this.updateCsm();let l=!1;p.length=0,m.length=0,f.length=0;const u=Ye;Ke.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),u.setFromProjectionMatrix(Ke);let d=!1,x=!1,P=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Re&&(d=!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&&(l=!0)),(e instanceof o||e instanceof i.Sprite)&&e.visible&&(e.material?.userData?.water||e.material?.uniforms&&null!=e.material?.uniforms[se])&&isObjectInFrustum(e,u)?(this.initDepthUniform(e.material),x=!0):e instanceof X&&(e.visible=!1,m.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ue]&&isObjectInFrustum(e,u)&&e.material instanceof C&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[de]&&isObjectInFrustum(e,u)&&(f.push(e),e.material.uniforms[de].value=this.sceneColorRenderTarget.texture,P=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[he])e.material.uniforms[he].value=s;else if(e instanceof o&&Array.isArray(e.material))for(const t of e.material)t.uniforms&&null!=t.uniforms[he]&&(t.uniforms[he].value=s)}),this.bloomPass.enabled=l,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderScene(Le.opaque),this.aoPass.output=ee.OUTPUT.Off,(x||P)&&(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,p.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&&d?(this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene),this.volumetricFogPass.enabled=!0):this.volumetricFogPass&&(this.volumetricFogPass.enabled=!1);try{!this.paused&&this.running&&(this.render(n),this.showStats&&h?.endQuery(),this.showStats&&c(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}a.end(),this.csm?.update(),this.running&&!0!==this.options.enableXR&&(this.fpsCap?setTimeout(()=>{requestAnimationFrame(S)},1e3/this.fpsCap):requestAnimationFrame(S))};!0===this.options.enableXR?this.renderer.setAnimationLoop(S):requestAnimationFrame(S)}applyGBufferMaterials(e){const t=this.gBufferCachedMaterials,s=this.gBufferCachedVisibility;t.clear(),s.length=0;ge(this.scene,i=>{if(at(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),a||(a=i.material[t].visible),this.initShadowUniform(i,i.material[t])}else i.material=this.createGBufferMaterial(i.material,e),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 u){for(const[t,s]of Object.entries(e.uniforms))if(s.value instanceof c){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 c){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(Le.opaque),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(Le.transparent),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),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=ut: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!==Le.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===Le.opaque&&this.gBufferCachedMaterials.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof u&&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,void(this.colorPass.enabled=!1);var e;(e=this.postProcessSettings).tonemapMapping=void 0,e.tonemapExposure=1,e.envIntensity=1,e.envTexture=void 0,e.vignetteIntensity=0,e.colorTint=new i.Color("white"),e.colorTintIntensity=0,e.depthFocus=void 0,e.depthAperture=void 0,e.depthMaxBlur=void 0,e.temperature=6500,e.temperatureTint=0,e.lut=void 0,e.lutIntensity=0;const t=this.postProcessSettings;let s,a=!1,r=!1,n=!1,o=!1;if(null==this.camera)return;const h=this.camera.getWorldPosition(Je);let u=[];for(const e of this.postProcessVolumes){if(!Xe(e.object))continue;let l=e.blendWeight??1;const d=e.distanceToPoint(h);d>e.blendRadius||(e.blendRadius>0&&(l*=Me(1-d/e.blendRadius,0,1)),l>1&&(l=1),l>0&&(u.push(e),void 0!==e.settings.tonemapMapping&&(t.tonemapMapping=e.settings.tonemapMapping),void 0!==e.settings.tonemapExposure&&(t.tonemapExposure=i.MathUtils.lerp(t.tonemapExposure,e.settings.tonemapExposure,l)),void 0!==e.settings.envTexture&&(t.envTexture=e.settings.envTexture),void 0!==e.settings.envIntensity&&(t.envIntensity=i.MathUtils.lerp(t.envIntensity,e.settings.envIntensity,l)),void 0!==e.settings.vignetteIntensity&&(t.vignetteIntensity=i.MathUtils.lerp(t.vignetteIntensity,e.settings.vignetteIntensity,l),r=!0),void 0!==e.settings.colorTint&&void 0!==e.settings.colorTintIntensity&&e.settings.colorTintIntensity>0&&(t.colorTint=t.colorTint.lerp(e.settings.colorTint,l),o=!0),void 0!==e.settings.colorTintIntensity&&(t.colorTintIntensity=i.MathUtils.lerp(t.colorTintIntensity,e.settings.colorTintIntensity,l)),void 0!==e.settings.depthFocus&&(a=!0,t.depthFocus=void 0!==t.depthFocus?i.MathUtils.lerp(t.depthFocus,e.settings.depthFocus,l):e.settings.depthFocus),void 0!==e.settings.depthAperture&&(a=!0,t.depthAperture=void 0!==t.depthAperture?i.MathUtils.lerp(t.depthAperture,e.settings.depthAperture,l):e.settings.depthAperture),void 0!==e.settings.depthMaxBlur&&(a=!0,t.depthMaxBlur=void 0!==t.depthMaxBlur?i.MathUtils.lerp(t.depthMaxBlur,e.settings.depthMaxBlur,l):e.settings.depthMaxBlur),void 0!==e.settings.temperature&&(t.temperature=i.MathUtils.lerp(t.temperature,e.settings.temperature,l)),void 0!==e.settings.temperatureTint&&(t.temperatureTint=i.MathUtils.lerp(t.temperatureTint,e.settings.temperatureTint,l)),void 0!==e.settings.lut&&(s=e.settings.lut,n=!0),void 0!==e.settings.lutIntensity&&(t.lutIntensity=i.MathUtils.lerp(t.lutIntensity,e.settings.lutIntensity,l),n=!0)))}this.renderer.toneMapping=t.tonemapMapping??i.NoToneMapping,this.renderer.toneMappingExposure=t.tonemapExposure,null!=t.envTexture&&(this.scene.environment=this.getEnvTexture(t.envTexture)),this.scene.environmentIntensity=t.envIntensity,this.colorPass.vignetteIntensity=t.vignetteIntensity,this.colorPass.vignetteEnabled=r,this.colorPass.colorTint=t.colorTint,this.colorPass.colorTintIntensity=t.colorTintIntensity,this.colorPass.enabled=r||o,a&&this.camera instanceof l?(this.dofPass.enabled=!0,void 0!==t.depthFocus&&(this.dofPass.uniforms.focus.value=t.depthFocus),void 0!==t.depthAperture&&(this.dofPass.uniforms.aperture.value=t.depthAperture),void 0!==t.depthMaxBlur&&(this.dofPass.uniforms.maxblur.value=t.depthMaxBlur)):this.dofPass.enabled=!1,this.colorPass.temperature=t.temperature,this.colorPass.temperatureTint=t.temperatureTint,this.lutPass.enabled=n,n&&(null!=s&&(s.flipY=!0,s.generateMipmaps=!1),this.lutPass.lut=s,this.lutPass.intensity=t.lutIntensity)}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,Ye)&&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!=fe(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===Ee.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Ee:(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 u&&(e.uniforms[se].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[ae]&&(e.uniforms[ae].value=this.camera.near),null!=e.uniforms[ie]&&(e.uniforms[ie].value=this.camera.far)))}initNormalUniform(e){e instanceof u&&null!=e.uniforms[ne]&&(e.uniforms[ne].value=this.gRenderTarget.textures[2])}initShadowUniform(e,t){t instanceof C&&(t.uniforms.receiveShadow?t.uniforms.receiveShadow.value=e.receiveShadow:t.uniforms.receiveShadow={value:e.receiveShadow})}initLightVolumeUniform(e){e instanceof C&&(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 u&&null!=e.uniforms[re]&&e.uniforms[re].value.set(this.gRenderTarget.width,this.gRenderTarget.height)}initAoUniform(e){if(this.aoPass.enabled){e.uniforms[ue].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 C&&!t.transparent&&t.depthWrite){let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Se(Pe);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new C({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}}};ze.activeView=null,ze=e=t([te(),s("design:paramtypes",[HTMLElement,Object])],ze);export{ze as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const $e=.05;function Xe(e){let t=e;for(;t;){if(!1===t.visible)return!1;t=t.parent}return!0}ee.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 Ye=new i.Frustum,Qe=new i.Box3,Ke=new i.Matrix4;export function isObjectInFrustum(e,t){const s=Qe.setFromObject(e);return t.intersectsBox(s)}const Je=new i.Vector3;const Ze=new n,et=new p;function tt(e,t,s=new i.Matrix3){return et.copy(e),et.x*=-1,et.y*=-1,et.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(et.y*=-1,et.z*=-1),s.setFromMatrix4(Ze.makeRotationFromEuler(et))}const st=new C({outputs:[G(0,0,0,0),G(0,0,0,0),D(E("white"),Fe(4))],transparent:!0}),it=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});st.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),it);function at(e){return e instanceof i.Sprite||e.isPoints||e.isLine||e.isLineSegments2||e.isTransformControls||e.isTransformControlsGizmo||e instanceof o&&rt(e,e.material)}function rt(e,t){return null==t||(Array.isArray(t)?t.some(t=>rt(e,t)):t instanceof i.RawShaderMaterial||t instanceof i.ShaderMaterial&&!(t instanceof C))}class nt extends Be{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 r=e.autoClear;e.autoClear=!1;const n=this.scene.matrixWorldAutoUpdate,l=this.scene.matrixAutoUpdate,h=e.shadowMap.autoUpdate;this.scene.matrixAutoUpdate=!1,e.shadowMap.autoUpdate=!1;const u=s.depthTexture;s.depthTexture=this.gRenderTarget.depthTexture,e.setRenderTarget(s),this.cachedVisibility.length=0;let d=0,c=this.toRender;if(c.length=0,this.scene.traverseVisible(e=>{const t=at(e);e instanceof o&&!t?(this.cachedVisibility.push(e),e.visible=!1):t&&(d++,c.push(e))}),d>0)for(const t of c)e.render(t,this.camera);this.cachedVisibility.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=r,s.depthTexture=u,this.scene.matrixWorldAutoUpdate=n,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class ot extends Be{constructor(e){super(),this.fn=e}render(e,t,s,i,a){this.fn(e,t,s,i,a)}}const lt=["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"],ht=F("fogColor");export class FogNode extends H{constructor(e,t=ht){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),r=e.get(U("fogFar")),n=e.get(U("fogNear")),o=e.get(U("fogDensity")),l=e.get(V(L.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( ${n}, ${r}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${a}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}const ut=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 r,Matrix4 as n,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as u,WebGLRenderTarget as d,Texture as c,Euler as p,MeshStandardMaterial as m}from"three";import{CopyShader as f,EffectComposer as g,FXAAShader as M,GammaCorrectionShader as v,LUTPass as y,RenderPass as T,ShaderPass as b,VRButton as P}from"three-stdlib";import{CSMShader as w,CSMUtil as x}from"./csm.js";import{colorToNormal as R,float as S,NodeShaderMaterial as C,standardMaterial as A,uniformFloat as U,uniformVec3 as F,toonMaterial as I,lambertMaterial as B,normalize as O,rgb as E,rgba as D,transformed as L,varying as V,varyingAttributes as _,varyingTransformed as j,vec4 as G,BooleanExpression as W,select as q,ifDefApply as N,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 Q,OutputPass as K}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 re,resolutionUniformName as ne,sceneNormalUniformName as oe,screenUV as le,supportsDepthTextureExtension as he}from"./shader-nodes/depth.js";import{elapsedTimeUniformName as ue}from"./shader-nodes/time.js";import{aoMapUniformName as de,sceneMapUniformName as ce}from"./shader-nodes/scene-sample.js";import{DepthPass as pe}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 ye}from"./rendering/color-pass.js";import{SSRPass as Te}from"./rendering/ssr/SSRPass.js";import{SSRShader as be}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as Pe}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as we}from"./rendering/outline-effect.js";import{UnrealBloomPass as xe}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as Re}from"./shader-nodes/depth.js";import{packDepthToRGBA as Se}from"three-shader-graph";import{FogVolumeObject as Ce}from"./rendering/fog/fog-volume-object";import{ParallaxStandardMaterial as Ae}from"./shader/builtin/standard-shader.js";import{parallaxOcclusionMapping as Ue}from"./shader-nodes/pom.js";import{FullScreenQuad as Fe}from"three-stdlib";import{edgeDepthEffect as Ie}from"./shader-nodes/effects";import{decalDiscard as Be}from"./shader-nodes/decal.js";import{Pass as Oe}from"three/examples/jsm/Addons.js";x.patchSetupMaterial();const Ee=document.createElement("div");Ee.style.position="absolute",Ee.style.left="50%",Ee.style.top="50%",Ee.style.color="black",Ee.style.zIndex="999";(new i.Layers).set(9);const De=new i.MeshBasicMaterial({color:"black"}),Le=new i.MeshDepthMaterial;var Ve;Le.depthPacking=i.RGBADepthPacking,Le.blending=i.NoBlending,Le.side=i.DoubleSide,function(e){e[e.opaque=0]="opaque",e[e.transparent=1]="transparent"}(Ve||(Ve={}));const _e=(()=>{const e=new Uint8Array([255,255,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),je=(()=>{const e=new Uint8Array([0,0,0,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),Ge=(()=>{const e=new Uint8Array([128,128,255,255]),t=new i.DataTexture(e,1,1,i.RGBAFormat);return t.needsUpdate=!0,t})(),We=new C({color:S(0),position:G(S(0))});We.visible=!1;const qe=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let Ne=0,ke=null;const He=new Map;function ze(){return null==ke&&(ke=new IntersectionObserver(e=>{for(const t of e){const e=He.get(t.target);e&&e(t.isIntersecting)}},{threshold:0})),ke}let $e=e=class{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.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)}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.postProcessVolumes=[],this.postProcessSettings={},this.csmUpdateInvervals=this.options.shadows?.cascadeUpdateIntervals,this._id=Ne++,this.fquadCopy=new Fe(new u(f)),this.fquadCopyOpaque=new Fe(new C({outputs:[k("tSceneColor",new c).sample(_.uv),G(k("tDepthTexture",new i.DepthTexture(1,1)).sample(_.uv).r)]})),this.simulationTime=0,this.simulationTimeScale=1,this.lightProbeIntensity=2,this.fquadBlendAO=(()=>{const e=G(1),t=new C({outputs:[k("tAO",new c).sample(le),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Fe(t)})(),this.resolutionScale=1,this.maxPixelRatio=qe?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.tbufferMaterialCache=new Map,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,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(P.createButton(this.renderer));const r=new we(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=r,this.createGRenderTarget(),this.composer=new g(this.renderer),this.composer.setSize(t.clientWidth,t.clientHeight);var n=(t.clientWidth||1)/(t.clientHeight||1);const o=new i.PerspectiveCamera(45,n,.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.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 T(this.scene,this.camera),new b(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const d=new xe(l,1.5,.4,.85);d.threshold=1,d.strength=.9,d.radius=.5,this.bloomPass=d;const p=new te(this.scene,this.camera,this.gRenderTarget.width,this.gRenderTarget.height,{});p.normalRenderTarget?.dispose(),p.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),p.output=te.OUTPUT.Off,p.enabled=!1,this.aoPass=p,this.fquadBlendAO.material.uniforms.tAO.value=p.pdRenderTarget.texture,be.fragmentShader=be.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Te({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=Te.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(p);const w=new lt((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 R=new lt((e,t,s,i,a)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(Ve.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(R),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new ot(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 Pe(l),this.composer.addPass(this.volumetricFogPass),this.volumetricFogPass.enabled=!0,this.dofPass=new Q(this.scene,this.camera,{focus:1,aperture:.025,maxblur:.01}),this.dofPass.enabled=!1,this.composer.addPass(this.dofPass);const S=new ye;this.composer.addPass(S),this.colorPass=S,S.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 A=new b(M);A.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(A),this.fxaaPass=A,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new b(v).clear=!1,this.fixStatsStyle(),this.lutPass=new y({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const U=new b(f,"prevtexture");U.enabled=!0,U.needsSwap=!1,U.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],U.renderToScreen=!0;const F=new K;this.composer.addPass(F)}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 T?t.camera=e:t instanceof fe?t.renderCamera=e:(t instanceof pe||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:qe?2:4,shadowMapSize:2048*(qe?.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)),r=Math.max(1,Math.floor(t.clientHeight*s)),n=new i.WebGLRenderTarget(a,r);return n.texture.minFilter=i.NearestFilter,n.texture.magFilter=i.NearestFilter,n.texture.generateMipmaps=!1,n.stencilBuffer=!1,n.depthTexture=new i.DepthTexture(a,r),n.depthTexture.type=i.UnsignedShortType,n.depthTexture.minFilter=i.NearestFilter,n.depthTexture.magFilter=i.NearestFilter,n}static createAOMaskDepthRenderTarget(e,t){const s=Math.max(1,t.clientWidth*e.getPixelRatio()),a=Math.max(1,t.clientHeight*e.getPixelRatio()),r=new i.DepthTexture(s,a);r.type=i.UnsignedInt248Type,r.minFilter=i.NearestFilter,r.magFilter=i.NearestFilter;const n=new i.WebGLRenderTarget(s,a,{type:i.HalfFloatType,depthTexture:r});return n.texture.minFilter=i.NearestFilter,n.texture.magFilter=i.NearestFilter,n.texture.generateMipmaps=!1,n.stencilBuffer=!1,n}createSceneColorRenderTarget(e,t){const s=this.gRenderTarget.width,a=this.gRenderTarget.height,r=new i.WebGLRenderTarget(s,a,{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return r.texture.minFilter=i.LinearFilter,r.texture.magFilter=i.LinearFilter,r.texture.generateMipmaps=!1,r.textures[1].minFilter=i.NearestFilter,r.textures[1].magFilter=i.NearestFilter,r}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: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(),this.container.replaceChildren();ze().unobserve(this.container),He.delete(this.container),this.volumetricFogPass.dispose(),x.clearSceneCache(this.scene)}onLoop(e){this.onLoopCallbacks.push(e)}removeOnLoop(e){const t=this.onLoopCallbacks.find(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 C&&(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:st(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 C||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)&&(t.uniforms.color.value.setFromColor(e.color),t.uniforms.opacity.value=e.opacity,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&&(t.uniforms.roughnessMap.value=e.roughnessMap,t.uniforms.metalnessMap.value=e.metalnessMap,t.uniforms.roughness.value=e.roughness,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 Ae&&(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===ht.includes(e)&&(t.value=a)}this.updateMaterialCommonProperties(e,t)}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}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of ht){const t=i[e],a=s[e];null!=a&&null!=t&&(t.value=a.value)}}createGBufferMaterial(e,t){const s=t===Ve.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let a=s.get(e);if(!0===e.userData.isGBufferMaterial)return e;if(null==a){let n=_.uv;if(e instanceof Ae&&null!=e.heightMap){const t=U("heightScale",e.heightScale??1);n=Ue(n,k("heightMap",e.heightMap),t)}let o=j.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??Ge,s=U("useNormalMap",null!=e.normalMap?1:0),i=U("normalScale",e.normalScale?.x??1),a=R(k("normalMap",t).sample(n),i);o=z(j.normal,a,s)}else e instanceof C&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=N("DOUBLE_SIDED",o,e=>q(new W("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?S(0):S(1);if(e instanceof i.MeshStandardMaterial){const t=U("roughness",e.roughness??1),s=e.roughnessMap??_e,i=U("useRoughnessMap",null!=e.roughnessMap?1:0),a=k("roughnessMap",s).sample(n).g.multiply(t);l=z(t,a,i)}else e instanceof C&&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,s=U("useLightMap",null!=e.lightMap?1:0),i=U("lightMapIntensity",e.lightMapIntensity??1),a=k("lightMap",t).sample(n).rgb.multiplyScalar(i);h=z(E(0),a,s)}let d=S(0);if(e instanceof i.MeshStandardMaterial){const t=U("metalness",e.metalness??0),s=e.metalnessMap??je,i=U("useMetalnessMap",null!=e.metalnessMap?1:0),a=k("metalnessMap",s).sample(n).b.multiply(t);d=z(t,a,i)}else e instanceof C&&e.outputRoughness;let c=null,p=S(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??_e,s=U("useAoMap",null!=e.aoMap?1:0);p=U("aoMapIntensity",e.aoMapIntensity??1);const i=k("aoMap",t).sample(n).r;c=z(S(1),i,s)}else e instanceof C&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=S(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(n).r}g=g.multiply(f)}else e instanceof C&&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=F("color",(new i.Vector3).setFromColor(e.color));const s=e.map??_e,a=U("useAlbedoMap",null!=e.map?1:0),r=k("map",s).sample(n),o=r.multiply(D(t,1)),l=D(t,1);M=z(l,o,a),e.vertexColors&&(M=M.multiply(G(V($.color.rgb),1)));const h=z(S(1),r.w,a);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let y=E(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=F("emissive",(new i.Vector3).setFromColor(e.emissive)),s=U("emissiveIntensity",e.emissiveIntensity),a=e.emissiveMap??je,r=U("useEmissiveMap",null!=e.emissiveMap?1:0),o=k("emissiveMap",a).sample(n).rgb.multiply(t);y=z(t,o,r),y=y.multiplyScalar(s)}else e instanceof C&&null!=e.outputEmissive&&(y=e.outputEmissive);let T=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(T=F("sheenColor",(new i.Vector3).setFromColor(e.sheenColor).multiplyScalar(e.sheen)),e.sheen>0&&null!=e.sheenColorMap)){const t=k("sheenColorMap",e.sheenColorMap).sample(n).rgb;T=T.multiply(t)}let b=null;if(e instanceof i.MeshPhysicalMaterial&&e.sheen>0&&(b=U("sheenRoughness",e.sheenRoughness),e.sheen>0&&null!=e.sheenRoughnessMap)){const t=k("sheenRoughnessMap",e.sheenRoughnessMap).sample(n).r;b=b.multiply(t)}let P=null;if(e instanceof i.MeshPhysicalMaterial&&e.anisotropy>0&&(P=U("anisotropy",e.anisotropy),e.anisotropy>0&&null!=e.anisotropyMap)){const t=k("anisotropyMap",e.anisotropyMap).sample(n).r;P=P.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 u&&null!=e.uniforms[ie],L=e instanceof u&&null!=e.uniforms[ce],H=e instanceof u&&null!=e.uniforms[de],Y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,Q=U("alphaTest",e.alphaTest);let K,J=e.alphaTest>0?g.lt(Q):Y&&t===Ve.opaque?g.lt(.8):null;!0===e.userData.isDecal&&(J=J?J.or(Be):Be),K=Y?G(0,0,0,0):(r=o,O(r).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const Z=e instanceof C?e.outputPosition:void 0,ee=e instanceof C?e.outputTransform:void 0;let te,se=D("black",1);if(e instanceof C&&null!=e.outputColor)se=e.outputColor;else if(e instanceof i.MeshStandardMaterial)se=A({color:M,metalness:d,roughness:l,emissive:y.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h,sheenColor:T,sheenRoughness:b,anisotropy:P,anisotropyDirection:w});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)se=B({color:M.rgb,ambientOcclusion:c,ambientOcclusionIntensity:p});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??E("black");null!=c&&(t=t.multiplyScalar(c.subtract(1).multiply(p).add(1))),e=e.add(t),se=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(se=I({color:M,emissive:y.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h}));(e instanceof C||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 re=D(se.rgb,g);ae&&(re=new FogNode(re));let ne=!0;if(t===Ve.opaque?(ne&&(ne=!x&&!L&&!H),ne&&(ne=!Y)):t===Ve.transparent&&ne&&(ne=Y||x||L||H),!ne)return a=We,s.set(e,a),a;a=new C({transform:ee,position:null==ee?Z:void 0,outputs:[re,y.rgba(t===Ve.opaque?Q:v?1:0),K],opacity:g,outputEncoding:!1,fog:ae,transparent:e.transparent,lights:!0,envMap:te,discard:J}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=a.uniforms.envMapIntensity&&(a.uniforms.envMapIntensity.value=e.envMapIntensity),"alphaMap"in e&&null!=e.alphaMap&&(a.alphaMap=e.alphaMap),(e instanceof C||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(a),e instanceof C&&(Object.assign(a.defines,e.defines),null!=a.uniforms[de]&&(a.uniforms[de].value=this.aoPass.pdRenderTarget.texture,a.defines.USE_SSAO_MAP="")),a.userData.mrtOutputs=3,a.forceSinglePass=e.forceSinglePass,a.side=e.side,a.blending=e.blending,Y?(a.depthWrite=!e.transparent,a.depthTest=e.depthTest,a.colorWrite=t===Ve.transparent):(a.depthWrite=e.depthWrite,a.depthTest=e.depthTest),a.visible=e.visible,a.alphaTest=e.alphaTest,a.alphaHash=e.alphaHash,a.vertexColors=e.vertexColors,a.premultipliedAlpha=e.premultipliedAlpha,a.toneMapped=e.toneMapped,a.blendAlpha=e.blendAlpha,a.blendColor=e.blendColor,a.polygonOffset=e.polygonOffset,a.polygonOffsetFactor=e.polygonOffsetFactor,a.polygonOffsetUnits=e.polygonOffsetUnits,a.blending=e.blending,a.wireframe=e.wireframe??!1,a.userData.isGBufferMaterial=!0,a.visible=ne,Object.assign(a.userData,e.userData),a.visible&&(this.csm.setupMaterial(a),e instanceof u&&Object.assign(a.uniforms,e.uniforms)),s.set(e,a)}var r;return a.visible&&(e instanceof u?this.updateUniformValues(e,a):this.updateMaterialProperties(e,a)),this.initLightVolumeUniform(a),a}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,r=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 u=10,d=1e3;const c=()=>{const e=this.renderer.info.render.calls;e>u&&(u=e,setTimeout(()=>u=10,5e3)),r.update(e,u);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 p=[],m=[],f=[];let g=0;const M=new n,v=new n;let y=0;let T=this.paused,b=!1,P=0;const w=()=>{e.activeView=this,b&&(b=!1,requestAnimationFrame(()=>R(P)))},x=ze();He.set(this.container,e=>{this.isIntersecting=e,e&&w()}),x.observe(this.container),this.container.addEventListener("pointerdown",()=>{w()},{capture:!0});const R=s=>{b=!1;const r=this.renderer.getContext();if(!this.running||null===this.container.offsetParent||this.paused&&r.drawingBufferHeight>1)return b=!0,P=s,setTimeout(()=>{b&&R(s)},500),void(this.paused&&(T=!0));if(this.renderer.domElement.parentElement!==this.container){if(e.activeView!==this&&null!==e.activeView)return b=!0,void(P=s);this.container.replaceChildren(this.renderer.domElement),this.resizeRender()}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 n=(s*=.001)-g;if(g=s,T&&(n=.016,T=!1),M.copy(this.camera.matrixWorld),n>1){let e=n;for(;e>.05;)t(Xe),e-=Xe;t(e)}else t(n);this.onLoopCallbacks.forEach(e=>e(n)),this.paused||(this.simulationTime+=n*this.simulationTimeScale);const l=this.simulationTime;this.camera?.updateMatrixWorld(),v.copy(this.camera.matrixWorld),s-y>.08&&!v.equals(M)&&(this.renderer.shadowMap.needsUpdate=!0,y=s),this.updateCsm();let u=!1;p.length=0,m.length=0,f.length=0;const d=Qe;Je.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),d.setFromProjectionMatrix(Je);let w=!1,x=!1,S=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Ce&&(w=!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&&(u=!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),x=!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 C&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ce]&&isObjectInFrustum(e,d)&&(f.push(e),e.material.uniforms[ce].value=this.sceneColorRenderTarget.texture,S=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[ue])e.material.uniforms[ue].value=l;else if(e instanceof o&&Array.isArray(e.material))for(const t of e.material)t.uniforms&&null!=t.uniforms[ue]&&(t.uniforms[ue].value=l)}),this.bloomPass.enabled=u,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderScene(Ve.opaque),this.aoPass.output=te.OUTPUT.Off,(x||S)&&(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,p.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&&w?(this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene),this.volumetricFogPass.enabled=!0):this.volumetricFogPass&&(this.volumetricFogPass.enabled=!1);try{!this.paused&&this.running&&(this.render(n),this.showStats&&h?.endQuery(),this.showStats&&c(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}a.end(),this.csm?.update(),this.running&&!0!==this.options.enableXR&&(this.fpsCap?setTimeout(()=>{requestAnimationFrame(R)},1e3/this.fpsCap):requestAnimationFrame(R))};!0===this.options.enableXR?this.renderer.setAnimationLoop(R):requestAnimationFrame(R)}applyGBufferMaterials(e){const t=this.gBufferCachedMaterials,s=this.gBufferCachedVisibility;t.clear(),s.length=0;Me(this.scene,i=>{if(rt(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),a||(a=i.material[t].visible),this.initShadowUniform(i,i.material[t])}else i.material=this.createGBufferMaterial(i.material,e),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 u){for(const[t,s]of Object.entries(e.uniforms))if(s.value instanceof c){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 c){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(Ve.opaque),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(Ve.transparent),await this.renderer.compileAsync(e,this.camera),this.unapplyGBufferMaterials(),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=dt: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!==Ve.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===Ve.opaque&&this.gBufferCachedMaterials.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof u&&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,void(this.colorPass.enabled=!1);var e;(e=this.postProcessSettings).tonemapMapping=void 0,e.tonemapExposure=1,e.envIntensity=1,e.envTexture=void 0,e.vignetteIntensity=0,e.colorTint=new i.Color("white"),e.colorTintIntensity=0,e.depthFocus=void 0,e.depthAperture=void 0,e.depthMaxBlur=void 0,e.temperature=6500,e.temperatureTint=0,e.lut=void 0,e.lutIntensity=0;const t=this.postProcessSettings;let s,a=!1,r=!1,n=!1,o=!1;if(null==this.camera)return;const h=this.camera.getWorldPosition(Ze);let u=[];for(const e of this.postProcessVolumes){if(!Ye(e.object))continue;let l=e.blendWeight??1;const d=e.distanceToPoint(h);d>e.blendRadius||(e.blendRadius>0&&(l*=ve(1-d/e.blendRadius,0,1)),l>1&&(l=1),l>0&&(u.push(e),void 0!==e.settings.tonemapMapping&&(t.tonemapMapping=e.settings.tonemapMapping),void 0!==e.settings.tonemapExposure&&(t.tonemapExposure=i.MathUtils.lerp(t.tonemapExposure,e.settings.tonemapExposure,l)),void 0!==e.settings.envTexture&&(t.envTexture=e.settings.envTexture),void 0!==e.settings.envIntensity&&(t.envIntensity=i.MathUtils.lerp(t.envIntensity,e.settings.envIntensity,l)),void 0!==e.settings.vignetteIntensity&&(t.vignetteIntensity=i.MathUtils.lerp(t.vignetteIntensity,e.settings.vignetteIntensity,l),r=!0),void 0!==e.settings.colorTint&&void 0!==e.settings.colorTintIntensity&&e.settings.colorTintIntensity>0&&(t.colorTint=t.colorTint.lerp(e.settings.colorTint,l),o=!0),void 0!==e.settings.colorTintIntensity&&(t.colorTintIntensity=i.MathUtils.lerp(t.colorTintIntensity,e.settings.colorTintIntensity,l)),void 0!==e.settings.depthFocus&&(a=!0,t.depthFocus=void 0!==t.depthFocus?i.MathUtils.lerp(t.depthFocus,e.settings.depthFocus,l):e.settings.depthFocus),void 0!==e.settings.depthAperture&&(a=!0,t.depthAperture=void 0!==t.depthAperture?i.MathUtils.lerp(t.depthAperture,e.settings.depthAperture,l):e.settings.depthAperture),void 0!==e.settings.depthMaxBlur&&(a=!0,t.depthMaxBlur=void 0!==t.depthMaxBlur?i.MathUtils.lerp(t.depthMaxBlur,e.settings.depthMaxBlur,l):e.settings.depthMaxBlur),void 0!==e.settings.temperature&&(t.temperature=i.MathUtils.lerp(t.temperature,e.settings.temperature,l)),void 0!==e.settings.temperatureTint&&(t.temperatureTint=i.MathUtils.lerp(t.temperatureTint,e.settings.temperatureTint,l)),void 0!==e.settings.lut&&(s=e.settings.lut,n=!0),void 0!==e.settings.lutIntensity&&(t.lutIntensity=i.MathUtils.lerp(t.lutIntensity,e.settings.lutIntensity,l),n=!0)))}this.renderer.toneMapping=t.tonemapMapping??i.NoToneMapping,this.renderer.toneMappingExposure=t.tonemapExposure,null!=t.envTexture&&(this.scene.environment=this.getEnvTexture(t.envTexture)),this.scene.environmentIntensity=t.envIntensity,this.colorPass.vignetteIntensity=t.vignetteIntensity,this.colorPass.vignetteEnabled=r,this.colorPass.colorTint=t.colorTint,this.colorPass.colorTintIntensity=t.colorTintIntensity,this.colorPass.enabled=r||o,a&&this.camera instanceof l?(this.dofPass.enabled=!0,void 0!==t.depthFocus&&(this.dofPass.uniforms.focus.value=t.depthFocus),void 0!==t.depthAperture&&(this.dofPass.uniforms.aperture.value=t.depthAperture),void 0!==t.depthMaxBlur&&(this.dofPass.uniforms.maxblur.value=t.depthMaxBlur)):this.dofPass.enabled=!1,this.colorPass.temperature=t.temperature,this.colorPass.temperatureTint=t.temperatureTint,this.lutPass.enabled=n,n&&(null!=s&&(s.flipY=!0,s.generateMipmaps=!1),this.lutPass.lut=s,this.lutPass.intensity=t.lutIntensity)}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,Qe)&&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===De.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=De:(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 u&&(e.uniforms[ie].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[re]&&(e.uniforms[re].value=this.camera.near),null!=e.uniforms[ae]&&(e.uniforms[ae].value=this.camera.far)))}initNormalUniform(e){e instanceof u&&null!=e.uniforms[oe]&&(e.uniforms[oe].value=this.gRenderTarget.textures[2])}initShadowUniform(e,t){t instanceof C&&(t.uniforms.receiveShadow?t.uniforms.receiveShadow.value=e.receiveShadow:t.uniforms.receiveShadow={value:e.receiveShadow})}initLightVolumeUniform(e){e instanceof C&&(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 u&&null!=e.uniforms[ne]&&e.uniforms[ne].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 C&&!t.transparent&&t.depthWrite){let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Se(Re);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new C({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}}};$e.activeView=null,$e=e=t([se(),s("design:paramtypes",[HTMLElement,Object])],$e);export{$e as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const Xe=.05;function Ye(e){let t=e;for(;t;){if(!1===t.visible)return!1;t=t.parent}return!0}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 Qe=new i.Frustum,Ke=new i.Box3,Je=new i.Matrix4;export function isObjectInFrustum(e,t){const s=Ke.setFromObject(e);return t.intersectsBox(s)}const Ze=new i.Vector3;const et=new n,tt=new p;function st(e,t,s=new i.Matrix3){return tt.copy(e),tt.x*=-1,tt.y*=-1,tt.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(tt.y*=-1,tt.z*=-1),s.setFromMatrix4(et.makeRotationFromEuler(tt))}const it=new C({outputs:[G(0,0,0,0),G(0,0,0,0),D(E("white"),Ie(4))],transparent:!0}),at=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});it.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),at);function rt(e){return e instanceof i.Sprite||e.isPoints||e.isLine||e.isLineSegments2||e.isTransformControls||e.isTransformControlsGizmo||e instanceof o&&nt(e,e.material)}function nt(e,t){return null==t||(Array.isArray(t)?t.some(t=>nt(e,t)):t instanceof i.RawShaderMaterial||t instanceof i.ShaderMaterial&&!(t instanceof C))}class ot extends Oe{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 r=e.autoClear;e.autoClear=!1;const n=this.scene.matrixWorldAutoUpdate,l=this.scene.matrixAutoUpdate,h=e.shadowMap.autoUpdate;this.scene.matrixAutoUpdate=!1,e.shadowMap.autoUpdate=!1;const u=s.depthTexture;s.depthTexture=this.gRenderTarget.depthTexture,e.setRenderTarget(s),this.cachedVisibility.length=0;let d=0,c=this.toRender;if(c.length=0,this.scene.traverseVisible(e=>{const t=rt(e);e instanceof o&&!t?(this.cachedVisibility.push(e),e.visible=!1):t&&(d++,c.push(e))}),d>0)for(const t of c)e.render(t,this.camera);this.cachedVisibility.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=r,s.depthTexture=u,this.scene.matrixWorldAutoUpdate=n,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class lt extends Oe{constructor(e){super(),this.fn=e}render(e,t,s,i,a){this.fn(e,t,s,i,a)}}const ht=["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"],ut=F("fogColor");export class FogNode extends H{constructor(e,t=ut){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),r=e.get(U("fogFar")),n=e.get(U("fogNear")),o=e.get(U("fogDensity")),l=e.get(V(L.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( ${n}, ${r}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${a}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}const dt=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
  */
@@ -51,6 +51,7 @@ export declare class AssetResourceLoader {
51
51
  }>;
52
52
  private _getTextureLoader;
53
53
  clearCache(asset: Asset): void;
54
+ clearCacheById(assetId: string): void;
54
55
  private asyncMeshResults;
55
56
  getMesh(asset: Asset, options?: GetMeshOptions): Promise<LoadedMesh>;
56
57
  private asyncAudioResults;
@@ -1,4 +1,4 @@
1
- import{AudioLoader as e,BufferGeometry as t,Group as s,LoadingManager as r,Mesh as i,Object3D as a,Texture as n,TextureLoader as o}from"three";import{GLTFLoader as l,MTLLoader as h,OBJLoader as c,DRACOLoader as u,LUTCubeLoader as d}from"three-stdlib";import{FBXLoader as m}from"three-stdlib";import{cloneMesh as f}from"../utils/mesh.js";import{pathJoin as p}from"../utils/files.js";import{Subject as g,firstValueFrom as y}from"rxjs";import{importCollisionShapes as w,isCollisionMesh as x}from"./collision/collision-shape-import.js";import*as M from"three";import{iterateMaterials as L}from"../utils/materials.js";import{applyMaterial as A}from"./materializer.js";import{BufferGeometryUtils as b,EXRLoader as v,KTX2Loader as _,TGALoader as T,UltraHDRLoader as C}from"three/examples/jsm/Addons.js";import{disposeScene as S}from"../utils/three/cleanup.js";const R=new u;R.setDecoderConfig({type:"js"}),R.setDecoderPath("/assets/draco/");const K=["glb","gltf","fbx","obj"];export class AssetResourceLoader{onError(e){console.error(e)}constructor(){this.cache=new Map,this.textureCache=new Map,this.loadingManager=new r,this.glbLoader=new l(this.loadingManager).setDRACOLoader(R),this.fbxLoader=new m(this.loadingManager),this.objLoader=new c(this.loadingManager),this.textureLoader=new o(this.loadingManager),this.tgaLoader=new T(this.loadingManager),this.exrLoader=new v(this.loadingManager),this.cubeLoader=new d(this.loadingManager),this.hdrLoader=new C(this.loadingManager),this.ktx2Loader=new _(this.loadingManager),this._textureLoader=new M.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this._retrievedMeshes=[],this._retrievedTextures=[],this.makeReady=new g,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)}setDataDir(e){this.basePath=p(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=function(e){return P.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}&v=${t}`:""):new URL(p("..",this.basePath,e),import.meta.url).href}async getTexture(e){if(!e||!e.fileKey)return null;if(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);null!=e.texture&&(t.flipY!==e.texture?.flipY?(t.needsUpdate=!0,t.flipY=e.texture?.flipY??!0):t.wrapS!==D(e.texture?.wrapS)?(t.needsUpdate=!0,t.wrapS=D(e.texture?.wrapS)):t.wrapT!==D(e.texture?.wrapT)&&(t.wrapT=D(e.texture?.wrapT),t.needsUpdate=!0))}else try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then(t=>(t.texture3D?t=t.texture3D:(t.wrapS=D(e.texture?.wrapS),t.wrapT=D(e.texture?.wrapT),t.flipY=e.texture?.flipY??!0),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 n||(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){"mesh"===e.type?(Array.from(this.cache.keys()).forEach(t=>{t.startsWith(e.fileKey)&&this.cache.delete(t)}),j(e.fileKey)):"texture"===e.type&&(this.textureCache.delete(e.id),j(e.fileKey))}async getMesh(e,t){if(await this.ready,null==e)return console.error("No asset was provided"),{scene:new s,animations:[]};if(!K.includes(e.fileFormat?.toLowerCase()))return console.error("Unsupported mesh file format "+e.fileFormat,e),{scene:new s,animations:[]};const r=e.fileKey+(!0===t?.mergeGeomtries?"1":"0");if(!this.cache.has(r))try{this.asyncMeshResults.has(r)||this.asyncMeshResults.set(r,this.loadMesh(e).finally(()=>this.asyncMeshResults.delete(r))),this.cache.set(r,await this.asyncMeshResults.get(r))}catch(e){return this.onError(e),{scene:new s,animations:[]}}const a=this.cache.get(r).scene,n=this.computeCollisionShapes(e,a);!0===t?.mergeGeomtries&&this.optimizeDrawGroups(a);const o=f(a),l=this.cache.get(r).animations;o.traverse(e=>{e instanceof i&&e.material instanceof Array&&(e.material=e.material.slice())});const h=new AssetMeshInstance;h.add(o),h.collisionShapes=n,h.animations=l;const c=e.receiveShadow??!0,u=e.castShadow??!1;if(o.traverse(e=>{e.castShadow=u,e.receiveShadow=c}),!0===t?.rescale&&"number"==typeof e.mesh?.rescale&&h.scale.setScalar(e.mesh?.rescale),!0===t?.applyMaterials){const s=t?.materialResolver??this.materialProvider;if(null!=s)for(const t of e.materialAssignments??[])await A(h,t,s);else console.warn(`applyMaterials was set to true for ${e.name} but no material resolver was provided.`)}return{scene:h,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),i=r.animations.find(e=>e.name===t);return null!=i&&this._animationCache.set(s,i),i}catch(e){return this.onError(e),null}finally{setTimeout(()=>this._animationPromises.delete(s),1e3)}})();return this._animationPromises.set(s,r),r}computeCollisionShapes(e,t){const s=e.id+e.mesh?.collisions?.shapeType;return this.collisionShapeCache.has(s)||this.collisionShapeCache.set(s,w(t,e)),this.collisionShapeCache.get(s)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then(e=>(e.scene.traverse(e=>{e instanceof i&&e.material,x(e)?e.visible=!1:e instanceof i&&e.geometry instanceof t&&(e.geometry.hasAttribute("normal")||e.geometry.computeVertexNormals())}),this._retrievedMeshes.push(e.scene),e.scene=function(e,t){let s=!1;if(t.traverseVisible(e=>{U.test(e.name)&&(s=!0)}),!s)return t;const r=new M.LOD,i=[t];for(;i.length>0;){const e=i.shift(),t=e.name.match(U);if(null!=t){const s=parseInt(t[1]);0===s?r.addLevel(e,0):console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`)}else i.push(...e.children)}return r}(0,e.scene),function(e){const t=I;I.length=0,e.traverse(e=>{(e instanceof M.Camera||e instanceof M.Light)&&t.push(e)}),t.forEach(e=>e.removeFromParent())}(e.scene),e))}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 M.SkinnedMesh)&&e.geometry instanceof t&&Array.isArray(e.material)&&!x(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 h=this.extractGeometryGroups(r,l);h.groups.length>1&&b.mergeGroups(h);const c=new i(h,o);c.copy(t,!1),c.geometry=h,c.material=o,n?n.add(c):e.add(c)}r.dispose()}let r=!0,a=0,n=0;if(e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!x(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==n&&0!==n&&(r=!1),n=t}else(e instanceof M.SkinnedMesh||e instanceof M.Bone)&&(r=!1)}),a>1&&r){const s=new Map;e.traverse(r=>{if(r instanceof i&&r.geometry instanceof t&&!x(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 i=s.get(t),a=e.matrixWorld.clone().invert().multiply(r.matrixWorld);i.geometries.push(r.geometry.clone().applyMatrix4(a)),i.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]:b.mergeGeometries(t.geometries,!0),s.groups.length>1&&b.mergeGroups(s),e.add(new i(s,t.material))}}e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!x(e)){const t=e.geometry;!Array.isArray(e.material)&&t.groups.length>1&&b.mergeGroups(t)}})}extractGeometryGroups(e,s){const r=e.index;if(!r){const r=new t;let i=0;for(const e of s)i+=e.count;if(0===i)return r;for(const t in e.attributes){const a=e.attributes[t],n=a.itemSize,o=a.array,l=new(0,o.constructor)(i*n);let h=0;for(const e of s){const t=e.start*n,s=e.count*n;for(let e=0;e<s;e++)l[h+e]=o[t+e];h+=s}const c=new M.BufferAttribute(l,n,a.normalized);r.setAttribute(t,c)}return r.groups=[{start:0,count:i,materialIndex:0}],r}const i=[];for(const e of s)for(let t=0;t<e.count;t++){const s=r.getX(e.start+t);i.push(s)}if(0===i.length)return new t;const a=new Map,n=[];let o=0;for(const e of i)a.has(e)||(a.set(e,o),o++),n.push(a.get(e));if(0===n.length||0===a.size)return new t;const l=new t;for(const t in e.attributes){const s=e.attributes[t],r=s.itemSize,i=s.array,n=new(0,i.constructor)(a.size*r);for(const[e,t]of a)for(let s=0;s<r;s++)n[t*r+s]=i[e*r+s];const o=new M.BufferAttribute(n,r,s.normalized);l.setAttribute(t,o)}const h=new((n.length>0?Math.max(...n):0)>65535?Uint32Array:Uint16Array)(n.length);for(let e=0;e<n.length;e++)h[e]=n[e];return l.setIndex(new M.BufferAttribute(h,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=>(k(e),e)).then(e=>({scene:e,animations:e.animations}))}}disposeAll(){this.cache.clear(),this._retrievedMeshes.forEach(e=>S(e)),this._retrievedTextures.forEach(e=>e.dispose()),this._retrievedMeshes.length=0,this._retrievedTextures.length=0}}const P=new Map;function j(e){P.set(e,P.get(e)??1)}function k(e){if(e instanceof i)for(const t of L(e.material))t instanceof M.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(k)}export class AssetMeshInstance extends a{}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find(e=>e.startsWith(t));return s?.substring(t.length)}function D(e){switch(e){case"clamp":return M.ClampToEdgeWrapping;case"repeat":return M.RepeatWrapping;case"mirror":return M.MirroredRepeatWrapping}return M.RepeatWrapping}new M.Matrix4;const I=[];const U=/_LOD(\d+)$/;/*
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{GLTFLoader as h,MTLLoader as u,OBJLoader as d,DRACOLoader as m,LUTCubeLoader as f}from"three-stdlib";import{FBXLoader as p}from"three-stdlib";import{cloneMesh as g}from"../utils/mesh.js";import{pathJoin as y}from"../utils/files.js";import{Subject as w,firstValueFrom as x}from"rxjs";import{BoxCollisionShape as M,CapsuleCollisionShape as A,CollisionShapeSource as b,CylinderCollisionShape as L,SphereCollisionShape as v}from"./collision/collision-shape.js";import{importCollisionShapes as _,isCollisionMesh as C}from"./collision/collision-shape-import.js";import*as S from"three";import{iterateMaterials as T}from"../utils/materials.js";import{applyMaterial as R}from"./materializer.js";import{BufferGeometryUtils as P,EXRLoader as j,KTX2Loader as k,TGALoader as K,UltraHDRLoader as D}from"three/examples/jsm/Addons.js";import{disposeScene as I}from"../utils/three/cleanup.js";const z=new m;z.setDecoderConfig({type:"js"}),z.setDecoderPath("/assets/draco/");const B=["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 h(this.loadingManager).setDRACOLoader(z),this.fbxLoader=new p(this.loadingManager),this.objLoader=new d(this.loadingManager),this.textureLoader=new l(this.loadingManager),this.tgaLoader=new K(this.loadingManager),this.exrLoader=new j(this.loadingManager),this.cubeLoader=new f(this.loadingManager),this.hdrLoader=new D(this.loadingManager),this.ktx2Loader=new k(this.loadingManager),this._textureLoader=new S.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this._retrievedMeshes=[],this._retrievedTextures=[],this.makeReady=new w,this.ready=x(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)}setDataDir(e){this.basePath=y(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=function(e){return U.get(e)}(e),s=getElectronArg("windowId");return null!=s||import.meta.url.includes(".vite")||import.meta.url.includes("hology/packages/core")?y(this.basePath,e)+(null!=s?`?windowId=${s}&v=${t}`:""):new URL(y("..",this.basePath,e),import.meta.url).href}async getTexture(e){if(!e||!e.fileKey)return null;if(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);null!=e.texture&&(t.flipY!==e.texture?.flipY?(t.needsUpdate=!0,t.flipY=e.texture?.flipY??!0):t.wrapS!==E(e.texture?.wrapS)?(t.needsUpdate=!0,t.wrapS=E(e.texture?.wrapS)):t.wrapT!==E(e.texture?.wrapT)&&(t.wrapT=E(e.texture?.wrapT),t.needsUpdate=!0))}else try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then(t=>(t.texture3D?t=t.texture3D:(t.wrapS=E(e.texture?.wrapS),t.wrapT=E(e.texture?.wrapT),t.flipY=e.texture?.flipY??!0),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.clearCacheById(e.id)}clearCacheById(e){const t=Array.from(this.cache.values()).find(t=>t.scene.userData.assetId===e);var s;t&&(Array.from(this.cache.keys()).forEach(e=>{this.cache.get(e)===t&&this.cache.delete(e)}),s=e,U.set(s,U.get(s)??1)),this.textureCache.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(!B.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=g(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 R(c,t,s);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 r=e.id+"|"+(e.mesh?.collisions?.shapeType??"")+"|"+JSON.stringify(e.mesh?.colliders??[]);if(!this.collisionShapeCache.has(r)){const a=e.mesh?.colliders??[],i=a.length>0?a.map(e=>{let t;switch(e.type){case"box":t=new M((new c).fromArray(e.size));break;case"sphere":t=new v(e.radius);break;case"capsule":t=new A(e.length,e.radius);break;case"cylinder":t=new L(e.radius,e.radius,e.height,16,new s)}return t.source=b.custom,t.offset.fromArray(e.position??[0,0,0]),t.rotation.fromArray(e.rotation??[0,0,0,"XYZ"]),t}):_(t,e);this.collisionShapeCache.set(r,i)}return this.collisionShapeCache.get(r)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then(e=>(e.scene.traverse(e=>{e instanceof i&&e.material,C(e)?e.visible=!1:e instanceof i&&e.geometry instanceof t&&(e.geometry.hasAttribute("normal")||e.geometry.computeVertexNormals())}),this._retrievedMeshes.push(e.scene),e.scene=function(e,t){let s=!1;if(t.traverseVisible(e=>{F.test(e.name)&&(s=!0)}),!s)return t;const r=new S.LOD,a=[t];for(;a.length>0;){const e=a.shift(),t=e.name.match(F);if(null!=t){const s=parseInt(t[1]);0===s?r.addLevel(e,0):console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`)}else a.push(...e.children)}return r}(0,e.scene),function(e){const t=G;G.length=0,e.traverse(e=>{(e instanceof S.Camera||e instanceof S.Light)&&t.push(e)}),t.forEach(e=>e.removeFromParent())}(e.scene),e))}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 S.SkinnedMesh)&&e.geometry instanceof t&&Array.isArray(e.material)&&!C(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&&P.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&&!C(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==n&&0!==n&&(r=!1),n=t}else(e instanceof S.SkinnedMesh||e instanceof S.Bone)&&(r=!1)}),a>1&&r){const s=new Map;e.traverse(r=>{if(r instanceof i&&r.geometry instanceof t&&!C(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]:P.mergeGeometries(t.geometries,!0),s.groups.length>1&&P.mergeGroups(s),e.add(new i(s,t.material))}}e.traverse(e=>{if(e instanceof i&&e.geometry instanceof t&&!C(e)){const t=e.geometry;!Array.isArray(e.material)&&t.groups.length>1&&P.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 S.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 S.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 S.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 u;t.materialOptions={normalizeRGB:!1};const s=await t.loadAsync(this.getUri(e.materialLib));this.objLoader.setMaterials(s)}return this.objLoader.loadAsync(t).then(e=>(W(e),e)).then(e=>({scene:e,animations:e.animations}))}}disposeAll(){this.cache.clear(),this._retrievedMeshes.forEach(e=>I(e)),this._retrievedTextures.forEach(e=>e.dispose()),this._retrievedMeshes.length=0,this._retrievedTextures.length=0}}const U=new Map;function W(e){if(e instanceof i)for(const t of T(e.material))t instanceof S.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(W)}export class AssetMeshInstance extends n{}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find(e=>e.startsWith(t));return s?.substring(t.length)}function E(e){switch(e){case"clamp":return S.ClampToEdgeWrapping;case"repeat":return S.RepeatWrapping;case"mirror":return S.MirroredRepeatWrapping}return S.RepeatWrapping}new S.Matrix4;const G=[];const F=/_LOD(\d+)$/;/*
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{Euler as e,Quaternion as t,Vector3 as n}from"three";import{BoxCollisionShape as o,CapsuleCollisionShape as r,CollisionShapeSource as s,ConvexPolyhedronCollisionShape as i,CylinderCollisionShape as l,SphereCollisionShape as m,TrimeshCollisionShape as a}from"./collision-shape.js";import*as u from"three";import{BufferGeometryUtils as h}from"three/examples/jsm/Addons.js";new t;export function importCollisionShapes(p,d){let x=d.mesh?.collisions?.shapeType;if(null==x){let e=!1;p.traverse(t=>{t.isMesh&&isCollisionMesh(t)&&(e=!0)}),x=e?"imported":"convex"}const g=[];if("mesh"===x){const e=[];if(p.traverse(t=>{if(t.isMesh&&!isCollisionMesh(t)){const n=t,o=n.geometry.clone();n.updateMatrixWorld();const r=p.matrixWorld.clone().invert().multiply(n.matrixWorld);o.applyMatrix4(r),e.push(o)}}),e.length>0){const t=h.mergeGeometries(e),n=new a(t);return n.source=s.rendered,g.push(n),g}}const f=p.matrixWorld.clone().invert(),y=new u.Matrix4;return p.traverse(u=>{if(u.isMesh){const h=u;if("imported"===x&&!isCollisionMesh(h))return;let p;if("imported"===x?p=function(t){if(t.name.startsWith(c.convex))return new i(t);if(t.name.startsWith(c.box)){t.geometry.computeBoundingBox();const e=t.geometry.boundingBox;if(null==e)return null;const r=new n;return e.getSize(r),new o(r)}if(t.name.startsWith(c.sphere)){t.geometry.computeBoundingSphere();const e=t.geometry.boundingSphere;return null==e?null:new m(e.radius)}if(t.name.startsWith(c.capsule)){t.geometry.computeBoundingBox();const e=t.geometry.boundingBox;if(null==e)return null;const o=new n;e.getSize(o);const s=Math.min(o.x,o.z)/2;return new r(o.y-2*s,s)}if(t.name.startsWith(c.cylinder)){t.geometry.computeBoundingBox();const o=t.geometry.boundingBox;if(null==o)return null;const r=new n;return o.getSize(r),new l(r.x/2,r.x/2,r.y,16,new e)}if(t.name.startsWith(c.trimesh))return new a(t.geometry)}(h):"convex"===x&&(p=new i(h)),null!=p){p.source="imported"===x?s.custom:s.rendered,h.updateMatrixWorld(),y.copy(f).multiply(h.matrixWorld);const o=new n,r=new t,i=new n;y.decompose(o,r,i),p.offset=o,p.rotation=(new e).setFromQuaternion(r),g.push(p),isCollisionMesh(h)&&(h.visible=!1)}}}),g.length>128&&console.warn(`Asset ${d.name} (${d.id}) has ${g.length} collision shapes. Consider setting Collision Shape Type to 'Mesh' to merge them.`),g}export function isCollisionMesh(e){return e.name.startsWith(c.convex)||e.name.startsWith(c.box)||e.name.startsWith(c.sphere)||e.name.startsWith(c.trimesh)||e.name.startsWith(c.capsule)||e.name.startsWith(c.cylinder)}var c;!function(e){e.convex="UCX_",e.box="UBX_",e.sphere="USP_",e.trimesh="UTM_",e.capsule="UCP_",e.cylinder="UCY_"}(c||(c={}));/*
1
+ import{Euler as e,Quaternion as t,Vector3 as n}from"three";import{BoxCollisionShape as o,CapsuleCollisionShape as r,CollisionShapeSource as s,ConvexPolyhedronCollisionShape as i,CylinderCollisionShape as l,SphereCollisionShape as a,TrimeshCollisionShape as m}from"./collision-shape.js";import*as u from"three";import{BufferGeometryUtils as c}from"three/examples/jsm/Addons.js";import{calculateOBB as p}from"../../utils/obb-utils.js";const h=new t,d=new n,f=new n(1,1,1),y=new t,g=new t,x=new n;export function importCollisionShapes(t,M){let b=M.mesh?.collisions?.shapeType;if(null==b){let e=!1;t.traverse(t=>{t.isMesh&&isCollisionMesh(t)&&(e=!0)}),b=e?"imported":"box"}const C=[];if("mesh"===b){const e=[];if(t.traverse(n=>{if(n.isMesh&&!isCollisionMesh(n)){const o=n,r=o.geometry.clone();o.updateMatrixWorld();const s=t.matrixWorld.clone().invert().multiply(o.matrixWorld);r.applyMatrix4(s),e.push(r)}}),e.length>0){const t=c.mergeGeometries(e),n=new m(t);return n.source=s.rendered,C.push(n),C}}const v=t.matrixWorld.clone().invert(),B=new u.Matrix4;return t.traverse(t=>{if(t.isMesh){const u=t;if("imported"===b&&!isCollisionMesh(u))return;let c;u.updateMatrixWorld(),B.copy(v).multiply(u.matrixWorld),B.decompose(d,h,f),"imported"===b?c=function(t){if(t.name.startsWith(w.convex))return new i(t);if(t.name.startsWith(w.box))return W(t.geometry);if(t.name.startsWith(w.sphere)){t.geometry.computeBoundingSphere();const e=t.geometry.boundingSphere;return null==e?null:new a(e.radius)}if(t.name.startsWith(w.capsule)){t.geometry.computeBoundingBox();const e=t.geometry.boundingBox;if(null==e)return null;const o=new n;e.getSize(o);const s=Math.min(o.x,o.z)/2;return new r(o.y-2*s,s)}if(t.name.startsWith(w.cylinder)){t.geometry.computeBoundingBox();const o=t.geometry.boundingBox;if(null==o)return null;const r=new n;return o.getSize(r),new l(r.x/2,r.x/2,r.y,16,new e)}if(t.name.startsWith(w.trimesh))return new m(t.geometry)}(u):"convex"===b?c=new i(u):"box"===b?c=W(u.geometry):"obb"===b&&(c=function(e){const t=p(e),n=new o(t.size);return n.offset.copy(t.center),n.rotation.copy(t.rotation),n}(u.geometry)),null!=c&&(c.source="imported"===b?s.custom:s.rendered,c.source===s.rendered&&(c.instancedOffset=c.offset.clone(),c.instancedRotation=c.rotation.clone()),function(e,t,n,o){x.copy(e.offset).multiply(o).applyQuaternion(n).add(t),e.offset.copy(x),y.setFromEuler(e.rotation),g.copy(n).multiply(y),e.rotation.setFromQuaternion(g)}(c,d,h,f),C.push(c),isCollisionMesh(u)&&(u.visible=!1))}}),C.length>128&&console.warn(`Asset ${M.name} (${M.id}) has ${C.length} collision shapes. Consider setting Collision Shape Type to 'Mesh' to merge them.`),C}export function isCollisionMesh(e){return e.name.startsWith(w.convex)||e.name.startsWith(w.box)||e.name.startsWith(w.sphere)||e.name.startsWith(w.trimesh)||e.name.startsWith(w.capsule)||e.name.startsWith(w.cylinder)}var w;function W(e){e.computeBoundingBox();const t=e.boundingBox;if(null==t)return null;const r=new n,s=new n;t.getSize(r),t.getCenter(s);const i=new o(r);return i.offset.copy(s),i.rotation.set(0,0,0),i}!function(e){e.convex="UCX_",e.box="UBX_",e.sphere="USP_",e.trimesh="UTM_",e.capsule="UCP_",e.cylinder="UCY_"}(w||(w={}));/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -7,9 +7,9 @@ export declare enum CollisionShapeSource {
7
7
  * instanced meshes in physics system
8
8
  */
9
9
  custom = 0,
10
- /** It is based on the geometry of the rendered mesh
11
- * In this case, we will ignore the position and rotation
12
- * for instanced meshes
10
+ /** It is based on the geometry of the rendered mesh.
11
+ * For instanced meshes we should use the mesh-local transform, because
12
+ * the rendered mesh transform is already baked into the instance matrix.
13
13
  */
14
14
  rendered = 1
15
15
  }
@@ -21,7 +21,6 @@ export declare class CollisionShape {
21
21
  friction?: number;
22
22
  restitution?: number;
23
23
  collisionGroup?: number;
24
- source?: CollisionShapeSource;
25
24
  /**
26
25
  * Collision groups are used to control which objects in a physics simulation can collide with each other.
27
26
  * Each collision shape can be assigned to one or more groups, and collision filters are used to specify
@@ -119,6 +118,8 @@ export declare class CapsuleCollisionShape extends CollisionShape {
119
118
  radius: number;
120
119
  constructor(length: number, radius: number);
121
120
  }
121
+ export declare function cloneCollisionShape<T extends CollisionShape>(shape: T): T;
122
+ export declare function toInstancedCollisionShape<T extends CollisionShape>(shape: T): T;
122
123
  export declare class PhysicalShapeMesh extends Mesh {
123
124
  collisionShape: CollisionShape;
124
125
  physics?: SceneObjectPhysicsSettings;
@@ -1,4 +1,4 @@
1
- import{Euler as s,Mesh as e,Vector3 as t}from"three";export var CollisionShapeSource;!function(s){s[s.custom=0]="custom",s[s.rendered=1]="rendered"}(CollisionShapeSource||(CollisionShapeSource={}));export class CollisionShape{constructor(){this.offset=new t,this.rotation=new s}withCollisionGroup(s){return this.collisionGroup=s,this}withRestitution(s){return this.restitution=s,this}withOffset(s){return this.offset.copy(s),this}withRotation(s){return this.rotation.copy(s),this}withDensity(s){return this.density=s,this}withMass(s){return this.mass=s,this}withFriction(s){return this.friction=s,this}static box(s){return new BoxCollisionShape(s)}static plane(s,e){return new PlaneCollisionShape(s,e)}static sphere(s){return new SphereCollisionShape(s)}static cylinder(s,e,t,i,o){return new CylinderCollisionShape(s,e,t,i,o)}static cone(s,e){return new ConeCollisionShape(s,e)}static convexPolyhedron(s){return new ConvexPolyhedronCollisionShape(s)}static trimesh(s){return new TrimeshCollisionShape(s)}static mesh(s){return new MeshCollisionShape(s)}static capsule(s,e){return new CapsuleCollisionShape(s,e)}}export class BoxCollisionShape extends CollisionShape{constructor(s){super(),this.dimensions=s}}export class PlaneCollisionShape extends CollisionShape{constructor(s,e){super(),this.width=s,this.height=e}}export class SphereCollisionShape extends CollisionShape{constructor(s){super(),this.radius=s}}export class CylinderCollisionShape extends CollisionShape{constructor(s,e,t,i,o){super(),this.radiusTop=s,this.radiusBottom=e,this.height=t,this.segments=i,this.orentation=o}}export class ConeCollisionShape extends CollisionShape{constructor(s,e){super(),this.radiusBottom=s,this.height=e}}export class ConvexPolyhedronCollisionShape extends CollisionShape{constructor(s){super(),this.mesh=s}}export class TrimeshCollisionShape extends CollisionShape{constructor(s){super(),this.geometry=s}}export class MeshCollisionShape extends CollisionShape{constructor(s){super(),this.geometry=s}}export class CapsuleCollisionShape extends CollisionShape{constructor(s,e){super(),this.length=s,this.radius=e}}export class PhysicalShapeMesh extends e{constructor(s,e,t,i){super(s,e),this.collisionShape=t,this.physics=i,this.isPhysicalShapeMesh=!0}}/*
1
+ import{Euler as e,Mesh as o,Vector3 as i}from"three";export var CollisionShapeSource;!function(e){e[e.custom=0]="custom",e[e.rendered=1]="rendered"}(CollisionShapeSource||(CollisionShapeSource={}));export class CollisionShape{constructor(){this.offset=new i,this.rotation=new e}withCollisionGroup(e){return this.collisionGroup=e,this}withRestitution(e){return this.restitution=e,this}withOffset(e){return this.offset.copy(e),this}withRotation(e){return this.rotation.copy(e),this}withDensity(e){return this.density=e,this}withMass(e){return this.mass=e,this}withFriction(e){return this.friction=e,this}static box(e){return new BoxCollisionShape(e)}static plane(e,o){return new PlaneCollisionShape(e,o)}static sphere(e){return new SphereCollisionShape(e)}static cylinder(e,o,i,s,n){return new CylinderCollisionShape(e,o,i,s,n)}static cone(e,o){return new ConeCollisionShape(e,o)}static convexPolyhedron(e){return new ConvexPolyhedronCollisionShape(e)}static trimesh(e){return new TrimeshCollisionShape(e)}static mesh(e){return new MeshCollisionShape(e)}static capsule(e,o){return new CapsuleCollisionShape(e,o)}}export class BoxCollisionShape extends CollisionShape{constructor(e){super(),this.dimensions=e}}export class PlaneCollisionShape extends CollisionShape{constructor(e,o){super(),this.width=e,this.height=o}}export class SphereCollisionShape extends CollisionShape{constructor(e){super(),this.radius=e}}export class CylinderCollisionShape extends CollisionShape{constructor(e,o,i,s,n){super(),this.radiusTop=e,this.radiusBottom=o,this.height=i,this.segments=s,this.orentation=n}}export class ConeCollisionShape extends CollisionShape{constructor(e,o){super(),this.radiusBottom=e,this.height=o}}export class ConvexPolyhedronCollisionShape extends CollisionShape{constructor(e){super(),this.mesh=e}}export class TrimeshCollisionShape extends CollisionShape{constructor(e){super(),this.geometry=e}}export class MeshCollisionShape extends CollisionShape{constructor(e){super(),this.geometry=e}}export class CapsuleCollisionShape extends CollisionShape{constructor(e,o){super(),this.length=e,this.radius=o}}export function cloneCollisionShape(e){let o;if(e instanceof BoxCollisionShape)o=new BoxCollisionShape(e.dimensions.clone());else if(e instanceof PlaneCollisionShape)o=new PlaneCollisionShape(e.width,e.height);else if(e instanceof SphereCollisionShape)o=new SphereCollisionShape(e.radius);else if(e instanceof CylinderCollisionShape)o=new CylinderCollisionShape(e.radiusTop,e.radiusBottom,e.height,e.segments,e.orentation.clone());else if(e instanceof ConeCollisionShape)o=new ConeCollisionShape(e.radiusBottom,e.height);else if(e instanceof ConvexPolyhedronCollisionShape)o=new ConvexPolyhedronCollisionShape(e.mesh);else if(e instanceof TrimeshCollisionShape)o=new TrimeshCollisionShape(e.geometry);else if(e instanceof MeshCollisionShape)o=new MeshCollisionShape(e.geometry);else{if(!(e instanceof CapsuleCollisionShape))throw new Error(`Unsupported collision shape: ${e?.constructor?.name??typeof e}`);o=new CapsuleCollisionShape(e.length,e.radius)}return o.offset.copy(e.offset),o.rotation.copy(e.rotation),o.source=e.source,o.density=e.density,o.mass=e.mass,o.friction=e.friction,o.restitution=e.restitution,o.collisionGroup=e.collisionGroup,null!=e.instancedOffset&&(o.instancedOffset=e.instancedOffset.clone()),null!=e.instancedRotation&&(o.instancedRotation=e.instancedRotation.clone()),o}const s=new i,n=new e;export function toInstancedCollisionShape(e){const o=cloneCollisionShape(e);return e.source===CollisionShapeSource.rendered&&(o.offset.copy(e.instancedOffset??s),o.rotation.copy(e.instancedRotation??n)),o}export class PhysicalShapeMesh extends o{constructor(e,o,i,s){super(e,o),this.collisionShape=i,this.physics=s,this.isPhysicalShapeMesh=!0}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -56,12 +56,16 @@ export type SceneObject = {
56
56
  id: SceneObjectId;
57
57
  /** A name describing what the object is. It is usually defaulted based on the object type */
58
58
  name: string;
59
+ /** Whether the object is enabled. Mainly used for actors and game play related objects but can also be used for meshes to disable them without having to remove them from the scene. */
60
+ enabled?: boolean;
59
61
  /** A list of child objects. These will spatially be relative to the parent. Often used to group other objects. */
60
62
  children?: SceneObject[];
61
63
  /** A referenced asset used for models (meshes) and prefabs */
62
64
  assetId?: AssetId;
63
65
  /** The type of shape */
64
66
  shape?: ShapeType;
67
+ /** If this shape is just a collider. Only relevant for object type shape_mesh */
68
+ collider?: boolean;
65
69
  /** Parameters for the shape. The possible shape params are defined per type in packages\core\src\scene\objects\shapes.ts */
66
70
  shapeParams?: Record<string, CustomParamValue>;
67
71
  light?: {