@hology/core 0.0.174 → 0.0.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as o}from"../scene/materializer.js";import{ViewController as r}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{builtInComponents as m}from"./actors/builtin/components/index.js";import{activeContainerInstance as d}from"./actors/internal/container-map.js";import{InputService as l}from"./input/index.js";import{RuntimeAssetsService as p}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as h}from"../scene/asset-resource-loader.js";import{AssetLoader as u}from"./services/asset-loader.js";import{polyfillClient as f}from"./polyfill.js";import{Subject as g}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as j}from"../scene/runtime-bundled-backend-service.js";import{Scene as b}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(l,g){if(f(),0!=g.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(r);const y=e.of("default"),I=new HologyRuntime(y),x=new n(y,{inEditor:!1});var D;e.set(n,x),D=g.element,Object.assign(D.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const R=new i(g.element,{enableXR:!0===g.xr?.enabled,maxPixelRatio:g.rendering?.maxPixelRatio,bloom:{enabled:!1!==g?.rendering?.bloom?.enabled},reflection:{enabled:!1!==g?.rendering?.reflection?.enabled}});R.renderer.shadowMap.enabled=g.rendering?.shadows?.enabled??!0,R.renderer.shadowMap.autoUpdate=g.rendering?.shadows?.autoUpdate??!0,null!=g?.rendering?.resolutionScale&&(R.resolutionScale=g.rendering.resolutionScale),R.renderer.debug.checkShaderErrors=!1,e.set(i,R);const A=new r(R);e.set(r,A);const G=new j,O=new p(G),P=new h;P.setDataDir(g.dataDir),P.initKtx2(R.renderer);const z=Object.entries(g.shaders).map(([e,t])=>({name:e,type:t})),E=Object.entries(g.actors).map(([e,t])=>({name:e,type:t})),H={...m,...g.components??{}},M=Object.entries(H).map(([e,t])=>({name:e,type:t})),W=new v(z);e.set(v,W);const k=new u(P,O,z);e.set(u,k);const F=new b,N=new o(F,new S,O,P,R,z,E,x,M);e.set(o,N);const T=e.get(s);return e.set(s,T),T.materializer=N,(async()=>{const n=e.get(a);if(await n.start(),I.isShutdown)return;if(await G.preloadData(),I.isShutdown)return;T.scene=F;const{scene:s,actors:o}=await t(R,g.sceneName,g.dataDir,g.shaders,g.actors,H,x,G,O,P,{detailTier:g.detailTier});T.scene=s,n.scene=T.scene;for(const e of F.children)T.scene.add(e);if(I.isShutdown)return void R.stop();e.import([c]);for(const e of o)T.addActor(e);n.addFromScene(s),console.log("Start compile shaders"),console.time("compile shaders"),await R.compileAsync(),console.timeEnd("compile shaders"),console.log("Finished compile shaders. Programs: ",R.renderer.info.programs?.length??0),R.loop(e=>{}),I.status=5,I.shutdownStarted.subscribe(()=>{P.disposeAll()}),d.value=y,y.remove(l),y.set({id:l,type:l});const r=y.get(l);d.value=null,I.gameInstance=r,y.get(w).start(),r instanceof GameInstance&&await r.onStart(),I._resolver(!0)})(),I}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new g,this.ready=new Promise(e=>{this._resolver=e})}getWorld(){return this.containerInstance.get(s)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0;const e=this.shutdownStarted;e.next(),e.complete(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(l).stop();const t=this.containerInstance.get(i);t?.stop();const n=this.containerInstance.get(r);n.setMuted(!0),n.dispose();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(o).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
1
+ import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as o}from"../scene/materializer.js";import{ViewController as r}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{builtInComponents as m}from"./actors/builtin/components/index.js";import{activeContainerInstance as d}from"./actors/internal/container-map.js";import{InputService as l}from"./input/index.js";import{RuntimeAssetsService as p}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as h}from"../scene/asset-resource-loader.js";import{AssetLoader as f}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as g}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as j}from"../scene/runtime-bundled-backend-service.js";import{Scene as b}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(l,g){if(u(),0!=g.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(r);const y=e.of("default"),I=new HologyRuntime(y),x=new n(y,{inEditor:!1});var D;e.set(n,x),D=g.element,Object.assign(D.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const R=new i(g.element,{enableXR:!0===g.xr?.enabled,maxPixelRatio:g.rendering?.maxPixelRatio,resolutionScale:g.rendering?.resolutionScale,bloom:{enabled:!1!==g?.rendering?.bloom?.enabled},reflection:{enabled:!1!==g?.rendering?.reflection?.enabled}});R.renderer.shadowMap.enabled=g.rendering?.shadows?.enabled??!0,R.renderer.shadowMap.autoUpdate=g.rendering?.shadows?.autoUpdate??!0,R.renderer.debug.checkShaderErrors=!1,e.set(i,R);const A=new r(R);e.set(r,A);const G=new j,O=new p(G),P=new h;P.setDataDir(g.dataDir),P.initKtx2(R.renderer);const z=Object.entries(g.shaders).map(([e,t])=>({name:e,type:t})),E=Object.entries(g.actors).map(([e,t])=>({name:e,type:t})),H={...m,...g.components??{}},M=Object.entries(H).map(([e,t])=>({name:e,type:t})),W=new v(z);e.set(v,W);const k=new f(P,O,z);e.set(f,k);const F=new b,N=new o(F,new S,O,P,R,z,E,x,M);e.set(o,N);const T=e.get(s);return e.set(s,T),T.materializer=N,(async()=>{const n=e.get(a);if(await n.start(),I.isShutdown)return;if(await G.preloadData(),I.isShutdown)return;T.scene=F;const{scene:s,actors:o}=await t(R,g.sceneName,g.dataDir,g.shaders,g.actors,H,x,G,O,P,{detailTier:g.detailTier});T.scene=s,n.scene=T.scene;for(const e of F.children)T.scene.add(e);if(I.isShutdown)return void R.stop();e.import([c]);for(const e of o)T.addActor(e);n.addFromScene(s),console.log("Start compile shaders"),console.time("compile shaders"),await R.compileAsync(),console.timeEnd("compile shaders"),console.log("Finished compile shaders. Programs: ",R.renderer.info.programs?.length??0),R.loop(e=>{}),I.status=5,I.shutdownStarted.subscribe(()=>{P.disposeAll()}),d.value=y,y.remove(l),y.set({id:l,type:l});const r=y.get(l);d.value=null,I.gameInstance=r,y.get(w).start(),r instanceof GameInstance&&await r.onStart(),I._resolver(!0)})(),I}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new g,this.ready=new Promise(e=>{this._resolver=e})}getWorld(){return this.containerInstance.get(s)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0;const e=this.shutdownStarted;e.next(),e.complete(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(l).stop();const t=this.containerInstance.get(i);t?.stop();const n=this.containerInstance.get(r);n.setMuted(!0),n.dispose();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(o).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -10,6 +10,7 @@ export type RenderingViewOptions = {
10
10
  enableOutlines?: boolean;
11
11
  enableXR?: boolean;
12
12
  maxPixelRatio?: number;
13
+ resolutionScale?: number;
13
14
  bloom?: {
14
15
  enabled?: boolean;
15
16
  };
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 r,Material as a,Matrix4 as n,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as u,WebGLRenderTarget as c,Texture as d,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 P,ShaderPass as x,VRButton as b}from"three-stdlib";import{CSMShader as y,CSMUtil as w}from"./csm.js";import{bool as S,colorToNormal as R,float as C,NodeShaderMaterial as A,standardMaterial as F,uniformFloat as U,uniformVec3 as B,toonMaterial as I,lambertMaterial as E,normalize as O,rgb as D,rgba as L,textureSampler2d as W,transformed as j,varying as G,varyingAttributes as V,varyingTransformed as _,vec4 as q,BooleanExpression as k,select as N,ifDefApply as H,uniformSampler2d as z,RgbaNode as $,mix 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 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 re,resolutionUniformName as ae,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 ce}from"./shader-nodes/scene-sample.js";import{DepthPass as de}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 Pe}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as xe}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as be}from"./rendering/outline-effect.js";import{UnrealBloomPass as ye}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as we}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 Fe}from"three-stdlib";import{edgeDepthEffect as Ue}from"./shader-nodes/effects";import{decalDiscard as Be}from"./shader-nodes/decal.js";import{Pass as Ie}from"three/examples/jsm/Addons.js";w.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 Oe=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 We=(()=>{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})(),Ve=new A({color:C(0),position:q(C(0))});Ve.visible=!1;const _e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let qe=0,ke=e=class{setPaused(e){this.paused=e}resizeRender(){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*this.resolutionScale,t*this.resolutionScale),this.dofPass.setSize(e*this.resolutionScale,t*this.resolutionScale),this.ssrPass.setSize(e*this.resolutionScale,t*this.resolutionScale),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.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),this.aoPass.setSize(e*this.resolutionScale,t*this.resolutionScale),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.windowVisible=!0,this.running=!0,this.paused=!1,this.fpsCap=null,this.postProcessVolumes=[],this.postProcessSettings={},this._id=qe++,this.fquadCopy=new Fe(new u(f)),this.fquadCopyOpaque=new Fe(new A({outputs:[z("tSceneColor",new d).sample(oe),q(z("tDepthTexture",new i.DepthTexture(1,1)).sample(oe).r)]})),this.fquadBlendAO=(()=>{const e=q(1),t=new A({outputs:[z("tAO",new d).sample(oe),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Fe(t)})(),this.resolutionScale=1,this.maxPixelRatio=_e?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.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 r,this.hadBloom=!1,this.bloomStoredMaterials={},this.bloomHidden=[],this._customDepthMaterialCache=new WeakMap,null!=s.maxPixelRatio&&(this.maxPixelRatio=s.maxPixelRatio),window.renderer=this.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(b.createButton(this.renderer));const a=new be(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=a,this.createGRenderTarget(),this.composer=new g(this.renderer);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,w.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 P(this.scene,this.camera),new x(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const c=new ye(l,1.5,.4,.85);c.threshold=1,c.strength=.9,c.radius=.5,this.bloomPass=c;const p=new ee(this.scene,this.camera,t.clientWidth,t.clientWidth,{});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,Pe.fragmentShader=Pe.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Te({renderer:this.renderer,scene:this.scene,camera:this.camera,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 y=new nt((e,t,s,i,r)=>{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(y);const S=new nt((e,t,s,i,r)=>{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 at(this.scene,this.camera,this.gRenderTarget),this.composer.addPass(this.phasedRenderPass),this.composer.addPass(c),c.emissiveTexture=this.gRenderTarget.textures[1],this.renderer.info.autoReset=!1,this.volumetricFogPass=new xe(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 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 C=new x(M);C.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(C),this.fxaaPass=C,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new x(v).clear=!1,this.fixStatsStyle(),this.lutPass=new T({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const F=new x(f,"prevtexture");F.enabled=!0,F.needsSwap=!1,F.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],F.renderToScreen=!0;const U=new K;this.composer.addPass(U)}fixStatsStyle(){const e=this.stats.dom;e.style.position="absolute";const t=e.getElementsByTagName("canvas");for(let e=0;e<t.length;e++)t.item(e).style.display="inline-block"}setEnableOutlines(e){this.outlinePass.enabled=e,this.fxaaPass.enabled=e}setCamera(e){this.camera=e,this.composer.passes.forEach(t=>{t instanceof P?t.camera=e:t instanceof me?t.renderCamera=e:(t instanceof de||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?(this.csm=new J({maxFar:100,lightFar:250,lightMargin:20,cascades:_e?2:4,shadowMapSize:2048*(_e?.5:1),lightDirection:new i.Vector3(.5,-1,-.6).normalize(),lightIntensity:.5*Math.PI,camera:this.camera,parent:this.scene,mode:"practical"}),this.csm&&Array.isArray(this.csm.lights),this.csm.fade=!0,h.lights_fragment_begin=y.lights_fragment_begin):(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 r=new i.WebGLRenderTarget(t.clientWidth*s,t.clientHeight*s);return r.texture.minFilter=i.NearestFilter,r.texture.magFilter=i.NearestFilter,r.texture.generateMipmaps=!1,r.stencilBuffer=!1,r.depthTexture=new i.DepthTexture(128,128),r.depthTexture.type=i.UnsignedShortType,r.depthTexture.minFilter=i.NearestFilter,r.depthTexture.magFilter=i.NearestFilter,r}static createAOMaskDepthRenderTarget(e,t){const s=new i.WebGLRenderTarget(t.clientWidth*e.getPixelRatio(),t.clientHeight*e.getPixelRatio(),{type:i.HalfFloatType});return s.texture.minFilter=i.NearestFilter,s.texture.magFilter=i.NearestFilter,s.texture.generateMipmaps=!1,s.stencilBuffer=!1,s.depthTexture=new i.DepthTexture(128,128),s.depthTexture.type=i.UnsignedInt248Type,s.depthTexture.minFilter=i.NearestFilter,s.depthTexture.magFilter=i.NearestFilter,s}createSceneColorRenderTarget(e,t){const s=new i.WebGLRenderTarget(t.clientWidth*this.renderer.getPixelRatio(),t.clientHeight*this.renderer.getPixelRatio(),{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return s.texture.minFilter=i.LinearFilter,s.texture.magFilter=i.LinearFilter,s.texture.generateMipmaps=!1,s}createGRenderTarget(){const e=this.container;null!=this.gRenderTarget&&this.gRenderTarget.dispose(),this.gRenderTarget=new c(e.clientWidth*this.renderer.getPixelRatio(),e.clientHeight*this.renderer.getPixelRatio(),{count:3,minFilter:i.NearestFilter,magFilter:i.NearestFilter,type:i.HalfFloatType,format:i.RGBAFormat}),this.gRenderTarget.depthTexture=new i.DepthTexture(e.clientWidth,e.clientHeight),this.gRenderTarget.depthTexture.type=i.UnsignedIntType,this.gRenderTarget.depthTexture.minFilter=i.NearestFilter,this.gRenderTarget.depthTexture.magFilter=i.NearestFilter,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(){this.running=!1,window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),document.removeEventListener("visibilitychange",this.onVisiblityChane),this.onLoopCallbacks=[],this.renderer.dispose(),this.gRenderTarget.dispose(),this.aoMaskDepthRenderTarget.dispose(),this.sceneColorRenderTarget.dispose(),this.csm.dispose(),this.container.replaceChildren(),this.volumetricFogPass.dispose(),w.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 A&&(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:Je(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 A||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)}updateUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s){const t=i[e],r=s[e].value;null!=t&&t.value!==r&&(t.value=r)}}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of ot){const t=i[e],r=s[e];null!=r&&null!=t&&(t.value=r.value)}}createGBufferMaterial(e,t){const s=t===Le.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let r=s.get(e);if(null==r){let n=V.uv;if(e instanceof Ce&&null!=e.heightMap){const t=U("heightScale",e.heightScale??1);n=Ae(n,W(e.heightMap),t)}let o=_.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??Ge,s=U("useNormalMap",null!=e.normalMap?1:0),i=U("normalScale",e.normalScale?.x??1),r=R(W(t).sample(n),i);o=X(_.normal,r,s)}else e instanceof A&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=H("DOUBLE_SIDED",o,e=>N(new k("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?C(0):C(1);if(e instanceof i.MeshStandardMaterial){const t=U("roughness",e.roughness??1),s=e.roughnessMap??We,i=U("useRoughnessMap",null!=e.roughnessMap?1:0),r=W(s).sample(n).g.multiply(t);l=X(t,r,i)}else e instanceof A&&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){const t=e.lightMap??je,s=U("useLightMap",null!=e.lightMap?1:0),i=U("lightMapIntensity",e.lightMapIntensity??1),r=W(t).sample(n).rgb.multiplyScalar(i);h=X(D(0),r,s)}let c=C(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),r=W(s).sample(n).b.multiply(t);c=X(t,r,i)}else e instanceof A&&e.outputRoughness;let d=null,p=C(1);if(e instanceof i.MeshStandardMaterial){const t=e.aoMap??We,s=U("useAoMap",null!=e.aoMap?1:0);p=U("aoMapIntensity",e.aoMapIntensity??1);const i=W(t).sample(n).r;d=X(C(1),i,s)}else e instanceof A&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.alphaMap??We,s=U("useAlphaMap",null!=e.alphaMap?1:0),i=W(t).sample(n).r;g=X(C(1),i,s),g=g.multiply(f)}else e instanceof A&&null!=e.outputOpacity&&(g=e.outputOpacity);let M=L(0,1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){const t=B("color",(new i.Vector3).setFromColor(e.color)),s=e.map??We,r=U("useAlbedoMap",null!=e.map?1:0),a=W(s).sample(n),o=a.multiply(L(t,1)),l=L(t,1);M=X(l,o,r);const h=X(C(1),a.w,r);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let T=D(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=B("emissive",(new i.Vector3).setFromColor(e.emissive)),s=U("emissiveIntensity",e.emissiveIntensity),r=e.emissiveMap??je,a=U("useEmissiveMap",null!=e.emissiveMap?1:0),o=W(r).sample(n).rgb.multiply(t);T=X(t,o,a),T=T.multiplyScalar(s)}else e instanceof A&&null!=e.outputEmissive&&(T=e.outputEmissive);const P=e instanceof u&&null!=e.uniforms[se],x=e instanceof u&&null!=e.uniforms[ce],b=e instanceof u&&null!=e.uniforms[ue],y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,w=U("alphaTest",e.alphaTest);let j,G=e.alphaTest>0?g.lt(w):y&&t===Le.opaque?g.lt(.8):S(!1);!0===e.userData.isDecal&&(G=G.or(Be)),j=y?q(0,0,0,0):(a=o,O(a).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const z=e instanceof A?e.outputPosition:void 0,$=e instanceof A?e.outputTransform:void 0;let Y,Q=L("black",1);if(e instanceof A&&null!=e.outputColor)Q=e.outputColor;else if(e instanceof i.MeshStandardMaterial)Q=F({color:M,metalness:c,roughness:l,emissive:T.rgb,normal:o,ambientOcclusion:d,ambientOcclusionIntensity:p,bakedLight:h});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)Q=E({color:M.rgb});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??D("white");null!=d&&(t=t.multiplyScalar(d.subtract(1).multiply(p).add(1))),e=e.multiply(t),Q=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(Q=I({color:M,emissive:T.rgb,normal:o,ambientOcclusion:d,ambientOcclusionIntensity:p,bakedLight:h}));(e instanceof A||e instanceof i.MeshStandardMaterial)&&(Y=e.envMap);let K=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(K=e.fog);let J=L(Q.rgb,g);K&&(J=new FogNode(J));let Z=!0;if(t===Le.opaque?(Z&&(Z=!P&&!x&&!b),Z&&(Z=!y)):t===Le.transparent&&Z&&(Z=y||P||x||b),!Z)return r=Ve,s.set(e,r),r;r=new A({transform:$,position:null==$?z:void 0,outputs:[J,T.rgba(t===Le.opaque?w:v?1:0),j],opacity:g,outputEncoding:!1,fog:K,transparent:e.transparent,lights:!0,envMap:Y,discard:G}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=r.uniforms.envMapIntensity&&(r.uniforms.envMapIntensity.value=e.envMapIntensity),(e instanceof A||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(r),e instanceof A&&Object.assign(r.defines,e.defines),r.userData.mrtOutputs=3,r.forceSinglePass=e.forceSinglePass,r.side=e.side,r.blending=e.blending,y?(r.depthWrite=!e.transparent,r.depthTest=e.depthTest,r.colorWrite=t===Le.transparent):(r.depthWrite=e.depthWrite,r.depthTest=e.depthTest),r.visible=e.visible,r.alphaTest=e.alphaTest,r.alphaHash=e.alphaHash,Object.assign(r.userData,e.userData),r.visible&&(this.csm.setupMaterial(r),e instanceof u&&Object.assign(r.uniforms,e.uniforms)),s.set(e,r)}var a;return r.visible&&e instanceof u&&this.updateUniformValues(e,r),r}loop(e,t=!1){const s=this.stats,r=s.addPanel(new Z.Panel("Calls","#83f","#002")),a=s.addPanel(new Z.Panel("Triangles","#c32","#002"));let l;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(l=new pe(this.renderer.getContext()),s.addPanel(l)),this.showStats=t;let h=10,u=1e3;const c=()=>{const e=this.renderer.info.render.calls;e>h&&(h=e,setTimeout(()=>h=10,5e3)),r.update(e,h);const t=this.renderer.info.render.triangles;t>u&&(u=t,setTimeout(()=>u=1e3,5e3)),a.update(t,u)};performance.now();i.Ray.prototype.intersectTriangle;this.resizeRender();const d=[],p=[],m=[];let f=0;const g=new n,M=new n;let v=0;let T=this.paused;const P=t=>{const r=this.renderer.getContext();if(this.paused&&this.running&&r.drawingBufferHeight>1)return setTimeout(()=>P(t),500),void(T=!0);this.renderer.clear(),this.applyPostProcessSettings(),this.renderer.autoClear=!1,this.renderer.clear(),this.renderer.setViewport(0,0,this.container.clientWidth,this.container.clientHeight),this.camera,s.begin(),this.showStats&&l?.startQuery(),this.ssrPass.gpuPanel=l;let a=(t*=.001)-f;if(f=t,T&&(a=.016,T=!1),g.copy(this.camera.matrixWorld),a>1){let t=a;for(;t>.05;)e(Ne),t-=Ne;e(t)}else e(a);this.onLoopCallbacks.forEach(e=>e(a)),this.camera?.updateMatrixWorld(),M.copy(this.camera.matrixWorld),t-v>.08&&!M.equals(g)&&(this.renderer.shadowMap.needsUpdate=!0,v=t),this.csm.update();let n=!1;d.length=0,p.length=0,m.length=0;const h=ze;Xe.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),h.setFromProjectionMatrix(Xe);let u=!1,x=!1,b=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Re&&(u=!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),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&&(n=!0)),(e instanceof o||e instanceof i.Sprite)&&e.visible&&(e.material?.userData?.water||e.material?.uniforms&&null!=e.material?.uniforms[se])&&isObjectInFrustum(e,h)?(this.initDepthUniform(e.material),x=!0):e instanceof Y&&(e.visible=!1,p.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ue]&&isObjectInFrustum(e,h)&&e.material instanceof A&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ce]&&isObjectInFrustum(e,h)&&(m.push(e),e.material.uniforms[ce].value=this.sceneColorRenderTarget.texture,b=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[he])e.material.uniforms[he].value=t;else if(e instanceof o&&Array.isArray(e.material))for(const s of e.material)s.uniforms&&null!=s.uniforms[he]&&(s.uniforms[he].value=t)}),this.bloomPass.enabled=n,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderScene(Le.opaque),this.aoPass.output=ee.OUTPUT.Off,(x||b)&&(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)),m.length,d.forEach(e=>e.visible=!0),p.forEach(e=>e.visible=!0),m.forEach(e=>e.visible=!0),this.aoPass.enabled,this.ssrPass&&(this.ssrPass.elapsedTime=t),this.volumetricFogPass&&u&&this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene);try{!this.paused&&this.running&&(this.render(a),this.showStats&&l?.endQuery(),this.showStats&&c(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}s.end(),this.csm?.update(),this.running&&!0!==this.options.enableXR&&(this.fpsCap?setTimeout(()=>{requestAnimationFrame(P)},1e3/this.fpsCap):requestAnimationFrame(P))};!0===this.options.enableXR?this.renderer.setAnimationLoop(P):requestAnimationFrame(P)}applyGBufferMaterials(e){tt.clear(),st.length=0;ge(this.scene,t=>{if(it(t))return st.push(t),t.visible=!1,!1;if(t instanceof o){tt.set(t,t.material);let s=!1;if(Array.isArray(t.material)){t.material=t.material.slice();for(let i=0;i<t.material.length;i++)t.material[i]=this.createGBufferMaterial(t.material[i],e),s||(s=t.material[i].visible)}else t.material=this.createGBufferMaterial(t.material,e),s||(s=t.material.visible);s?t.visible=!0:null!=t.children&&0!=t.children.length||(st.push(t),t.visible=!1)}})}unapplyGBufferMaterials(){tt.forEach((e,t)=>{t.material=e}),st.forEach((e,t)=>{e.visible=!0,e.updateMatrixWorld(!0)})}async compileAsync(){this.compileInProgress||(this.renderer.setRenderTarget(this.gRenderTarget),this.compileInProgress=!0,this.applyGBufferMaterials(Le.opaque),await this.renderer.compileAsync(this.scene,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(Le.transparent),await this.renderer.compileAsync(this.scene,this.camera),this.unapplyGBufferMaterials(),this.compileInProgress=!1,this.renderer.setRenderTarget(null))}renderScene(e){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&&tt.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,r=!1,a=!1,n=!1,o=!1;if(null==this.camera)return;const h=this.camera.getWorldPosition(Ye);let u=[];for(const e of this.postProcessVolumes){if(!He(e.object))continue;let l=e.blendWeight??1;const c=e.distanceToPoint(h);c>e.blendRadius||(e.blendRadius>0&&(l*=Me(1-c/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),a=!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&&(r=!0,t.depthFocus=void 0!==t.depthFocus?i.MathUtils.lerp(t.depthFocus,e.settings.depthFocus,l):e.settings.depthFocus),void 0!==e.settings.depthAperture&&(r=!0,t.depthAperture=void 0!==t.depthAperture?i.MathUtils.lerp(t.depthAperture,e.settings.depthAperture,l):e.settings.depthAperture),void 0!==e.settings.depthMaxBlur&&(r=!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=a,this.colorPass.colorTint=t.colorTint,this.colorPass.colorTintIntensity=t.colorTintIntensity,this.colorPass.enabled=a||o,r&&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(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,ze)&&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===Oe.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Oe:(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[re]&&(e.uniforms[re].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 A&&t.uniforms.receiveShadow&&(t.uniforms.receiveShadow.value=e.receiveShadow)}initResolutionUniform(e){if(e instanceof u&&null!=e.uniforms[ae]){const t=this.previousClientWith,s=this.previousClientHeight;e.uniforms[ae].value.set(t*this.renderer.getPixelRatio(),s*this.renderer.getPixelRatio())}}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 A&&!t.transparent&&t.depthWrite){let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Se(we);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new A({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}}};ke=e=t([te(),s("design:paramtypes",[HTMLElement,Object])],ke);export{ke as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const Ne=.05;function He(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 ze=new i.Frustum,$e=new i.Box3,Xe=new i.Matrix4;export function isObjectInFrustum(e,t){const s=$e.setFromObject(e);return t.intersectsBox(s)}const Ye=new i.Vector3;const Qe=new n,Ke=new p;function Je(e,t,s=new i.Matrix3){return Ke.copy(e),Ke.x*=-1,Ke.y*=-1,Ke.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(Ke.y*=-1,Ke.z*=-1),s.setFromMatrix4(Qe.makeRotationFromEuler(Ke))}const Ze=new A({outputs:[q(0,0,0,0),q(0,0,0,0),L(D("white"),Ue(4))],transparent:!0}),et=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});Ze.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),et);const tt=new Map,st=[];function it(e){return e instanceof i.Sprite||e.isPoints||e.isLine||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 A))}class at extends Ie{constructor(e,t,s){super(),this.scene=e,this.camera=t,this.gRenderTarget=s,this.needsSwap=!1}render(e,t,s,i,r){const a=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),st.length=0;let c=0;this.scene.traverseVisible(e=>{const t=it(e);e instanceof o&&!t?(st.push(e),e.visible=!1):t&&c++}),c>0&&e.render(this.scene,this.camera),st.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=a,s.depthTexture=u,this.scene.matrixWorldAutoUpdate=n,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class nt extends Ie{constructor(e){super(),this.fn=e}render(e,t,s,i,r){this.fn(e,t,s,i,r)}}const ot=["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"],lt=B("fogColor");export class FogNode extends ${constructor(e,t=lt){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),r=e.get(this.fogColor),a=e.get(U("fogFar")),n=e.get(U("fogNear")),o=e.get(U("fogDensity")),l=e.get(G(j.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}, ${a}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${r}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}/*
1
+ var e;import{__decorate as t,__metadata as s}from"tslib";import*as i from"three";import{Color as r,Material as a,Matrix4 as n,Mesh as o,PerspectiveCamera as l,ShaderChunk as h,ShaderMaterial as d,WebGLRenderTarget as u,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 x,ShaderPass as P,VRButton as b}from"three-stdlib";import{CSMShader as y,CSMUtil as w}from"./csm.js";import{bool as R,colorToNormal as S,float as C,NodeShaderMaterial as A,standardMaterial as F,uniformFloat as U,uniformVec3 as B,toonMaterial as I,lambertMaterial as E,normalize as O,rgb as D,rgba as L,textureSampler2d as W,transformed as j,varying as G,varyingAttributes as V,varyingTransformed as _,vec4 as N,BooleanExpression as q,select as k,ifDefApply as z,uniformSampler2d as H,RgbaNode as $,mix 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 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 re,resolutionUniformName as ae,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 de,sceneMapUniformName as ue}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 xe}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as Pe}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as be}from"./rendering/outline-effect.js";import{UnrealBloomPass as ye}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as we}from"./shader-nodes/depth.js";import{packDepthToRGBA as Re}from"three-shader-graph";import{FogVolumeObject as Se}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 Fe}from"three-stdlib";import{edgeDepthEffect as Ue}from"./shader-nodes/effects";import{decalDiscard as Be}from"./shader-nodes/decal.js";import{Pass as Ie}from"three/examples/jsm/Addons.js";w.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 Oe=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 We=(()=>{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})(),Ve=new A({color:C(0),position:N(C(0))});Ve.visible=!1;const _e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let Ne=0,qe=e=class{setPaused(e){this.paused=e}resizeRender(){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.windowVisible=!0,this.running=!0,this.paused=!1,this.fpsCap=null,this.postProcessVolumes=[],this.postProcessSettings={},this._id=Ne++,this.fquadCopy=new Fe(new d(f)),this.fquadCopyOpaque=new Fe(new A({outputs:[H("tSceneColor",new c).sample(V.uv),N(H("tDepthTexture",new i.DepthTexture(1,1)).sample(V.uv).r)]})),this.fquadBlendAO=(()=>{const e=N(1),t=new A({outputs:[H("tAO",new c).sample(oe),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Fe(t)})(),this.resolutionScale=1,this.maxPixelRatio=_e?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.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 r,this.hadBloom=!1,this.bloomStoredMaterials={},this.bloomHidden=[],this._customDepthMaterialCache=new WeakMap,null!=s.maxPixelRatio&&(this.maxPixelRatio=s.maxPixelRatio),this.resolutionScale=s.resolutionScale??1,window.renderer=this.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(b.createButton(this.renderer));const a=new be(this.renderer,{defaultThickness:.005,defaultColor:[0,0,0],defaultAlpha:1,defaultKeepAlive:!0});this.outlineEffect=a,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,w.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 x(this.scene,this.camera),new P(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const u=new ye(l,1.5,.4,.85);u.threshold=1,u.strength=.9,u.radius=.5,this.bloomPass=u;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,xe.fragmentShader=xe.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 y=new nt((e,t,s,i,r)=>{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(y);const R=new nt((e,t,s,i,r)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(Le.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(R),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new at(this.scene,this.camera,this.gRenderTarget),this.composer.addPass(this.phasedRenderPass),this.composer.addPass(u),u.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 ve;this.composer.addPass(S),this.colorPass=S,S.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 C=new P(M);C.uniforms.resolution.value.set(1/t.clientWidth,1/t.clientHeight),this.composer.addPass(C),this.fxaaPass=C,this.fxaaPass.enabled=!1,!0===s.enableOutlines&&this.setEnableOutlines(!0),new P(v).clear=!1,this.fixStatsStyle(),this.lutPass=new T({}),this.lutPass.enabled=!1,this.composer.addPass(this.lutPass);const F=new P(f,"prevtexture");F.enabled=!0,F.needsSwap=!1,F.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[1],F.renderToScreen=!0;const U=new K;this.composer.addPass(U)}fixStatsStyle(){const e=this.stats.dom;e.style.position="absolute";const t=e.getElementsByTagName("canvas");for(let e=0;e<t.length;e++)t.item(e).style.display="inline-block"}setEnableOutlines(e){this.outlinePass.enabled=e,this.fxaaPass.enabled=e}setCamera(e){this.camera=e,this.composer.passes.forEach(t=>{t instanceof x?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?(this.csm=new J({maxFar:100,lightFar:250,lightMargin:20,cascades:_e?2:4,shadowMapSize:2048*(_e?.5:1),lightDirection:new i.Vector3(.5,-1,-.6).normalize(),lightIntensity:.5*Math.PI,camera:this.camera,parent:this.scene,mode:"practical"}),this.csm&&Array.isArray(this.csm.lights),this.csm.fade=!0,h.lights_fragment_begin=y.lights_fragment_begin):(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 r=Math.max(1,Math.floor(t.clientWidth*s)),a=Math.max(1,Math.floor(t.clientHeight*s)),n=new i.WebGLRenderTarget(r,a);return n.texture.minFilter=i.NearestFilter,n.texture.magFilter=i.NearestFilter,n.texture.generateMipmaps=!1,n.stencilBuffer=!1,n.depthTexture=new i.DepthTexture(r,a),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()),r=Math.max(1,t.clientHeight*e.getPixelRatio()),a=new i.DepthTexture(s,r);a.type=i.UnsignedInt248Type,a.minFilter=i.NearestFilter,a.magFilter=i.NearestFilter;const n=new i.WebGLRenderTarget(s,r,{type:i.HalfFloatType,depthTexture:a});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,r=this.gRenderTarget.height,a=new i.WebGLRenderTarget(s,r,{count:2,type:i.FloatType,format:i.RGBAFormat,colorSpace:i.SRGBColorSpace,depthBuffer:!1,stencilBuffer:!1});return a.texture.minFilter=i.LinearFilter,a.texture.magFilter=i.LinearFilter,a.texture.generateMipmaps=!1,a.textures[1].minFilter=i.NearestFilter,a.textures[1].magFilter=i.NearestFilter,a}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()),r=new i.DepthTexture(t,s);r.type=i.UnsignedIntType,r.minFilter=i.NearestFilter,r.magFilter=i.NearestFilter,this.gRenderTarget=new u(t,s,{count:3,minFilter:i.NearestFilter,magFilter:i.NearestFilter,type:i.HalfFloatType,format:i.RGBAFormat,depthTexture:r}),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(){this.running=!1,window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),document.removeEventListener("visibilitychange",this.onVisiblityChane),this.onLoopCallbacks=[],this.renderer.dispose(),this.gRenderTarget.dispose(),this.aoMaskDepthRenderTarget.dispose(),this.sceneColorRenderTarget.dispose(),this.csm.dispose(),this.container.replaceChildren(),this.volumetricFogPass.dispose(),w.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 A&&(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:Je(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 A||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)}updateUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e in s){const t=i[e],r=s[e].value;null!=t&&t.value!==r&&(t.value=r)}}updateLightUniformValues(e,t){const s=e.uniforms,i=t.uniforms;for(const e of ot){const t=i[e],r=s[e];null!=r&&null!=t&&(t.value=r.value)}}createGBufferMaterial(e,t){const s=t===Le.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let r=s.get(e);if(null==r){let n=V.uv;if(e instanceof Ce&&null!=e.heightMap){const t=U("heightScale",e.heightScale??1);n=Ae(n,W(e.heightMap),t)}let o=_.normal;if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.normalMap??Ge,s=U("useNormalMap",null!=e.normalMap?1:0),i=U("normalScale",e.normalScale?.x??1),r=S(W(t).sample(n),i);o=X(_.normal,r,s)}else e instanceof A&&null!=e.outputNormal&&(o=e.outputNormal);!0!==e.userData.disableAO&&(o=z("DOUBLE_SIDED",o,e=>k(new q("gl_FrontFacing"),e,e.multiplyScalar(-1))));let l=e.userData?.reflective?C(0):C(1);if(e instanceof i.MeshStandardMaterial){const t=U("roughness",e.roughness??1),s=e.roughnessMap??We,i=U("useRoughnessMap",null!=e.roughnessMap?1:0),r=W(s).sample(n).g.multiply(t);l=X(t,r,i)}else e instanceof A&&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){const t=e.lightMap??je,s=U("useLightMap",null!=e.lightMap?1:0),i=U("lightMapIntensity",e.lightMapIntensity??1),r=W(t).sample(n).rgb.multiplyScalar(i);h=X(D(0),r,s)}let u=C(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),r=W(s).sample(n).b.multiply(t);u=X(t,r,i)}else e instanceof A&&e.outputRoughness;let c=null,p=C(1);if(e instanceof i.MeshStandardMaterial){const t=e.aoMap??We,s=U("useAoMap",null!=e.aoMap?1:0);p=U("aoMapIntensity",e.aoMapIntensity??1);const i=W(t).sample(n).r;c=X(C(1),i,s)}else e instanceof A&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=C(1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=e.alphaMap??We,s=U("useAlphaMap",null!=e.alphaMap?1:0),i=W(t).sample(n).r;g=X(C(1),i,s),g=g.multiply(f)}else e instanceof A&&null!=e.outputOpacity&&(g=e.outputOpacity);let M=L(0,1);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial){const t=B("color",(new i.Vector3).setFromColor(e.color)),s=e.map??We,r=U("useAlbedoMap",null!=e.map?1:0),a=W(s).sample(n),o=a.multiply(L(t,1)),l=L(t,1);M=X(l,o,r);const h=X(C(1),a.w,r);g=g.multiply(h)}const v=!0===e.userData.hasBloom;let T=D(0);if(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial){const t=B("emissive",(new i.Vector3).setFromColor(e.emissive)),s=U("emissiveIntensity",e.emissiveIntensity),r=e.emissiveMap??je,a=U("useEmissiveMap",null!=e.emissiveMap?1:0),o=W(r).sample(n).rgb.multiply(t);T=X(t,o,a),T=T.multiplyScalar(s)}else e instanceof A&&null!=e.outputEmissive&&(T=e.outputEmissive);const x=e instanceof d&&null!=e.uniforms[se],P=e instanceof d&&null!=e.uniforms[ue],b=e instanceof d&&null!=e.uniforms[de],y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,w=U("alphaTest",e.alphaTest);let j,G=e.alphaTest>0?g.lt(w):y&&t===Le.opaque?g.lt(.8):R(!1);!0===e.userData.isDecal&&(G=G.or(Be)),j=y?N(0,0,0,0):(a=o,O(a).multiplyScalar(.5).addScalar(.5)).rgba(e.userData?.reflective?l:1);const H=e instanceof A?e.outputPosition:void 0,$=e instanceof A?e.outputTransform:void 0;let Y,Q=L("black",1);if(e instanceof A&&null!=e.outputColor)Q=e.outputColor;else if(e instanceof i.MeshStandardMaterial)Q=F({color:M,metalness:u,roughness:l,emissive:T.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)Q=E({color:M.rgb});else if(e instanceof i.MeshBasicMaterial){let e=M.rgb,t=h??D("white");null!=c&&(t=t.multiplyScalar(c.subtract(1).multiply(p).add(1))),e=e.multiply(t),Q=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(Q=I({color:M,emissive:T.rgb,normal:o,ambientOcclusion:c,ambientOcclusionIntensity:p,bakedLight:h}));(e instanceof A||e instanceof i.MeshStandardMaterial)&&(Y=e.envMap);let K=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(K=e.fog);let J=L(Q.rgb,g);K&&(J=new FogNode(J));let Z=!0;if(t===Le.opaque?(Z&&(Z=!x&&!P&&!b),Z&&(Z=!y)):t===Le.transparent&&Z&&(Z=y||x||P||b),!Z)return r=Ve,s.set(e,r),r;r=new A({transform:$,position:null==$?H:void 0,outputs:[J,T.rgba(t===Le.opaque?w:v?1:0),j],opacity:g,outputEncoding:!1,fog:K,transparent:e.transparent,lights:!0,envMap:Y,discard:G}),e instanceof i.MeshStandardMaterial&&null!=e.envMap&&null!=r.uniforms.envMapIntensity&&(r.uniforms.envMapIntensity.value=e.envMapIntensity),(e instanceof A||e instanceof i.MeshStandardMaterial)&&this.applyEnvMap(r),e instanceof A&&Object.assign(r.defines,e.defines),r.userData.mrtOutputs=3,r.forceSinglePass=e.forceSinglePass,r.side=e.side,r.blending=e.blending,y?(r.depthWrite=!e.transparent,r.depthTest=e.depthTest,r.colorWrite=t===Le.transparent):(r.depthWrite=e.depthWrite,r.depthTest=e.depthTest),r.visible=e.visible,r.alphaTest=e.alphaTest,r.alphaHash=e.alphaHash,Object.assign(r.userData,e.userData),r.visible&&(this.csm.setupMaterial(r),e instanceof d&&Object.assign(r.uniforms,e.uniforms)),s.set(e,r)}var a;return r.visible&&e instanceof d&&this.updateUniformValues(e,r),r}loop(e,t=!1){const s=this.stats,r=s.addPanel(new Z.Panel("Calls","#83f","#002")),a=s.addPanel(new Z.Panel("Triangles","#c32","#002"));let l;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(l=new pe(this.renderer.getContext()),s.addPanel(l)),this.showStats=t;let h=10,d=1e3;const u=()=>{const e=this.renderer.info.render.calls;e>h&&(h=e,setTimeout(()=>h=10,5e3)),r.update(e,h);const t=this.renderer.info.render.triangles;t>d&&(d=t,setTimeout(()=>d=1e3,5e3)),a.update(t,d)};performance.now();i.Ray.prototype.intersectTriangle;this.resizeRender();const c=[],p=[],m=[];let f=0;const g=new n,M=new n;let v=0;let T=this.paused;const x=t=>{const r=this.renderer.getContext();if(this.paused&&this.running&&r.drawingBufferHeight>1)return setTimeout(()=>x(t),500),void(T=!0);this.renderer.clear(),this.applyPostProcessSettings(),this.renderer.autoClear=!1,this.renderer.clear(),this.renderer.setViewport(0,0,this.container.clientWidth,this.container.clientHeight),this.camera,s.begin(),this.showStats&&l?.startQuery(),this.ssrPass.gpuPanel=l;let a=(t*=.001)-f;if(f=t,T&&(a=.016,T=!1),g.copy(this.camera.matrixWorld),a>1){let t=a;for(;t>.05;)e(ke),t-=ke;e(t)}else e(a);this.onLoopCallbacks.forEach(e=>e(a)),this.camera?.updateMatrixWorld(),M.copy(this.camera.matrixWorld),t-v>.08&&!M.equals(g)&&(this.renderer.shadowMap.needsUpdate=!0,v=t),this.csm.update();let n=!1;c.length=0,p.length=0,m.length=0;const h=He;Xe.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),h.setFromProjectionMatrix(Xe);let d=!1,P=!1,b=!1;this.scene.traverseVisible(e=>{if(this.setupCsm(e),this.outlineEffect.apply(e),e instanceof Se&&(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),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&&(n=!0)),(e instanceof o||e instanceof i.Sprite)&&e.visible&&(e.material?.userData?.water||e.material?.uniforms&&null!=e.material?.uniforms[se])&&isObjectInFrustum(e,h)?(this.initDepthUniform(e.material),P=!0):e instanceof Y&&(e.visible=!1,p.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[de]&&isObjectInFrustum(e,h)&&e.material instanceof A&&this.initAoUniform(e.material),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[ue]&&isObjectInFrustum(e,h)&&(m.push(e),e.material.uniforms[ue].value=this.sceneColorRenderTarget.texture,b=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[he])e.material.uniforms[he].value=t;else if(e instanceof o&&Array.isArray(e.material))for(const s of e.material)s.uniforms&&null!=s.uniforms[he]&&(s.uniforms[he].value=t)}),this.bloomPass.enabled=n,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderScene(Le.opaque),this.aoPass.output=ee.OUTPUT.Off,(P||b)&&(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)),m.length,c.forEach(e=>e.visible=!0),p.forEach(e=>e.visible=!0),m.forEach(e=>e.visible=!0),this.aoPass.enabled,this.ssrPass&&(this.ssrPass.elapsedTime=t),this.volumetricFogPass&&d&&this.volumetricFogPass.update(this.camera,this.gRenderTarget,this.csm,this.scene);try{!this.paused&&this.running&&(this.render(a),this.showStats&&l?.endQuery(),this.showStats&&u(),this.renderer.info.reset(),this.renderOverlay())}catch(e){console.warn(e)}s.end(),this.csm?.update(),this.running&&!0!==this.options.enableXR&&(this.fpsCap?setTimeout(()=>{requestAnimationFrame(x)},1e3/this.fpsCap):requestAnimationFrame(x))};!0===this.options.enableXR?this.renderer.setAnimationLoop(x):requestAnimationFrame(x)}applyGBufferMaterials(e){tt.clear(),st.length=0;ge(this.scene,t=>{if(it(t))return st.push(t),t.visible=!1,!1;if(t instanceof o){tt.set(t,t.material);let s=!1;if(Array.isArray(t.material)){t.material=t.material.slice();for(let i=0;i<t.material.length;i++)t.material[i]=this.createGBufferMaterial(t.material[i],e),s||(s=t.material[i].visible)}else t.material=this.createGBufferMaterial(t.material,e),s||(s=t.material.visible);s?t.visible=!0:null!=t.children&&0!=t.children.length||(st.push(t),t.visible=!1)}})}unapplyGBufferMaterials(){tt.forEach((e,t)=>{t.material=e}),st.forEach((e,t)=>{e.visible=!0,e.updateMatrixWorld(!0)})}async compileAsync(){this.compileInProgress||(this.renderer.setRenderTarget(this.gRenderTarget),this.compileInProgress=!0,this.applyGBufferMaterials(Le.opaque),await this.renderer.compileAsync(this.scene,this.camera),this.unapplyGBufferMaterials(),this.applyGBufferMaterials(Le.transparent),await this.renderer.compileAsync(this.scene,this.camera),this.unapplyGBufferMaterials(),this.compileInProgress=!1,this.renderer.setRenderTarget(null))}renderScene(e){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&&tt.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof d&&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,r=!1,a=!1,n=!1,o=!1;if(null==this.camera)return;const h=this.camera.getWorldPosition(Ye);let d=[];for(const e of this.postProcessVolumes){if(!ze(e.object))continue;let l=e.blendWeight??1;const u=e.distanceToPoint(h);u>e.blendRadius||(e.blendRadius>0&&(l*=Me(1-u/e.blendRadius,0,1)),l>1&&(l=1),l>0&&(d.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),a=!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&&(r=!0,t.depthFocus=void 0!==t.depthFocus?i.MathUtils.lerp(t.depthFocus,e.settings.depthFocus,l):e.settings.depthFocus),void 0!==e.settings.depthAperture&&(r=!0,t.depthAperture=void 0!==t.depthAperture?i.MathUtils.lerp(t.depthAperture,e.settings.depthAperture,l):e.settings.depthAperture),void 0!==e.settings.depthMaxBlur&&(r=!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=a,this.colorPass.colorTint=t.colorTint,this.colorPass.colorTintIntensity=t.colorTintIntensity,this.colorPass.enabled=a||o,r&&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(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,He)&&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===Oe.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Oe:(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 d&&(e.uniforms[se].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[re]&&(e.uniforms[re].value=this.camera.near),null!=e.uniforms[ie]&&(e.uniforms[ie].value=this.camera.far)))}initNormalUniform(e){e instanceof d&&null!=e.uniforms[ne]&&(e.uniforms[ne].value=this.gRenderTarget.textures[2])}initShadowUniform(e,t){t instanceof A&&t.uniforms.receiveShadow&&(t.uniforms.receiveShadow.value=e.receiveShadow)}initResolutionUniform(e){e instanceof d&&null!=e.uniforms[ae]&&e.uniforms[ae].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 A&&!t.transparent&&t.depthWrite){let s=this._customDepthMaterialCache.get(t);if(null==s){const e=Re(we);let i;null!=t.alphaTest&&t.alphaTest>0&&null!=t.outputOpacity&&(i=t.outputOpacity.lt(t.alphaTest)),s=new A({color:e,discard:i}),this._customDepthMaterialCache.set(t,s)}e.customDepthMaterial=s}}};qe=e=t([te(),s("design:paramtypes",[HTMLElement,Object])],qe);export{qe as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const ke=.05;function ze(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 He=new i.Frustum,$e=new i.Box3,Xe=new i.Matrix4;export function isObjectInFrustum(e,t){const s=$e.setFromObject(e);return t.intersectsBox(s)}const Ye=new i.Vector3;const Qe=new n,Ke=new p;function Je(e,t,s=new i.Matrix3){return Ke.copy(e),Ke.x*=-1,Ke.y*=-1,Ke.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(Ke.y*=-1,Ke.z*=-1),s.setFromMatrix4(Qe.makeRotationFromEuler(Ke))}const Ze=new A({outputs:[N(0,0,0,0),N(0,0,0,0),L(D("white"),Ue(4))],transparent:!0}),et=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});Ze.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),et);const tt=new Map,st=[];function it(e){return e instanceof i.Sprite||e.isPoints||e.isLine||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 A))}class at extends Ie{constructor(e,t,s){super(),this.scene=e,this.camera=t,this.gRenderTarget=s,this.needsSwap=!1}render(e,t,s,i,r){const a=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 d=s.depthTexture;s.depthTexture=this.gRenderTarget.depthTexture,e.setRenderTarget(s),st.length=0;let u=0;this.scene.traverseVisible(e=>{const t=it(e);e instanceof o&&!t?(st.push(e),e.visible=!1):t&&u++}),u>0&&e.render(this.scene,this.camera),st.forEach((e,t)=>{e.visible=!0}),e.setRenderTarget(null),e.autoClear=a,s.depthTexture=d,this.scene.matrixWorldAutoUpdate=n,this.scene.matrixAutoUpdate=l,e.shadowMap.autoUpdate=h}}class nt extends Ie{constructor(e){super(),this.fn=e}render(e,t,s,i,r){this.fn(e,t,s,i,r)}}const ot=["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"],lt=B("fogColor");export class FogNode extends ${constructor(e,t=lt){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),r=e.get(this.fogColor),a=e.get(U("fogFar")),n=e.get(U("fogNear")),o=e.get(U("fogDensity")),l=e.get(G(j.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}, ${a}, ${l} );\n #endif\n vec4 color_vec4_${t} = vec4(mix(${s}, ${r}, fogFactor_${t}), ${i});\n `,out:`color_vec4_${t}`}}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{attributes as t,dot as r,float as e,ifDefApply as o,normalize as i,pow as m,saturate as n,transformed as p,uniforms as a,varying as c,varyingAttributes as f,vec4 as l}from"three-shader-graph";import{fragmentLinearEyeDepth as s,linearEyeDepth as u}from"./depth.js";import{oneMinus as d}from"./math.js";a.modelMatrix.multiplyVec(l(t.position,1));export function fresnelEffect(t=1){const i=o("FLIP_SIDED",p.normal,()=>p.normal.multiplyScalar(-1));return m(d(n(r(p.viewDir,i))),e(t))}const h=e(1).subtract(u.subtract(s).divide(u));export function edgeDepthEffect(t=1){return m(h,e(t))}/*
1
+ import{attributes as t,dot as r,float as e,ifDefApply as o,max as i,normalize as m,pow as n,saturate as p,transformed as a,uniforms as c,varying as f,varyingAttributes as l,vec4 as s}from"three-shader-graph";import{fragmentLinearEyeDepth as u,linearEyeDepth as d}from"./depth.js";import{oneMinus as h}from"./math.js";c.modelMatrix.multiplyVec(s(t.position,1));export function fresnelEffect(t=1){const i=o("FLIP_SIDED",a.normal,()=>a.normal.multiplyScalar(-1));return n(h(p(r(a.viewDir,i))),e(t))}const D=e(1).subtract(d.subtract(u).divide(d));export function edgeDepthEffect(t=1){return i(n(D,e(t)),0)}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hology/core",
3
- "version": "0.0.174",
3
+ "version": "0.0.175",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -174,7 +174,7 @@
174
174
  "recast-navigation": "0.39.0",
175
175
  "rxjs": "7.8.1",
176
176
  "three-mesh-bvh": "^0.7.5",
177
- "three-shader-graph": "^0.2.33",
177
+ "three-shader-graph": "^0.2.36",
178
178
  "three-stdlib": "2.34.0",
179
179
  "ts-key-enum": "^2.0.12",
180
180
  "typedi": "^0.10.0"