@hology/core 0.0.172 → 0.0.174

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,7 +1,8 @@
1
1
  import { CustomRenderer, MeshRenderer, Particle } from '@hology/nebula';
2
2
  import * as THREE from 'three';
3
3
  import { Object3D } from 'three';
4
- import { OutputTextureSetting, ViewController } from '../../gameplay';
4
+ import { ViewController } from '../../gameplay/services/render.js';
5
+ import { OutputTextureSetting } from './vfx-asset.js';
5
6
  export declare class MultiRenderer extends CustomRenderer {
6
7
  private worldContainer;
7
8
  private localContainer;
@@ -1,6 +1,7 @@
1
+ import * as THREE from 'three';
2
+ import { AnimationAction, Vector3 } from 'three';
1
3
  import { ActionInput, AxisInput, RotationInput } from '../../../../../gameplay/input/index.js';
2
4
  import { PhysicsSystem } from '../../../../../gameplay/services/physics/physics-system.js';
3
- import { Vector3, AnimationAction } from 'three';
4
5
  import { ActorComponent } from '../../../component.js';
5
6
  import { CharacterMovementMode } from './modes.js';
6
7
  export declare class CharacterMovementComponent extends ActorComponent {
@@ -45,7 +46,7 @@ export declare class CharacterMovementComponent extends ActorComponent {
45
46
  * inputs should be ignored.
46
47
  */
47
48
  enabled: boolean;
48
- readonly velocity: Vector3;
49
+ readonly velocity: THREE.Vector3;
49
50
  mode: CharacterMovementMode;
50
51
  isSprinting: boolean;
51
52
  pressedJump: boolean;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import{ActionInput as i,AxisInput as o,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as a,Vector3 as c,ArrowHelper as l}from"three";import{ActorComponent as h,Component as p}from"../../../component.js";import{CharacterMovementMode as m}from"./modes.js";import{CapsuleCollisionShape as u}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as d}from"rxjs";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import g from"@dimforge/rapier3d-compat";import{RootMotionClip as f}from"../../../../../gameplay/animation/root-motion.js";import*as S from"three";import{clamp as w}from"../../../../../utils/math.js";const v=new c,M=new c,x=1/30,T=131070;let b=class extends h{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(t){super(),this.physicsSystem=t,this.directionInput=new o,this.jumpInput=new i,this.sprintInput=new i,this.rotationInput=new s,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=a.degToRad(70),this.maxSlopeClimbAngle=a.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new c,this.mode=m.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.impulse=new c,this.impulseDamping=2;const e=this.cc=this.physicsSystem.getCharacterController(.1);e.enableSnapToGround(.1),e.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let e=this.rotationInput.rotation.y;const i=new c,o=new c,s=new c,n=new c(0,0,1),r=new c,l=new c,h=new c;let p=0,u=null;const g=new c,b=new c,j=new c,C=new c,R=new c,D=new c,k=this.characterCollision?null:T;let q=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(d(this.disposed)).subscribe(d=>{if(this.checkGrounded(d),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof f){const t=this.rootMotionInterpolant;this.resetRootMotion&&(g.fromArray(t.evaluate(0)),this.resetRootMotion=!1),C.fromArray(t.evaluate(this.rootMotionAction.time)),b.subVectors(C,g),g.copy(C),this.rootMotionAction.getRoot().getWorldScale(j),b.multiply(j)}}d>x&&(d=x);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=b.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;const T=q!==this.rotateToMovementDirection;let B=this.rotationInput.rotation.y-e;T&&(this.actor.object.quaternion.setFromEuler(H.set(0,this.rotationInput.rotation.y,0)),q?this.actor.object.quaternion.setFromEuler(H.set(0,this.rotationInput.rotation.y,0)):(B=0,e=this.rotationInput.rotation.y,n.set(0,0,1)),q=this.rotateToMovementDirection),s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const W=!this.rotateToMovementDirection&&r.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(h.set(0,0,0),this.rotateToMovementDirection){if(r.lengthSq()>0){this.smoothRotation?(P=r,Q=11*d,O=D,(N=n).normalize(),P.normalize(),z.setFromUnitVectors(N,P),F.identity(),F.slerp(z,Q),O.copy(N).applyQuaternion(F)):D.copy(r),z.setFromUnitVectors(n.clone().normalize(),D.clone().normalize()),n.copy(D);const t=(B%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,i=Math.abs(t),o=this.smoothRotation?w(10*d*t,-i,i):t;E.setFromEuler(H.set(0,o,0)),z.multiply(E),this.actor.object.applyQuaternion(z),h.copy(this.actor.object.getWorldDirection(V).normalize()),e+=o}}else e+=B,this.actor.object.quaternion.multiply(z.setFromEuler(H.set(0,B,0))),r.lengthSq()>0&&h.copy(r).applyQuaternion(this.actor.object.quaternion).normalize();var N,P,Q,O;if(R.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,R),this.mode===m.walking?(0!==h.lengthSq()?(p=Math.min(W,p),p=a.lerp(p,W,4*d)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=d*this.getEffectiveGravity(),l.add(R)):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),this.velocity.y+=d*this.getEffectiveGravity(),l.copy(this.velocity),l.addScaledVector(h,this.fallingMovementControl),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),B)),this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);l.x=a.lerp(l.x,this.impulse.x,t),l.z=a.lerp(l.z,this.impulse.z,t),l.y+=this.impulse.y;const e=Math.exp(-this.impulseDamping*d);this.impulse.x*=e,this.impulse.y>0?this.impulse.y+=d*this.getEffectiveGravity():this.impulse.y*=e,this.impulse.z*=e}else this.impulse.set(0,0,0);if(o.copy(l).normalize(),i.copy(l),l.length()>0||!this.isGrounded||y){if(y?(b.applyQuaternion(this.actor.quaternion),b.y+=d*this.getEffectiveGravity(),v.copy(b)):v.copy(l).multiplyScalar(d),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,R.y*d)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,k),t.computedCollision(0,G),null!=G&&null!=G.normal1)){const e=(new S.Vector3).copy(G.normal1);Math.acos(e.dot(A))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,k))}else M.set(0,0,0);this.physicsSystem.setNextKinematicTranslation(this.actor,M);let J=function(t){if(t.numComputedCollisions()>0){const e=t.computedCollision(0);I.x=e.normal2.x,I.y=e.normal2.y,I.z=e.normal2.z;const i=I.angleTo(A);I.x=e.normal1.x,I.y=e.normal1.y,I.z=e.normal1.z;const o=I.angleTo(A);return!(i<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!J||this.mode!==m.falling&&(null==u?u=performance.now():performance.now()-u>100&&(this.mode=m.falling,this.velocity.copy(i))),this.isGrounded&&this.velocity.y<=0&&(this.mode,m.falling,this.mode=m.walking,this.velocity.y=0,u=null),this.mode,m.walking,this.horizontalSpeed=p})}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new l(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout(()=>{t.removeFromParent()},30);const e=new l(M,this.actor.position,1,16711680);this.actor.object.parent.add(e),setTimeout(()=>{e.removeFromParent()},30)}setRootMotionAction(t){const e=t?.getClip();if(e instanceof f){this.rootMotionAction=t,this.resetRootMotion=!0;const i=[];this.rootMotionInterpolant=e.motionTrack.InterpolantFactoryMethodSmooth(i)}}getWallDirection(t,e){const i=t.clone().negate().cross(A);return i.dot(e)<0?i.negate():i}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;D.y=-.05,this.physicsSystem.rayTest(j.addVectors(this.actor.position,R.set(0,this.offset,0)),C.addVectors(this.actor.position,D),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new u(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=T,t}step(t){}performMovement(t){}arrowHelper(t,e,i){const o=new l(t.clone().normalize(),e,1,i);this.actor.object.parent.add(o),setTimeout(()=>{o.removeFromParent()},30)}};b=t([p({inEditor:!1}),e("design:paramtypes",[n])],b);export{b as CharacterMovementComponent};const A=new c(0,1,0),I=new c;const j=new c,C=new c,R=new c(0,1,0),D=new c(0,-.1,0),G=(new c(0,-1,0),new g.CharacterCollision),z=new S.Quaternion,F=new S.Quaternion,E=new S.Quaternion,H=new S.Euler,V=new S.Vector3;/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import i from"@dimforge/rapier3d-compat";import{takeUntil as o}from"rxjs";import*as s from"three";import{ArrowHelper as n,MathUtils as r,Vector3 as a}from"three";import{RootMotionClip as c}from"../../../../../gameplay/animation/root-motion.js";import{ActionInput as l,AxisInput as h,RotationInput as p}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as m,RayTestResult as u}from"../../../../../gameplay/services/physics/physics-system.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{clamp as y}from"../../../../../utils/math.js";import{PhysicsBodyType as g}from"../../../../services/physics/physics-system.js";import{ActorComponent as f,Component as S}from"../../../component.js";import{CharacterMovementMode as w}from"./modes.js";const v=new a,M=new a,x=1/30,T=131070;let b=class extends f{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(t){super(),this.physicsSystem=t,this.directionInput=new h,this.jumpInput=new l,this.sprintInput=new l,this.rotationInput=new p,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new a,this.mode=w.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new u,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.impulse=new a,this.impulseDamping=2;const e=this.cc=this.physicsSystem.getCharacterController(.1);e.enableSnapToGround(.1),e.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:g.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let e=this.rotationInput.rotation.y;const i=new a,n=new a,l=new a,h=new a(0,0,1),p=new a,m=new a,u=new a;let d=0,f=null;const S=new a,b=new a,j=new a,C=new a,R=new a,D=new a,k=this.characterCollision?null:T;let q=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(o(this.disposed)).subscribe(o=>{if(this.checkGrounded(o),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof c){const t=this.rootMotionInterpolant;this.resetRootMotion&&(S.fromArray(t.evaluate(0)),this.resetRootMotion=!1),C.fromArray(t.evaluate(this.rootMotionAction.time)),b.subVectors(C,S),S.copy(C),this.rootMotionAction.getRoot().getWorldScale(j),b.multiply(j)}}o>x&&(o=x);const g=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=b.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;const T=q!==this.rotateToMovementDirection;let B=this.rotationInput.rotation.y-e;T&&(this.actor.object.quaternion.setFromEuler(H.set(0,this.rotationInput.rotation.y,0)),q?this.actor.object.quaternion.setFromEuler(H.set(0,this.rotationInput.rotation.y,0)):(B=0,e=this.rotationInput.rotation.y,h.set(0,0,1)),q=this.rotateToMovementDirection),l.copy(this.actor.position),p.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const W=!this.rotateToMovementDirection&&p.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(u.set(0,0,0),this.rotateToMovementDirection){if(p.lengthSq()>0){this.smoothRotation?(P=p,Q=11*o,O=D,(N=h).normalize(),P.normalize(),z.setFromUnitVectors(N,P),F.identity(),F.slerp(z,Q),O.copy(N).applyQuaternion(F)):D.copy(p),z.setFromUnitVectors(h.clone().normalize(),D.clone().normalize()),h.copy(D);const t=(B%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,i=Math.abs(t),s=this.smoothRotation?y(10*o*t,-i,i):t;E.setFromEuler(H.set(0,s,0)),z.multiply(E),this.actor.object.applyQuaternion(z),u.copy(this.actor.object.getWorldDirection(V).normalize()),e+=s}}else e+=B,this.actor.object.quaternion.multiply(z.setFromEuler(H.set(0,B,0))),p.lengthSq()>0&&u.copy(p).applyQuaternion(this.actor.object.quaternion).normalize();var N,P,Q,O;if(R.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,R),this.mode===w.walking?(0!==u.lengthSq()?(d=Math.min(W,d),d=r.lerp(d,W,4*o)):d=0,m.copy(u).multiplyScalar(d),this.pressedJump&&(this.mode=w.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),m.y=o*this.getEffectiveGravity(),m.add(R)):this.mode===w.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=w.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),this.velocity.y+=o*this.getEffectiveGravity(),m.copy(this.velocity),m.addScaledVector(u,this.fallingMovementControl),this.fallingReorientation&&m.applyAxisAngle(new a(0,1,0),B)),this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);m.x=r.lerp(m.x,this.impulse.x,t),m.z=r.lerp(m.z,this.impulse.z,t),m.y+=this.impulse.y;const e=Math.exp(-this.impulseDamping*o);this.impulse.x*=e,this.impulse.y>0?this.impulse.y+=o*this.getEffectiveGravity():this.impulse.y*=e,this.impulse.z*=e}else this.impulse.set(0,0,0);if(n.copy(m).normalize(),i.copy(m),m.length()>0||!this.isGrounded||g){if(g?(b.applyQuaternion(this.actor.quaternion),b.y+=o*this.getEffectiveGravity(),v.copy(b)):v.copy(m).multiplyScalar(o),this.isGrounded&&this.mode===w.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,R.y*o)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,k),t.computedCollision(0,G),null!=G&&null!=G.normal1)){const e=(new s.Vector3).copy(G.normal1);Math.acos(e.dot(A))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,k))}else M.set(0,0,0);this.physicsSystem.setNextKinematicTranslation(this.actor,M);let J=function(t){if(t.numComputedCollisions()>0){const e=t.computedCollision(0);I.x=e.normal2.x,I.y=e.normal2.y,I.z=e.normal2.z;const i=I.angleTo(A);I.x=e.normal1.x,I.y=e.normal1.y,I.z=e.normal1.z;const o=I.angleTo(A);return!(i<100)&&o>t.minSlopeSlideAngle()}return!1}(t);g||this.isGrounded&&!J||this.mode!==w.falling&&(null==f?f=performance.now():performance.now()-f>100&&(this.mode=w.falling,this.velocity.copy(i))),this.isGrounded&&this.velocity.y<=0&&(this.mode,w.falling,this.mode=w.walking,this.velocity.y=0,f=null),this.mode,w.walking,this.horizontalSpeed=d})}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new n(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout(()=>{t.removeFromParent()},30);const e=new n(M,this.actor.position,1,16711680);this.actor.object.parent.add(e),setTimeout(()=>{e.removeFromParent()},30)}setRootMotionAction(t){const e=t?.getClip();if(e instanceof c){this.rootMotionAction=t,this.resetRootMotion=!0;const i=[];this.rootMotionInterpolant=e.motionTrack.InterpolantFactoryMethodSmooth(i)}}getWallDirection(t,e){const i=t.clone().negate().cross(A);return i.dot(e)<0?i.negate():i}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;D.y=-.05,this.physicsSystem.rayTest(j.addVectors(this.actor.position,R.set(0,this.offset,0)),C.addVectors(this.actor.position,D),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=T,t}step(t){}performMovement(t){}arrowHelper(t,e,i){const o=new n(t.clone().normalize(),e,1,i);this.actor.object.parent.add(o),setTimeout(()=>{o.removeFromParent()},30)}};b=t([S({inEditor:!1}),e("design:paramtypes",[m])],b);export{b as CharacterMovementComponent};const A=new a(0,1,0),I=new a;const j=new a,C=new a,R=new a(0,1,0),D=new a(0,-.1,0),G=(new a(0,-1,0),new i.CharacterCollision),z=new s.Quaternion,F=new s.Quaternion,E=new s.Quaternion,H=new s.Euler,V=new s.Vector3;/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -4,7 +4,8 @@ import { CharacterAnimationComponent } from './character/character-animation.js'
4
4
  import { TweenComponent } from './tween-component.js';
5
5
  import { TriggerVolumeComponent } from '../trigger-volume.js';
6
6
  import { PositionalAudioComponent } from '../positional-audio-actor.js';
7
- import { CameraComponent, ThirdPersonCameraComponent } from '../../../../gameplay/actors/index.js';
7
+ import { CameraComponent } from '../../camera/camera-component.js';
8
+ import { ThirdPersonCameraComponent } from '../../camera/third-person-camera-component.js';
8
9
  export declare const builtInComponents: {
9
10
  MeshComponent: typeof MeshComponent;
10
11
  TweenComponent: typeof TweenComponent;
@@ -1,4 +1,4 @@
1
- import{MeshComponent as o}from"./mesh-component.js";import{CharacterMovementComponent as t}from"./character/character-movement.js";import{CharacterAnimationComponent as e}from"./character/character-animation.js";import{TweenComponent as n}from"./tween-component.js";import{TriggerVolumeComponent as r}from"../trigger-volume.js";import{PositionalAudioComponent as m}from"../positional-audio-actor.js";import{CameraComponent as a,ThirdPersonCameraComponent as i}from"../../../../gameplay/actors/index.js";export const builtInComponents={MeshComponent:o,TweenComponent:n,CharacterMovementComponent:t,CharacterAnimationComponent:e,TriggerVolumeComponent:r,PositionalAudioComponent:m,CameraComponent:a,ThirdPersonCameraComponent:i};export default builtInComponents;/*
1
+ import{MeshComponent as o}from"./mesh-component.js";import{CharacterMovementComponent as e}from"./character/character-movement.js";import{CharacterAnimationComponent as r}from"./character/character-animation.js";import{TweenComponent as m}from"./tween-component.js";import{TriggerVolumeComponent as t}from"../trigger-volume.js";import{PositionalAudioComponent as n}from"../positional-audio-actor.js";import{CameraComponent as a}from"../../camera/camera-component.js";import{ThirdPersonCameraComponent as p}from"../../camera/third-person-camera-component.js";export const builtInComponents={MeshComponent:o,TweenComponent:m,CharacterMovementComponent:e,CharacterAnimationComponent:r,TriggerVolumeComponent:t,PositionalAudioComponent:n,CameraComponent:a,ThirdPersonCameraComponent:p};export default builtInComponents;/*
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{__decorate as t,__metadata as i}from"tslib";import{PhysicsBodyType as s,PhysicsSystem as e}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as n}from"../../../../index.js";import{Parameter as r}from"../../../../shader/parameter.js";import{Euler as c,Object3D as h,Vector3 as p}from"three";import{ActorComponent as l,Component as a}from"../../component.js";import{firstValueFrom as y}from"rxjs";const d={friction:.1,mass:0,restitution:1,bodyType:s.static,continousCollisionDetection:!1};let u=class extends l{constructor(t){super(),this.physicsSystem=t,this.position=new p,this.rotation=new c,this.scale=new p(1,1,1),this.collision=!0,this.bodyType=s.static,this.mass=d.mass,this.friction=d.friction,this.restitution=d.restitution,this.isTrigger=!1,this.continousCollisionDetection=d.continousCollisionDetection}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();this.collision&&t.length>0&&this.physicsSystem.addActor(this.actor,t,{...d,isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection,restitution:this.restitution}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof o?this.currentMesh.collisionShapes:this.currentMesh instanceof n?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([r({type:h,label:"Model"}),i("design:type",Object)],u.prototype,"object",void 0),t([r(),i("design:type",p)],u.prototype,"position",void 0),t([r(),i("design:type",c)],u.prototype,"rotation",void 0),t([r(),i("design:type",p)],u.prototype,"scale",void 0),t([r({help:"Whether this mesh should have collision and/or physics simulation"}),i("design:type",Boolean)],u.prototype,"collision",void 0),t([r({requires:{collision:!0},options:[{name:"Static",value:s.static},{name:"Kinematic",value:s.kinematic},{name:"Dynamic",value:s.dynamic}]}),i("design:type",Number)],u.prototype,"bodyType",void 0),t([r({help:"Only for dynamic objects.",requires:{collision:!0,bodyType:s.dynamic}}),i("design:type",Number)],u.prototype,"mass",void 0),t([r({help:"How much it slows down when touching other objects. Only for dynamic objects.",requires:{collision:!0,bodyType:s.dynamic}}),i("design:type",Number)],u.prototype,"friction",void 0),t([r({help:"Control how much to bounce. Only for dynamic objects.",requires:{collision:!0,bodyType:s.dynamic}}),i("design:type",Number)],u.prototype,"restitution",void 0),t([r({requires:{collision:!0}}),i("design:type",Boolean)],u.prototype,"isTrigger",void 0),u=t([a({inEditor:!0}),i("design:paramtypes",[e])],u);export{u as MeshComponent};/*
1
+ import{__decorate as t,__metadata as i}from"tslib";import{PhysicsBodyType as e,PhysicsSystem as s}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as r}from"../../../../index.js";import{Parameter as n}from"../../../../shader/parameter.js";import{Euler as h,Object3D as c,Vector3 as p}from"three";import{ActorComponent as l,Component as a}from"../../component.js";import{firstValueFrom as y}from"rxjs";let u=null;let d=class extends l{constructor(t){super(),this.physicsSystem=t,this.position=new p,this.rotation=new h,this.scale=new p(1,1,1),this.collision=!0,this.bodyType=2,this.mass=0,this.friction=.1,this.restitution=1,this.isTrigger=!1,this.continousCollisionDetection=!1}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();this.collision&&t.length>0&&this.physicsSystem.addActor(this.actor,t,{...(null===u&&(u={friction:.1,mass:0,restitution:1,bodyType:e.static,continousCollisionDetection:!1}),u),isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection,restitution:this.restitution}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof o?this.currentMesh.collisionShapes:this.currentMesh instanceof r?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([n({type:c,label:"Model"}),i("design:type",Object)],d.prototype,"object",void 0),t([n(),i("design:type",p)],d.prototype,"position",void 0),t([n(),i("design:type",h)],d.prototype,"rotation",void 0),t([n(),i("design:type",p)],d.prototype,"scale",void 0),t([n({help:"Whether this mesh should have collision and/or physics simulation"}),i("design:type",Boolean)],d.prototype,"collision",void 0),t([n({requires:{collision:!0},options:[{name:"Static",value:2},{name:"Kinematic",value:4},{name:"Dynamic",value:1}]}),i("design:type",Number)],d.prototype,"bodyType",void 0),t([n({help:"Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"mass",void 0),t([n({help:"How much it slows down when touching other objects. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"friction",void 0),t([n({help:"Control how much to bounce. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"restitution",void 0),t([n({requires:{collision:!0}}),i("design:type",Boolean)],d.prototype,"isTrigger",void 0),d=t([a({inEditor:!0}),i("design:paramtypes",[s])],d);export{d as MeshComponent};/*
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{__decorate as t,__metadata as i}from"tslib";import{Euler as e,Vector3 as o}from"three";import{Subject as s}from"rxjs";import{ActorComponent as a,Component as n}from"../../component.js";import{Parameter as h}from"../../../../shader/parameter.js";import{Curve2 as r}from"../../../../utils/curve.js";import{inject as l}from"../../../../gameplay/inject.js";import{PhysicsSystem as p}from"../../../../gameplay/index.js";let d=class extends a{constructor(){super(...arguments),this.animatePosition=!1,this.targetPosition=new o(0,1,0),this.animateRotation=!1,this.targetRotation=new o(0,0,0),this.animateScale=!1,this.targetScale=new o(1,1,1),this.duration=1,this.delay=0,this.easing=r.linear(),this.relative=!0,this.loop=!1,this.pingPong=!1,this.autoPlay=!0,this.inEditor=!1,this.onComplete=new s,this.onLoop=new s,this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.delayRemaining=0,this.direction=1,this.loopCount=0,this.startPosition=new o,this.startRotation=new e,this.startScale=new o,this.endPosition=new o,this.endRotation=new e,this.endScale=new o,this.physics=l(p)}onInit(){this.autoPlay&&this.inEditor&&this.play()}onBeginPlay(){this.autoPlay&&!this.inEditor&&this.play()}onEndPlay(){this.onComplete.complete(),this.onLoop.complete()}play(){this.isPlaying&&!this.isPaused||(this.isPlaying||(this.captureStartValues(),this.computeEndValues(),this.elapsed=0,this.delayRemaining=this.delay,this.direction=1,this.loopCount=0),this.isPlaying=!0,this.isPaused=!1,this.physics.updateActorTransform(this.actor))}pause(){this.isPaused=!0}stop(){this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.applyValues(0)}reverse(){this.direction*=-1}restart(){this.stop(),this.play()}get progress(){return this.duration>0?this.elapsed/this.duration:0}get playing(){return this.isPlaying&&!this.isPaused}onUpdate(t){if(!this.isPlaying||this.isPaused)return;if(this.delayRemaining>0)return void(this.delayRemaining-=t);this.elapsed+=t*this.direction,this.elapsed>=this.duration?(this.elapsed=this.duration,this.handleComplete()):this.elapsed<=0&&(this.elapsed=0,this.handleComplete());const i=this.elapsed/this.duration,e=this.easing.getY(i);this.applyValues(e)}captureStartValues(){this.startPosition.copy(this.actor.position),this.startRotation.copy(this.actor.rotation),this.startScale.copy(this.actor.object.scale)}computeEndValues(){if(this.animatePosition&&(this.relative?this.endPosition.copy(this.startPosition).add(this.targetPosition):this.endPosition.copy(this.targetPosition)),this.animateRotation){const t=new o(this.targetRotation.x*Math.PI/180,this.targetRotation.y*Math.PI/180,this.targetRotation.z*Math.PI/180);this.relative?this.endRotation.set(this.startRotation.x+t.x,this.startRotation.y+t.y,this.startRotation.z+t.z):this.endRotation.set(t.x,t.y,t.z)}this.animateScale&&(this.relative?this.endScale.set(this.startScale.x*this.targetScale.x,this.startScale.y*this.targetScale.y,this.startScale.z*this.targetScale.z):this.endScale.copy(this.targetScale))}applyValues(t){this.animatePosition&&this.actor.position.lerpVectors(this.startPosition,this.endPosition,t),this.animateRotation&&this.actor.rotation.set(this.startRotation.x+(this.endRotation.x-this.startRotation.x)*t,this.startRotation.y+(this.endRotation.y-this.startRotation.y)*t,this.startRotation.z+(this.endRotation.z-this.startRotation.z)*t),this.animateScale&&this.actor.object.scale.lerpVectors(this.startScale,this.endScale,t)}handleComplete(){this.loopCount++,this.onLoop.next(this.loopCount),this.loop?this.pingPong?this.direction*=-1:this.elapsed=0:(this.isPlaying=!1,this.onComplete.next())}};t([h({help:"Enable position animation"}),i("design:type",Boolean)],d.prototype,"animatePosition",void 0),t([h({help:"The position to animate to (relative offset or absolute world position)",requires:{animatePosition:!0}}),i("design:type",o)],d.prototype,"targetPosition",void 0),t([h({help:"Enable rotation animation"}),i("design:type",Boolean)],d.prototype,"animateRotation",void 0),t([h({help:"The rotation to animate to in degrees (relative offset or absolute)",requires:{animateRotation:!0}}),i("design:type",o)],d.prototype,"targetRotation",void 0),t([h({label:"Animate Scale",help:"Enable scale animation"}),i("design:type",Boolean)],d.prototype,"animateScale",void 0),t([h({help:"The scale to animate to (relative multiplier or absolute)",requires:{animateScale:!0}}),i("design:type",o)],d.prototype,"targetScale",void 0),t([h({help:"Animation duration in seconds",range:[.01,60],precision:2}),i("design:type",Number)],d.prototype,"duration",void 0),t([h({help:"Delay before animation starts in seconds",range:[0,60],precision:2}),i("design:type",Number)],d.prototype,"delay",void 0),t([h({help:"The easing curve for the animation"}),i("design:type",r)],d.prototype,"easing",void 0),t([h({help:"If true, targets are offsets from initial values. If false, targets are absolute values."}),i("design:type",Boolean)],d.prototype,"relative",void 0),t([h({help:"Repeat the animation forever"}),i("design:type",Boolean)],d.prototype,"loop",void 0),t([h({help:"Reverse direction each loop (yo-yo effect)",requires:{loop:!0}}),i("design:type",Boolean)],d.prototype,"pingPong",void 0),t([h({help:"Start animation automatically when the actor spawns"}),i("design:type",Boolean)],d.prototype,"autoPlay",void 0),t([h({help:"Play the animation in the editor. Useful for testing."}),i("design:type",Boolean)],d.prototype,"inEditor",void 0),d=t([n({inEditor:!0})],d);export{d as TweenComponent};/*
1
+ import{__decorate as t,__metadata as i}from"tslib";import{Euler as e,Vector3 as o}from"three";import{Subject as s}from"rxjs";import{ActorComponent as a,Component as n}from"../../component.js";import{Parameter as h}from"../../../../shader/parameter.js";import{Curve2 as r}from"../../../../utils/curve.js";import{inject as l}from"../../../../gameplay/inject.js";import{PhysicsSystem as p}from"../../../../gameplay/services/physics/physics-system.js";let d=class extends a{constructor(){super(...arguments),this.animatePosition=!1,this.targetPosition=new o(0,1,0),this.animateRotation=!1,this.targetRotation=new o(0,0,0),this.animateScale=!1,this.targetScale=new o(1,1,1),this.duration=1,this.delay=0,this.easing=r.linear(),this.relative=!0,this.loop=!1,this.pingPong=!1,this.autoPlay=!0,this.inEditor=!1,this.onComplete=new s,this.onLoop=new s,this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.delayRemaining=0,this.direction=1,this.loopCount=0,this.startPosition=new o,this.startRotation=new e,this.startScale=new o,this.endPosition=new o,this.endRotation=new e,this.endScale=new o,this.physics=l(p)}onInit(){this.autoPlay&&this.inEditor&&this.play()}onBeginPlay(){this.autoPlay&&!this.inEditor&&this.play()}onEndPlay(){this.onComplete.complete(),this.onLoop.complete()}play(){this.isPlaying&&!this.isPaused||(this.isPlaying||(this.captureStartValues(),this.computeEndValues(),this.elapsed=0,this.delayRemaining=this.delay,this.direction=1,this.loopCount=0),this.isPlaying=!0,this.isPaused=!1,this.physics.updateActorTransform(this.actor))}pause(){this.isPaused=!0}stop(){this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.applyValues(0)}reverse(){this.direction*=-1}restart(){this.stop(),this.play()}get progress(){return this.duration>0?this.elapsed/this.duration:0}get playing(){return this.isPlaying&&!this.isPaused}onUpdate(t){if(!this.isPlaying||this.isPaused)return;if(this.delayRemaining>0)return void(this.delayRemaining-=t);this.elapsed+=t*this.direction,this.elapsed>=this.duration?(this.elapsed=this.duration,this.handleComplete()):this.elapsed<=0&&(this.elapsed=0,this.handleComplete());const i=this.elapsed/this.duration,e=this.easing.getY(i);this.applyValues(e)}captureStartValues(){this.startPosition.copy(this.actor.position),this.startRotation.copy(this.actor.rotation),this.startScale.copy(this.actor.object.scale)}computeEndValues(){if(this.animatePosition&&(this.relative?this.endPosition.copy(this.startPosition).add(this.targetPosition):this.endPosition.copy(this.targetPosition)),this.animateRotation){const t=new o(this.targetRotation.x*Math.PI/180,this.targetRotation.y*Math.PI/180,this.targetRotation.z*Math.PI/180);this.relative?this.endRotation.set(this.startRotation.x+t.x,this.startRotation.y+t.y,this.startRotation.z+t.z):this.endRotation.set(t.x,t.y,t.z)}this.animateScale&&(this.relative?this.endScale.set(this.startScale.x*this.targetScale.x,this.startScale.y*this.targetScale.y,this.startScale.z*this.targetScale.z):this.endScale.copy(this.targetScale))}applyValues(t){this.animatePosition&&this.actor.position.lerpVectors(this.startPosition,this.endPosition,t),this.animateRotation&&this.actor.rotation.set(this.startRotation.x+(this.endRotation.x-this.startRotation.x)*t,this.startRotation.y+(this.endRotation.y-this.startRotation.y)*t,this.startRotation.z+(this.endRotation.z-this.startRotation.z)*t),this.animateScale&&this.actor.object.scale.lerpVectors(this.startScale,this.endScale,t)}handleComplete(){this.loopCount++,this.onLoop.next(this.loopCount),this.loop?this.pingPong?this.direction*=-1:this.elapsed=0:(this.isPlaying=!1,this.onComplete.next())}};t([h({help:"Enable position animation"}),i("design:type",Boolean)],d.prototype,"animatePosition",void 0),t([h({help:"The position to animate to (relative offset or absolute world position)",requires:{animatePosition:!0}}),i("design:type",o)],d.prototype,"targetPosition",void 0),t([h({help:"Enable rotation animation"}),i("design:type",Boolean)],d.prototype,"animateRotation",void 0),t([h({help:"The rotation to animate to in degrees (relative offset or absolute)",requires:{animateRotation:!0}}),i("design:type",o)],d.prototype,"targetRotation",void 0),t([h({label:"Animate Scale",help:"Enable scale animation"}),i("design:type",Boolean)],d.prototype,"animateScale",void 0),t([h({help:"The scale to animate to (relative multiplier or absolute)",requires:{animateScale:!0}}),i("design:type",o)],d.prototype,"targetScale",void 0),t([h({help:"Animation duration in seconds",range:[.01,60],precision:2}),i("design:type",Number)],d.prototype,"duration",void 0),t([h({help:"Delay before animation starts in seconds",range:[0,60],precision:2}),i("design:type",Number)],d.prototype,"delay",void 0),t([h({help:"The easing curve for the animation"}),i("design:type",r)],d.prototype,"easing",void 0),t([h({help:"If true, targets are offsets from initial values. If false, targets are absolute values."}),i("design:type",Boolean)],d.prototype,"relative",void 0),t([h({help:"Repeat the animation forever"}),i("design:type",Boolean)],d.prototype,"loop",void 0),t([h({help:"Reverse direction each loop (yo-yo effect)",requires:{loop:!0}}),i("design:type",Boolean)],d.prototype,"pingPong",void 0),t([h({help:"Start animation automatically when the actor spawns"}),i("design:type",Boolean)],d.prototype,"autoPlay",void 0),t([h({help:"Play the animation in the editor. Useful for testing."}),i("design:type",Boolean)],d.prototype,"inEditor",void 0),d=t([n({inEditor:!0})],d);export{d as TweenComponent};/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,7 +1,7 @@
1
1
  import { BaseActor } from "../..";
2
2
  import { Texture } from 'three';
3
3
  import * as THREE from 'three';
4
- import { ActorComponent } from "../../../gameplay";
4
+ import { ActorComponent } from "../../actors/component.js";
5
5
  export type PostProcessingVolumeShape = {
6
6
  kind: 'box';
7
7
  box: THREE.Box3;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Actor as o,Attach as i,attach as r,BaseActor as p,Component as s,inject as n,Parameter as d}from"../..";import{Texture as m}from"three";import{tonemapMappings as y}from"../../../rendering/tone-mapping";import{OBB as u}from"three/examples/jsm/math/OBB.js";import{Vector3 as a}from"three";import*as b from"three";import{RenderingView as g}from"../../../rendering.js";import{TriggerVolumeMesh as h}from"./components/volume-editor-component.js";import{ActorComponent as l}from"../../../gameplay";let v=class extends l{};e([d({options:y}),t("design:type",Number)],v.prototype,"tonemapMapping",void 0),e([d(),t("design:type",Number)],v.prototype,"tonemapExposure",void 0),e([d(),t("design:type",m)],v.prototype,"envTexture",void 0),e([d(),t("design:type",Number)],v.prototype,"envIntensity",void 0),e([d(),t("design:type",Number)],v.prototype,"vignetteIntensity",void 0),e([d(),t("design:type",b.Color)],v.prototype,"colorTint",void 0),e([d(),t("design:type",Number)],v.prototype,"colorTintIntensity",void 0),e([d(),t("design:type",Number)],v.prototype,"depthFocus",void 0),e([d(),t("design:type",Number)],v.prototype,"depthAperture",void 0),e([d(),t("design:type",Number)],v.prototype,"depthMaxBlur",void 0),e([d({range:[1e3,4e4],precision:.1}),t("design:type",Number)],v.prototype,"temperature",void 0),e([d({range:[-1,1]}),t("design:type",Number)],v.prototype,"temperatureTint",void 0),e([d({label:"LUT"}),t("design:type",m)],v.prototype,"lut",void 0),e([d({label:"LUT Intensity",range:[0,1]}),t("design:type",Number)],v.prototype,"lutIntensity",void 0),v=e([s()],v);export{v as PostProcessSettings};let c=class extends p{constructor(){super(),this.bounded=!1,this.priority=0,this.blendWeight=1,this.blendRadius=0,this.box=new u(void 0,new b.Vector3(.5,.5,.5)),this.view=n(g),this.editorView=r(h),this.disposed.subscribe(()=>{this.view.removePostProcessVolume(this)})}onInit(){this.view.addPostProcessVolume(this),this.editorView.visible=this.bounded}containsPoint(e){return!this.bounded||(this.resetBox(),this.box.containsPoint(e))}distanceToPoint(e){return this.bounded?(this.resetBox(),this.box.clampPoint(e,N),N.distanceTo(e)):0}resetBox(){const e=this.box;e.center.set(0,0,0),e.halfSize.set(.5,.5,.5),e.rotation.copy(x.rotation),e.applyMatrix4(this.object.matrixWorld)}};e([i(),t("design:type",v)],c.prototype,"settings",void 0),e([d(),t("design:type",Boolean)],c.prototype,"bounded",void 0),e([d({precision:0}),t("design:type",Number)],c.prototype,"priority",void 0),e([d({range:[0,1]}),t("design:type",Number)],c.prototype,"blendWeight",void 0),e([d(),t("design:type",Number)],c.prototype,"blendRadius",void 0),c=e([o(),t("design:paramtypes",[])],c);export{c as PostProcessVolume};const x=new u,N=new a;/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Actor as o,Attach as i,attach as r,BaseActor as p,Component as s,inject as n,Parameter as d}from"../..";import{Texture as m}from"three";import{tonemapMappings as y}from"../../../rendering/tone-mapping";import{OBB as u}from"three/examples/jsm/math/OBB.js";import{Vector3 as a}from"three";import*as b from"three";import{RenderingView as h}from"../../../rendering.js";import{TriggerVolumeMesh as g}from"./components/volume-editor-component.js";import{ActorComponent as l}from"../../actors/component.js";let v=class extends l{};e([d({options:y}),t("design:type",Number)],v.prototype,"tonemapMapping",void 0),e([d(),t("design:type",Number)],v.prototype,"tonemapExposure",void 0),e([d(),t("design:type",m)],v.prototype,"envTexture",void 0),e([d(),t("design:type",Number)],v.prototype,"envIntensity",void 0),e([d(),t("design:type",Number)],v.prototype,"vignetteIntensity",void 0),e([d(),t("design:type",b.Color)],v.prototype,"colorTint",void 0),e([d(),t("design:type",Number)],v.prototype,"colorTintIntensity",void 0),e([d(),t("design:type",Number)],v.prototype,"depthFocus",void 0),e([d(),t("design:type",Number)],v.prototype,"depthAperture",void 0),e([d(),t("design:type",Number)],v.prototype,"depthMaxBlur",void 0),e([d({range:[1e3,4e4],precision:.1}),t("design:type",Number)],v.prototype,"temperature",void 0),e([d({range:[-1,1]}),t("design:type",Number)],v.prototype,"temperatureTint",void 0),e([d({label:"LUT"}),t("design:type",m)],v.prototype,"lut",void 0),e([d({label:"LUT Intensity",range:[0,1]}),t("design:type",Number)],v.prototype,"lutIntensity",void 0),v=e([s()],v);export{v as PostProcessSettings};let c=class extends p{constructor(){super(),this.bounded=!1,this.priority=0,this.blendWeight=1,this.blendRadius=0,this.box=new u(void 0,new b.Vector3(.5,.5,.5)),this.view=n(h),this.editorView=r(g),this.disposed.subscribe(()=>{this.view.removePostProcessVolume(this)})}onInit(){this.view.addPostProcessVolume(this),this.editorView.visible=this.bounded}containsPoint(e){return!this.bounded||(this.resetBox(),this.box.containsPoint(e))}distanceToPoint(e){return this.bounded?(this.resetBox(),this.box.clampPoint(e,N),N.distanceTo(e)):0}resetBox(){const e=this.box;e.center.set(0,0,0),e.halfSize.set(.5,.5,.5),e.rotation.copy(x.rotation),e.applyMatrix4(this.object.matrixWorld)}};e([i(),t("design:type",v)],c.prototype,"settings",void 0),e([d(),t("design:type",Boolean)],c.prototype,"bounded",void 0),e([d({precision:0}),t("design:type",Number)],c.prototype,"priority",void 0),e([d({range:[0,1]}),t("design:type",Number)],c.prototype,"blendWeight",void 0),e([d(),t("design:type",Number)],c.prototype,"blendRadius",void 0),c=e([o(),t("design:paramtypes",[])],c);export{c as PostProcessVolume};const x=new u,N=new a;/*
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 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 r}from"../scene/materializer.js";import{ViewController as o}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 w}from"rxjs";import{PointerEvents as g}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,w){if(f(),0!=w.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(o);const y=e.of("default"),I=new HologyRuntime(y),x=new n(y,{inEditor:!1});var D;e.set(n,x),D=w.element,Object.assign(D.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const R=new i(w.element,{enableXR:!0===w.xr?.enabled,maxPixelRatio:w.rendering?.maxPixelRatio,bloom:{enabled:!1!==w?.rendering?.bloom?.enabled},reflection:{enabled:!1!==w?.rendering?.reflection?.enabled}});R.renderer.shadowMap.enabled=w.rendering?.shadows?.enabled??!0,R.renderer.shadowMap.autoUpdate=w.rendering?.shadows?.autoUpdate??!0,null!=w?.rendering?.resolutionScale&&(R.resolutionScale=w.rendering.resolutionScale),R.renderer.debug.checkShaderErrors=!1,e.set(i,R);const G=new o(R);e.set(o,G);const O=new j,z=new p(O),A=new h;A.setDataDir(w.dataDir),A.initKtx2(R.renderer);const H=Object.entries(w.shaders).map(([e,t])=>({name:e,type:t})),M=Object.entries(w.actors).map(([e,t])=>({name:e,type:t})),P={...m,...w.components??{}},W=Object.entries(P).map(([e,t])=>({name:e,type:t})),k=new v(H);e.set(v,k);const E=new u(A,z,H);e.set(u,E);const N=new b,T=new r(N,new S,z,A,R,H,M,x,W);e.set(r,T);const U=e.get(s);return e.set(s,U),U.materializer=T,(async()=>{const n=e.get(a);if(await n.start(),I.isShutdown)return;if(await O.preloadData(),I.isShutdown)return;U.scene=N;const{scene:s,actors:r}=await t(R,w.sceneName,w.dataDir,w.shaders,w.actors,P,x,O,z,A,{detailTier:w.detailTier});U.scene=s,n.scene=U.scene;for(const e of N.children)U.scene.add(e);if(I.isShutdown)return void R.stop();e.import([c]);for(const e of r)U.addActor(e);n.addFromScene(s),R.loop(e=>{}),I.status=5,I.shutdownStarted.subscribe(()=>{A.disposeAll()}),d.value=y,y.remove(l),y.set({id:l,type:l});const o=y.get(l);d.value=null,I.gameInstance=o,y.get(g).start(),o instanceof GameInstance&&await o.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 w,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(o);n.setMuted(!0),n.dispose();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(g).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 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()}}/*
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{__decorate as t,__metadata as e}from"tslib";import{Raycaster as i,Vector2 as o}from"three";import{Service as n}from"typedi";import{ViewController as s}from"./render";import{World as r}from"./world";import{inject as c}from"../../gameplay";import{Subject as h,tap as p,map as a,filter as d,takeUntil as l,withLatestFrom as b,mergeMap as P,merge as u,from as j}from"rxjs";let w=class{constructor(){this.view=c(s),this.world=c(r),this.enabled=!1,this.stopped=new h,this.monitoredObjects=new Map,this.useCache=!1,this.cachePointerPosition=new o,this.pointerPosition=new o,this.adjustedPosition=new o,this.raycastIntersectionResult=[],this.raycaster=new i,this.onClick=new h,this.onDoubleClick=new h,this.onPointerMove=new h,this.onPointerDown=new h,this.onPointerUp=new h,this.onPointerEnterObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),p(t=>{null==t&&(e=!1)}),d(t=>null!=t&&!e),p(()=>{e=!0}),a(e=>({intersection:e,object:t})))},this.onPointerEnterActor=t=>this.onPointerEnterObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerEnterActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerEnterActor(t))),this.onPointerLeaveObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),p(t=>{null!=t&&(e=!1)}),d(t=>null==t&&!e),p(()=>{e=!0}),a(e=>({intersection:e,object:t})))},this.onPointerLeaveActor=t=>this.onPointerLeaveObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerLeaveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerLeaveActor(t))),this.onClickObject3D=t=>{const e=this.onPointerDown.pipe(a(()=>this.findIntersection(t)));return this.onPointerUp.pipe(a(()=>this.findIntersection(t))).pipe(this.tapMonitorObject(t),b(e),d(([t,e])=>null!=t&&null!=e),a(([e])=>({intersection:e,object:t})))},this.onClickActor=t=>this.onClickObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onClickActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onClickActor(t))),this.onPointerDownActor=t=>this.onPointerDownObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerDownActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerDownActor(t))),this.onPointerDownObject3D=t=>this.onPointerDown.pipe(this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.onPointerUpActor=t=>this.onPointerUpObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerUpActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerUpActor(t))),this.onPointerUpObject3D=t=>this.onPointerUp.pipe(this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.onPointerMoveActor=t=>this.onPointerMoveObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerMoveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerMoveActor(t))),this.onPointerMoveObject3D=t=>this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.usingPointerMoveEvents=!1,this.handlers={click:t=>{this.onClick.next(t)},dblclick:t=>{this.onDoubleClick.next(t)},pointermove:t=>{this.onPointerMove.next(t)},pointerup:t=>{this.onPointerUp.next(t)},pointerdown:t=>{this.onPointerDown.next(t)}},this.raycaster.firstHitOnly=!0}start(){this.enabled||(this.enabled=!0,Object.entries(this.handlers).forEach(([t,e])=>{this.view.htmlElement.addEventListener(t,i=>{("pointermove"!==t||this.usingPointerMoveEvents)&&(this.updateRaycast(i),e(i))})}),this.view.onLateUpdate().pipe(l(this.stopped)).subscribe(()=>this.useCache=!1))}stop(){this.enabled=!1,Object.entries(this.handlers).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.stopped.next(!0),this.onClick.complete(),this.onDoubleClick.complete(),this.onPointerMove.complete(),this.onPointerDown.complete(),this.onPointerUp.complete()}addMonitoredObject(t){const e=this.monitoredObjects.get(t)??0;this.monitoredObjects.set(t,e+1)}removeMonitoriedObject(t){const e=this.monitoredObjects.get(t);null!=e&&(e>1?this.monitoredObjects.set(t,e-1):this.monitoredObjects.delete(t))}updateRaycast(t){this.pointerPosition.set(t.x,t.y),this.useCache&&this.cachePointerPosition.equals(this.pointerPosition)||(this.cachePointerPosition.copy(this.pointerPosition),this.useCache=!0,this.adjustedPosition.x=t.offsetX/this.view.htmlElement.offsetWidth*2-1,this.adjustedPosition.y=-t.offsetY/this.view.htmlElement.offsetHeight*2+1,this.raycaster.setFromCamera(this.adjustedPosition,this.view.getCamera()),this.raycastIntersectionResult.length=0,this.raycaster.intersectObject(this.world.scene,!0,this.raycastIntersectionResult))}tapUsingPointerMove(){return p({subscribe:()=>{this.usingPointerMoveEvents=!0},unsubscribe:()=>{}})}tapMonitorObject(t){return p({subscribe:()=>{this.addMonitoredObject(t)},unsubscribe:()=>{this.removeMonitoriedObject(t)}})}findIntersection(t){if(this.raycastIntersectionResult.length>0){let e=this.raycastIntersectionResult[0].object;for(;null!=e;){if(e.uuid===t.uuid)return this.raycastIntersectionResult[0];e=e.parent}}return null}};w=t([n(),e("design:paramtypes",[])],w);export{w as PointerEvents};/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import{Raycaster as i,Vector2 as o}from"three";import{Service as n}from"typedi";import{ViewController as s}from"./render";import{World as r}from"./world";import{inject as c}from"../inject.js";import{Subject as h,tap as p,map as a,filter as d,takeUntil as l,withLatestFrom as b,mergeMap as P,merge as u,from as j}from"rxjs";let w=class{constructor(){this.view=c(s),this.world=c(r),this.enabled=!1,this.stopped=new h,this.monitoredObjects=new Map,this.useCache=!1,this.cachePointerPosition=new o,this.pointerPosition=new o,this.adjustedPosition=new o,this.raycastIntersectionResult=[],this.raycaster=new i,this.onClick=new h,this.onDoubleClick=new h,this.onPointerMove=new h,this.onPointerDown=new h,this.onPointerUp=new h,this.onPointerEnterObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),p(t=>{null==t&&(e=!1)}),d(t=>null!=t&&!e),p(()=>{e=!0}),a(e=>({intersection:e,object:t})))},this.onPointerEnterActor=t=>this.onPointerEnterObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerEnterActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerEnterActor(t))),this.onPointerLeaveObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),p(t=>{null!=t&&(e=!1)}),d(t=>null==t&&!e),p(()=>{e=!0}),a(e=>({intersection:e,object:t})))},this.onPointerLeaveActor=t=>this.onPointerLeaveObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerLeaveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerLeaveActor(t))),this.onClickObject3D=t=>{const e=this.onPointerDown.pipe(a(()=>this.findIntersection(t)));return this.onPointerUp.pipe(a(()=>this.findIntersection(t))).pipe(this.tapMonitorObject(t),b(e),d(([t,e])=>null!=t&&null!=e),a(([e])=>({intersection:e,object:t})))},this.onClickActor=t=>this.onClickObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onClickActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onClickActor(t))),this.onPointerDownActor=t=>this.onPointerDownObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerDownActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerDownActor(t))),this.onPointerDownObject3D=t=>this.onPointerDown.pipe(this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.onPointerUpActor=t=>this.onPointerUpObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerUpActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerUpActor(t))),this.onPointerUpObject3D=t=>this.onPointerUp.pipe(this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.onPointerMoveActor=t=>this.onPointerMoveObject3D(t.object).pipe(l(t.disposed),a(({intersection:e})=>({intersection:e,actor:t}))),this.onPointerMoveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d(e=>e instanceof t),P(t=>this.onPointerMoveActor(t))),this.onPointerMoveObject3D=t=>this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a(()=>this.findIntersection(t)),d(t=>null!=t),a(e=>({intersection:e,object:t}))),this.usingPointerMoveEvents=!1,this.handlers={click:t=>{this.onClick.next(t)},dblclick:t=>{this.onDoubleClick.next(t)},pointermove:t=>{this.onPointerMove.next(t)},pointerup:t=>{this.onPointerUp.next(t)},pointerdown:t=>{this.onPointerDown.next(t)}},this.raycaster.firstHitOnly=!0}start(){this.enabled||(this.enabled=!0,Object.entries(this.handlers).forEach(([t,e])=>{this.view.htmlElement.addEventListener(t,i=>{("pointermove"!==t||this.usingPointerMoveEvents)&&(this.updateRaycast(i),e(i))})}),this.view.onLateUpdate().pipe(l(this.stopped)).subscribe(()=>this.useCache=!1))}stop(){this.enabled=!1,Object.entries(this.handlers).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.stopped.next(!0),this.onClick.complete(),this.onDoubleClick.complete(),this.onPointerMove.complete(),this.onPointerDown.complete(),this.onPointerUp.complete()}addMonitoredObject(t){const e=this.monitoredObjects.get(t)??0;this.monitoredObjects.set(t,e+1)}removeMonitoriedObject(t){const e=this.monitoredObjects.get(t);null!=e&&(e>1?this.monitoredObjects.set(t,e-1):this.monitoredObjects.delete(t))}updateRaycast(t){this.pointerPosition.set(t.x,t.y),this.useCache&&this.cachePointerPosition.equals(this.pointerPosition)||(this.cachePointerPosition.copy(this.pointerPosition),this.useCache=!0,this.adjustedPosition.x=t.offsetX/this.view.htmlElement.offsetWidth*2-1,this.adjustedPosition.y=-t.offsetY/this.view.htmlElement.offsetHeight*2+1,this.raycaster.setFromCamera(this.adjustedPosition,this.view.getCamera()),this.raycastIntersectionResult.length=0,this.raycaster.intersectObject(this.world.scene,!0,this.raycastIntersectionResult))}tapUsingPointerMove(){return p({subscribe:()=>{this.usingPointerMoveEvents=!0},unsubscribe:()=>{}})}tapMonitorObject(t){return p({subscribe:()=>{this.addMonitoredObject(t)},unsubscribe:()=>{this.removeMonitoriedObject(t)}})}findIntersection(t){if(this.raycastIntersectionResult.length>0){let e=this.raycastIntersectionResult[0].object;for(;null!=e;){if(e.uuid===t.uuid)return this.raycastIntersectionResult[0];e=e.parent}}return null}};w=t([n(),e("design:paramtypes",[])],w);export{w as PointerEvents};/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -114,6 +114,10 @@ export declare class RenderingView {
114
114
  private updateLightUniformValues;
115
115
  private createGBufferMaterial;
116
116
  loop(onFrame: (deltaTime: number) => any, showStats?: boolean): void;
117
+ private applyGBufferMaterials;
118
+ private unapplyGBufferMaterials;
119
+ private compileInProgress;
120
+ compileAsync(): Promise<void>;
117
121
  private renderScene;
118
122
  private pmremGenerator?;
119
123
  private pmremGeneratorResults;
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 d,WebGLRenderTarget as u,Texture as c,Euler as p,MeshStandardMaterial as m}from"three";import{CopyShader as f,EffectComposer as g,FXAAShader as v,GammaCorrectionShader as M,LUTPass as T,RenderPass as b,ShaderPass as x,VRButton as P}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 E,toonMaterial as O,lambertMaterial as B,normalize as I,rgb as D,rgba as W,textureSampler2d as L,transformed as j,varying as V,varyingAttributes as _,varyingTransformed as G,vec4 as q,BooleanExpression as k,select as N,ifDefApply as H,uniformSampler2d as z,RgbaNode 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 J from"three/examples/jsm/libs/stats.module.js";import{GTAOPass as Z}from"three/examples/jsm/postprocessing/GTAOPass.js";import{Service as ee}from"typedi";import{depthUniformName as te,farUniformName as se,nearUniformName as ie,resolutionUniformName as re,sceneNormalUniformName as ae,screenUV as ne,supportsDepthTextureExtension as oe}from"./shader-nodes/depth.js";import{elapsedTimeUniformName as le}from"./shader-nodes/time.js";import{aoMapUniformName as he,sceneMapUniformName as de}from"./shader-nodes/scene-sample.js";import{DepthPass as ue}from"./utils/three/depth-pass.js";import{GPUStatsPanel as ce}from"./utils/three/gpu-stats-panel.js";import{OutlinePass as pe}from"./utils/three/outline-pass.js";import{findFirstVisibleObject as me,traverseVisibleStop as fe}from"./utils/three/traverse.js";import{clamp as ge}from"./utils/math.js";import{ColorPass as ve}from"./rendering/color-pass.js";import{SSRPass as Me}from"./rendering/ssr/SSRPass.js";import{SSRShader as Te}from"./rendering/ssr/SSRShader.js";import{VolumetricFogPass as be}from"./rendering/fog/volumetric-fog-pass.js";import{OutlineEffect as xe}from"./rendering/outline-effect.js";import{UnrealBloomPass as Pe}from"./rendering/bloom/UnrealBloomPass.js";import{highPrecisionEyeDepth as ye}from"./shader-nodes/depth.js";import{packDepthToRGBA as we}from"three-shader-graph";import{FogVolumeObject as Se}from"./rendering/fog/fog-volume-object";import{ParallaxStandardMaterial as Re}from"./shader/builtin/standard-shader.js";import{parallaxOcclusionMapping as Ce}from"./shader-nodes/pom.js";import{FullScreenQuad as Ae}from"three-stdlib";import{edgeDepthEffect as Fe}from"./shader-nodes/effects";import{decalDiscard as Ue}from"./shader-nodes/decal.js";import{Pass as Ee}from"three/examples/jsm/Addons.js";w.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 Be=new i.MeshBasicMaterial({color:"black"}),Ie=new i.MeshDepthMaterial;var De;Ie.depthPacking=i.RGBADepthPacking,Ie.blending=i.NoBlending,Ie.side=i.DoubleSide,function(e){e[e.opaque=0]="opaque",e[e.transparent=1]="transparent"}(De||(De={}));const We=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let Le=0,je=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=Le++,this.fquadCopy=new Ae(new d(f)),this.fquadCopyOpaque=new Ae(new A({outputs:[z("tSceneColor",new c).sample(ne),q(z("tDepthTexture",new i.DepthTexture(1,1)).sample(ne).r)]})),this.fquadBlendAO=(()=>{const e=q(1),t=new A({outputs:[z("tAO",new c).sample(ne),e,e],transparent:!0});t.depthWrite=!1,t.depthTest=!1,t.blending=i.MultiplyBlending;return new Ae(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 J,this._showStats=!0,this.gbufferMaterialCache=new Map,this.tbufferMaterialCache=new Map,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(P.createButton(this.renderer));const a=new xe(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=oe(this.renderer),t.replaceChildren(this.renderer.domElement),this.setupEventListeners(),this.aoMaskDepthRenderTarget=e.createAOMaskDepthRenderTarget(this.renderer,this.container),this.sceneColorRenderTarget=this.createSceneColorRenderTarget(this.renderer,this.container);const l=new i.Vector2(t.clientWidth,t.clientHeight),h=(new b(this.scene,this.camera),new x(f,"prevtexture"));h.enabled=!0,h.needsSwap=!0,h.material.uniforms.tDiffuse.value=this.gRenderTarget.textures[0],this.copyPass=h;const u=new Pe(l,1.5,.4,.85);u.threshold=1,u.strength=.9,u.radius=.5,this.bloomPass=u;const p=new Z(this.scene,this.camera,t.clientWidth,t.clientWidth,{});p.normalRenderTarget?.dispose(),p.setGBuffer(this.gRenderTarget.depthTexture,this.gRenderTarget.textures[2]),p.output=Z.OUTPUT.Off,p.enabled=!1,this.aoPass=p,this.fquadBlendAO.material.uniforms.tAO.value=p.pdRenderTarget.texture,Te.fragmentShader=Te.fragmentShader.replace("if(metalness==0.) return;","if(metalness<0.1) return;");const m=new Me({renderer:this.renderer,scene:this.scene,camera:this.camera,groundReflector:null,selects:[],normalTexture:this.gRenderTarget.textures[2],depthTexture:this.gRenderTarget.depthTexture});m.output=Me.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 tt((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 tt((e,t,s,i,r)=>{this.renderer.setRenderTarget(this.gRenderTarget),this.renderScene(De.transparent),this.renderer.setRenderTarget(null)});this.composer.addPass(S),this.composer.addPass(h),this.composer.addPass(m),this.phasedRenderPass=new et(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 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 pe(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(v);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(M).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 Q;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 b?t.camera=e:t instanceof pe?t.renderCamera=e:(t instanceof ue||t instanceof Z)&&(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 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"}),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 u(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:$e(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 st){const t=i[e],r=s[e];null!=r&&null!=t&&(t.value=r.value)}}createGBufferMaterial(e,t){const s=t===De.opaque?this.gbufferMaterialCache:this.tbufferMaterialCache;let r=s.get(e);if(null==r){let n=_.uv;e instanceof Re&&null!=e.heightMap&&(n=Ce(n,L(e.heightMap),C(e.heightScale??1)));let o=G.normal;e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial?null!=e.normalMap&&(o=R(L(e.normalMap).sample(n),e.normalScale.x??1)):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);l=null!=e.roughnessMap?L(e.roughnessMap).sample(n).g.multiply(t):t}else e instanceof A&&null!=e.outputRoughness&&(l=e.outputRoughness);let h=null;(e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial||e instanceof i.MeshBasicMaterial)&&null!=e.lightMap&&(h=L(e.lightMap).sample(n).rgb.multiplyScalar(e.lightMapIntensity));let u,c=C(0);if(e instanceof i.MeshStandardMaterial){const t=U("metalness",e.metalness??0);c=null!=e.metalnessMap?L(e.metalnessMap).sample(n).b.multiply(t):t}else e instanceof A&&e.outputRoughness;let p=C(1);e instanceof i.MeshStandardMaterial?null!=e.aoMap&&(u=L(e.aoMap).sample(n).r,p=U("aoMapIntensity",e.aoMapIntensity)):e instanceof A&&e.outputRoughness;const f=U("opacity",e.opacity??1);let g=C(1);e instanceof i.MeshStandardMaterial||e instanceof i.MeshLambertMaterial||e instanceof i.MeshBasicMaterial||e instanceof i.MeshToonMaterial||e instanceof i.MeshPhongMaterial?(null!=e.alphaMap&&(g=L(e.alphaMap).sample(n).r),g=g.multiply(f)):e instanceof A&&null!=e.outputOpacity&&(g=e.outputOpacity);let v=W(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=E("color",(new i.Vector3).setFromColor(e.color));null!=e.map?(v=L(e.map).sample(n).multiply(W(t,1)),g=g.multiply(v.w)):v=W(t,1)}const M=!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=E("emissive",(new i.Vector3).setFromColor(e.emissive));T=null!=e.emissiveMap?L(e.emissiveMap).sample(n).rgb.multiply(t):t,T=T.multiplyScalar(e.emissiveIntensity)}else e instanceof A&&null!=e.outputEmissive&&(T=e.outputEmissive);const b=e instanceof d&&null!=e.uniforms[te],x=e instanceof d&&null!=e.uniforms[de],P=e instanceof d&&null!=e.uniforms[he],y=e.transparent&&e.alphaTest<=.01||e.blending===i.AdditiveBlending,w=U("alphaTest",e.alphaTest);let j,V=e.alphaTest>0?g.lt(w):y&&t===De.opaque?g.lt(.8):S(!1);!0===e.userData.isDecal&&(V=V.or(Ue)),j=y?q(0,0,0,0):(a=o,I(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 X,Y=W("black",1);if(e instanceof A&&null!=e.outputColor)Y=e.outputColor;else if(e instanceof i.MeshStandardMaterial)Y=F({color:v,metalness:c,roughness:l,emissive:T.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:p,bakedLight:h});else if(e instanceof i.MeshLambertMaterial||e instanceof i.MeshPhongMaterial)Y=B({color:v.rgb});else if(e instanceof i.MeshBasicMaterial){let e=v.rgb,t=h??D("white");null!=u&&(t=t.multiplyScalar(u.subtract(1).multiply(p).add(1))),e=e.multiply(t),Y=e.rgba(g)}else e instanceof i.MeshToonMaterial&&(Y=O({color:v,emissive:T.rgb,normal:o,ambientOcclusion:u,ambientOcclusionIntensity:p,bakedLight:h}));(e instanceof A||e instanceof i.MeshStandardMaterial)&&(X=e.envMap);let Q=!0;(e instanceof m||e instanceof i.MeshBasicMaterial||e instanceof i.ShaderMaterial)&&(Q=e.fog);let K=W(Y.rgb,g);Q&&(K=new FogNode(K)),r=new A({transform:$,position:null==$?z:void 0,outputs:[K,T.rgba(t===De.opaque?w:M?1:0),j],opacity:g,outputEncoding:!1,fog:Q,transparent:e.transparent,lights:!0,envMap:X,discard:V}),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===De.transparent):(r.depthWrite=e.depthWrite,r.depthTest=e.depthTest),r.visible=e.visible,r.alphaTest=e.alphaTest,r.alphaHash=e.alphaHash,t===De.opaque?(r.visible&&(r.visible=!b&&!x&&!P),r.visible&&(r.visible=!y)):t===De.transparent&&r.visible&&(r.visible=y||b||x||P),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 J.Panel("Calls","#83f","#002")),a=s.addPanel(new J.Panel("Triangles","#c32","#002"));let l;navigator.userAgent.includes("Chrome")&&navigator.userAgent.includes("HologyEngine")&&(l=new ce(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,v=new n;let M=0;let T=this.paused;const b=t=>{const r=this.renderer.getContext();if(this.paused&&this.running&&r.drawingBufferHeight>1)return setTimeout(()=>b(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(Ve),t-=Ve;e(t)}else e(a);this.onLoopCallbacks.forEach(e=>e(a)),this.camera?.updateMatrixWorld(),v.copy(this.camera.matrixWorld),t-M>.08&&!v.equals(g)&&(this.renderer.shadowMap.needsUpdate=!0,M=t),this.csm.update();let n=!1;c.length=0,p.length=0,m.length=0;const h=Ge;ke.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),h.setFromProjectionMatrix(ke);let d=!1,x=!1,P=!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[te])&&isObjectInFrustum(e,h)?(this.initDepthUniform(e.material),x=!0):e instanceof X&&(e.visible=!1,p.push(e)),(e instanceof o||e instanceof i.Sprite)&&e.material?.uniforms&&null!=e.material?.uniforms[he]&&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[de]&&isObjectInFrustum(e,h)&&(m.push(e),e.material.uniforms[de].value=this.sceneColorRenderTarget.texture,P=!0),e instanceof o&&e.material?.uniforms&&null!=e.material?.uniforms[le])e.material.uniforms[le].value=t;else if(e instanceof o&&Array.isArray(e.material))for(const s of e.material)s.uniforms&&null!=s.uniforms[le]&&(s.uniforms[le].value=t)}),this.bloomPass.enabled=n,this.renderer.setRenderTarget(this.gRenderTarget),this.renderer.clear(),this.renderScene(De.opaque),this.aoPass.output=Z.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)),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(b)},1e3/this.fpsCap):requestAnimationFrame(b))};!0===this.options.enableXR?this.renderer.setAnimationLoop(b):requestAnimationFrame(b)}renderScene(e){Qe.clear(),Ke.length=0;fe(this.scene,t=>{if(Je(t))return Ke.push(t),t.visible=!1,!1;if(t instanceof o){Qe.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||(Ke.push(t),t.visible=!1)}});const t=this.scene.matrixWorldAutoUpdate,s=this.scene.matrixAutoUpdate,i=this.renderer.shadowMap.autoUpdate;e!==De.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===De.opaque&&Qe.forEach((e,t)=>{!Array.isArray(e)&&!Array.isArray(t.material)&&e instanceof d&&this.updateLightUniformValues(t.material,e)}),Qe.forEach((e,t)=>{t.material=e}),Ke.forEach((e,t)=>{e.visible=!0,e.updateMatrixWorld(!0)}),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(Ne);let d=[];for(const e of this.postProcessVolumes){if(!_e(e.object))continue;let l=e.blendWeight??1;const u=e.distanceToPoint(h);u>e.blendRadius||(e.blendRadius>0&&(l*=ge(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,Ge)&&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!=me(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===Be.id)return;this.bloomStoredMaterials[e.uuid]=e.material,!0!==e.material.transparent?e.material=Be:(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[te].value=this.sceneColorRenderTarget.textures[1],this.camera instanceof l&&(null!=e.uniforms[ie]&&(e.uniforms[ie].value=this.camera.near),null!=e.uniforms[se]&&(e.uniforms[se].value=this.camera.far)))}initNormalUniform(e){e instanceof d&&null!=e.uniforms[ae]&&(e.uniforms[ae].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 d&&null!=e.uniforms[re]){const t=this.previousClientWith,s=this.previousClientHeight;e.uniforms[re].value.set(t*this.renderer.getPixelRatio(),s*this.renderer.getPixelRatio())}}initAoUniform(e){if(this.aoPass.enabled){e.uniforms[he].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=we(ye);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}}};je=e=t([ee(),s("design:paramtypes",[HTMLElement,Object])],je);export{je as RenderingView};export function setRenderingPaused(e){null!=window.editor?.viewer?.renderingView&&(window.editor.viewer.renderingView.paused=e)}const Ve=.05;function _e(e){let t=e;for(;t;){if(!1===t.visible)return!1;t=t.parent}return!0}Z.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 Ge=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 Ne=new i.Vector3;const He=new n,ze=new p;function $e(e,t,s=new i.Matrix3){return ze.copy(e),ze.x*=-1,ze.y*=-1,ze.z*=-1,t.isCubeTexture&&!1===t.isRenderTargetTexture&&(ze.y*=-1,ze.z*=-1),s.setFromMatrix4(He.makeRotationFromEuler(ze))}const Xe=new A({outputs:[q(0,0,0,0),q(0,0,0,0),W(D("white"),Fe(4))],transparent:!0}),Ye=new i.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.5});Xe.depthWrite=!1;new o(new i.BoxGeometry(4,4,4),Ye);const Qe=new Map,Ke=[];function Je(e){return e instanceof i.Sprite||e.isPoints||e.isLine||e.isTransformControls||e.isTransformControlsGizmo||e instanceof o&&Ze(e,e.material)}function Ze(e,t){return null==t||(Array.isArray(t)?t.some(t=>Ze(e,t)):t instanceof i.RawShaderMaterial||t instanceof i.ShaderMaterial&&!(t instanceof A))}class et extends Ee{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),Ke.length=0;let u=0;this.scene.traverseVisible(e=>{const t=Je(e);e instanceof o&&!t?(Ke.push(e),e.visible=!1):t&&u++}),u>0&&e.render(this.scene,this.camera),Ke.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 tt extends Ee{constructor(e){super(),this.fn=e}render(e,t,s,i,r){this.fn(e,t,s,i,r)}}const st=["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"],it=E("fogColor");export class FogNode extends ${constructor(e,t=it){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(V(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 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}`}}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import { Object3D } from "three";
2
2
  import { Asset } from "../model";
3
- import { BaseActor } from "../../gameplay";
3
+ import { BaseActor } from "../../gameplay/actors/actor.js";
4
4
  export declare class Prefab {
5
5
  asset: Asset;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hology/core",
3
- "version": "0.0.172",
3
+ "version": "0.0.174",
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.32",
177
+ "three-shader-graph": "^0.2.33",
178
178
  "three-stdlib": "2.34.0",
179
179
  "ts-key-enum": "^2.0.12",
180
180
  "typedi": "^0.10.0"