@hology/core 0.0.107 → 0.0.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/effects/vfx/trail-renderer.d.ts +1 -0
  2. package/dist/effects/vfx/trail-renderer.d.ts.map +1 -1
  3. package/dist/effects/vfx/trail-renderer.js +1 -1
  4. package/dist/effects/vfx/vfx-renderers.d.ts.map +1 -1
  5. package/dist/effects/vfx/vfx-renderers.js +1 -1
  6. package/dist/gameplay/actors/actor.d.ts +1 -1
  7. package/dist/gameplay/actors/actor.d.ts.map +1 -1
  8. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts.map +1 -1
  9. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  10. package/dist/gameplay/actors/builtin/post-process-volume-actor.d.ts +0 -1
  11. package/dist/gameplay/actors/builtin/post-process-volume-actor.d.ts.map +1 -1
  12. package/dist/gameplay/actors/builtin/post-process-volume-actor.js +1 -1
  13. package/dist/gameplay/initiate.d.ts.map +1 -1
  14. package/dist/gameplay/initiate.js +1 -1
  15. package/dist/gameplay/services/physics/abstract-physics-system.d.ts +0 -8
  16. package/dist/gameplay/services/physics/abstract-physics-system.d.ts.map +1 -1
  17. package/dist/gameplay/services/physics/physics-system.d.ts +64 -11
  18. package/dist/gameplay/services/physics/physics-system.d.ts.map +1 -1
  19. package/dist/gameplay/services/physics/physics-system.js +1 -1
  20. package/dist/gameplay/services/render.d.ts +17 -0
  21. package/dist/gameplay/services/render.d.ts.map +1 -1
  22. package/dist/gameplay/services/render.js +1 -1
  23. package/dist/rendering.d.ts +1 -1
  24. package/dist/rendering.d.ts.map +1 -1
  25. package/dist/rendering.js +1 -1
  26. package/package.json +2 -2
  27. package/tsconfig.tsbuildinfo +1 -1
  28. package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +0 -38
  29. package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts.map +0 -1
  30. package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +0 -4
@@ -44,6 +44,7 @@ export declare class Trail extends THREE.Object3D {
44
44
  initializeMesh(): void;
45
45
  destroyMesh(): void;
46
46
  reset(): void;
47
+ setAllNodesToCurrentTargetPosition(): void;
47
48
  updateUniforms(): void;
48
49
  advance: () => void;
49
50
  advanceWithPositionAndOrientation(nextPosition: any, orientationTangent: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"trail-renderer.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/trail-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAuP,MAAM,oBAAoB,CAAC;AAC5S,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAiCpD,eAAO,MAAM,OAAO,uCAMlB,CAAA;AAEF,eAAO,MAAM,WAAW,uCAGtB,CAAA;AAEF,qBAAa,KAAM,SAAQ,KAAK,CAAC,QAAQ;IACvC,MAAM,EAAE,OAAO,CAAA;IACf,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAA;IACrC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAK;IACtC,cAAc,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAA;IACpC,iBAAiB,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAA;IACvC,kBAAkB,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAA;IACxC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAK;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,M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C;IAED,MAAM,CAAC,gBAAgB,gBAA6B;IACpD,MAAM,KAAK,eAAe,kBAEzB;IAED,MAAM,KAAK,sBAAsB,WAEhC;IAED,MAAM,KAAK,gBAAgB,WAE1B;IAED,MAAM,KAAK,cAAc,WAExB;IAED,MAAM,KAAK,YAAY,WAEtB;IAED,MAAM,CAAC,MAAM;;;;;;;;;;MAsGZ;CACF"}
@@ -1,4 +1,4 @@
1
- import{timeUniforms as e}from"../../shader-nodes";import*as t from"three";import{NodeShaderMaterial as r,uniformBool as i,uniformFloat as a,uniformVec2 as n,mix as s,uniformVec4 as o,attributeFloat as h,attributeVec3 as c,select as l,float as d,textureSampler2d as u,attributes as m,uniforms as g,rgba as p,vec4 as y,varying as f,vec2 as x,normalize as v,cross as T,max as V}from"three-shader-graph";a("trailLength");const C=a("verticesPerNode"),N=a("minID"),P=a("maxID"),b=(a("dragTexture"),a("maxTrailLength")),D=n("textureTileFactor",new t.Vector2(1,1)),w=o("headColor",new t.Vector4),F=o("tailColor",new t.Vector4),I=i("taper",!1),U=(a("scale",1),h("nodeID")),A=h("nodeVertexID"),L=c("nodeCenter"),M=P.subtract(U).divide(P.subtract(N)),S=l(I,M,d(0)),B=f(d(1).subtract(M).multiplyVec4(w).add(M.multiplyVec4(F))),H=v(g.cameraPosition.subtract(L)),z=v(c("nodeTangent")),G=a("width",1),O=v(T(z,H)).multiplyScalar(A.subtract(d(.5))).multiplyScalar(G),j=y(d(1).subtract(S).multiplyVec3(O).add(V(S,d(1)).multiplyVec3(L)),1),E=y(d(1).subtract(S).multiplyVec3(m.position).add(S.multiplyVec3(L)),1),R=g.projectionMatrix.multiply(g.viewMatrix).multiplyVec(j),q=g.projectionMatrix.multiply(g.viewMatrix).multiplyVec(E);export const trailUV=f(x(M.multiply(D.x),A.divide(C).multiply(D.y).multiply(2)));export const trailDragUV=f(x(U.divide(b).multiply(D.x),A.divide(C).multiply(D.y).multiply(2)));export class Trail extends t.Object3D{constructor(e,r){super(),this.nodeCenters=[],this.nodeIDs=[],this.advance=function(){const e=new t.Matrix4;return function(){this.targetObject.updateMatrixWorld(),e.copy(this.targetObject.matrixWorld),this.advanceWithTransform(e),this.updateUniforms()}}(),this.advanceGeometry=function(e,t){const r=this.currentEnd+1>=this.length?0:this.currentEnd+1;if(t?this.updateNodePositionsFromTransformMatrix(r,t):this.updateNodePositionsFromOrientationTangent(r,e.position,e.tangent),this.currentLength>=1&&(this.connectNodes(this.currentEnd,r),this.currentLength>=this.length)){const e=this.currentEnd+1>=this.length?0:this.currentEnd+1;this.disconnectNodes(e)}this.currentLength<this.length&&this.currentLength++,this.currentEnd++,this.currentEnd>=this.length&&(this.currentEnd=0),this.currentLength>=1&&(this.currentLength<this.length?this.geometry.setDrawRange(0,(this.currentLength-1)*this.FaceIndicesPerNode):this.geometry.setDrawRange(0,this.currentLength*this.FaceIndicesPerNode)),this.updateNodeID(this.currentEnd,this.currentNodeID),this.currentNodeID++},this.updateHead=function(){const e=new t.Matrix4;return function(){this.currentEnd<0||(this.targetObject.updateMatrixWorld(),e.copy(this.targetObject.matrixWorld),this.updateNodePositionsFromTransformMatrix(this.currentEnd,e))}}(),this.updateNodePositionsFromOrientationTangent=function(){const e=new t.Quaternion,r=new t.Vector3,i=[];for(let e=0;e<Trail.MaxHeadVertices;e++){const e=new t.Vector3;i.push(e)}return function(t,a,n){const s=this.geometry.getAttribute("position");this.updateNodeCenter(t,a),r.copy(a),r.sub(Trail.LocalHeadOrigin),e.setFromUnitVectors(Trail.LocalOrientationTangent,n);for(let t=0;t<this.localHeadGeometry.length;t++){const a=i[t];a.copy(this.localHeadGeometry[t]),a.applyQuaternion(e),a.add(r)}for(let e=0;e<this.localHeadGeometry.length;e++){const r=(this.VerticesPerNode*t+e)*Trail.PositionComponentCount,a=i[e];s.array[r]=a.x,s.array[r+1]=a.y,s.array[r+2]=a.z}s.needsUpdate=!0}}(),this.updateNodePositionsFromTransformMatrix=function(){const e=new t.Matrix3,r=new t.Quaternion,i=new t.Vector3,a=new t.Vector3,n=new t.Vector3,s=new t.Vector3,o=new t.Box3,h=new t.Vector3,c=[];for(let e=0;e<Trail.MaxHeadVertices;e++){const e=new t.Vector3;c.push(e)}const l=new t.Vector3(1,0,0);return function(d,u){const m=this.geometry.getAttribute("position");i.set(0,0,0),i.applyMatrix4(u),this.updateNodeCenter(d,i);for(let e=0;e<this.localHeadGeometry.length;e++){c[e].copy(this.localHeadGeometry[e])}for(let e=0;e<this.localHeadGeometry.length;e++){c[e].applyMatrix4(u)}if(this.lastNodeCenter&&this.orientToMovement&&(function(e,t){const r=t.elements;e.set(r[0],r[1],r[2],r[4],r[5],r[6],r[8],r[9],r[10])}(e,u),n.set(0,0,-1),n.applyMatrix3(e),s.copy(this.currentNodeCenter),s.sub(this.lastNodeCenter),s.normalize(),s.lengthSq()<=1e-4&&this.lastOrientationDir&&s.copy(this.lastOrientationDir),s.lengthSq()>1e-4)){this.lastOrientationDir||(this.lastOrientationDir=new t.Vector3),r.setFromUnitVectors(n,s),a.copy(this.currentNodeCenter);for(let e=0;e<this.localHeadGeometry.length;e++){const t=c[e];t.sub(a),t.applyQuaternion(r),t.add(a)}}this.lastNodeCenter&&this.currentNodeCenter&&this.billboard&&!this.currentNodeCenter.equals(this.lastNodeCenter)&&(l.copy(this.currentNodeCenter).sub(this.lastNodeCenter),l.normalize());const g=this.geometry.getAttribute("nodeTangent");for(let e=0;e<this.localHeadGeometry.length;e++){const t=(this.VerticesPerNode*d+e)*Trail.PositionComponentCount,r=c[e];this.billboard?(g.array[t]=l.x,g.array[t+1]=l.y,g.array[t+2]=l.z):(m.array[t]=r.x,m.array[t+1]=r.y,m.array[t+2]=r.z)}this.billboard?(this.mesh.frustumCulled=!1,g.needsUpdate=!0,g.updateRange={offset:d*this.VerticesPerNode*3,count:3*this.VerticesPerNode}):(m.needsUpdate=!0,m.addUpdateRange(d*this.VerticesPerNode*Trail.PositionComponentCount,this.VerticesPerNode*Trail.PositionComponentCount)),o.makeEmpty();for(let e=0;e<this.currentLength*this.VerticesPerNode;e++){const t=3*e;h.set(m.array[t],m.array[t+1],m.array[t+2]),o.expandByPoint(h)}this.mesh.visible=!o.isEmpty(),null==this.geometry.boundingBox&&(this.geometry.boundingBox=new t.Box3),this.geometry.boundingBox.copy(o),null==this.geometry.boundingSphere&&(this.geometry.boundingSphere=new t.Sphere),this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere)}}(),this.connectNodes=(()=>{const e={attribute:null,offset:0,count:-1};return(t,r)=>{const i=this.geometry.getIndex();for(let e=0;e<this.localHeadGeometry.length-1;e++){const a=this.VerticesPerNode*t+e,n=this.VerticesPerNode*r+e,s=(t*this.FacesPerNode+e*Trail.FacesPerQuad)*Trail.IndicesPerFace;i.array[s]=a,i.array[s+1]=n,i.array[s+2]=a+1,i.array[s+3]=n,i.array[s+4]=n+1,i.array[s+5]=a+1}return i.needsUpdate=!0,i.clearUpdateRanges(),e.attribute=i,e.offset=t*this.FacesPerNode*Trail.IndicesPerFace,e.count=this.FacesPerNode*Trail.IndicesPerFace,e}})(),this.disconnectNodes=(()=>{const e={attribute:null,offset:0,count:-1};return t=>{const r=this.geometry.getIndex();for(let e=0;e<this.localHeadGeometry.length-1;e++){const i=(t*this.FacesPerNode+e*Trail.FacesPerQuad)*Trail.IndicesPerFace;r.array[i]=0,r.array[i+1]=0,r.array[i+2]=0,r.array[i+3]=0,r.array[i+4]=0,r.array[i+5]=0}return r.needsUpdate=!0,r.clearUpdateRanges(),e.attribute=r,e.offset=t*this.FacesPerNode*Trail.IndicesPerFace,e.count=this.FacesPerNode*Trail.IndicesPerFace,e}})(),this.active=!1,this.orientToMovement=!1,r&&(this.orientToMovement=!0),this.scene=e,this.geometry=null,this.mesh=null,this.nodeCenters=[],this.lastNodeCenter=null,this.currentNodeCenter=null,this.lastOrientationDir=null,this.nodeIDs=[],this.currentLength=0,this.currentEnd=0,this.currentNodeID=0,this.advanceFrequency=60,this.advancePeriod=1/this.advanceFrequency,this.lastAdvanceTime=0,this.paused=!1,this.pauseAdvanceUpdateTimeDiff=0}setAdvanceFrequency(e){this.advanceFrequency=e,this.advancePeriod=1/this.advanceFrequency}initialize(e,r,i,a,n,s,o=!1){this.deactivate(),this.destroyMesh(),this.length=r>0?r+1:0,this.dragTexture=i?1:0,this.targetObject=s,this.billboard=o,this.initializeLocalHeadGeometry(a,n),null!=e.uniforms.width&&(e.uniforms.width.value=a),this.nodeIDs=[],this.nodeCenters=[];for(let e=0;e<this.length;e++)this.nodeIDs[e]=-1,this.nodeCenters[e]=new t.Vector3;this.material=e,this.initializeGeometry(),this.initializeMesh(),this.material.uniforms.dragTexture&&(this.material.uniforms.trailLength.value=0),this.material.uniforms.minID.value=0,this.material.uniforms.maxID.value=0,this.material.uniforms.dragTexture&&(this.material.uniforms.dragTexture.value=this.dragTexture),this.material.uniforms.maxTrailLength&&(this.material.uniforms.maxTrailLength.value=this.length),this.material.uniforms.verticesPerNode&&(this.material.uniforms.verticesPerNode.value=this.VerticesPerNode),this.material.uniforms.textureTileFactor&&(this.material.uniforms.textureTileFactor.value=new t.Vector2(1,1)),this.material.uniforms.scale&&(this.material.uniforms.scale.value=1),this.reset()}initializeLocalHeadGeometry(e,r){if(this.localHeadGeometry=[],r){this.VerticesPerNode=0;for(let e=0;e<r.length&&e<Trail.MaxHeadVertices;e++){const i=r[e];if(i&&i instanceof t.Vector3){const e=new t.Vector3;e.copy(i),this.localHeadGeometry.push(e),this.VerticesPerNode++}}}else{const r=(e||1)/2;this.localHeadGeometry.push(new t.Vector3(-r,0,0)),this.localHeadGeometry.push(new t.Vector3(r,0,0)),this.VerticesPerNode=2}this.FacesPerNode=2*(this.VerticesPerNode-1),this.FaceIndicesPerNode=3*this.FacesPerNode}initializeGeometry(){this.vertexCount=this.length*this.VerticesPerNode,this.faceCount=this.length*this.FacesPerNode;const e=new t.BufferGeometry,r=new Float32Array(this.vertexCount),i=new Float32Array(this.vertexCount*this.VerticesPerNode),a=new Float32Array(this.vertexCount*Trail.PositionComponentCount),n=new Float32Array(this.vertexCount*Trail.PositionComponentCount),s=new Float32Array(this.vertexCount*Trail.UVComponentCount),o=new Uint32Array(this.faceCount*Trail.IndicesPerFace),h=new Float32Array(3*this.vertexCount),c=new t.BufferAttribute(h,3);c.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeTangent",c);const l=new t.BufferAttribute(r,1);l.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeID",l);const d=new t.BufferAttribute(i,1);d.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeVertexID",d);const u=new t.BufferAttribute(n,Trail.PositionComponentCount);u.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeCenter",u);const m=new t.BufferAttribute(a,Trail.PositionComponentCount);m.setUsage(t.DynamicDrawUsage),e.setAttribute("position",m);const g=new t.BufferAttribute(s,Trail.UVComponentCount);g.setUsage(t.DynamicDrawUsage),e.setAttribute("uv",g);const p=new t.BufferAttribute(o,1);p.setUsage(t.DynamicDrawUsage),e.setIndex(p),this.geometry=e}zeroVertices(){const e=this.geometry.getAttribute("position");for(let t=0;t<this.vertexCount;t++){const r=3*t;e.array[r]=0,e.array[r+1]=0,e.array[r+2]=0}e.needsUpdate=!0}zeroIndices(){if(null==this.geometry)throw"Geometry not initialized";const e=this.geometry.getIndex();for(let t=0;t<this.faceCount;t++){const r=3*t;e.array[r]=0,e.array[r+1]=0,e.array[r+2]=0}e.needsUpdate=!0,e.clearUpdateRanges()}formInitialFaces(){this.zeroIndices();const e=this.geometry.getIndex();for(let e=0;e<this.length-1;e++)this.connectNodes(e,e+1);e.needsUpdate=!0,e.clearUpdateRanges()}initializeMesh(){if(null==this.geometry)throw"Geometry not initialized";this.mesh=new t.Mesh(this.geometry,this.material),this.mesh.matrixAutoUpdate=!1}destroyMesh(){this.mesh&&(this.scene.remove(this.mesh),this.mesh=null)}reset(){this.currentLength=0,this.currentEnd=-1,this.lastNodeCenter=null,this.currentNodeCenter=null,this.lastOrientationDir=null,this.currentNodeID=0,this.formInitialFaces(),this.zeroVertices(),this.geometry.setDrawRange(0,0)}updateUniforms(){this.currentLength<this.length?this.material.uniforms.minID.value=0:this.material.uniforms.minID.value=this.currentNodeID-this.length,this.material.uniforms.maxID.value=this.currentNodeID,this.material.uniforms.trailLength&&(this.material.uniforms.trailLength.value=this.currentLength),this.material.uniforms.maxTrailLength&&(this.material.uniforms.maxTrailLength.value=this.length),this.material.uniforms.verticesPerNod&&(this.material.uniforms.verticesPerNode.value=this.VerticesPerNode)}advanceWithPositionAndOrientation(e,t){this.advanceGeometry({position:e,tangent:t},null)}advanceWithTransform(e){this.advanceGeometry(null,e)}currentTime(){return performance.now()/1e3}pause(){this.paused||(this.paused=!0,this.pauseAdvanceUpdateTimeDiff=this.currentTime()-this.lastAdvanceTime)}resume(){this.paused&&(this.paused=!1,this.lastAdvanceTime=this.currentTime()-this.pauseAdvanceUpdateTimeDiff)}update(){if(!this.paused){const e=this.currentTime();this.lastAdvanceTime||(this.lastAdvanceTime=e),e-this.lastAdvanceTime>this.advancePeriod?(this.advance(),this.lastAdvanceTime=e):this.updateHead()}}updateNodeID(e,t){this.nodeIDs[e]=t;const r=this.geometry.getAttribute("nodeID"),i=this.geometry.getAttribute("nodeVertexID");for(let a=0;a<this.VerticesPerNode;a++){const n=e*this.VerticesPerNode+a;r.array[n]=t,i.array[n]=a}r.needsUpdate=!0,i.needsUpdate=!0,r.addUpdateRange(e*this.VerticesPerNode,this.VerticesPerNode),i.addUpdateRange(e*this.VerticesPerNode,this.VerticesPerNode)}updateNodeCenter(e,t){this.lastNodeCenter=this.currentNodeCenter,this.currentNodeCenter=this.nodeCenters[e],this.currentNodeCenter.copy(t);const r=this.geometry.getAttribute("nodeCenter");for(let i=0;i<this.VerticesPerNode;i++){const a=3*(e*this.VerticesPerNode+i);r.array[a]=t.x,r.array[a+1]=t.y,r.array[a+2]=t.z}r.needsUpdate=!0,r.updateRanges=[{start:e*this.VerticesPerNode*Trail.PositionComponentCount,count:this.VerticesPerNode*Trail.PositionComponentCount}]}deactivate(){this.active&&(this.scene.remove(this.mesh),this.active=!1)}activate(){this.active||(this.scene.add(this.mesh),this.active=!0)}static getTrailShaderNodes(e){return{position:e?R:q,color:B,fraction:M}}static applyTrailShaderParameters(e){e.transparent=!0,e.alphaTest=.5,e.blending=t.CustomBlending,e.blendSrc=t.SrcAlphaFactor,e.blendDst=t.OneMinusSrcAlphaFactor,e.blendEquation=t.AddEquation,e.depthTest=!0,e.depthWrite=!1,e.side=t.DoubleSide}static createBaseMaterial(t,i,a,n=!1){let{position:o}=Trail.getTrailShaderNodes(n),h=s(w,F,M).rgba;if(null!=t){let r=trailUV;null!=i&&(r=r.add(x(e.elapsed.multiply(-i),0)));const n=u(t).sample(r);let s=h.a;switch(a??"red"){case"none":break;case"red":s=s.multiply(n.r);break;case"alpha":s=s.multiply(n.a)}h=p(h.rgb.multiply(n.rgb),s)}const c=new r({position:o,color:h});return Trail.applyTrailShaderParameters(c),c}static get MaxHeadVertices(){return 128}static get LocalOrientationTangent(){return Trail._LocalOrientationTangent}static get LocalHeadOrigin(){return Trail._LocalHeadOrigin}static get PositionComponentCount(){return 3}static get UVComponentCount(){return 2}static get IndicesPerFace(){return 3}static get FacesPerQuad(){return 2}}Trail._LocalOrientationTangent=new t.Vector3(1,0,0),Trail._LocalHeadOrigin=new t.Vector3(0,0,0),Trail.Shader={get BaseVertexVars(){return["attribute float nodeID;","attribute float nodeVertexID;","attribute vec3 nodeCenter;","uniform float minID;","uniform float maxID;","uniform float trailLength;","uniform float maxTrailLength;","uniform float verticesPerNode;","uniform vec2 textureTileFactor;","uniform bool taper;","uniform vec4 headColor;","uniform vec4 tailColor;","varying vec4 vColor;"].join("\n")},get TexturedVertexVars(){return[this.BaseVertexVars,"varying vec2 vUV;","uniform float dragTexture;"].join("\n")},BaseFragmentVars:["varying vec4 vColor;","uniform sampler2D trailTexture;"].join("\n"),get TexturedFragmentVars(){return[this.BaseFragmentVars,"varying vec2 vUV;"].join("\n")},get VertexShaderCore(){return["float fraction = (maxID - nodeID) / (maxID - minID);","float fractionSize = taper ? fraction : 0.0;","vColor = (1.0 - fraction) * headColor + fraction * tailColor;","vec4 realPosition = vec4((1.0 - fractionSize) * position.xyz + fractionSize * nodeCenter.xyz, 1.0); "].join("\n")},get BaseVertexShader(){return[this.BaseVertexVars,"void main() { ",this.VertexShaderCore,"gl_Position = projectionMatrix * viewMatrix * realPosition;","}"].join("\n")},get BaseFragmentShader(){return[this.BaseFragmentVars,"void main() { ","gl_FragColor = vColor;","}"].join("\n")},get TexturedVertexShader(){return[this.TexturedVertexVars,"void main() { ",this.VertexShaderCore,"float s = 0.0;","float t = 0.0;","if (dragTexture == 1.0) { "," s = fraction * textureTileFactor.s; "," t = (nodeVertexID / verticesPerNode) * textureTileFactor.t;","} else { "," s = nodeID / maxTrailLength * textureTileFactor.s;"," t = (nodeVertexID / verticesPerNode) * textureTileFactor.t;","}","vUV = vec2(s, t); ","gl_Position = projectionMatrix * viewMatrix * realPosition;","}"].join("\n")},get TexturedFragmentShader(){return[this.TexturedFragmentVars,"void main() { ","vec4 textureColor = texture2D(trailTexture, vUV);","gl_FragColor = vColor * textureColor;","}"].join("\n")}};/*
1
+ import{timeUniforms as e}from"../../shader-nodes";import*as t from"three";import{NodeShaderMaterial as r,uniformBool as i,uniformFloat as n,uniformVec2 as a,mix as s,uniformVec4 as o,attributeFloat as h,attributeVec3 as l,select as c,float as d,textureSampler2d as u,attributes as m,uniforms as g,rgba as y,vec4 as p,varying as f,vec2 as x,normalize as v,vec3 as T,cross as V,max as C,length as P}from"three-shader-graph";n("trailLength");const N=n("verticesPerNode"),b=n("minID"),D=n("maxID"),w=(n("dragTexture"),n("maxTrailLength")),F=a("textureTileFactor",new t.Vector2(1,1)),I=o("headColor",new t.Vector4),U=o("tailColor",new t.Vector4),A=i("taper",!1),L=(n("scale",1),h("nodeID")),O=h("nodeVertexID"),M=l("nodeCenter"),B=D.subtract(L).divide(D.subtract(b)),S=c(A,B,d(0)),z=f(d(1).subtract(B).multiplyVec4(I).add(B.multiplyVec4(U))),H=v(g.cameraPosition.subtract(M)),G=v(l("nodeTangent")),j=n("width",1),E=v(V(c(P(G).gt(d(.1)),G,T(1,0,0)),H)).multiplyScalar(O.subtract(d(.5))).multiplyScalar(j),R=p(d(1).subtract(S).multiplyVec3(E).add(C(S,d(1)).multiplyVec3(M)),1),W=p(d(1).subtract(S).multiplyVec3(m.position).add(S.multiplyVec3(M)),1),q=g.projectionMatrix.multiply(g.viewMatrix).multiplyVec(R),_=g.projectionMatrix.multiply(g.viewMatrix).multiplyVec(W);export const trailUV=f(x(B.multiply(F.x),O.divide(N).multiply(F.y).multiply(2)));export const trailDragUV=f(x(L.divide(w).multiply(F.x),O.divide(N).multiply(F.y).multiply(2)));export class Trail extends t.Object3D{constructor(e,r){super(),this.nodeCenters=[],this.nodeIDs=[],this.advance=function(){const e=new t.Matrix4;return function(){this.targetObject.updateMatrixWorld(),e.copy(this.targetObject.matrixWorld),this.advanceWithTransform(e),this.updateUniforms()}}(),this.advanceGeometry=function(e,t){const r=this.currentEnd+1>=this.length?0:this.currentEnd+1;if(t?this.updateNodePositionsFromTransformMatrix(r,t):this.updateNodePositionsFromOrientationTangent(r,e.position,e.tangent),this.currentLength>=1&&(this.connectNodes(this.currentEnd,r),this.currentLength>=this.length)){const e=this.currentEnd+1>=this.length?0:this.currentEnd+1;this.disconnectNodes(e)}this.currentLength<this.length&&this.currentLength++,this.currentEnd++,this.currentEnd>=this.length&&(this.currentEnd=0),this.currentLength>=1?(this.currentLength<this.length?this.geometry.setDrawRange(0,(this.currentLength-1)*this.FaceIndicesPerNode):this.geometry.setDrawRange(0,this.currentLength*this.FaceIndicesPerNode),this.mesh&&(this.mesh.visible=!0)):(this.geometry.setDrawRange(0,0),this.mesh&&(this.mesh.visible=!1)),this.updateNodeID(this.currentEnd,this.currentNodeID),this.currentNodeID++},this.updateHead=function(){const e=new t.Matrix4;return function(){this.currentEnd<0||(this.targetObject.updateMatrixWorld(),e.copy(this.targetObject.matrixWorld),this.updateNodePositionsFromTransformMatrix(this.currentEnd,e))}}(),this.updateNodePositionsFromOrientationTangent=function(){const e=new t.Quaternion,r=new t.Vector3,i=[];for(let e=0;e<Trail.MaxHeadVertices;e++){const e=new t.Vector3;i.push(e)}return function(t,n,a){const s=this.geometry.getAttribute("position");this.updateNodeCenter(t,n),r.copy(n),r.sub(Trail.LocalHeadOrigin),e.setFromUnitVectors(Trail.LocalOrientationTangent,a);for(let t=0;t<this.localHeadGeometry.length;t++){const n=i[t];n.copy(this.localHeadGeometry[t]),n.applyQuaternion(e),n.add(r)}for(let e=0;e<this.localHeadGeometry.length;e++){const r=(this.VerticesPerNode*t+e)*Trail.PositionComponentCount,n=i[e];s.array[r]=n.x,s.array[r+1]=n.y,s.array[r+2]=n.z}s.needsUpdate=!0}}(),this.updateNodePositionsFromTransformMatrix=function(){const e=new t.Matrix3,r=new t.Quaternion,i=new t.Vector3,n=new t.Vector3,a=new t.Vector3,s=new t.Vector3,o=new t.Box3,h=new t.Vector3,l=[];for(let e=0;e<Trail.MaxHeadVertices;e++){const e=new t.Vector3;l.push(e)}const c=new t.Vector3(1,0,0);return function(d,u){const m=this.geometry.getAttribute("position");i.set(0,0,0),i.applyMatrix4(u),this.updateNodeCenter(d,i);for(let e=0;e<this.localHeadGeometry.length;e++){l[e].copy(this.localHeadGeometry[e])}for(let e=0;e<this.localHeadGeometry.length;e++){l[e].applyMatrix4(u)}if(this.lastNodeCenter&&this.orientToMovement&&(function(e,t){const r=t.elements;e.set(r[0],r[1],r[2],r[4],r[5],r[6],r[8],r[9],r[10])}(e,u),a.set(0,0,-1),a.applyMatrix3(e),s.copy(this.currentNodeCenter),s.sub(this.lastNodeCenter),s.normalize(),s.lengthSq()<=1e-4&&this.lastOrientationDir&&s.copy(this.lastOrientationDir),s.lengthSq()>1e-4)){this.lastOrientationDir||(this.lastOrientationDir=new t.Vector3),r.setFromUnitVectors(a,s),n.copy(this.currentNodeCenter);for(let e=0;e<this.localHeadGeometry.length;e++){const t=l[e];t.sub(n),t.applyQuaternion(r),t.add(n)}}this.billboard&&(this.lastNodeCenter&&this.currentNodeCenter&&!this.currentNodeCenter.equals(this.lastNodeCenter)?(c.copy(this.currentNodeCenter).sub(this.lastNodeCenter),c.normalize(),this.lastOrientationDir||(this.lastOrientationDir=new t.Vector3),this.lastOrientationDir.copy(c)):this.lastOrientationDir?c.copy(this.lastOrientationDir):(c.set(1,0,0),c.applyMatrix4(u),c.normalize(),this.lastOrientationDir||(this.lastOrientationDir=new t.Vector3),this.lastOrientationDir.copy(c)));const g=this.geometry.getAttribute("nodeTangent");for(let e=0;e<this.localHeadGeometry.length;e++){const t=(this.VerticesPerNode*d+e)*Trail.PositionComponentCount,r=l[e];this.billboard?(g.array[t]=c.x,g.array[t+1]=c.y,g.array[t+2]=c.z):(m.array[t]=r.x,m.array[t+1]=r.y,m.array[t+2]=r.z)}if(this.billboard?(this.mesh.frustumCulled=!1,g.needsUpdate=!0,g.addUpdateRange(d*this.VerticesPerNode*Trail.PositionComponentCount,this.VerticesPerNode*Trail.PositionComponentCount)):(m.needsUpdate=!0,m.addUpdateRange(d*this.VerticesPerNode*Trail.PositionComponentCount,this.VerticesPerNode*Trail.PositionComponentCount)),o.makeEmpty(),this.billboard)for(let e=0;e<this.currentLength;e++){const r=(this.currentEnd-e+this.length)%this.length,i=this.nodeCenters[r];if(i){const e=this.material.uniforms.width?.5*this.material.uniforms.width.value:.5;o.expandByPoint(i.clone().add(new t.Vector3(e,e,e))),o.expandByPoint(i.clone().sub(new t.Vector3(e,e,e)))}}else for(let e=0;e<this.currentLength*this.VerticesPerNode;e++){const t=3*e;h.set(m.array[t],m.array[t+1],m.array[t+2]),o.expandByPoint(h)}this.mesh.visible=!o.isEmpty(),null==this.geometry.boundingBox&&(this.geometry.boundingBox=new t.Box3),this.geometry.boundingBox.copy(o),null==this.geometry.boundingSphere&&(this.geometry.boundingSphere=new t.Sphere),this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere)}}(),this.connectNodes=(()=>{const e={attribute:null,offset:0,count:-1};return(t,r)=>{const i=this.geometry.getIndex();for(let e=0;e<this.localHeadGeometry.length-1;e++){const n=this.VerticesPerNode*t+e,a=this.VerticesPerNode*r+e,s=(t*this.FacesPerNode+e*Trail.FacesPerQuad)*Trail.IndicesPerFace;i.array[s]=n,i.array[s+1]=a,i.array[s+2]=n+1,i.array[s+3]=a,i.array[s+4]=a+1,i.array[s+5]=n+1}return i.needsUpdate=!0,i.clearUpdateRanges(),e.attribute=i,e.offset=t*this.FacesPerNode*Trail.IndicesPerFace,e.count=this.FacesPerNode*Trail.IndicesPerFace,e}})(),this.disconnectNodes=(()=>{const e={attribute:null,offset:0,count:-1};return t=>{const r=this.geometry.getIndex();for(let e=0;e<this.localHeadGeometry.length-1;e++){const i=(t*this.FacesPerNode+e*Trail.FacesPerQuad)*Trail.IndicesPerFace;r.array[i]=0,r.array[i+1]=0,r.array[i+2]=0,r.array[i+3]=0,r.array[i+4]=0,r.array[i+5]=0}return r.needsUpdate=!0,r.clearUpdateRanges(),e.attribute=r,e.offset=t*this.FacesPerNode*Trail.IndicesPerFace,e.count=this.FacesPerNode*Trail.IndicesPerFace,e}})(),this.active=!1,this.orientToMovement=!1,r&&(this.orientToMovement=!0),this.scene=e,this.geometry=null,this.mesh=null,this.nodeCenters=[],this.lastNodeCenter=null,this.currentNodeCenter=null,this.lastOrientationDir=null,this.nodeIDs=[],this.currentLength=0,this.currentEnd=0,this.currentNodeID=0,this.advanceFrequency=60,this.advancePeriod=1/this.advanceFrequency,this.lastAdvanceTime=0,this.paused=!1,this.pauseAdvanceUpdateTimeDiff=0}setAdvanceFrequency(e){this.advanceFrequency=e,this.advancePeriod=1/this.advanceFrequency}initialize(e,r,i,n,a,s,o=!1){this.deactivate(),this.destroyMesh(),this.length=r>0?r+1:0,this.dragTexture=i?1:0,this.targetObject=s,this.billboard=o,this.initializeLocalHeadGeometry(n,a),null!=e.uniforms.width&&(e.uniforms.width.value=n),this.nodeIDs=[],this.nodeCenters=[];for(let e=0;e<this.length;e++)this.nodeIDs[e]=-1,this.nodeCenters[e]=new t.Vector3;this.setAllNodesToCurrentTargetPosition(),this.material=e,this.initializeGeometry(),this.initializeMesh(),this.material.uniforms.dragTexture&&(this.material.uniforms.trailLength.value=0),this.material.uniforms.minID.value=0,this.material.uniforms.maxID.value=0,this.material.uniforms.dragTexture&&(this.material.uniforms.dragTexture.value=this.dragTexture),this.material.uniforms.maxTrailLength&&(this.material.uniforms.maxTrailLength.value=this.length),this.material.uniforms.verticesPerNode&&(this.material.uniforms.verticesPerNode.value=this.VerticesPerNode),this.material.uniforms.textureTileFactor&&(this.material.uniforms.textureTileFactor.value=new t.Vector2(1,1)),this.material.uniforms.scale&&(this.material.uniforms.scale.value=1),this.reset()}initializeLocalHeadGeometry(e,r){if(this.localHeadGeometry=[],r){this.VerticesPerNode=0;for(let e=0;e<r.length&&e<Trail.MaxHeadVertices;e++){const i=r[e];if(i&&i instanceof t.Vector3){const e=new t.Vector3;e.copy(i),this.localHeadGeometry.push(e),this.VerticesPerNode++}}}else{const r=(e||1)/2;this.localHeadGeometry.push(new t.Vector3(-r,0,0)),this.localHeadGeometry.push(new t.Vector3(r,0,0)),this.VerticesPerNode=2}this.FacesPerNode=2*(this.VerticesPerNode-1),this.FaceIndicesPerNode=3*this.FacesPerNode}initializeGeometry(){this.vertexCount=this.length*this.VerticesPerNode,this.faceCount=this.length*this.FacesPerNode;const e=new t.BufferGeometry,r=new Float32Array(this.vertexCount),i=new Float32Array(this.vertexCount*this.VerticesPerNode),n=new Float32Array(this.vertexCount*Trail.PositionComponentCount),a=new Float32Array(this.vertexCount*Trail.PositionComponentCount),s=new Float32Array(this.vertexCount*Trail.UVComponentCount),o=new Uint32Array(this.faceCount*Trail.IndicesPerFace),h=new Float32Array(3*this.vertexCount),l=new t.BufferAttribute(h,3);l.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeTangent",l);const c=new t.BufferAttribute(r,1);c.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeID",c);const d=new t.BufferAttribute(i,1);d.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeVertexID",d);const u=new t.BufferAttribute(a,Trail.PositionComponentCount);u.setUsage(t.DynamicDrawUsage),e.setAttribute("nodeCenter",u);const m=new t.BufferAttribute(n,Trail.PositionComponentCount);m.setUsage(t.DynamicDrawUsage),e.setAttribute("position",m);const g=new t.BufferAttribute(s,Trail.UVComponentCount);g.setUsage(t.DynamicDrawUsage),e.setAttribute("uv",g);const y=new t.BufferAttribute(o,1);y.setUsage(t.DynamicDrawUsage),e.setIndex(y),this.geometry=e}zeroVertices(){const e=this.geometry.getAttribute("position");for(let t=0;t<this.vertexCount;t++){const r=3*t;e.array[r]=0,e.array[r+1]=0,e.array[r+2]=0}e.needsUpdate=!0}zeroIndices(){if(null==this.geometry)throw"Geometry not initialized";const e=this.geometry.getIndex();for(let t=0;t<this.faceCount;t++){const r=3*t;e.array[r]=0,e.array[r+1]=0,e.array[r+2]=0}e.needsUpdate=!0,e.clearUpdateRanges()}formInitialFaces(){this.zeroIndices();const e=this.geometry.getIndex();for(let e=0;e<this.length-1;e++)this.connectNodes(e,e+1);e.needsUpdate=!0,e.clearUpdateRanges()}initializeMesh(){if(null==this.geometry)throw"Geometry not initialized";this.mesh=new t.Mesh(this.geometry,this.material),this.mesh.matrixAutoUpdate=!1,this.mesh.visible=!1}destroyMesh(){this.mesh&&(this.scene.remove(this.mesh),this.mesh=null)}reset(){this.currentLength=0,this.currentEnd=-1,this.lastNodeCenter=null,this.currentNodeCenter=null,this.lastOrientationDir=null,this.currentNodeID=0,this.formInitialFaces(),this.zeroVertices(),this.geometry.setDrawRange(0,0),this.setAllNodesToCurrentTargetPosition(),this.mesh&&(this.mesh.visible=!0)}setAllNodesToCurrentTargetPosition(){if(!this.targetObject)return;const e=new t.Vector3;this.targetObject.getWorldPosition(e);for(let t=0;t<this.length;t++)this.nodeCenters[t].copy(e);if(this.billboard&&this.geometry){const e=this.geometry.getAttribute("nodeTangent"),r=new t.Vector3(1,0,0);this.targetObject.matrixWorld&&(r.applyMatrix4(this.targetObject.matrixWorld),r.normalize());for(let t=0;t<this.vertexCount;t++){const i=3*t;e.array[i]=r.x,e.array[i+1]=r.y,e.array[i+2]=r.z}e.needsUpdate=!0}}updateUniforms(){this.currentLength<this.length?this.material.uniforms.minID.value=0:this.material.uniforms.minID.value=this.currentNodeID-this.length,this.material.uniforms.maxID.value=this.currentNodeID,this.material.uniforms.trailLength&&(this.material.uniforms.trailLength.value=this.currentLength),this.material.uniforms.maxTrailLength&&(this.material.uniforms.maxTrailLength.value=this.length),this.material.uniforms.verticesPerNode&&(this.material.uniforms.verticesPerNode.value=this.VerticesPerNode)}advanceWithPositionAndOrientation(e,t){this.advanceGeometry({position:e,tangent:t},null)}advanceWithTransform(e){this.advanceGeometry(null,e)}currentTime(){return performance.now()/1e3}pause(){this.paused||(this.paused=!0,this.pauseAdvanceUpdateTimeDiff=this.currentTime()-this.lastAdvanceTime)}resume(){this.paused&&(this.paused=!1,this.lastAdvanceTime=this.currentTime()-this.pauseAdvanceUpdateTimeDiff)}update(){if(!this.paused){const e=this.currentTime();this.lastAdvanceTime||(this.lastAdvanceTime=e),e-this.lastAdvanceTime>this.advancePeriod?(this.advance(),this.lastAdvanceTime=e):this.updateHead()}}updateNodeID(e,t){this.nodeIDs[e]=t;const r=this.geometry.getAttribute("nodeID"),i=this.geometry.getAttribute("nodeVertexID");for(let n=0;n<this.VerticesPerNode;n++){const a=e*this.VerticesPerNode+n;r.array[a]=t,i.array[a]=n}r.needsUpdate=!0,i.needsUpdate=!0,r.addUpdateRange(e*this.VerticesPerNode,this.VerticesPerNode),i.addUpdateRange(e*this.VerticesPerNode,this.VerticesPerNode)}updateNodeCenter(e,t){this.lastNodeCenter=this.currentNodeCenter,this.currentNodeCenter=this.nodeCenters[e],this.currentNodeCenter.copy(t);const r=this.geometry.getAttribute("nodeCenter");for(let i=0;i<this.VerticesPerNode;i++){const n=3*(e*this.VerticesPerNode+i);r.array[n]=t.x,r.array[n+1]=t.y,r.array[n+2]=t.z}r.needsUpdate=!0,r.updateRanges=[{start:e*this.VerticesPerNode*Trail.PositionComponentCount,count:this.VerticesPerNode*Trail.PositionComponentCount}]}deactivate(){this.active&&(this.scene.remove(this.mesh),this.active=!1)}activate(){this.active||(this.scene.add(this.mesh),this.active=!0)}static getTrailShaderNodes(e){return{position:e?q:_,color:z,fraction:B}}static applyTrailShaderParameters(e){e.transparent=!0,e.alphaTest=.5,e.blending=t.CustomBlending,e.blendSrc=t.SrcAlphaFactor,e.blendDst=t.OneMinusSrcAlphaFactor,e.blendEquation=t.AddEquation,e.depthTest=!0,e.depthWrite=!1,e.side=t.DoubleSide}static createBaseMaterial(t,i,n,a=!1){let{position:o}=Trail.getTrailShaderNodes(a),h=s(I,U,B).rgba;if(null!=t){let r=trailUV;null!=i&&(r=r.add(x(e.elapsed.multiply(-i),0)));const a=u(t).sample(r);let s=h.a;switch(n??"red"){case"none":break;case"red":s=s.multiply(a.r);break;case"alpha":s=s.multiply(a.a)}h=y(h.rgb.multiply(a.rgb),s)}const l=new r({position:o,color:h});return Trail.applyTrailShaderParameters(l),l}static get MaxHeadVertices(){return 128}static get LocalOrientationTangent(){return Trail._LocalOrientationTangent}static get LocalHeadOrigin(){return Trail._LocalHeadOrigin}static get PositionComponentCount(){return 3}static get UVComponentCount(){return 2}static get IndicesPerFace(){return 3}static get FacesPerQuad(){return 2}}Trail._LocalOrientationTangent=new t.Vector3(1,0,0),Trail._LocalHeadOrigin=new t.Vector3(0,0,0),Trail.Shader={get BaseVertexVars(){return["attribute float nodeID;","attribute float nodeVertexID;","attribute vec3 nodeCenter;","uniform float minID;","uniform float maxID;","uniform float trailLength;","uniform float maxTrailLength;","uniform float verticesPerNode;","uniform vec2 textureTileFactor;","uniform bool taper;","uniform vec4 headColor;","uniform vec4 tailColor;","varying vec4 vColor;"].join("\n")},get TexturedVertexVars(){return[this.BaseVertexVars,"varying vec2 vUV;","uniform float dragTexture;"].join("\n")},BaseFragmentVars:["varying vec4 vColor;","uniform sampler2D trailTexture;"].join("\n"),get TexturedFragmentVars(){return[this.BaseFragmentVars,"varying vec2 vUV;"].join("\n")},get VertexShaderCore(){return["float fraction = (maxID - nodeID) / (maxID - minID);","float fractionSize = taper ? fraction : 0.0;","vColor = (1.0 - fraction) * headColor + fraction * tailColor;","vec4 realPosition = vec4((1.0 - fractionSize) * position.xyz + fractionSize * nodeCenter.xyz, 1.0); "].join("\n")},get BaseVertexShader(){return[this.BaseVertexVars,"void main() { ",this.VertexShaderCore,"gl_Position = projectionMatrix * viewMatrix * realPosition;","}"].join("\n")},get BaseFragmentShader(){return[this.BaseFragmentVars,"void main() { ","gl_FragColor = vColor;","}"].join("\n")},get TexturedVertexShader(){return[this.TexturedVertexVars,"void main() { ",this.VertexShaderCore,"float s = 0.0;","float t = 0.0;","if (dragTexture == 1.0) { "," s = fraction * textureTileFactor.s; "," t = (nodeVertexID / verticesPerNode) * textureTileFactor.t;","} else { "," s = nodeID / maxTrailLength * textureTileFactor.s;"," t = (nodeVertexID / verticesPerNode) * textureTileFactor.t;","}","vUV = vec2(s, t); ","gl_Position = projectionMatrix * viewMatrix * realPosition;","}"].join("\n")},get TexturedFragmentShader(){return[this.TexturedFragmentVars,"void main() { ","vec4 textureColor = texture2D(trailTexture, vUV);","gl_FragColor = vColor * textureColor;","}"].join("\n")}};/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"vfx-renderers.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAQ,QAAQ,EAA4B,MAAM,gBAAgB,CAAA;AACvG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAA2B,QAAQ,EAAc,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,c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B;IAExC,OAAO,CAAC,YAAY;IAWpB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAAC,IAAI,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAC;IAsElF,gBAAgB,CAAC,QAAQ,KAAA;IA0CzB,cAAc,CAAC,QAAQ,KAAA;CAiBxB;AAgDD;;;;;GAKG;AACH,iBAAS,2BAA2B,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAqExF;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import{CustomRenderer as e,MeshRenderer as t,PUID as r}from"@hology/nebula";import*as a from"three";import{InstancedBufferAttribute as o,Object3D as i}from"three";import{NodeShaderMaterial as n}from"three-shader-graph";import{StretchedSprite as s}from"./stretched-sprite.js";import{Trail as l}from"./trail-renderer.js";import{SpriteNodeShaderMaterial as c}from"../../shader/sprite-shader";var d;!function(e){e[e.mesh=0]="mesh",e[e.instanced=1]="instanced",e[e.sprite=2]="sprite",e[e.stretchedBillboard=3]="stretchedBillboard",e[e.trail=4]="trail"}(d||(d={}));export class MultiRenderer extends e{constructor(e,t,r,a){super(),this.worldContainer=e,this.localContainer=t,this.three=r,this.view=a,this.localRenderers=[],this.worldRenderers=[]}onSystemUpdate(){for(const e of this.worldRenderers)e?.onSystemUpdate();for(const e of this.localRenderers)e?.onSystemUpdate()}onParticleCreated(e){e.target=null,this.getRenderer(e)?.onParticleCreated(e)}onParticleUpdate(e){this.getRenderer(e)?.onParticleUpdate(e)}onParticleDead(e){this.getRenderer(e)?.onParticleDead(e),e._renderer=null}getRenderer(e){if(e._renderer)return e._renderer;const t=(null!=e?.parent?e?.parent._space:null)??"world",r="world"===t?this.worldContainer:this.localContainer,o="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==o[d.trail]&&(o[d.trail]=new TrailRenderer(r,this.three)),e._renderer=o[d.trail]):e.body instanceof s?(null==o[d.stretchedBillboard]&&(o[d.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=o[d.stretchedBillboard]):e.body instanceof a.Sprite||e.body instanceof a.Mesh&&"sprite"===e.body.name?(null==o[d.sprite]&&(o[d.sprite]=new CombinedRenderer(r,this.three)),e._renderer=o[d.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof n?(null==o[d.instanced]&&(o[d.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=o[d.instanced]):e.body instanceof a.Object3D?(null==o[d.mesh]&&(o[d.mesh]=new CombinedRenderer(r,this.three)),e._renderer=o[d.mesh]):void 0}dispose(){this.localRenderers.forEach((e=>{e instanceof InstancedRenderer&&e.dispose()})),this.worldRenderers.forEach((e=>{e instanceof InstancedRenderer&&e.dispose()}))}}export class TrailRenderer extends t{constructor(){super(...arguments),this.trails=[]}dispose(){}onSystemUpdate(){for(const e of this.trails)e.update()}onParticleCreated(e){const t=e.body,r=new l(this.container,!1),o=new i,n=l.createBaseMaterial(t.texture,t.scrollSpeed,t.opacityChannel,t.billboard??!1);n.uniforms.taper.value=t.taper??!1;const s=new a.Color(t.color??0).multiplyScalar(t.intensity),c=new a.Color(t.colorEnd??0).multiplyScalar(t.intensityEnd??t.intensity??1);n.uniforms.headColor&&n.uniforms.tailColor&&(n.uniforms.headColor.value=new a.Vector4(s.r,s.g,s.b,t.opacityStart??1),n.uniforms.tailColor.value=new a.Vector4(c.r,c.g,c.b,t.opacityEnd??1)),t.bloom&&(n.userData.hasBloom=!0),r.initialize(n,Math.round(t.length??10),!1,t.width,null,o,t.billboard??!1);const d=e.rotation;o.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=o}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);const r=e.body;let a=x;e.old&&e.old.position?a.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize():a.copy(e.velocity).normalize();const o=w;o.setFromUnitVectors(a,y),t.rotation.set(0,0,0),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.applyQuaternion(o);const i=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=i){const t=this.trails[i];if(e.useAlpha&&t.material.uniforms.headColor&&t.material.uniforms.tailColor){t.material.uniforms.headColor.value.setW(r.opacityStart*e.alpha);t.material.uniforms.tailColor.value.setW(r.opacityEnd*e.alpha)}}}onParticleDead(e){const t=e.target,r=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=r){const e=this.trails[r];e.removeFromParent(),e.mesh.removeFromParent(),t.removeFromParent(),this.trails.splice(r,1)}}}export class CombinedRenderer extends t{dispose(){}scale(e){const t=e.transform.initialScale;e.target instanceof a.Sprite?null!=t?e.target.scale.set(t.x*e.scale*e.radius,t.y*e.scale*e.radius,1):e.target.scale.set(e.scale*e.radius,e.scale*e.radius,1):null!=t?e.target.scale.set(t.x*e.scale,t.y*e.scale,t.z*e.scale):super.scale(e)}rotate(e){e.target.material.rotation=e.rotation.z}onParticleCreated(e){e.target||(e.target=this._targetPool.get(e.body),(e.useAlpha||e.useColor)&&(e.target instanceof a.Mesh||e.target instanceof a.Sprite&&e.target.material instanceof a.Material)&&(e.target.material.__puid=r.id(e.body.material),e.target.material=this._materialPool.get(e.target.material))),e.target&&e.target instanceof i&&(e.target.position.set(e.position.x,e.position.y,e.position.z),this.container.add(e.target))}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:o,rotation:n}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof c?e.target.material.rotation=e.rotation.z:t.rotation.set(n.x,n.y,n.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof i){const r=m.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(u);a.applyAxisAngle(p,Math.PI/-2),h.setFromUnitVectors(a,r),t.quaternion.copy(h)}t.material instanceof a.Material&&(r&&(t.material instanceof c&&null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha,t.material.uniformsNeedUpdate=!0),t.material.opacity=e.alpha,t.material.transparent=!0),o&&(null!=t.material.color?t.material.color.copy(e.color):t.material instanceof a.ShaderMaterial&&null!=t.material.uniforms.color&&(t.material.uniforms.color.value=e.color,t.material.uniformsNeedUpdate=!0)))}}onParticleDead(e){e.target&&(e.target.material&&(e.useAlpha||e.useColor)&&this._materialPool.expire(e.target.material),this._targetPool.expire(e.target),this.container.remove(e.target),e.target=null)}}export class StretchedSpriteInstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach((e=>e.mesh.geometry.dispose()))}onSystemUpdate(){for(const e of this.meshes){const t=e.mesh.geometry.getAttribute("offset"),r=e.mesh.geometry.getAttribute("size"),o=e.mesh.geometry.getAttribute("velocity"),i=e.mesh.geometry.getAttribute("rotation"),n=e.mesh.geometry.getAttribute("color");let s=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=C.copy(l.color).getRGB(M);n.setXYZW(s,e.r,e.g,e.b,1),n.needsUpdate=!0}l.useAlpha&&(n.setW(s,l.alpha),n.needsUpdate=!0),"number"==typeof l.rotation?i.setX(s,l.rotation):i.setX(s,l.rotation.x);const e=l.position;if(t.setXYZ(s,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(s,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;o.setXYZW(s,m.x*c,m.y*c,m.z*c,d),s++}s>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*s),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*s),r.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,4*s),n.needsUpdate=!0,o.clearUpdateRanges(),o.addUpdateRange(0,4*s),o.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,s),i.needsUpdate=!0)}}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof s&&null==e.target){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(null==r){const i=this.calcMaxCount(e),n=new a.InstancedBufferGeometry;n.setIndex(t.geometry.getIndex()),n.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&n.setAttribute("normal",t.geometry.getAttribute("normal")),n.setAttribute("uv",t.geometry.getAttribute("uv"));const s=new o(new Float32Array(3*i),3);s.setUsage(a.DynamicDrawUsage),n.setAttribute("offset",s);const l=new o(new Float32Array(4*i),4);if(l.setUsage(a.DynamicDrawUsage),n.setAttribute("color",l),t.material instanceof c){const e=new a.Color(t.material.color);for(let t=0;t<l.count;t++)l.setXYZW(t,e.r,e.g,e.b,1)}const d=new o(new Float32Array(3*i),3);d.setUsage(a.DynamicDrawUsage),n.setAttribute("size",d);const m=new o(new Float32Array(4*i),4);m.setUsage(a.DynamicDrawUsage),n.setAttribute("velocity",m);const u=new o(new Float32Array(4*i),1);u.setUsage(a.DynamicDrawUsage),n.setAttribute("rotation",u),r={mesh:new a.Mesh(n,t.material),indices:new Float32Array(i),particles:[]},this.meshes.push(r),this.container.add(r.mesh)}let i=r.indices.findIndex((e=>0===e));i<0&&(i=function(e){let t=e[0],r=0;for(let a=1;a<e.length;a++)e[a]<t&&(t=e[a],r=a);return r}(r.indices)),r.indices[i]=performance.now(),e.target=i,r.particles[i]=e}}onParticleUpdate(e){}onParticleDead(e){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(r){const t=r.mesh.geometry.getAttribute("size");t.setXYZ(e.target,0,0,0),t.needsUpdate=!0,r.particles[e.target]=null,r.indices[e.target]=0}e.target=null}}const m=new a.Vector3,u=new a.Vector3,h=new a.Quaternion,p=new a.Vector3(1,0,0);export class InstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach((e=>e.mesh.dispose()))}onSystemUpdate(){for(const e of this.meshes);}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof a.Sprite)return;const t=e.body;let r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));if(null==r){const o=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,o),indices:new Array(o).fill(null),particles:[]},r.mesh.setColorAt(0,C.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="";const i=new Float32Array(3*o);b.makeScale(0,0,0);for(let e=0;e<o;e++)i[3*e+0]=1,i[3*e+1]=1,r.mesh.setMatrixAt(e,b);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3)),this.meshes.push(r),this.container.add(r.mesh)}let o=r.indices.findIndex((e=>null==e));if(o<0&&(o=r.indices.indexOf(Math.min(...r.indices))),r.indices[o]=performance.now(),e.target=o,r.particles[o]=e,"number"==typeof e.target){e.transform.initialScale;const t=e.body;let r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));f(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent=!0)}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:o}=e;if(null==t)return;const i=e.body,n=this.meshes.find((e=>e.mesh.geometry.uuid===i.geometry.uuid&&e.mesh.material.uuid===i.material.uuid));if(null==n)return;n.mesh.frustumCulled=!1,f(e,n.mesh),a&&(n.mesh.setColorAt(e.target,C.copy(e.color)),n.mesh.instanceColor.needsUpdate=!0);const s=n.mesh.geometry.getAttribute("particleData");r&&s.setX(e.target,e.alpha),s.setY(e.target,e.energy),s.needsUpdate=!0}onParticleDead(e){if(null!=e.target){const t=e.body,r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));if(null==r)return;r.indices[e.target]=null,e.scale=0,f(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const g=new i;function f(e,t){if(x.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=m.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize();t.getMatrixAt(e.target,g.matrix);const a=g.getWorldDirection(A);a.applyAxisAngle(p,Math.PI/-2),w.setFromUnitVectors(a,r)}else U.set(e.rotation.x,e.rotation.y,e.rotation.z),w.setFromEuler(U);const r=e.transform.initialScale;null!=r?A.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):A.set(e.scale,e.scale,e.scale),b.compose(x,w,A),t.setMatrixAt(e.target,b),t.instanceMatrix.needsUpdate=!0}const y=new a.Vector3(0,0,-1),b=new a.Matrix4,w=new a.Quaternion,x=new a.Vector3,A=new a.Vector3,U=new a.Euler,C=new a.Color(0),M={r:0,g:0,b:0};function P(e,t){const r=e.mesh,o=r.count,i=[],n=r.geometry.getAttribute("particleData"),s=new a.Vector3;for(let l=0;l<o;l++){const o=new a.Matrix4,c=new a.Color;r.getMatrixAt(l,o),r.getColorAt(l,c);const d=n.getX(l);s.setFromMatrixPosition(o);const m=s.distanceTo(t.position);i.push({index:l,distance:m,matrix:o,particle:e.particles[l],color:c,pdx:d})}i.sort(((e,t)=>t.distance-e.distance));for(let e=0;e<o;e++){const t=i[e].matrix;null==i[e].particle&&t.makeScale(0,0,0),r.setMatrixAt(e,t),r.setColorAt(e,i[e].color),n.setX(e,i[e].pdx)}r.instanceMatrix.needsUpdate=!0}export{P as sortInstancedMeshByDistance};/*
1
+ import{CustomRenderer as e,MeshRenderer as t,PUID as r}from"@hology/nebula";import*as a from"three";import{InstancedBufferAttribute as o,Object3D as i}from"three";import{NodeShaderMaterial as n}from"three-shader-graph";import{StretchedSprite as s}from"./stretched-sprite.js";import{Trail as l}from"./trail-renderer.js";import{SpriteNodeShaderMaterial as c}from"../../shader/sprite-shader";var d;!function(e){e[e.mesh=0]="mesh",e[e.instanced=1]="instanced",e[e.sprite=2]="sprite",e[e.stretchedBillboard=3]="stretchedBillboard",e[e.trail=4]="trail"}(d||(d={}));export class MultiRenderer extends e{constructor(e,t,r,a){super(),this.worldContainer=e,this.localContainer=t,this.three=r,this.view=a,this.localRenderers=[],this.worldRenderers=[]}onSystemUpdate(){for(const e of this.worldRenderers)e?.onSystemUpdate();for(const e of this.localRenderers)e?.onSystemUpdate()}onParticleCreated(e){e.target=null,this.getRenderer(e)?.onParticleCreated(e)}onParticleUpdate(e){this.getRenderer(e)?.onParticleUpdate(e)}onParticleDead(e){this.getRenderer(e)?.onParticleDead(e),e._renderer=null}getRenderer(e){if(e._renderer)return e._renderer;const t=(null!=e?.parent?e?.parent._space:null)??"world",r="world"===t?this.worldContainer:this.localContainer,o="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==o[d.trail]&&(o[d.trail]=new TrailRenderer(r,this.three)),e._renderer=o[d.trail]):e.body instanceof s?(null==o[d.stretchedBillboard]&&(o[d.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=o[d.stretchedBillboard]):e.body instanceof a.Sprite||e.body instanceof a.Mesh&&"sprite"===e.body.name?(null==o[d.sprite]&&(o[d.sprite]=new CombinedRenderer(r,this.three)),e._renderer=o[d.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof n?(null==o[d.instanced]&&(o[d.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=o[d.instanced]):e.body instanceof a.Object3D?(null==o[d.mesh]&&(o[d.mesh]=new CombinedRenderer(r,this.three)),e._renderer=o[d.mesh]):void 0}dispose(){this.localRenderers.forEach((e=>{e instanceof InstancedRenderer&&e.dispose()})),this.worldRenderers.forEach((e=>{e instanceof InstancedRenderer&&e.dispose()}))}}export class TrailRenderer extends t{constructor(){super(...arguments),this.trails=[]}dispose(){}onSystemUpdate(){for(const e of this.trails)e.update()}onParticleCreated(e){const t=e.body,r=new l(this.container,!1),o=new i;this.container.add(o),o.updateMatrixWorld(),o.updateWorldMatrix(!0,!0);const n=l.createBaseMaterial(t.texture,t.scrollSpeed,t.opacityChannel,t.billboard??!1);n.uniforms.taper.value=t.taper??!1;const s=new a.Color(t.color??0).multiplyScalar(t.intensity),c=new a.Color(t.colorEnd??0).multiplyScalar(t.intensityEnd??t.intensity??1);n.uniforms.headColor&&n.uniforms.tailColor&&(n.uniforms.headColor.value=new a.Vector4(s.r,s.g,s.b,t.opacityStart??1),n.uniforms.tailColor.value=new a.Vector4(c.r,c.g,c.b,t.opacityEnd??1)),t.bloom&&(n.userData.hasBloom=!0),r.initialize(n,Math.round(t.length??10),!1,t.width,null,o,t.billboard??!1);const d=e.rotation;o.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=o}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);const r=e.body;let a=x;e.old&&e.old.position?a.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize():a.copy(e.velocity).normalize();const o=w;o.setFromUnitVectors(a,y),t.rotation.set(0,0,0),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.applyQuaternion(o);const i=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=i){const t=this.trails[i];if(e.useAlpha&&t.material.uniforms.headColor&&t.material.uniforms.tailColor){t.material.uniforms.headColor.value.setW(r.opacityStart*e.alpha);t.material.uniforms.tailColor.value.setW(r.opacityEnd*e.alpha)}}}onParticleDead(e){const t=e.target,r=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=r){const e=this.trails[r];e.removeFromParent(),e.mesh.removeFromParent(),e.targetObject.removeFromParent(),t.removeFromParent(),this.trails.splice(r,1)}}}export class CombinedRenderer extends t{dispose(){}scale(e){const t=e.transform.initialScale;e.target instanceof a.Sprite?null!=t?e.target.scale.set(t.x*e.scale*e.radius,t.y*e.scale*e.radius,1):e.target.scale.set(e.scale*e.radius,e.scale*e.radius,1):null!=t?e.target.scale.set(t.x*e.scale,t.y*e.scale,t.z*e.scale):super.scale(e)}rotate(e){e.target.material.rotation=e.rotation.z}onParticleCreated(e){e.target||(e.target=this._targetPool.get(e.body),(e.useAlpha||e.useColor)&&(e.target instanceof a.Mesh||e.target instanceof a.Sprite&&e.target.material instanceof a.Material)&&(e.target.material.__puid=r.id(e.body.material),e.target.material=this._materialPool.get(e.target.material))),e.target&&e.target instanceof i&&(e.target.position.set(e.position.x,e.position.y,e.position.z),this.container.add(e.target))}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:o,rotation:n}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof c?e.target.material.rotation=e.rotation.z:t.rotation.set(n.x,n.y,n.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof i){const r=m.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(u);a.applyAxisAngle(p,Math.PI/-2),h.setFromUnitVectors(a,r),t.quaternion.copy(h)}t.material instanceof a.Material&&(r&&(t.material instanceof c&&null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha,t.material.uniformsNeedUpdate=!0),t.material.opacity=e.alpha,t.material.transparent=!0),o&&(null!=t.material.color?t.material.color.copy(e.color):t.material instanceof a.ShaderMaterial&&null!=t.material.uniforms.color&&(t.material.uniforms.color.value=e.color,t.material.uniformsNeedUpdate=!0)))}}onParticleDead(e){e.target&&(e.target.material&&(e.useAlpha||e.useColor)&&this._materialPool.expire(e.target.material),this._targetPool.expire(e.target),this.container.remove(e.target),e.target=null)}}export class StretchedSpriteInstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach((e=>e.mesh.geometry.dispose()))}onSystemUpdate(){for(const e of this.meshes){const t=e.mesh.geometry.getAttribute("offset"),r=e.mesh.geometry.getAttribute("size"),o=e.mesh.geometry.getAttribute("velocity"),i=e.mesh.geometry.getAttribute("rotation"),n=e.mesh.geometry.getAttribute("color");let s=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=C.copy(l.color).getRGB(M);n.setXYZW(s,e.r,e.g,e.b,1),n.needsUpdate=!0}l.useAlpha&&(n.setW(s,l.alpha),n.needsUpdate=!0),"number"==typeof l.rotation?i.setX(s,l.rotation):i.setX(s,l.rotation.x);const e=l.position;if(t.setXYZ(s,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(s,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;o.setXYZW(s,m.x*c,m.y*c,m.z*c,d),s++}s>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*s),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*s),r.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,4*s),n.needsUpdate=!0,o.clearUpdateRanges(),o.addUpdateRange(0,4*s),o.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,s),i.needsUpdate=!0)}}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof s&&null==e.target){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(null==r){const i=this.calcMaxCount(e),n=new a.InstancedBufferGeometry;n.setIndex(t.geometry.getIndex()),n.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&n.setAttribute("normal",t.geometry.getAttribute("normal")),n.setAttribute("uv",t.geometry.getAttribute("uv"));const s=new o(new Float32Array(3*i),3);s.setUsage(a.DynamicDrawUsage),n.setAttribute("offset",s);const l=new o(new Float32Array(4*i),4);if(l.setUsage(a.DynamicDrawUsage),n.setAttribute("color",l),t.material instanceof c){const e=new a.Color(t.material.color);for(let t=0;t<l.count;t++)l.setXYZW(t,e.r,e.g,e.b,1)}const d=new o(new Float32Array(3*i),3);d.setUsage(a.DynamicDrawUsage),n.setAttribute("size",d);const m=new o(new Float32Array(4*i),4);m.setUsage(a.DynamicDrawUsage),n.setAttribute("velocity",m);const u=new o(new Float32Array(4*i),1);u.setUsage(a.DynamicDrawUsage),n.setAttribute("rotation",u),r={mesh:new a.Mesh(n,t.material),indices:new Float32Array(i),particles:[]},this.meshes.push(r),this.container.add(r.mesh)}let i=r.indices.findIndex((e=>0===e));i<0&&(i=function(e){let t=e[0],r=0;for(let a=1;a<e.length;a++)e[a]<t&&(t=e[a],r=a);return r}(r.indices)),r.indices[i]=performance.now(),e.target=i,r.particles[i]=e}}onParticleUpdate(e){}onParticleDead(e){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(r){const t=r.mesh.geometry.getAttribute("size");t.setXYZ(e.target,0,0,0),t.needsUpdate=!0,r.particles[e.target]=null,r.indices[e.target]=0}e.target=null}}const m=new a.Vector3,u=new a.Vector3,h=new a.Quaternion,p=new a.Vector3(1,0,0);export class InstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach((e=>e.mesh.dispose()))}onSystemUpdate(){for(const e of this.meshes);}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof a.Sprite)return;const t=e.body;let r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));if(null==r){const o=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,o),indices:new Array(o).fill(null),particles:[]},r.mesh.setColorAt(0,C.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="";const i=new Float32Array(3*o);b.makeScale(0,0,0);for(let e=0;e<o;e++)i[3*e+0]=1,i[3*e+1]=1,r.mesh.setMatrixAt(e,b);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3)),this.meshes.push(r),this.container.add(r.mesh)}let o=r.indices.findIndex((e=>null==e));if(o<0&&(o=r.indices.indexOf(Math.min(...r.indices))),r.indices[o]=performance.now(),e.target=o,r.particles[o]=e,"number"==typeof e.target){e.transform.initialScale;const t=e.body;let r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));f(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent=!0)}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:o}=e;if(null==t)return;const i=e.body,n=this.meshes.find((e=>e.mesh.geometry.uuid===i.geometry.uuid&&e.mesh.material.uuid===i.material.uuid));if(null==n)return;n.mesh.frustumCulled=!1,f(e,n.mesh),a&&(n.mesh.setColorAt(e.target,C.copy(e.color)),n.mesh.instanceColor.needsUpdate=!0);const s=n.mesh.geometry.getAttribute("particleData");r&&s.setX(e.target,e.alpha),s.setY(e.target,e.energy),s.needsUpdate=!0}onParticleDead(e){if(null!=e.target){const t=e.body,r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));if(null==r)return;r.indices[e.target]=null,e.scale=0,f(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const g=new i;function f(e,t){if(x.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=m.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize();t.getMatrixAt(e.target,g.matrix);const a=g.getWorldDirection(A);a.applyAxisAngle(p,Math.PI/-2),w.setFromUnitVectors(a,r)}else U.set(e.rotation.x,e.rotation.y,e.rotation.z),w.setFromEuler(U);const r=e.transform.initialScale;null!=r?A.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):A.set(e.scale,e.scale,e.scale),b.compose(x,w,A),t.setMatrixAt(e.target,b),t.instanceMatrix.needsUpdate=!0}const y=new a.Vector3(0,0,-1),b=new a.Matrix4,w=new a.Quaternion,x=new a.Vector3,A=new a.Vector3,U=new a.Euler,C=new a.Color(0),M={r:0,g:0,b:0};function P(e,t){const r=e.mesh,o=r.count,i=[],n=r.geometry.getAttribute("particleData"),s=new a.Vector3;for(let l=0;l<o;l++){const o=new a.Matrix4,c=new a.Color;r.getMatrixAt(l,o),r.getColorAt(l,c);const d=n.getX(l);s.setFromMatrixPosition(o);const m=s.distanceTo(t.position);i.push({index:l,distance:m,matrix:o,particle:e.particles[l],color:c,pdx:d})}i.sort(((e,t)=>t.distance-e.distance));for(let e=0;e<o;e++){const t=i[e].matrix;null==i[e].particle&&t.makeScale(0,0,0),r.setMatrixAt(e,t),r.setColorAt(e,i[e].color),n.setX(e,i[e].pdx)}r.instanceMatrix.needsUpdate=!0}export{P as sortInstancedMeshByDistance};/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -32,7 +32,7 @@ export declare abstract class BaseActor {
32
32
  onLateUpdate(deltaTime: number): void;
33
33
  constructor();
34
34
  attach<T extends ActorComponent>(type: Constructable<T>, props?: ComponentAttachProps<T>): T;
35
- getComponent<T extends ActorComponent>(type: Constructable<T>): T;
35
+ getComponent<T extends ActorComponent>(type: Constructable<T>): T | undefined;
36
36
  }
37
37
  export declare function _setupActorUpdateEventHandlers(): void;
38
38
  //# sourceMappingURL=actor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../../src/gameplay/actors/actor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAa,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAS,MAAM,OAAO,CAAA;AACvC,OAAkB,EAAE,aAAa,EAAW,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAU,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAO7E,wBAAgB,KAAK,KAEF,sBAAiB,UAMnC;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;GAEG;AACH,8BAAsB,SAAS;IAC7B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAY;IAIzB,eAAe,UAAQ;IAE9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAc;IACvC,QAAQ,CAAC,QAAQ,gBAAsB;IACvC,IACI,QAAQ,4BAEX;IACD,IACI,UAAU,+BAEb;IACD,IACI,QAAQ,0BAEX;IACD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI;IAC5B,WAAW,IAAI,IAAI;IACnB,SAAS,IAAI,IAAI;IACjB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IACjC;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;;IAYrC,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC;IAiC5F,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;CAOlE;AAID,wBAAgB,8BAA8B,SAO7C"}
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../../src/gameplay/actors/actor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAa,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAS,MAAM,OAAO,CAAA;AACvC,OAAkB,EAAE,aAAa,EAAW,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAU,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAO7E,wBAAgB,KAAK,KAEF,sBAAiB,UAMnC;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;GAEG;AACH,8BAAsB,SAAS;IAC7B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAY;IAIzB,eAAe,UAAQ;IAE9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAc;IACvC,QAAQ,CAAC,QAAQ,gBAAsB;IACvC,IACI,QAAQ,4BAEX;IACD,IACI,UAAU,+BAEb;IACD,IACI,QAAQ,0BAEX;IACD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI;IAC5B,WAAW,IAAI,IAAI;IACnB,SAAS,IAAI,IAAI;IACjB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IACjC;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;;IAYrC,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC;IAiC5F,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,GAAC,SAAS;CAQ5E;AAID,wBAAgB,8BAA8B,SAO7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"navmesh-actor.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/navmesh-actor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,E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AAM,CAAO;IAIxB,OAAO,CAAC,QAAQ,CAAa;IAIhB,aAAa,EAAE,MAAM,CAAK;IACV,kBAAkB,EAAE,MAAM,CAAK;IAI5B,QAAQ,EAAE,MAAM,CAAM;IAG/C,OAAO,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,gBAAgB,CAAgB;IAGlC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B7B,SAAS,IAAI,IAAI;IAIjB,OAAO,CAAC,IAAI;CAyPb;AAED,eAAe,YAAY,CAAA"}
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as o,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,debounceTime as f,filter as w,firstValueFrom as b,Subject as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as B}from"three/examples/jsm/Addons.js";import{Actor as M,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as C,World as j,attach as k,inject as F}from"../../";import{DynamicTiledNavMesh as I}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as P,toSharedFloat32Array as V,toSharedUint32Array as G}from"../../../utils/buffer";import{sleepDelay as N}from"../../../utils/async";import{TriggerVolumeMesh as D}from"./components/volume-editor-component";var E;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(E||(E={}));let H=E.none,R=new m(!1);export async function safeRecastInit(){return H===E.none?(H=E.starting,p().then((()=>{R.next(!0),H=E.started}))):b(R.pipe(w((e=>e))))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const T=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=F(A),this.view=F(C),this.world=F(j),this.editorVisualisation=k(D),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout((()=>{this.init()}),10),this.recreateInterval=setInterval((()=>{if("_hology_transform_group"===this.object.parent?.name)return;X.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new g,this.init())}),1e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale),console.log(this.bounds);const e=Math.min(Math.ceil(Math.min(this.bounds.max.x-this.bounds.min.x,this.bounds.max.z-this.bounds.min.z)),400),t=Math.max(this.cellSize,.01),n={tileSize:e,walkableClimb:this.walkableClimb/t,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:t,ch:t,maxSimplificationError:1.3,maxEdgeLen:200},o=new I({navMeshBounds:this.bounds,recastConfig:n,maxTiles:1024,workers:T,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=o.navMesh;const s=this.tileSize*n.cs*2,i=performance.now(),r=new Map,a=new u;a.userData.isDebugDrawer=!0;o.navMesh;const c=this.bounds,l=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(s),(new x.Vector3).copy(e).addScalar(s)),n=[],o=this.physics.world.bodies;if(null==o)return[];const i=new x.Box3;for(const e of o.getAll())for(let o=0,s=e.numColliders();o<s;o++){const s=e.collider(o);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+o,c=r.get(a)?.mesh,l=c??O(s);if(W(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0,o=i.intersectsBox(this.bounds);r.set(a,{pos:s.translation(),mesh:l}),e&&o&&n.push(l)}}return n},h=new x.Box3,p=new Map,m=new Map;let w=!0,b=performance.now(),g=!1;const v=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await N(t)})(),()=>{n=!0}}((async()=>{if(g)return;const e=new x.Box3,t=l();for(const n of t){const t=p.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),p.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=o.getTilesForBounds(e);if(0!=n.length){const s=[];for(const n of t)h.setFromObject(n),h.intersectsBox(e)&&s.push(n);console.log("intersecting meshes",s.length);let[i,r]=d(s);r=function(e,t,n){const o=new x.Vector3,s=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let s=0;s<3;s++){const a=3*t[i+s];if(o.fromArray(e,a),!n.containsPoint(o)){r=!1;break}}r&&s.push(t[i],t[i+1],t[i+2])}return new Uint32Array(s)}(i,r,c),P&&(i=V(i),r=G(r));const a=w;w=!1,await Promise.all(n.map((e=>(b=performance.now(),o.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];m.set(t,(m.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>v())),o.onNavMeshUpdate.pipe(y(this.disposed),f(200)).subscribe((()=>{a.clear(),a.drawNavMesh(o.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(a)),this.disposed.subscribe((()=>{o?.destroy(),a.removeFromParent(),a.dispose()}));const B=performance.now()-i;B>1e3&&console.warn(`NavMesh update took ${B} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([M()],q);export default q;function _(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const o=t,s=o.heights,i=o.nrows,r=o.ncols,a=o.scale.x,c=o.scale.z,h=o.scale.y,p=i+1,u=new x.PlaneGeometry(c,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=s[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new B).setFromPoints(t),o=[];n.faces.forEach((e=>{const t=e.edge.head().point,n=e.edge.next.head().point,s=e.edge.next.next.head().point;o.push(t.x,t.y,t.z),o.push(n.x,n.y,n.z),o.push(s.x,s.y,s.z)}));const s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(o,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?o.setIndex(new x.Uint16BufferAttribute(n,1)):o=v.mergeVertices(o),o.computeVertexNormals(),o}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function O(e){const t=_(e);if(null==t)return null;const n=L,o=new x.Mesh(t,n);return o.geometry.computeBoundingBox(),o.geometry.scale(1.01,1.01,1.01),o}function W(e,t){const n=e.translation(),o=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(o.x,o.y,o.z,o.w)}const X=new x.Box3,L=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as o,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as B}from"three/examples/jsm/Addons.js";import{Actor as M,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as C,World as j,attach as k,inject as F}from"../../";import{sleepDelay as I}from"../../../utils/async";import{hasSharedArrayBufferSupport as P,toSharedFloat32Array as V,toSharedUint32Array as G}from"../../../utils/buffer";import{DynamicTiledNavMesh as N}from"../../ai/dynamic-tiled-navmesh";import{TriggerVolumeMesh as D}from"./components/volume-editor-component";var E;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(E||(E={}));let H=E.none,R=new m(!1);export async function safeRecastInit(){return H===E.none?(H=E.starting,p().then((()=>{R.next(!0),H=E.started}))):g(R.pipe(b((e=>e))))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const T=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=F(A),this.view=F(C),this.world=F(j),this.editorVisualisation=k(D),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout((()=>{this.init()}),10),this.recreateInterval=setInterval((()=>{if("_hology_transform_group"===this.object.parent?.name)return;X.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())}),1e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale),console.log(this.bounds);const e=Math.min(Math.ceil(Math.min(this.bounds.max.x-this.bounds.min.x,this.bounds.max.z-this.bounds.min.z)),400),t=Math.max(this.cellSize,.01),n={tileSize:e,walkableClimb:this.walkableClimb/t,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:t,ch:t,maxSimplificationError:1.3,maxEdgeLen:200},o=new N({navMeshBounds:this.bounds,recastConfig:n,maxTiles:1024,workers:T,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=o.navMesh;const s=this.tileSize*n.cs*2,i=performance.now(),r=new Map,a=new u;a.userData.isDebugDrawer=!0;o.navMesh;const c=this.bounds,l=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(s),(new x.Vector3).copy(e).addScalar(s)),n=[],o=this.physics.world.bodies;if(null==o)return[];const i=new x.Box3;for(const e of o.getAll())for(let o=0,s=e.numColliders();o<s;o++){const s=e.collider(o);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+o,c=r.get(a)?.mesh,l=c??O(s);if(W(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0,o=i.intersectsBox(this.bounds);r.set(a,{pos:s.translation(),mesh:l}),e&&o&&n.push(l)}}return n},h=new x.Box3,p=new Map,m=new Map;let f=!0,b=performance.now(),g=!1;const v=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await I(t)})(),()=>{n=!0}}((async()=>{if(g)return;const e=new x.Box3,t=l();for(const n of t){const t=p.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),p.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=o.getTilesForBounds(e);if(0!=n.length){const s=[];for(const n of t)h.setFromObject(n),h.intersectsBox(e)&&s.push(n);console.log("intersecting meshes",s.length);let[i,r]=d(s);r=function(e,t,n){const o=new x.Vector3,s=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let s=0;s<3;s++){const a=3*t[i+s];if(o.fromArray(e,a),!n.containsPoint(o)){r=!1;break}}r&&s.push(t[i],t[i+1],t[i+2])}return new Uint32Array(s)}(i,r,c),P&&(i=V(i),r=G(r));const a=f;f=!1,await Promise.all(n.map((e=>(b=performance.now(),o.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];m.set(t,(m.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>v())),o.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe((()=>{a.clear(),a.drawNavMesh(o.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(a)),this.disposed.subscribe((()=>{o?.destroy(),a.removeFromParent(),a.dispose()}));const B=performance.now()-i;B>1e3&&console.warn(`NavMesh update took ${B} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([M()],q);export default q;function _(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const o=t,s=o.heights,i=o.nrows,r=o.ncols,a=o.scale.x,c=o.scale.z,h=o.scale.y,p=i+1,u=new x.PlaneGeometry(c,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=s[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new B).setFromPoints(t),o=[];n.faces.forEach((e=>{const t=e.edge.head().point,n=e.edge.next.head().point,s=e.edge.next.next.head().point;o.push(t.x,t.y,t.z),o.push(n.x,n.y,n.z),o.push(s.x,s.y,s.z)}));const s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(o,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?o.setIndex(new x.Uint16BufferAttribute(n,1)):o=v.mergeVertices(o),o.computeVertexNormals(),o}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function O(e){const t=_(e);if(null==t)return null;const n=L,o=new x.Mesh(t,n);return o.geometry.computeBoundingBox(),o.geometry.scale(1.01,1.01,1.01),o}function W(e,t){const n=e.translation(),o=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(o.x,o.y,o.z,o.w)}const X=new x.Box3,L=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -27,7 +27,6 @@ export declare class PostProcessSettings extends ActorComponent {
27
27
  temperatureTint?: number;
28
28
  lut?: Texture;
29
29
  lutIntensity?: number;
30
- resetToDefault(): void;
31
30
  }
32
31
  export declare class PostProcessVolume extends BaseActor {
33
32
  settings: PostProcessSettings;
@@ -1 +1 @@
1
- {"version":3,"file":"post-process-volume-actor.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/post-process-volume-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAgC,MAAM,OAAO,CAAC;AACvF,OAAO,EAAgJ,OAAO,EAAC,MAAM,OAAO,CAAC;AAK7K,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,MAAM,yBAAyB,GACjC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAA;CAAE,CAAC;AAG7C,qBACa,mBAAoB,SAAQ,cAAc;IAErD,cAAc,CAAC,EAAE,MAAM,CAAA;IASvB,eAAe,CAAC,EAAE,MAAM,CAAA;IAGxB,UAAU,CAAC,EAAE,OAAO,CAAA;IAGpB,YAAY,CAAC,EAAE,MAAM,CAAA;IAMrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAG1B,SAAS,CAAC,EAAE,KAAK,CAAC,KAAK,CAAA;IAGvB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B,uFAAuF;IAEvF,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,6CAA6C;IAE7C,aAAa,CAAC,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BACa,mBAAoB,SAAQ,cAAc;IAErD,cAAc,CAAC,EAAE,MAAM,CAAA;IASvB,eAAe,CAAC,EAAE,MAAM,CAAA;IAGxB,UAAU,CAAC,EAAE,OAAO,CAAA;IAGpB,YAAY,CAAC,EAAE,MAAM,CAAA;IAMrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAG1B,SAAS,CAAC,EAAE,KAAK,CAAC,KAAK,CAAA;IAGvB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B,uFAAuF;IAEvF,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,6CAA6C;IAE7C,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,4BAA4B;IAE5B,YAAY,CAAC,EAAE,MAAM,CAAA;IAGrB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,GAAG,CAAC,EAAE,OAAO,CAAA;IAGb,YAAY,CAAC,EAAE,MAAM,CAAA;CAiDtB;AAGD,qBACa,iBAAkB,SAAQ,SAAS;IAG9C,QAAQ,EAAE,mBAAmB,CAAA;IAG7B,OAAO,EAAE,OAAO,CAAQ;IAGxB,QAAQ,EAAE,MAAM,CAAI;IAGpB,WAAW,EAAE,MAAM,CAAI;IAGvB,WAAW,EAAE,MAAM,CAAI;IAQvB,OAAO,CAAC,GAAG,CAAkD;IAE7D,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,UAAU,CAA4B;;IAS9C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAK9B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO;IASlC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO;IASpC,OAAO,CAAC,QAAQ;CAQjB"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import{Actor as o,Attach as i,attach as r,BaseActor as s,Component as n,inject as p,Parameter as d}from"../..";import{Texture as m}from"three";import{tonemapMappings as y}from"../../../rendering/tone-mapping";import{OBB as h}from"three/examples/jsm/math/OBB.js";import{Vector3 as u}from"three";import*as a from"three";import{RenderingView as v}from"../../../rendering.js";import{TriggerVolumeMesh as l}from"./components/volume-editor-component.js";import{ActorComponent as g}from"../../../gameplay";let b=class extends g{resetToDefault(){this.tonemapMapping=void 0,this.tonemapExposure=1,this.envIntensity=1,this.envTexture=void 0,this.vignetteIntensity=0,this.colorTint=new a.Color("white"),this.colorTintIntensity=0,this.depthFocus=void 0,this.depthAperture=void 0,this.depthMaxBlur=void 0,this.temperature=6500,this.temperatureTint=0,this.lut=void 0,this.lutIntensity=0}};t([d({options:y}),e("design:type",Number)],b.prototype,"tonemapMapping",void 0),t([d(),e("design:type",Number)],b.prototype,"tonemapExposure",void 0),t([d(),e("design:type",m)],b.prototype,"envTexture",void 0),t([d(),e("design:type",Number)],b.prototype,"envIntensity",void 0),t([d(),e("design:type",Number)],b.prototype,"vignetteIntensity",void 0),t([d(),e("design:type",a.Color)],b.prototype,"colorTint",void 0),t([d(),e("design:type",Number)],b.prototype,"colorTintIntensity",void 0),t([d(),e("design:type",Number)],b.prototype,"depthFocus",void 0),t([d(),e("design:type",Number)],b.prototype,"depthAperture",void 0),t([d(),e("design:type",Number)],b.prototype,"depthMaxBlur",void 0),t([d({range:[1e3,4e4],precision:.1}),e("design:type",Number)],b.prototype,"temperature",void 0),t([d({range:[-1,1]}),e("design:type",Number)],b.prototype,"temperatureTint",void 0),t([d({label:"LUT"}),e("design:type",m)],b.prototype,"lut",void 0),t([d({label:"LUT Intensity",range:[0,1]}),e("design:type",Number)],b.prototype,"lutIntensity",void 0),b=t([n()],b);export{b as PostProcessSettings};let c=class extends s{constructor(){super(),this.bounded=!1,this.priority=0,this.blendWeight=1,this.blendRadius=0,this.box=new h(void 0,new a.Vector3(.5,.5,.5)),this.view=p(v),this.editorView=r(l),this.disposed.subscribe((()=>{this.view.removePostProcessVolume(this)}))}onInit(){this.view.addPostProcessVolume(this),this.editorView.visible=this.bounded}containsPoint(t){return!this.bounded||(this.resetBox(),this.box.containsPoint(t))}distanceToPoint(t){return this.bounded?(this.resetBox(),this.box.clampPoint(t,N),N.distanceTo(t)):0}resetBox(){const t=this.box;t.center.set(0,0,0),t.halfSize.set(.5,.5,.5),t.rotation.copy(x.rotation),t.applyMatrix4(this.object.matrixWorld)}};t([i(),e("design:type",b)],c.prototype,"settings",void 0),t([d(),e("design:type",Boolean)],c.prototype,"bounded",void 0),t([d({precision:0}),e("design:type",Number)],c.prototype,"priority",void 0),t([d({range:[0,1]}),e("design:type",Number)],c.prototype,"blendWeight",void 0),t([d(),e("design:type",Number)],c.prototype,"blendRadius",void 0),c=t([o(),e("design:paramtypes",[])],c);export{c as PostProcessVolume};const x=new h,N=new u;/*
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;/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"initiate.d.ts","sourceRoot":"","sources":["../../src/gameplay/initiate.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAa3C,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAA;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AAM,EACjC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,kBAAkB,GACzB,aAAa,CAAC,MAAM,CAAC,CAmJvB;AAGD,8BAAsB,YAAY;IAChC,OAAO,IAAI,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;IAC7B,UAAU,IAAI,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;CACjC;AAID,wBAAgB,iBAAiB,SAEhC;AAED;;;;;;GAMG;AAEH,0BAAkB,mBAAmB;IACnC,UAAU,IAAI;IACd,OAAO,IAAI;IACX,OAAO,KAAK;CACb;AAED,qBAAa,aAAa,CAAC,MAAM,GAAG,OAAO;IAYvC,OAAO,CAAC,iBAAiB;IAXpB,MAAM,EAAE,mBAAmB,CAAiC;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,UAAQ;IAClB,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,CAAsB;IAC9D,OAAO,CAAC,SAAS,CAA2B;IAC5C;;OAEG;IACH,SAAgB,KAAK,mBAA8D;gBAGzE,iBAAiB,EAAE,iBAAiB;IAE9C,QAAQ,IAAI,KAAK;IAIjB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;IAI/C;;OAEG;IACH,QAAQ;CAyBT"}
@@ -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{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as f}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(d,f){if(u(),0!=f.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 b;e.set(n,x),b=f.element,Object.assign(b.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const D=new i(f.element,{enableXR:!0===f.xr?.enabled,maxPixelRatio:f.rendering?.maxPixelRatio});D.renderer.shadowMap.enabled=f.rendering?.shadows?.enabled??!0,D.renderer.shadowMap.autoUpdate=f.rendering?.shadows?.autoUpdate??!0,null!=f?.rendering?.resolutionScale&&(D.resolutionScale=f.rendering.resolutionScale),e.set(i,D);const R=new o(D);e.set(o,R);const G=new g,z=new l(G),H=new p;H.setDataDir(f.dataDir),H.initKtx2(D.renderer);const O=Object.entries(f.shaders).map((([e,t])=>({name:e,type:t}))),P=Object.entries(f.actors).map((([e,t])=>({name:e,type:t}))),W=new v(O);e.set(v,W);const A=new h(H,z,O);e.set(h,A);const M=new j,N=new r(M,new S,z,H,D,O,P,x);e.set(r,N);const U=e.get(s);return e.set(s,U),U.materializer=N,(async()=>{const n=e.get(a);if(n.scene=U.scene,await n.start(),I.isShutdown)return;if(await G.preloadData(),I.isShutdown)return;U.scene=M;const{scene:s,actors:r}=await t(D,f.sceneName,f.dataDir,f.shaders,f.actors,x,G,z,H);U.scene=s;for(const e of M.children)U.scene.add(e);if(I.isShutdown)return void D.stop();e.import([c]);for(const e of r)U.addActor(e);n.addFromScene(s),D.loop((e=>{})),I.status=5,m.value=y,y.remove(d),y.set({id:d,type:d});const o=y.get(d);m.value=null,I.gameInstance=o,y.get(w).start(),o instanceof GameInstance&&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 f,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,this.shutdownStarted.next(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(d).stop();const e=this.containerInstance.get(i);e?.stop();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
1
+ import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as 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{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as f}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";export function initiateGame(d,f){if(u(),0!=f.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 b;e.set(n,x),b=f.element,Object.assign(b.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const D=new i(f.element,{enableXR:!0===f.xr?.enabled,maxPixelRatio:f.rendering?.maxPixelRatio});D.renderer.shadowMap.enabled=f.rendering?.shadows?.enabled??!0,D.renderer.shadowMap.autoUpdate=f.rendering?.shadows?.autoUpdate??!0,null!=f?.rendering?.resolutionScale&&(D.resolutionScale=f.rendering.resolutionScale),e.set(i,D);const R=new o(D);e.set(o,R);const G=new g,z=new l(G),H=new p;H.setDataDir(f.dataDir),H.initKtx2(D.renderer);const O=Object.entries(f.shaders).map((([e,t])=>({name:e,type:t}))),P=Object.entries(f.actors).map((([e,t])=>({name:e,type:t}))),W=new v(O);e.set(v,W);const A=new h(H,z,O);e.set(h,A);const M=new j,N=new r(M,new S,z,H,D,O,P,x);e.set(r,N);const U=e.get(s);return e.set(s,U),U.materializer=N,(async()=>{const n=e.get(a);if(await n.start(),I.isShutdown)return;if(await G.preloadData(),I.isShutdown)return;U.scene=M;const{scene:s,actors:r}=await t(D,f.sceneName,f.dataDir,f.shaders,f.actors,x,G,z,H);U.scene=s,n.scene=U.scene;for(const e of M.children)U.scene.add(e);if(I.isShutdown)return void D.stop();e.import([c]);for(const e of r)U.addActor(e);n.addFromScene(s),D.loop((e=>{})),I.status=5,m.value=y,y.remove(d),y.set({id:d,type:d});const o=y.get(d);m.value=null,I.gameInstance=o,y.get(w).start(),o instanceof GameInstance&&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 f,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,this.shutdownStarted.next(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(d).stop();const e=this.containerInstance.get(i);e?.stop();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -186,14 +186,6 @@ export declare abstract class AbstractPhysicsSystem {
186
186
  * Updates the transform of an actor's physics body to match its visual representation
187
187
  */
188
188
  abstract updateActorTransform(actor: BaseActor): void;
189
- /**
190
- * Gets the contact points between an actor and other objects in a specific direction
191
- */
192
- abstract getActorContacts(actor: BaseActor, direction: Vector3): {
193
- ri: Vector3;
194
- rj: Vector3;
195
- ni: Vector3;
196
- }[];
197
189
  /**
198
190
  * Stops the physics simulation and cleans up resources
199
191
  */
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-physics-system.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/services/physics/abstract-physics-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAA;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,2BAA2B,EAAE,OAAO,CAAA;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,eAAe,CAAA;IACrB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;GAIG;AACH,8BAAsB,qBAAqB;IACzC;;OAEG;IAC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AI,EAAE,CAAC,EACP,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GACzB,UAAU,CAAC,CAAC,CAAC;IAEhB;;OAEG;aACa,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAE5D;;OAEG;aACa,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG;QACtE,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAA;KACZ,EAAE;IAEH;;OAEG;aACa,IAAI,IAAI,IAAI;CAC7B"}
1
+ {"version":3,"file":"abstract-physics-system.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/services/physics/abstract-physics-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAA;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,2BAA2B,EAAE,OAAO,CAAA;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,eAAe,CAAA;IACrB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;GAIG;AACH,8BAAsB,qBAAqB;IACzC;;OAEG;IACH,kBAAyB,KAAK,EAAE,OAAO,CAAC,IAAI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AAC,CAAC,CAAC,GACzB,UAAU,CAAC,CAAC,CAAC;IAEhB;;OAEG;aACa,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAE5D;;OAEG;aACa,IAAI,IAAI,IAAI;CAC7B"}
@@ -8,6 +8,24 @@ import { BaseActor } from '../../actors/actor.js';
8
8
  import { ViewController } from '../render.js';
9
9
  import { AbstractPhysicsSystem, ActorPhysicsOptions } from './abstract-physics-system.js';
10
10
  export { Component, ActorComponent, type ComponentOptions, attach, Attach } from '../../actors/component.js';
11
+ /**
12
+ * Pairwise filtering using bit masks.
13
+ *
14
+ * This filtering method is based on two 16-bit values:
15
+ * - The interaction groups (the 16 left-most bits of `self.0`).
16
+ * - The interaction mask (the 16 right-most bits of `self.0`).
17
+ *
18
+ * An interaction is allowed between two filters `a` and `b` two conditions
19
+ * are met simultaneously:
20
+ * - The interaction groups of `a` has at least one bit set to `1` in common with the interaction mask of `b`.
21
+ * - The interaction groups of `b` has at least one bit set to `1` in common with the interaction mask of `a`.
22
+ * In other words, interactions are allowed between two filter iff. the following condition is met:
23
+ *
24
+ * ```
25
+ * ((a >> 16) & b) != 0 && ((b >> 16) & a) != 0
26
+ * ```
27
+ */
28
+ export type InteractionGroups = number;
11
29
  export declare class RayTestResult {
12
30
  actor?: BaseActor;
13
31
  hasHit: boolean;
@@ -18,10 +36,25 @@ export declare class RayTestResult {
18
36
  interface RayTestOptions {
19
37
  debugColor?: ColorRepresentation;
20
38
  debugLifetime?: number;
21
- collisionFilter?: number;
39
+ collisionFilter?: InteractionGroups;
22
40
  excludeActor?: BaseActor;
23
41
  excludeTriggers?: boolean;
24
42
  }
43
+ export declare class ShapeCastResult {
44
+ static shared: ShapeCastResult;
45
+ actor?: BaseActor;
46
+ hasHit: boolean;
47
+ distance: number;
48
+ /**
49
+ * The world-space contact point at the point of impact.
50
+ */
51
+ hitPoint: Vector3;
52
+ /**
53
+ * The world-space normal of the collider hit at the point of impact.
54
+ */
55
+ normal: Vector3;
56
+ reset(): void;
57
+ }
25
58
  export declare enum PhysicsBodyType {
26
59
  dynamic = 1,
27
60
  static = 2,
@@ -52,6 +85,8 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
52
85
  constructor(viewController: ViewController);
53
86
  private shapeCacheBox;
54
87
  private shapeCacheBall;
88
+ private getBallShape;
89
+ private getBoxShape;
55
90
  /**
56
91
  * Check if there is any objects in the physics world currently that
57
92
  * intersects with this box.
@@ -413,16 +448,34 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
413
448
  */
414
449
  private setupWorld;
415
450
  /**
416
- * Gets the contact points between an actor and other objects in a specific direction.
417
- * @param actor - The actor to check contacts for
418
- * @param direction - The direction to check in
419
- * @returns Array of contact points with position and normal information
420
- */
421
- getActorContacts(actor: BaseActor, direction: Vector3): {
422
- ri: Vector3;
423
- rj: Vector3;
424
- ni: Vector3;
425
- }[];
451
+ * Performs a sphere cast (swept sphere collision test) in the physics world.
452
+ * This method checks if a sphere, starting at a given position and with a given radius,
453
+ * would intersect with any colliders in the physics world when moved along the given direction
454
+ * up to the specified distance.
455
+ *
456
+ * @param position - The starting position of the sphere (THREE.Vector3)
457
+ * @param radius - The radius of the sphere
458
+ * @param direction - The direction vector along which to cast the sphere (THREE.Vector3)
459
+ * @param distance - The maximum distance to cast the sphere
460
+ * @param result - Optional. A ShapeCastResult object to store the result. If not provided, a shared instance is used.
461
+ * @param collisionFilter - Optional. An interaction group filter to restrict which objects are considered for collision.
462
+ * @returns The ShapeCastResult containing hit information if a collision occurred, or indicating no hit otherwise.
463
+ */
464
+ sphereCast(position: Vector3, radius: number, direction: Vector3, distance: number, result?: ShapeCastResult, collisionFilter?: InteractionGroups): ShapeCastResult;
465
+ /**
466
+ * Performs a shape cast (swept collision test) for the given actor in a specified direction and distance.
467
+ * This method checks if the actor's collider(s) would intersect with any other colliders in the physics world
468
+ * when moved along the given direction up to the specified distance. The result contains information about
469
+ * the first hit, including contact points, normals, and the hit actor.
470
+ *
471
+ * @param actor - The actor whose shape will be cast through the world.
472
+ * @param direction - The direction vector along which to cast the shape.
473
+ * @param distance - The maximum distance to cast the shape.
474
+ * @param result - Optional. A ShapeCastResult object to store the result. If not provided, a shared instance is used.
475
+ * @param collisionFilter - Optional. An interaction group filter to restrict which objects are considered for collision.
476
+ * @returns The ShapeCastResult containing hit information if a collision occurred, or indicating no hit otherwise.
477
+ */
478
+ castActorShape(actor: BaseActor, direction: Vector3, distance: number, result?: ShapeCastResult, collisionFilter?: InteractionGroups): ShapeCastResult;
426
479
  /**
427
480
  * Stops the physics simulation and cleans up resources.
428
481
  */
@@ -1 +1 @@
1
- {"version":3,"file":"physics-system.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/services/physics/physics-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAgE,UAAU,EAAE,OAAO,EAA2B,MAAM,MAAM,CAAA;AACjI,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAGL,mBAAmB,EAE6C,QAAQ,EAIxE,OAAO,EACR,MAAM,OAAO,CAAA;AAGd,OAAO,EAGL,cAAc,EASf,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,YAAY,EAAQ,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAW,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAM7C,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAGzF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAG7G,qBAAa,aAAa;IAGxB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,MAAM,EAAE,OAAO,CAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAgB;I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