x_ite 12.1.7 → 12.1.9
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.
- package/README.md +5 -5
- package/dist/assets/components/AnnotationComponent.js +2 -2
- package/dist/assets/components/AnnotationComponent.min.js +2 -2
- package/dist/assets/components/CADGeometryComponent.js +2 -2
- package/dist/assets/components/CADGeometryComponent.min.js +2 -2
- package/dist/assets/components/CubeMapTexturingComponent.js +2 -2
- package/dist/assets/components/CubeMapTexturingComponent.min.js +2 -2
- package/dist/assets/components/DISComponent.js +2 -2
- package/dist/assets/components/DISComponent.min.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.min.js +2 -2
- package/dist/assets/components/Geometry2DComponent.js +2 -2
- package/dist/assets/components/Geometry2DComponent.min.js +2 -2
- package/dist/assets/components/GeospatialComponent.js +2 -2
- package/dist/assets/components/GeospatialComponent.min.js +2 -2
- package/dist/assets/components/HAnimComponent.js +2 -2
- package/dist/assets/components/HAnimComponent.min.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.min.js +2 -2
- package/dist/assets/components/LayoutComponent.js +2 -2
- package/dist/assets/components/LayoutComponent.min.js +2 -2
- package/dist/assets/components/NURBSComponent.js +2 -2
- package/dist/assets/components/NURBSComponent.min.js +2 -2
- package/dist/assets/components/ParticleSystemsComponent.js +2 -2
- package/dist/assets/components/ParticleSystemsComponent.min.js +2 -2
- package/dist/assets/components/PickingComponent.js +2 -2
- package/dist/assets/components/PickingComponent.min.js +2 -2
- package/dist/assets/components/RigidBodyPhysicsComponent.js +4 -4
- package/dist/assets/components/RigidBodyPhysicsComponent.min.js +2 -2
- package/dist/assets/components/ScriptingComponent.js +2 -2
- package/dist/assets/components/ScriptingComponent.min.js +2 -2
- package/dist/assets/components/TextComponent.js +2 -2
- package/dist/assets/components/TextComponent.min.js +2 -2
- package/dist/assets/components/TextureProjectionComponent.js +2 -2
- package/dist/assets/components/TextureProjectionComponent.min.js +2 -2
- package/dist/assets/components/Texturing3DComponent.js +67 -67
- package/dist/assets/components/Texturing3DComponent.min.js +2 -2
- package/dist/assets/components/VolumeRenderingComponent.js +2 -2
- package/dist/assets/components/VolumeRenderingComponent.min.js +2 -2
- package/dist/assets/components/WebXRComponent.js +8 -4
- package/dist/assets/components/WebXRComponent.min.js +2 -2
- package/dist/assets/components/X_ITEComponent.js +2 -2
- package/dist/assets/components/X_ITEComponent.min.js +2 -2
- package/dist/assets/images/no_sound.svg +1 -0
- package/dist/assets/images/play_circle.svg +1 -0
- package/dist/assets/images/stop_circle.svg +1 -0
- package/dist/example.html +62 -7
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +51535 -51692
- package/dist/x_ite.min.js +2 -2
- package/dist/x_ite.min.mjs +2 -2
- package/dist/x_ite.mjs +51569 -51726
- package/dist/x_ite.zip +0 -0
- package/package.json +3 -3
- package/dist/assets/images/cancel.svg +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* X_ITE v12.1.
|
|
2
|
-
const e=window[Symbol.for("X_ITE.X3D-12.1.7")];(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=e.Components;var n=t.n(i);const s=e.Fields;var o=t.n(s);const r=e.X3DFieldDefinition;var a=t.n(r);const c=e.FieldDefinitionArray;var l=t.n(c);const d=e.X3DNode;var u=t.n(d);const h=e.Namespace;var m=t.n(h);const _={forces:Symbol(),colors:Symbol(),texCoords:Symbol(),scales:Symbol()},p=m().add("ParticleSampler",_),f=e.GeometryType;var x=t.n(f);const g=e.X3DConstants;var v=t.n(g);const y=m().add("Line3.glsl","\n#if defined(X3D_BOUNDED_VOLUME)||defined(X3D_VOLUME_EMITTER)\nstruct Line3{vec3 point;vec3 direction;};bool intersects(const in Line3 line,const in vec3 a,const in vec3 b,const in vec3 c,out vec3 r){vec3 edge1=b-a;vec3 edge2=c-a;vec3 pvec=cross(line.direction,edge2);float det=dot(edge1,pvec);if(det==0.)return false;float inv_det=1./det;vec3 tvec=line.point-a;float u=dot(tvec,pvec)*inv_det;if(u<0.||u>1.)return false;vec3 qvec=cross(tvec,edge1);float v=dot(line.direction,qvec)*inv_det;if(v<0.||u+v>1.)return false;r=vec3(u,v,1.-u-v);return true;}\n#endif\n"),T=m().add("Plane3.glsl","\n#if defined(X3D_BOUNDED_VOLUME)||defined(X3D_VOLUME_EMITTER)\nstruct Plane3{vec3 normal;float distanceFromOrigin;};Plane3 plane3(const in vec3 point,const in vec3 normal){return Plane3(normal,dot(normal,point));}float plane_distance(const in Plane3 plane,const in vec3 point){return dot(point,plane.normal)-plane.distanceFromOrigin;}bool intersects(const in Plane3 plane,const in Line3 line,out vec3 point){float theta=dot(line.direction,plane.normal);if(theta==0.)return false;float t=(plane.distanceFromOrigin-dot(plane.normal,line.point))/theta;point=line.point+line.direction*t;return true;}void sort(inout vec4 points[ARRAY_SIZE],const in int count,const in Plane3 plane){const float shrink=1./1.3;int gap=count;bool exchanged=true;while(exchanged){gap=int(float(gap)*shrink);if(gap<=1){exchanged=false;gap=1;}for(int i=0,l=count-gap;i<l;++i){int j=gap+i;if(plane_distance(plane,points[i].xyz)>plane_distance(plane,points[j].xyz)){vec4 tmp1=points[i];points[i]=points[j];points[j]=tmp1;exchanged=true;}}}}int min_index(const in vec4 points[ARRAY_SIZE],const in int count,const in float value,const in Plane3 plane){int index=-1;float dist=1000000.;for(int i=0;i<count;++i){float d=plane_distance(plane,points[i].xyz);if(d>=value&&d<dist){dist=d;index=i;}}return index;}\n#endif\n"),E=m().add("Box3.glsl","\n#if defined(X3D_VOLUME_EMITTER)||defined(X3D_BOUNDED_VOLUME)\nbool intersects(const in vec3 min,const in vec3 max,const in Line3 line){vec3 intersection;if(intersects(plane3(max,vec3(0.,0.,1.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(min,vec3(0.,0.,-1.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(max,vec3(0.,1.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(min,vec3(0.,-1.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(max,vec3(1.,0.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.yz,max.yz),vec4(min.yz,intersection.yz))))return true;}return false;}\n#endif\n"),I=m().add("BVH.glsl","\n#if defined(X3D_VOLUME_EMITTER)||defined(X3D_BOUNDED_VOLUME)\n#define BVH_NODE 0\n#define BVH_TRIANGLE 1\n#define BVH_STACK_SIZE 32\nint bvhNodeIndex=0;void setBVHIndex(const in int index){bvhNodeIndex=index;}int getBVHRoot(const in sampler2D volume,const in int hierarchyIndex,const in int rootIndex){return int(texelFetch(volume,rootIndex,0).x)+hierarchyIndex;}int getBVHType(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).x);}vec3 getBVHMin(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+1,0).xyz;}vec3 getBVHMax(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+2,0).xyz;}int getBVHLeft(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).y)+hierarchyIndex;}int getBVHRight(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).z)+hierarchyIndex;}int getBVHTriangle(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).y);}\n#if defined(X3D_VOLUME_EMITTER)\nint getIntersections(const in sampler2D volume,const in int verticesIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r))points[count++]=vec4(r.z*a+r.x*b+r.y*c,1.);current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nint getIntersections(const in sampler2D volume,const in int verticesIndex,const in int normalsIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE],out vec3 normals[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r)){points[count]=vec4(r.z*a+r.x*b+r.y*c,1.);int n=normalsIndex+t;vec3 n0=texelFetch(volume,n,0).xyz;vec3 n1=texelFetch(volume,n+1,0).xyz;vec3 n2=texelFetch(volume,n+2,0).xyz;normals[count]=r.z*n0+r.x*n1+r.y*n2;++count;}current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}\n#endif\n#endif\n");function b(e){u().call(this,e),this.addType(v().X3DParticleEmitterNode),this.addChildObjects(v().outputOnly,"bbox_changed",new(o().SFTime)),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.defines=[],this.samplers=[],this.uniforms=new Map,this.callbacks=[],this.functions=[],this.programs=new Map}Object.assign(Object.setPrototypeOf(b.prototype,u().prototype),{initialize(){u().prototype.initialize.call(this);const e=this.getBrowser().getContext();this.transformFeedback=e.createTransformFeedback(),this._on.addInterest("set_on__",this),this._speed.addInterest("set_speed__",this),this._variation.addInterest("set_variation__",this),this._mass.addInterest("set_mass__",this),this._surfaceArea.addInterest("set_surfaceArea__",this),this.addSampler("boundedVolume");for(const e in p)this.addSampler(e);this.addUniform("speed","uniform float speed;"),this.addUniform("variation","uniform float variation;"),this.addCallback(this.set_speed__),this.addCallback(this.set_variation__),this.addFunction(y),this.addFunction(T),this.addFunction(E),this.addFunction(I),this.set_on__(),this.set_mass__(),this.set_surfaceArea__()},isExplosive:()=>!1,getMass(){return this.mass},getSurfaceArea(){return this.surfaceArea},set_on__(){this.on=this._on.getValue()},set_speed__(){this.setUniform("uniform1f","speed",Math.max(this._speed.getValue(),0))},set_variation__(){this.setUniform("uniform1f","variation",Math.max(this._variation.getValue(),0))},set_mass__(){this.mass=Math.max(this._mass.getValue(),0)},set_surfaceArea__(){this.surfaceArea=Math.max(this._surfaceArea.getValue(),0)},getRandomValue:(e,t)=>Math.random()*(t-e)+e,getRandomNormal(e){const t=this.getRandomValue(-1,1)*Math.PI,i=this.getRandomValue(-1,1),n=Math.acos(i),s=Math.sin(n);return e.set(Math.sin(t)*s,Math.cos(t)*s,i)},animate(e,t){const i=this.getBrowser(),n=i.getContext(),s=this.getProgram(e),o=e.inputParticles;n.useProgram(s),n.uniform1i(s.randomSeed,4294967295*Math.random()),n.uniform1f(s.particleLifetime,e.particleLifetime),n.uniform1f(s.lifetimeVariation,e.lifetimeVariation),n.uniform1f(s.deltaTime,t),n.uniform2f(s.particleSize,e._particleSize.x,e._particleSize.y),e.boundedHierarchyRoot>-1&&(n.uniform1i(s.boundedVerticesIndex,e.boundedVerticesIndex),n.uniform1i(s.boundedNormalsIndex,e.boundedNormalsIndex),n.uniform1i(s.boundedHierarchyIndex,e.boundedHierarchyIndex),n.uniform1i(s.boundedHierarchyRoot,e.boundedHierarchyRoot),n.activeTexture(n.TEXTURE0+s.boundedVolumeTextureUnit),n.bindTexture(n.TEXTURE_2D,e.boundedTexture));for(const t of e.samplers)n.activeTexture(n.TEXTURE0+s[t]),n.bindTexture(n.TEXTURE_2D,e[t]);if(this.activateTextures(n,s),o.vertexArrayObject.enable(s)){const{particlesStride:t,particleOffsets:i}=e;for(const[e,r]of s.inputs)n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(r),n.vertexAttribPointer(r,4,n.FLOAT,!1,t,i[e])}n.bindFramebuffer(n.FRAMEBUFFER,i.getDefaultFramebuffer()),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,this.transformFeedback),n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,0,e.outputParticles),n.enable(n.RASTERIZER_DISCARD),n.beginTransformFeedback(n.POINTS),n.drawArrays(n.POINTS,0,e.numParticles),n.endTransformFeedback(),n.disable(n.RASTERIZER_DISCARD),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,null)},addDefine(e){this.defines.push(e)},addSampler(e){this.samplers.push(e)},addUniform(e,t){this.uniforms.set(e,t)},setUniform(e,t,i,n,s){const o=this.getBrowser().getContext();for(const r of this.programs.values())o.useProgram(r),o[e](r[t],i,n,s)},addCallback(e){this.callbacks.push(e)},addFunction(e){this.functions.push(e)},getProgram(e){const{geometryType:t,createParticles:i,numColors:n,numTexCoords:s,texCoordCount:o,numScales:r,numForces:a,boundedHierarchyRoot:c}=e;let l="";return l+=t,l+=i&&this.on?1:0,l+=".",l+=n,l+=".",l+=s,l+=".",l+=o,l+=".",l+=r,l+=".",l+=a,l+=".",l+=c,this.programs.get(l)??this.createProgram(l,e)},createProgram(e,t){const i=this.getBrowser(),n=i.getContext(),s=this.defines.slice();s.push(`#define X3D_GEOMETRY_TYPE ${t.geometryType}`),s.push(""+(t.createParticles&&this.on?"#define X3D_CREATE_PARTICLES":"")),s.push(`#define X3D_NUM_COLORS ${t.numColors}`),s.push(`#define X3D_NUM_TEX_COORDS ${t.numTexCoords}`),s.push(`#define X3D_TEX_COORDS_COUNT ${t.texCoordCount}`),s.push(`#define X3D_NUM_SCALES ${t.numScales}`),s.push(`#define X3D_NUM_FORCES ${t.numForces}`),s.push(""+(t.boundedHierarchyRoot>-1?"#define X3D_BOUNDED_VOLUME":""));const o=`#version 300 es\nprecision highp float;precision highp int;precision highp sampler2D;\n${s.join("\n")}\nuniform int randomSeed;uniform float particleLifetime;uniform float lifetimeVariation;uniform float deltaTime;uniform vec2 particleSize;\n#if X3D_NUM_FORCES>0\nuniform sampler2D forces;\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nuniform int boundedVerticesIndex;uniform int boundedNormalsIndex;uniform int boundedHierarchyIndex;uniform int boundedHierarchyRoot;uniform sampler2D boundedVolume;\n#endif\n#if X3D_NUM_COLORS>0\nuniform sampler2D colors;\n#endif\n#if X3D_NUM_TEX_COORDS>0\nuniform sampler2D texCoords;\n#endif\n#if X3D_NUM_SCALES>0\nuniform sampler2D scales;\n#endif\n${Array.from(this.uniforms.values()).join("\n")}\nin vec4 input0;in vec4 input2;in vec4 input6;out vec4 output0;out vec4 output1;out vec4 output2;out vec4 output3;out vec4 output4;out vec4 output5;out vec4 output6;\n${Object.entries(x()).map(([e,t])=>`#define ${e} ${t}`).join("\n")}\nconst int ARRAY_SIZE=32;const float M_PI=3.14159265359;uniform float NaN;vec4 texelFetch(const in sampler2D sampler,const in int index,const in int lod){int x=textureSize(sampler,lod).x;ivec2 p=ivec2(index % x,index/x);vec4 t=texelFetch(sampler,p,lod);return t;}vec3 save_normalize(const in vec3 vector){float l=length(vector);if(l==0.)return vec3(0);return vector/l;}vec4 Quaternion(const in vec3 fromVector,const in vec3 toVector){vec3 from=save_normalize(fromVector);vec3 to=save_normalize(toVector);float cos_angle=dot(from,to);vec3 cross_vec=cross(from,to);float cross_len=length(cross_vec);if(cross_len==0.){if(cos_angle>0.){return vec4(0.,0.,0.,1.);}else{vec3 t=cross(from,vec3(1.,0.,0.));if(dot(t,t)==0.)t=cross(from,vec3(0.,1.,0.));t=save_normalize(t);return vec4(t,0.);}}else{float s=sqrt(abs(1.-cos_angle)*.5);cross_vec=save_normalize(cross_vec);return vec4(cross_vec*s,sqrt(abs(1.+cos_angle)*.5));}}vec3 multVecQuat(const in vec3 v,const in vec4 q){float a=q.w*q.w-q.x*q.x-q.y*q.y-q.z*q.z;float b=2.*(v.x*q.x+v.y*q.y+v.z*q.z);float c=2.*q.w;vec3 r=a*v.xyz+b*q.xyz+c*(q.yzx*v.zxy-q.zxy*v.yzx);return r;}mat3 Matrix3(const in vec4 quaternion){float x=quaternion.x;float y=quaternion.y;float z=quaternion.z;float w=quaternion.w;float A=y*y;float B=z*z;float C=x*y;float D=z*w;float E=z*x;float F=y*w;float G=x*x;float H=y*z;float I=x*w;return mat3(1.-2.*(A+B),2.*(C+D),2.*(E-F),2.*(C-D),1.-2.*(B+G),2.*(H+I),2.*(E+F),2.*(H-I),1.-2.*(A+G));}uint seed=1u;void srand(const in int value){seed=uint(value);}float random(){seed=seed*1103515245u+12345u;return float(seed)/4294967295.;}float getRandomValue(const in float min,const in float max){return min+random()*(max-min);}float getRandomLifetime(){float v=particleLifetime*lifetimeVariation;float min_=max(0.,particleLifetime-v);float max_=particleLifetime+v;return getRandomValue(min_,max_);}float getRandomSpeed(){float v=speed*variation;float min_=max(0.,speed-v);float max_=speed+v;return getRandomValue(min_,max_);}vec3 getRandomNormal(){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(-1.,1.);float r=sqrt(1.-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithAngle(const in float angle){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(cos(angle),1.);float r=sqrt(1.-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithDirectionAndAngle(const in vec3 direction,const in float angle){vec4 rotation=Quaternion(vec3(0.,0.,1.),direction);vec3 normal=getRandomNormalWithAngle(angle);return multVecQuat(normal,rotation);}vec3 getRandomSurfaceNormal(const in vec3 direction){float theta=getRandomValue(-M_PI,M_PI);float cphi=pow(random(),1./3.);float r=sqrt(1.-cphi*cphi);vec3 normal=vec3(sin(theta)*r,cos(theta)*r,cphi);vec4 rotation=Quaternion(vec3(0.,0.,1.),direction);return multVecQuat(normal,rotation);}vec3 getRandomSphericalVelocity(){vec3 normal=getRandomNormal();float speed=getRandomSpeed();return normal*speed;}int upperBound(const in sampler2D sampler,in int count,const in float value){int first=0;int step=0;while(count>0){int index=first;step=count>>1;index+=step;if(value<texelFetch(sampler,index,0).x){count=step;}else{first=++index;count-=step+1;}}return first;}\n#if X3D_NUM_TEX_COORDS>0\nvoid interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;}else{int index=upperBound(sampler,count,fraction);if(index<count)index0=index-1;else index0=0;}}\n#endif\n#if X3D_NUM_COLORS>0||X3D_NUM_SCALES>0||defined(X3D_POLYLINE_EMITTER)||defined(X3D_SURFACE_EMITTER)||defined(X3D_VOLUME_EMITTER)\nvoid interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0,out int index1,out float weight){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;index1=0;weight=0.;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;index1=count-1;weight=1.;}else{int index=upperBound(sampler,count,fraction);if(index<count){index1=index;index0=index-1;float key0=texelFetch(sampler,index0,0).x;float key1=texelFetch(sampler,index1,0).x;weight=clamp((fraction-key0)/(key1-key0),0.,1.);}else{index0=0;index1=0;weight=0.;}}}\n#endif\n#if defined(X3D_SURFACE_EMITTER)||defined(X3D_VOLUME_EMITTER)\nvec3 getRandomBarycentricCoord(){float u=random();float v=random();if(u+v>1.){u=1.-u;v=1.-v;}float t=1.-u-v;return vec3(t,u,v);}void getRandomPointOnSurface(const in sampler2D surface,const in int verticesIndex,const in int normalsIndex,out vec4 position,out vec3 normal){float lastAreaSoFar=texelFetch(surface,verticesIndex-1,0).x;float fraction=random()*lastAreaSoFar;int index0;int index1;int index2;float weight;interpolate(surface,verticesIndex,fraction,index0,index1,weight);index0*=3;index1=index0+1;index2=index0+2;vec4 vertex0=texelFetch(surface,verticesIndex+index0,0);vec4 vertex1=texelFetch(surface,verticesIndex+index1,0);vec4 vertex2=texelFetch(surface,verticesIndex+index2,0);vec3 normal0=texelFetch(surface,normalsIndex+index0,0).xyz;vec3 normal1=texelFetch(surface,normalsIndex+index1,0).xyz;vec3 normal2=texelFetch(surface,normalsIndex+index2,0).xyz;vec3 r=getRandomBarycentricCoord();position=r.z*vertex0+r.x*vertex1+r.y*vertex2;normal=save_normalize(r.z*normal0+r.x*normal1+r.y*normal2);}\n#endif\n${this.functions.join("\n")}\n#if X3D_NUM_TEX_COORDS>0\nint getTexCoordIndex0(const in float fraction){int index0=0;interpolate(texCoords,X3D_NUM_TEX_COORDS,fraction,index0);return X3D_NUM_TEX_COORDS+index0*X3D_TEX_COORDS_COUNT;}\n#else\n#define getTexCoordIndex0(fraction)(-1)\n#endif\n#if X3D_NUM_COLORS>0\nvec4 getColor(const in float fraction){int index0;int index1;float weight;interpolate(colors,X3D_NUM_COLORS,fraction,index0,index1,weight);vec4 color0=texelFetch(colors,X3D_NUM_COLORS+index0,0);vec4 color1=texelFetch(colors,X3D_NUM_COLORS+index1,0);return mix(color0,color1,weight);}\n#else\n#define getColor(fraction)(vec4(1))\n#endif\n#if X3D_NUM_SCALES>0\nvec3 getScale(const in float fraction){int index0;int index1;float weight;interpolate(scales,X3D_NUM_SCALES,fraction,index0,index1,weight);vec3 scale0=texelFetch(scales,X3D_NUM_SCALES+index0,0).xyz;vec3 scale1=texelFetch(scales,X3D_NUM_SCALES+index1,0).xyz;return mix(scale0,scale1,weight);}\n#else\n#define getScale(fraction)(vec3(1))\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nvoid bounce(const in float deltaTime,const in vec4 fromPosition,inout vec4 toPosition,inout vec3 velocity){Line3 line=Line3(fromPosition.xyz,save_normalize(velocity));vec4 points[ARRAY_SIZE];vec3 normals[ARRAY_SIZE];int numIntersections=getIntersections(boundedVolume,boundedVerticesIndex,boundedNormalsIndex,boundedHierarchyIndex,boundedHierarchyRoot,line,points,normals);if(numIntersections==0)return;Plane3 plane1=plane3(line.point,line.direction);int index=min_index(points,numIntersections,0.,plane1);if(index==-1)return;vec3 point=points[index].xyz;vec3 normal=save_normalize(normals[index]);Plane3 plane2=plane3(point,normal);if(sign(plane_distance(plane2,fromPosition.xyz))==sign(plane_distance(plane2,toPosition.xyz)))return;float damping=length(normals[index]);velocity=reflect(velocity,normal);toPosition=vec4(point+save_normalize(velocity)*.0001,1.);velocity*=damping;}\n#endif\nvoid main(){int life=int(input0[0]);float lifetime=input0[1];float elapsedTime=input0[2]+deltaTime;float fraction=elapsedTime/lifetime;srand((gl_VertexID+randomSeed)*randomSeed);if(elapsedTime>lifetime){lifetime=getRandomLifetime();elapsedTime=0.;fraction=0.;output0=vec4(max(life+1,1),lifetime,elapsedTime,getTexCoordIndex0(fraction));\n#if defined(X3D_CREATE_PARTICLES)\noutput1=getColor(fraction);output2=vec4(getRandomVelocity(),0.);output6=getRandomPosition();\n#else\noutput1=vec4(0);output2=vec4(0);output6=vec4(NaN);\n#endif\n}else{vec3 velocity=input2.xyz;vec4 position=input6;\n#if X3D_NUM_FORCES>0\nfor(int i=0;i<X3D_NUM_FORCES;++i){vec4 force=texelFetch(forces,i,0);float turbulence=force.w;vec3 normal=getRandomNormalWithDirectionAndAngle(force.xyz,turbulence);float speed=length(force.xyz);velocity+=normal*speed;}\n#endif\nposition.xyz+=velocity*deltaTime;\n#if defined(X3D_BOUNDED_VOLUME)\nbounce(deltaTime,input6,position,velocity);\n#endif\noutput0=vec4(life,lifetime,elapsedTime,getTexCoordIndex0(fraction));output1=getColor(fraction);output2=vec4(velocity,0.);output6=position;}vec3 scale=getScale(fraction);\n#if X3D_GEOMETRY_TYPE==POINT||X3D_GEOMETRY_TYPE==SPRITE||X3D_GEOMETRY_TYPE==GEOMETRY\noutput3=vec4(scale.x,0.,0.,0.);output4=vec4(0.,scale.y,0.,0.);output5=vec4(0.,0.,scale.z,0.);\n#elif X3D_GEOMETRY_TYPE==LINE\nmat3 m=Matrix3(Quaternion(vec3(0.,0.,1.),output2.xyz));\n#if X3D_NUM_SCALES>0\nm*=mat3(scale.x,0.,0.,0.,scale.y,0.,0.,0.,scale.z);\n#endif\noutput3=vec4(m[0],0.);output4=vec4(m[1],0.);output5=vec4(m[2],0.);\n#else\nvec2 s=particleSize*scale.xy;output3=vec4(s.x,0.,0.,0.);output4=vec4(0.,s.y,0.,0.);output5=vec4(0.,0.,scale.z,0.);\n#endif\n}`,r=n.createShader(n.VERTEX_SHADER);n.shaderSource(r,o),n.compileShader(r),n.getShaderParameter(r,n.COMPILE_STATUS)||console.error(n.getShaderInfoLog(r));const a=n.createShader(n.FRAGMENT_SHADER);n.shaderSource(a,"#version 300 es\nprecision highp float;void main(){}"),n.compileShader(a),n.getShaderParameter(a,n.COMPILE_STATUS)||console.error(n.getShaderInfoLog(a));const c=n.createProgram();n.attachShader(c,r),n.attachShader(c,a),n.transformFeedbackVaryings(c,Array.from({length:7},(e,t)=>"output"+t),n.INTERLEAVED_ATTRIBS),n.linkProgram(c),n.getProgramParameter(c,n.LINK_STATUS)||console.error(`Couldn't initialize particle shader: ${n.getProgramInfoLog(c)}`),this.programs.set(e,c),n.useProgram(c),c.inputs=[[0,n.getAttribLocation(c,"input0")],[2,n.getAttribLocation(c,"input2")],[6,n.getAttribLocation(c,"input6")]],c.randomSeed=n.getUniformLocation(c,"randomSeed"),c.particleLifetime=n.getUniformLocation(c,"particleLifetime"),c.lifetimeVariation=n.getUniformLocation(c,"lifetimeVariation"),c.deltaTime=n.getUniformLocation(c,"deltaTime"),c.particleSize=n.getUniformLocation(c,"particleSize"),c.boundedVerticesIndex=n.getUniformLocation(c,"boundedVerticesIndex"),c.boundedNormalsIndex=n.getUniformLocation(c,"boundedNormalsIndex"),c.boundedHierarchyIndex=n.getUniformLocation(c,"boundedHierarchyIndex"),c.boundedHierarchyRoot=n.getUniformLocation(c,"boundedHierarchyRoot"),c.boundedVolume=n.getUniformLocation(c,"boundedVolume");for(const e in p)c[e]=n.getUniformLocation(c,e);for(const e of this.uniforms.keys())c[e]=n.getUniformLocation(c,e);n.uniform1f(n.getUniformLocation(c,"NaN"),NaN);for(const e of this.samplers){const t=n.getUniformLocation(c,e);n.uniform1i(t,c[e+"TextureUnit"]=i.getTextureUnit())}for(const[e,t]of Object.entries(p))c[t]=c[e+"TextureUnit"];i.resetTextureUnits();for(const e of this.callbacks)e.call(this);return c},activateTextures(){},createTexture(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},getTextureUnit(e,t,i){const n=t[i];return void 0===n?t[i]=e.getTextureUnit():n}}),Object.defineProperties(b,u().getStaticProperties("X3DParticleEmitterNode","ParticleSystems",1));const R=b,w=m().add("X3DParticleEmitterNode",R),S=e.Vector3;var F=t.n(S);function O(e){w.call(this,e),this.addType(v().PointEmitter),this._position.setUnit("length")}Object.assign(Object.setPrototypeOf(O.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.addDefine("#define X3D_POINT_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addCallback(this.set_position__),this.addCallback(this.set_direction__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()},set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})()}),Object.defineProperties(O,{...u().getStaticProperties("PointEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const A=O,N=m().add("PointEmitter",A),P=Symbol();function D(){}Object.assign(D.prototype,{getDefaultEmitter(){return this[P]??=(()=>{const e=new N(this.getPrivateScene());return e.setup(),e})()}});const V=D,C=m().add("X3DParticleSystemsContext",V);function B(e){u().call(this,e),this.addType(v().X3DParticlePhysicsModelNode)}Object.assign(Object.setPrototypeOf(B.prototype,u().prototype),{addForce(){}}),Object.defineProperties(B,u().getStaticProperties("X3DParticlePhysicsModelNode","ParticleSystems",1));const M=B,U=m().add("X3DParticlePhysicsModelNode",M),z=e.X3DCast;var L=t.n(z);function X(e){U.call(this,e),this.addType(v().BoundedPhysicsModel)}Object.assign(Object.setPrototypeOf(X.prototype,U.prototype),{initialize(){U.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},getBBox(){return this.geometryNode?.getBBox()},set_geometry__(){this.geometryNode?._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=L()(v().X3DGeometryNode,this._geometry),this.geometryNode?._rebuild.addInterest("addNodeEvent",this)},addGeometry(e,t){if(!this.geometryNode)return;if(!this._enabled.getValue())return;const i=this._damping.getValue(),n=this.geometryNode.getNormals().getValue(),s=this.geometryNode.getVertices().getValue();for(const t of n)e.push(t*i);for(const e of s)t.push(e)}}),Object.defineProperties(X,{...u().getStaticProperties("BoundedPhysicsModel","ParticleSystems",2,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"damping",new(o().SFFloat)(1)),new(a())(v().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const k=X,j=m().add("BoundedPhysicsModel",k);function G(e){w.call(this,e),this.addType(v().ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle")}Object.assign(Object.setPrototypeOf(G.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.addDefine("#define X3D_CONE_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("angle","uniform float angle;"),this.addCallback(this.set_position__),this.addCallback(this.set_direction__),this.addCallback(this.set_angle__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n {\n return getRandomSphericalVelocity ();\n }\n else\n {\n vec3 normal = getRandomNormalWithDirectionAndAngle (direction, angle);\n float speed = getRandomSpeed ();\n\n return normal * speed;\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()},set_direction__(){const{x:e,y:t,z:i}=this._direction.getValue();this.setUniform("uniform3f","direction",e,t,i)},set_angle__(){this.setUniform("uniform1f","angle",this._angle.getValue())}}),Object.defineProperties(G,{...u().getStaticProperties("ConeEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"angle",new(o().SFFloat)(.785398)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const H=G,Y=m().add("ConeEmitter",H);function q(e){w.call(this,e),this.addType(v().ExplosionEmitter),this._position.setUnit("length")}Object.assign(Object.setPrototypeOf(q.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this.addDefine("#define X3D_EXPLOSION_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addCallback(this.set_position__),this.addFunction("vec3 getRandomVelocity ()\n {\n return getRandomSphericalVelocity ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),isExplosive:()=>!0,set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()}}),Object.defineProperties(q,{...u().getStaticProperties("ExplosionEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const W=q,K=m().add("ExplosionEmitter",W);function Z(e){U.call(this,e),this.addType(v().ForcePhysicsModel),this._force.setUnit("force")}Object.assign(Object.setPrototypeOf(Z.prototype,U.prototype),{addForce:(()=>{const e=new(F());return function(t,i,n,s){return!!this._enabled.getValue()&&(s.set(e.assign(this._force.getValue()).multiply(n),4*t),s[4*t+3]=0,!0)}})()}),Object.defineProperties(Z,{...u().getStaticProperties("ForcePhysicsModel","ParticleSystems",1,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"force",new(o().SFVec3f)(0,-9.8,0))]),enumerable:!0}});const Q=Z,$=m().add("ForcePhysicsModel",Q),J=e.X3DShapeNode;var ee=t.n(J);const te=e.GeometryContext;var ie=t.n(te);const ne=e.VertexArray;var se=t.n(ne);const oe=e.AlphaMode;var re=t.n(oe);const ae=e.LineSet;var ce=t.n(ae);const le=e.Coordinate;var de=t.n(le);const ue=e.Matrix4;var he=t.n(ue);const me=e.Matrix3;var _e=t.n(me);const pe=e.Plane3;var fe=t.n(pe);const xe=e.QuickSort;var ge=t.n(xe);const ve=new(F()),ye=new(F()),Te=new(F()),Ee={u:0,v:0,t:0},Ie=[F().Z_AXIS,F().NEGATIVE_Z_AXIS,F().Y_AXIS,F().NEGATIVE_Y_AXIS,F().X_AXIS];function be(e,t){this.vertices=e.vertices,this.normals=e.normals,this.triangle=t,this.i4=12*t,this.i3=9*t}function Re(e,t,i,n){this.min=new(F()),this.max=new(F()),this.planes=[],this.intersection=new(F());const s=e.vertices,o=this.min,r=this.max,a=i+n;let c,l=12*t[i];o.set(s[l],s[l+1],s[l+2]),r.assign(o);for(let e=i;e<a;++e)l=12*t[e],ve.set(s[l],s[l+1],s[l+2]),ye.set(s[l+4],s[l+5],s[l+6]),Te.set(s[l+8],s[l+9],s[l+10]),o.min(ve,ye,Te),r.max(ve,ye,Te);for(let e=0;e<5;++e)this.planes[e]=new(fe())(e%2?o:r,Ie[e]);n>2?(e.sorter.compare.axis=this.getLongestAxis(o,r),e.sorter.sort(i,a),c=n>>>1):c=1;const d=n-c;this.left=c>1?new Re(e,t,i,c):new be(e,t[i]),this.right=d>1?new Re(e,t,i+c,d):new be(e,t[i+c])}function we(e,t){const i=e.length/12;switch(this.vertices=e,this.normals=t,i){case 0:this.root=null;break;case 1:this.root=new be(this,0);break;default:{const t=[];for(let e=0;e<i;++e)t.push(e);this.sorter=new(ge())(t,function(e,t){return function(i,n){return Math.min(e[i+t],e[i+4+t],e[i+8+t])<Math.min(e[n+t],e[n+4+t],e[n+8+t])}}(e,0)),this.root=new Re(this,t,0,i);break}}}Object.assign(be.prototype,{intersectsLine(e,t,i){const n=this.vertices,s=this.normals,o=this.i4,r=this.i3;if(ve.x=n[o],ve.y=n[o+1],ve.z=n[o+2],ye.x=n[o+4],ye.y=n[o+5],ye.z=n[o+6],Te.x=n[o+8],Te.y=n[o+9],Te.z=n[o+10],e.intersectsTriangle(ve,ye,Te,Ee)){const{u:e,v:a,t:c}=Ee,l=t.size++;l>=t.length&&t.push(new(F())),t[l].set(e*n[o]+a*n[o+4]+c*n[o+8],e*n[o+1]+a*n[o+5]+c*n[o+9],e*n[o+2]+a*n[o+6]+c*n[o+10]),i&&(l>=i.length&&i.push(new(F())),i[l].set(e*s[r]+a*s[r+3]+c*s[r+6],e*s[r+1]+a*s[r+4]+c*s[r+7],e*s[r+2]+a*s[r+5]+c*s[r+8]))}},toArray(e){const t=e.length/4;return e.push(1,3*this.triangle,0,0),t}}),Object.assign(Re.prototype,{intersectsLine(e,t,i){this.intersectsBBox(e)&&(this.left.intersectsLine(e,t,i),this.right.intersectsLine(e,t,i))},intersectsBBox(e){const t=this.planes,i=this.min,n=this.max,s=i.x,o=n.x,r=i.y,a=n.y,c=i.z,l=n.z,d=this.intersection;return!!(t[0].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.y>=r&&d.y<=a)||(!!(t[1].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.y>=r&&d.y<=a)||(!!(t[2].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.z>=c&&d.z<=l)||(!!(t[3].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.z>=c&&d.z<=l)||!!(t[4].intersectsLine(e,d)&&d.y>=r&&d.y<=a&&d.z>=c&&d.z<=l))))},getLongestAxis(e,t){const i=t.x-e.x,n=t.y-e.y,s=t.z-e.z;return i<n?n<s?2:1:i<s?2:0},toArray(e){const t=this.left.toArray(e),i=this.right.toArray(e),n=this.min,s=this.max,o=e.length/4;return e.push(0,t,i,0,n.x,n.y,n.z,0,s.x,s.y,s.z,0),o}}),Object.assign(we.prototype,{intersectsLine(e,t,i){return t.size=0,this.root?(this.root.intersectsLine(e,t,i),t.size):0},toArray(e){if(this.root){const t=this.root.toArray(e);e.push(t,0,0,0)}return e}});const Se=we,Fe=m().add("BVH",Se),Oe=new Float32Array([0,0,0,1]),Ae=new Float32Array([0,0,0,1,1,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,1,-.5,-.5,0,1,.5,-.5,0,1,.5,.5,0,1,-.5,-.5,0,1,.5,.5,0,1,-.5,.5,0,1]);function Ne(e){ee().call(this,e),this.addType(v().ParticleSystem),this._particleSize.setUnit("length"),e.getSpecificationVersion()<=3.3&&(this.addAlias("colorRamp",this._color),this.addAlias("texCoordRamp",this._texCoord));const t=this.getBrowser();this.maxParticles=0,this.numParticles=0,this.spriteSize=new(F()),this.samplers=new Set,this.forcePhysicsModelNodes=[],this.forces=new Float32Array(4),this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.colorRamp=new Float32Array,this.texCoordRamp=new Float32Array,this.scaleRamp=new Float32Array,this.geometryContext=new(ie())({textureCoordinateNode:t.getDefaultTextureCoordinate()}),this.creationTime=0,this.pauseTime=0,this.deltaTime=0,this.particlesStride=7*Float32Array.BYTES_PER_ELEMENT*4,this.particleOffsets=Array.from({length:7},(e,t)=>4*Float32Array.BYTES_PER_ELEMENT*t),this.particleOffset=this.particleOffsets[0],this.colorOffset=this.particleOffsets[1],this.velocityOffset=this.particleOffsets[2],this.matrixOffset=this.particleOffsets[3],this.texCoordOffset=0,this.instancesStride=this.particlesStride}Object.assign(Object.setPrototypeOf(Ne.prototype,ee().prototype),{initialize(){ee().prototype.initialize.call(this);const e=this.getBrowser(),t=e.getContext();this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_enabled__",this),this._geometryType.addInterest("set_geometryType__",this),this._geometryType.addInterest("set_texCoord__",this),this._maxParticles.addInterest("set_enabled__",this),this._particleLifetime.addInterest("set_particleLifetime__",this),this._particleLifetime.addInterest("set_bbox__",this),this._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._lifetimeVariation.addInterest("set_bbox__",this),this._particleSize.addInterest("set_particleSize__",this),this._emitter.addInterest("set_emitter__",this),this._emitter.addInterest("set_bbox__",this),this._physics.addInterest("set_physics__",this),this._colorKey.addInterest("set_color__",this),this._color.addInterest("set_colorRamp__",this),this._texCoordKey.addInterest("set_texCoord__",this),this._texCoord.addInterest("set_texCoordRamp__",this),this._scaleKey.addInterest("set_scale__",this),this._scale.addInterest("set_scaleRamp__",this),this.inputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(se())(t),thickLinesVertexArrayObject:new(se())(t)}),this.outputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(se())(t),thickLinesVertexArrayObject:new(se())(t)}),this.boundedTexture=this.createTexture();for(const e of Object.values(p))this[e]=this.createTexture();this.geometryBuffer=this.createBuffer(),this.texCoordBuffers=new Array(e.getMaxTexCoords()).fill(this.geometryBuffer),this.lineGeometryNode=new(ce())(this.getExecutionContext()),this.lineCoordinateNode=new(de())(this.getExecutionContext()),this.lineCoordinateNode._point=[0,0,-.5,0,0,.5],this.lineGeometryNode._vertexCount=[2],this.lineGeometryNode._coord=this.lineCoordinateNode,this.lineCoordinateNode.setup(),this.lineGeometryNode.setup(),this.set_emitter__(),this.set_enabled__(),this.set_geometryType__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_particleSize__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__(),this.set_scaleRamp__(),this.set_bbox__()},getShapeKey(){return this.numTexCoords?2:1},getGeometryContext(){return this.geometryType===x().GEOMETRY?this.getGeometry():this.geometryContext},getGeometryType(){return this.geometryType},getNumInstances(){return this.numParticles},getInstances(){return this.outputParticles},set_bbox__(){if(this.isDefaultBBoxSize())if(this.boundedPhysicsModelNodes.length){this.bbox.set();for(const e of this.boundedPhysicsModelNodes){const t=e.getBBox();t&&this.bbox.add(t)}}else this.emitterNode?.getBBox(this.bbox,this);else this.bbox.set(this._bboxSize.getValue(),this._bboxCenter.getValue());this.bboxSize.assign(this.bbox.size),this.bboxCenter.assign(this.bbox.center)},set_transparent__(){const e=this.appearanceNode.getAlphaMode();e===re().AUTO?(this.setTransparent(this.getAppearance().isTransparent()||this.colorRampNode?.isTransparent()||this.geometryType===x().GEOMETRY&&this.geometryNode?.isTransparent()),this.setAlphaMode(this.isTransparent()?re().BLEND:re().OPAQUE)):(this.setTransparent(e===re().BLEND),this.setAlphaMode(e))},set_live__(){this.getLive().getValue()?this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime&&(this.creationTime+=Date.now()/1e3-this.pauseTime,this.pauseTime=0)):this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().removeInterest("animateParticles",this),0===this.pauseTime&&(this.pauseTime=Date.now()/1e3))},set_enabled__(){this._enabled.getValue()&&this._maxParticles.getValue()?this._isActive.getValue()||(this.getLive().getValue()?(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime=0):this.pauseTime=Date.now()/1e3,this._isActive=!0,delete this.traverse):this._isActive.getValue()&&(this.getLive().getValue()&&this.getBrowser().sensorEvents().removeInterest("animateParticles",this),this._isActive=!1,this.numParticles=0,this.traverse=Function.prototype),this.set_maxParticles__()},set_geometryType__(){const e=this.getBrowser().getContext();switch(this.geometryType=x().get(this._geometryType.getValue())??x().QUAD,this.geometryType){case x().POINT:this.geometryContext.geometryType=0,this.geometryContext.hasNormals=!1,this.texCoordCount=0,this.vertexCount=1,this.hasNormals=!1,this.verticesOffset=0,this.primitiveMode=e.POINTS,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,Oe,e.DYNAMIC_DRAW);break;case x().LINE:this.geometryContext.geometryType=1,this.geometryContext.hasNormals=!1,this.texCoordCount=0;break;case x().TRIANGLE:case x().QUAD:case x().SPRITE:this.geometryContext.geometryType=2,this.geometryContext.hasNormals=!0,this.texCoordCount=4,this.vertexCount=6,this.hasNormals=!0,this.texCoordsOffset=0,this.normalOffset=24*Float32Array.BYTES_PER_ELEMENT,this.verticesOffset=27*Float32Array.BYTES_PER_ELEMENT,this.primitiveMode=e.TRIANGLES,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,Ae,e.DYNAMIC_DRAW);break;case x().GEOMETRY:this.texCoordCount=0}this.geometryContext.updateGeometryKey(),this.updateVertexArrays(),this.set_objects__()},set_maxParticles__(){const e=this.numParticles,t=Math.max(0,this._maxParticles.getValue());this.maxParticles=t,this.numParticles=Math.min(e,t),this.emitterNode.isExplosive()||(this.creationTime=Date.now()/1e3),this.resizeBuffers(e),this.updateVertexArrays(),this.set_objects__()},set_particleLifetime__(){this.particleLifetime=Math.max(this._particleLifetime.getValue(),0)},set_lifetimeVariation__(){this.lifetimeVariation=Math.max(this._lifetimeVariation.getValue(),0)},set_particleSize__(){this.lineCoordinateNode._point[0].z=-this._particleSize.y/2,this.lineCoordinateNode._point[1].z=+this._particleSize.y/2,this.spriteSize.set(...this._particleSize)},set_emitter__(){this.emitterNode?._bbox_changed.removeInterest("set_bbox__",this),this.emitterNode=L()(v().X3DParticleEmitterNode,this._emitter)??this.getBrowser().getDefaultEmitter(),this.emitterNode._bbox_changed.addInterest("set_bbox__",this)},set_physics__(){const e=this._physics.getValue(),t=this.forcePhysicsModelNodes,i=this.boundedPhysicsModelNodes;for(const e of i)e.removeInterest("set_boundedPhysics__",this),e.removeInterest("set_bbox__",this);t.length=0,i.length=0;for(let n=0,s=e.length;n<s;++n)try{const s=e[n].getValue().getInnerNode(),o=s.getType();for(let e=o.length-1;e>=0;--e){switch(o[e]){case v().ForcePhysicsModel:case v().WindPhysicsModel:t.push(s);break;case v().BoundedPhysicsModel:i.push(s);break;default:continue}break}}catch{}for(const e of i)e.addInterest("set_boundedPhysics__",this),e.addInterest("set_bbox__",this);this.set_boundedPhysics__()},set_boundedPhysics__(){const e=this.getBrowser().getContext(),t=this.boundedPhysicsModelNodes,i=this.boundedNormals,n=this.boundedVertices;i.length=0,n.length=0;for(let e=0,s=t.length;e<s;++e)t[e].addGeometry(i,n);const s=new Fe(n,i).toArray([]),o=n.length/4,r=i.length/3,a=s.length/4,c=Math.ceil(Math.sqrt(o+r+a)),l=new Float32Array(c*c*4);this.boundedVerticesIndex=0,this.boundedNormalsIndex=o,this.boundedHierarchyIndex=this.boundedNormalsIndex+r,this.boundedHierarchyRoot=this.boundedHierarchyIndex+a-1,l.set(n);for(let e=4*this.boundedNormalsIndex,t=0,n=i.length;t<n;e+=4,t+=3)l[e+0]=i[t+0],l[e+1]=i[t+1],l[e+2]=i[t+2];l.set(s,4*this.boundedHierarchyIndex),c&&(e.bindTexture(e.TEXTURE_2D,this.boundedTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,c,c,0,e.RGBA,e.FLOAT,l))},set_colorRamp__(){this.colorRampNode?.removeInterest("set_color__",this),this.colorRampNode=L()(v().X3DColorNode,this._color),this.colorRampNode?.addInterest("set_color__",this),this.set_color__(),this.set_transparent__()},set_color__(){const e=this.getBrowser().getContext(),t=this._colorKey,i=t.length,n=Math.ceil(Math.sqrt(2*i));let s=this.colorRamp;n*n*4>s.length&&(s=this.colorRamp=new Float32Array(n*n*4));for(let e=0;e<i;++e)s[4*e]=t[e];this.colorRampNode?s.set(this.colorRampNode.addColors([],i).slice(0,4*i),4*i):s.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.colors]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numColors=i,this.geometryContext.colorMaterial=!(!i||!this.colorRampNode),i?this.samplers.add(p.colors):this.samplers.delete(p.colors),this.geometryContext.updateGeometryKey(),this.updateVertexArrays()},set_texCoordRamp__(){this.texCoordRampNode?.removeInterest("set_texCoord__",this),this.texCoordRampNode=L()(v().X3DTextureCoordinateNode,this._texCoord),this.texCoordRampNode?.addInterest("set_texCoord__",this),this.set_texCoord__()},set_texCoord__(){const e=this.getBrowser().getContext(),t=this._texCoordKey,i=t.length,n=Math.ceil(Math.sqrt(i+i*this.texCoordCount));let s=this.texCoordRamp;n*n*4>s.length?s=this.texCoordRamp=new Float32Array(n*n*4):s.fill(0);for(let e=0;e<i;++e)s[4*e]=t[e];this.texCoordRampNode&&s.set(this.texCoordRampNode.addPoints([]).slice(0,i*this.texCoordCount*4),4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.texCoords]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numTexCoords=this.texCoordRampNode?i:0,i?this.samplers.add(p.texCoords):this.samplers.delete(p.texCoords),this.updateVertexArrays()},set_scaleRamp__(){this.scaleRampNode?.removeInterest("set_scale__",this),this.scaleRampNode=L()(v().Coordinate,this._scale),this.scaleRampNode?.addInterest("set_scale__",this),this.set_scale__()},set_scale__(){const e=this.getBrowser().getContext(),t=this._scaleKey,i=t.length,n=Math.ceil(Math.sqrt(2*i));let s=this.scaleRamp;n*n*4>s.length?s=this.scaleRamp=new Float32Array(n*n*4):s.fill(0);for(let e=0;e<i;++e)s[4*e]=t[e];this.scaleRampNode?s.set(this.scaleRampNode.addPoints([],i).slice(0,4*i),4*i):s.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.scales]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numScales=i,i?this.samplers.add(p.scales):this.samplers.delete(p.scales),this.updateVertexArrays()},updateVertexArrays(){this.inputParticles.vertexArrayObject.update(),this.outputParticles.vertexArrayObject.update(),this.inputParticles.thickLinesVertexArrayObject.update(),this.outputParticles.thickLinesVertexArrayObject.update()},createTexture(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},createBuffer(){const e=this.getBrowser().getContext(),t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Uint32Array,e.DYNAMIC_DRAW),t},resizeBuffers(e){const t=this.getBrowser().getContext(),i=this.maxParticles,n=this.particlesStride,s=Object.assign(t.createBuffer(),this.outputParticles),o=new Uint8Array(i*n);t.bindBuffer(t.ARRAY_BUFFER,this.inputParticles),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW),t.bindBuffer(t.COPY_READ_BUFFER,this.outputParticles),t.bindBuffer(t.ARRAY_BUFFER,s),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW),t.copyBufferSubData(t.COPY_READ_BUFFER,t.ARRAY_BUFFER,0,0,Math.min(i*n,e*n)),t.deleteBuffer(this.outputParticles),this.outputParticles=s},animateParticles(){const e=this.getBrowser(),t=e.getContext(),i=this.emitterNode,n=1/Math.max(this.getBrowser().getCurrentFrameRate(),10);let s=this.deltaTime=(14*this.deltaTime+n)/15;if(i.isExplosive()){const e=Date.now()/1e3,t=this.particleLifetime+this.particleLifetime*this.lifetimeVariation;e-this.creationTime>t?(this.creationTime=e,this.numParticles=this.maxParticles,this.createParticles=this._createParticles.getValue(),s=Number.POSITIVE_INFINITY,this.set_objects__()):this.createParticles=!1}else if(this.createParticles=this._createParticles.getValue(),this.numParticles<this.maxParticles){const e=Date.now()/1e3,t=Math.max(0,Math.floor((e-this.creationTime)*this.maxParticles/this.particleLifetime));t&&(this.creationTime=e),this.numParticles=Math.min(this.maxParticles,this.numParticles+t),this.set_objects__()}if(i.getMass()){const e=this.forcePhysicsModelNodes;let n=e.length,o=this.forces,r=s/i.getMass();4*n>o.length&&(o=this.forces=new Float32Array(4*n));let a=0;for(let t=0;t<n;++t)a+=!e[t].addForce(t-a,i,r,o);this.numForces=n-=a,n?(t.bindTexture(t.TEXTURE_2D,this[p.forces]),t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,n,1,0,t.RGBA,t.FLOAT,o),this.samplers.add(p.forces)):this.samplers.delete(p.forces)}else this.numForces=0,this.samplers.delete(p.forces);const o=this.outputParticles;this.outputParticles=this.inputParticles,this.inputParticles=o,i.animate(this,s),e.addBrowserEvent()},updateSprite:(()=>{const e=new Float32Array(Ae),t=[new(F())(-.5,-.5,0),new(F())(.5,-.5,0),new(F())(.5,.5,0),new(F())(-.5,-.5,0),new(F())(.5,.5,0),new(F())(-.5,.5,0)],i=new(F());return function(n,s){for(let t=0;t<3;++t)e[24+t]=s[6+t];const o=this.spriteSize;for(let n=0;n<6;++n){const r=27+4*n;s.multVecMatrix(i.assign(t[n]).multVec(o)),e.set(i,r)}n.bindBuffer(n.ARRAY_BUFFER,this.geometryBuffer),n.bufferData(n.ARRAY_BUFFER,e,n.DYNAMIC_DRAW)}})(),displaySimple(e,t,i){switch(this.geometryType){case x().LINE:this.lineGeometryNode.displaySimpleInstanced(e,i,this);break;case x().GEOMETRY:this.getGeometry().displaySimpleInstanced(e,i,this);break;case x().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));default:{const t=this.outputParticles;if(t.vertexArrayObject.enable(i.getProgram())){const n=this.particlesStride;i.enableParticleAttribute(e,t,n,this.particleOffset,1),i.enableInstanceMatrixAttribute(e,t,n,this.matrixOffset,1),i.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(this.primitiveMode,0,this.vertexCount,this.numParticles);break}}},display(e,t){switch(this.geometryType){case x().LINE:this.lineGeometryNode.displayInstanced(e,t,this);break;case x().GEOMETRY:this.getGeometry().displayInstanced(e,t,this);break;case x().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));case x().QUAD:case x().TRIANGLE:{const i=he().prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(i?e.CCW:e.CW),e.enable(e.CULL_FACE)}default:{const i=t.viewport,n=this.getBrowser(),s=this.getAppearance(),o=s.getRenderModes(),r=s.getShader(this.geometryContext,t),a=n.getPrimitiveMode(this.primitiveMode);this.geometryType!==x().POINT||t.transparent||e.enable(e.SAMPLE_ALPHA_TO_COVERAGE),e.viewport(...i);for(const t of o)t.enable(e);if(r.enable(e),r.setUniforms(e,t,this.geometryContext),this.numTexCoords){const t=n.getTextureUnit();e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this[p.texCoords]),e.uniform1i(r.x3d_TexCoordRamp,t)}const c=this.outputParticles;if(c.vertexArrayObject.enable(r.getProgram())){const{particlesStride:t}=this;r.enableParticleAttribute(e,c,t,this.particleOffset,1),r.enableParticleVelocityAttribute(e,c,t,this.velocityOffset,1),r.enableInstanceMatrixAttribute(e,c,t,this.matrixOffset,1),this.geometryContext.colorMaterial&&(r.enableColorAttribute(e,c,t,this.colorOffset),r.colorAttributeDivisor(e,1)),this.texCoordCount&&r.enableTexCoordAttribute(e,this.texCoordBuffers,0,this.texCoordOffset),this.hasNormals&&(r.enableNormalAttribute(e,this.geometryBuffer,0,this.normalOffset),r.normalAttributeDivisor(e,this.maxParticles)),r.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(a,0,this.vertexCount,this.numParticles);for(const t of o)t.disable(e);n.resetTextureUnits(),this.geometryType!==x().POINT||t.transparent||e.disable(e.SAMPLE_ALPHA_TO_COVERAGE);break}}},getScreenAlignedRotation:(()=>{const e=new(he()),t=new(F()),i=new(F()),n=new(F()),s=new(_e());return function(o){return e.assign(o).inverse(),e.multDirMatrix(t.assign(F().Y_AXIS)),e.multDirMatrix(n.assign(F().Z_AXIS)),t.cross(n),i.assign(n).cross(t),t.normalize(),i.normalize(),n.normalize(),s.set(...t,...i,...n),s}})()}),Object.defineProperties(Ne,{...u().getStaticProperties("ParticleSystem","ParticleSystems",2,"children","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().initializeOnly,"geometryType",new(o().SFString)("QUAD")),new(a())(v().inputOutput,"createParticles",new(o().SFBool)(!0)),new(a())(v().inputOutput,"maxParticles",new(o().SFInt32)(200)),new(a())(v().inputOutput,"particleLifetime",new(o().SFFloat)(5)),new(a())(v().inputOutput,"lifetimeVariation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"particleSize",new(o().SFVec2f)(.02,.02)),new(a())(v().initializeOnly,"emitter",new(o().SFNode)),new(a())(v().initializeOnly,"physics",new(o().MFNode)),new(a())(v().initializeOnly,"colorKey",new(o().MFFloat)),new(a())(v().initializeOnly,"color",new(o().SFNode)),new(a())(v().initializeOnly,"texCoordKey",new(o().MFFloat)),new(a())(v().initializeOnly,"texCoord",new(o().SFNode)),new(a())(v().initializeOnly,"scaleKey",new(o().MFFloat)),new(a())(v().initializeOnly,"scale",new(o().SFNode)),new(a())(v().outputOnly,"isActive",new(o().SFBool)),new(a())(v().inputOutput,"pointerEvents",new(o().SFBool)(!0)),new(a())(v().inputOutput,"castShadow",new(o().SFBool)(!0)),new(a())(v().inputOutput,"visible",new(o().SFBool)(!0)),new(a())(v().inputOutput,"bboxDisplay",new(o().SFBool)),new(a())(v().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(a())(v().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(a())(v().inputOutput,"appearance",new(o().SFNode)),new(a())(v().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const Pe=Ne,De=m().add("ParticleSystem",Pe),Ve=e.IndexedLineSet;var Ce=t.n(Ve);function Be(e){w.call(this,e),this.addType(v().PolylineEmitter),this.verticesIndex=-1,this.polylinesNode=new(Ce())(e),this.polylinesArray=new Float32Array}Object.assign(Object.setPrototypeOf(Be.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.polylinesTexture=this.createTexture(),this._direction.addInterest("set_direction__",this),this._set_coordIndex.addFieldInterest(this._coordIndex),this._coordIndex.addFieldInterest(this.polylinesNode._coordIndex),this._coord.addFieldInterest(this.polylinesNode._coord),this.polylinesNode._coordIndex=this._coordIndex,this.polylinesNode._coord=this._coord,this.polylinesNode.setPrivate(!0),this.polylinesNode.setup(),this.polylinesNode._rebuild.addInterest("set_polylines__",this),this.addDefine("#define X3D_POLYLINE_EMITTER"),this.addSampler("polylines"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("polylines","uniform sampler2D polylines;"),this.addCallback(this.set_direction__),this.addCallback(this.set_verticesIndex__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (verticesIndex < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n // Determine index0, index1 and weight.\n\n float lastLengthSoFar = texelFetch (polylines, verticesIndex - 1, 0) .x;\n float fraction = random () * lastLengthSoFar;\n\n int index0 = 0;\n int index1 = 0;\n float weight = 0.0;\n\n interpolate (polylines, verticesIndex, fraction, index0, index1, weight);\n\n // Interpolate and return position.\n\n index0 *= 2;\n index1 = index0 + 1;\n\n vec4 vertex0 = texelFetch (polylines, verticesIndex + index0, 0);\n vec4 vertex1 = texelFetch (polylines, verticesIndex + index1, 0);\n\n return mix (vertex0, vertex1, weight);\n }\n }"),this.set_polylines__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.polylinesNode.getBBox().center).add(this.polylinesNode.getBBox())}})(),set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})(),set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_polylines__:(()=>{const e=new(F()),t=new(F());return function(){const i=this.getBrowser().getContext(),n=this.polylinesNode.getVertices().getValue(),s=n.length/4,o=s/2+1,r=Math.ceil(Math.sqrt(o+s)),a=o;let c=this.polylinesArray;c.length<r*r*4&&(c=this.polylinesArray=new Float32Array(r*r*4));let l=0;for(let i=0,s=n.length;i<s;i+=8)e.set(n[i],n[i+1],n[i+2]),t.set(n[i+4],n[i+5],n[i+6]),c[i/2+4]=l+=t.subtract(e).norm();c.set(n,4*a),this.verticesIndex=s?a:-1,r&&(i.bindTexture(i.TEXTURE_2D,this.polylinesTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,r,r,0,i.RGBA,i.FLOAT,c)),this.set_verticesIndex__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.polylinesTextureUnit),e.bindTexture(e.TEXTURE_2D,this.polylinesTexture)}}),Object.defineProperties(Be,{...u().getStaticProperties("PolylineEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOnly,"set_coordIndex",new(o().MFInt32)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(a())(v().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const Me=Be,Ue=m().add("PolylineEmitter",Me),ze=e.Triangle3;var Le=t.n(ze);function Xe(e){w.call(this,e),this.addType(v().SurfaceEmitter),this.verticesIndex=-1,this.normalsIndex=-1,this.surfaceArray=new Float32Array}Object.assign(Object.setPrototypeOf(Xe.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.surfaceTexture=this.createTexture(),this._surface.addInterest("set_surface__",this),this.addDefine("#define X3D_SURFACE_EMITTER"),this.addSampler("surface"),this.addUniform("solid","uniform bool solid;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("surface","uniform sampler2D surface;"),this.addCallback(this.set_solid__),this.addCallback(this.set_verticesIndex__),this.addCallback(this.set_normalsIndex__),this.addFunction("vec4 position; vec3 getRandomVelocity ()\n {\n if (verticesIndex < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n vec3 normal;\n\n getRandomPointOnSurface (surface, verticesIndex, normalsIndex, position, normal);\n\n if (solid == false && random () > 0.5)\n normal = -normal;\n\n return normal * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return verticesIndex < 0 ? vec4 (NaN) : position;\n }"),this.set_surface__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){if(!this.surfaceNode)return t.set();const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.surfaceNode.getBBox().center).add(this.surfaceNode.getBBox())}})(),set_surface__(){this.surfaceNode&&(this.surfaceNode._solid.removeInterest("set_solid__",this),this.surfaceNode._rebuild.removeInterest("set_geometry__",this)),this.surfaceNode=L()(v().X3DGeometryNode,this._surface),this.surfaceNode&&(this.surfaceNode._solid.addInterest("set_solid__",this),this.surfaceNode._rebuild.addInterest("set_geometry__",this)),this.set_solid__(),this.set_geometry__()},set_solid__(){this.setUniform("uniform1i","solid",this.surfaceNode?._solid.getValue()??!0)},set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_normalsIndex__(){this.setUniform("uniform1i","normalsIndex",this.normalsIndex)},set_geometry__:(()=>{const e=new(F()),t=new(F()),i=new(F());return function(){const n=this.getBrowser().getContext();if(this.surfaceNode){const s=this.surfaceNode.getVertices().getValue(),o=this.surfaceNode.getNormals().getValue(),r=s.length/4,a=r/3+1,c=Math.ceil(Math.sqrt(a+r+r)),l=a,d=l+r;let u=this.surfaceArray;u.length<c*c*4&&(u=this.surfaceArray=new Float32Array(c*c*4));let h=0;for(let n=0,o=s.length;n<o;n+=12)e.set(s[n],s[n+1],s[n+2]),t.set(s[n+4],s[n+5],s[n+6]),i.set(s[n+8],s[n+9],s[n+10]),u[n/3+4]=h+=Le().area(e,t,i);u.set(s,4*l);for(let e=4*d,t=0,i=o.length;t<i;e+=4,t+=3)u[e+0]=o[t+0],u[e+1]=o[t+1],u[e+2]=o[t+2];this.verticesIndex=r?l:-1,this.normalsIndex=r?d:-1,c&&(n.bindTexture(n.TEXTURE_2D,this.surfaceTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,c,c,0,n.RGBA,n.FLOAT,u))}else this.verticesIndex=-1,this.normalsIndex=-1;this.set_verticesIndex__(),this.set_normalsIndex__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.surfaceTextureUnit),e.bindTexture(e.TEXTURE_2D,this.surfaceTexture)}}),Object.defineProperties(Xe,{...u().getStaticProperties("SurfaceEmitter","ParticleSystems",2,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"surface",new(o().SFNode))]),enumerable:!0}});const ke=Xe,je=m().add("SurfaceEmitter",ke),Ge=e.IndexedFaceSet;var He=t.n(Ge);function Ye(e){w.call(this,e),this.addType(v().VolumeEmitter),this.verticesIndex=-1,this.normalsIndex=-1,this.hierarchyIndex=-1,this.hierarchyRoot=-1,this.volumeNode=new(He())(e),this.volumeArray=new Float32Array}Object.assign(Object.setPrototypeOf(Ye.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.volumeTexture=this.createTexture(),this._set_coordIndex.addFieldInterest(this._coordIndex),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.volumeNode._coordIndex),this._coord.addFieldInterest(this.volumeNode._coord),this.volumeNode._creaseAngle=Math.PI,this.volumeNode._convex=!1,this.volumeNode._coordIndex=this._coordIndex,this.volumeNode._coord=this._coord,this.volumeNode.setPrivate(!0),this.volumeNode.setup(),this.volumeNode._rebuild.addInterest("set_geometry__",this),this.addDefine("#define X3D_VOLUME_EMITTER"),this.addSampler("volume"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("hierarchyIndex","uniform int hierarchyIndex;"),this.addUniform("hierarchyRoot","uniform int hierarchyRoot;"),this.addUniform("volume","uniform sampler2D volume;"),this.addCallback(this.set_direction__),this.addCallback(this.set_verticesIndex__),this.addCallback(this.set_normalsIndex__),this.addCallback(this.set_hierarchyIndex__),this.addCallback(this.set_hierarchyRoot__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (hierarchyRoot < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (hierarchyRoot < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n vec4 point;\n vec3 normal;\n\n getRandomPointOnSurface (volume, verticesIndex, normalsIndex, point, normal);\n\n Line3 line = Line3 (point .xyz, getRandomSurfaceNormal (normal));\n\n vec4 points [ARRAY_SIZE];\n\n int numIntersections = getIntersections (volume, verticesIndex, hierarchyIndex, hierarchyRoot, line, points);\n\n numIntersections -= numIntersections % 2; // We need an even count of intersections.\n\n switch (numIntersections)\n {\n case 0:\n return vec4 (0.0);\n case 2:\n break;\n default:\n sort (points, numIntersections, plane3 (line .point, line .direction));\n break;\n }\n\n int index = int (fract (random ()) * float (numIntersections / 2)) * 2; // Select random intersection.\n\n return mix (points [index], points [index + 1], random ());\n }\n }"),this.set_geometry__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.volumeNode.getBBox().center).add(this.volumeNode.getBBox())}})(),set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})(),set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_normalsIndex__(){this.setUniform("uniform1i","normalsIndex",this.normalsIndex)},set_hierarchyIndex__(){this.setUniform("uniform1i","hierarchyIndex",this.hierarchyIndex)},set_hierarchyRoot__(){this.setUniform("uniform1i","hierarchyRoot",this.hierarchyRoot)},set_geometry__:(()=>{const e=new(F()),t=new(F()),i=new(F());return function(){const n=this.getBrowser().getContext(),s=this.volumeNode.getVertices().getValue(),o=this.volumeNode.getNormals().getValue(),r=new Fe(s,o).toArray([]),a=s.length/4,c=o.length/3,l=a/3+1,d=r.length/4,u=Math.ceil(Math.sqrt(l+a+a+d)),h=l,m=h+a,_=m+c;let p=this.volumeArray;p.length<u*u*4&&(p=this.volumeArray=new Float32Array(u*u*4));let f=0;for(let n=0,o=s.length;n<o;n+=12)e.set(s[n],s[n+1],s[n+2]),t.set(s[n+4],s[n+5],s[n+6]),i.set(s[n+8],s[n+9],s[n+10]),p[n/3+4]=f+=Le().area(e,t,i);p.set(s,4*h);for(let e=4*m,t=0,i=o.length;t<i;e+=4,t+=3)p[e+0]=o[t+0],p[e+1]=o[t+1],p[e+2]=o[t+2];p.set(r,4*_),this.verticesIndex=h,this.normalsIndex=m,this.hierarchyIndex=_,this.hierarchyRoot=_+d-1,u&&(n.bindTexture(n.TEXTURE_2D,this.volumeTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,u,u,0,n.RGBA,n.FLOAT,p)),this.set_verticesIndex__(),this.set_normalsIndex__(),this.set_hierarchyIndex__(),this.set_hierarchyRoot__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.volumeTextureUnit),e.bindTexture(e.TEXTURE_2D,this.volumeTexture)}}),Object.defineProperties(Ye,{...u().getStaticProperties("VolumeEmitter","ParticleSystems",2,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOnly,"set_coordIndex",new(o().MFInt32)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().initializeOnly,"internal",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(a())(v().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const qe=Ye,We=m().add("VolumeEmitter",qe),Ke=e.Algorithm;var Ze=t.n(Ke);function Qe(e){U.call(this,e),this.addType(v().WindPhysicsModel),this._speed.setUnit("speed"),e.getSpecificationVersion()<=3.3&&(this._direction=new(F()))}Object.assign(Object.setPrototypeOf(Qe.prototype,U.prototype),{getRandomSpeed(e){const t=Math.max(this._speed.getValue(),0),i=t*Math.max(this._gustiness.getValue(),0);return e.getRandomValue(Math.max(0,t-i),t+i)},addForce:(()=>{const e=new(F());return function(t,i,n,s){if(this._enabled.getValue()){const o=i.getSurfaceArea(),r=this.getRandomSpeed(i),a=10**(2*Math.log(r))*.64615;return this._direction.getValue().equals(F().ZERO)?i.getRandomNormal(e):e.assign(this._direction.getValue()).normalize(),s.set(e.multiply(o*a*n),4*t),s[4*t+3]=Math.PI*Ze().clamp(this._turbulence.getValue(),0,1),!0}return!1}})()}),Object.defineProperties(Qe,{...u().getStaticProperties("WindPhysicsModel","ParticleSystems",1,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(1,0,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)(.1)),new(a())(v().inputOutput,"gustiness",new(o().SFFloat)(.1)),new(a())(v().inputOutput,"turbulence",new(o().SFFloat))]),enumerable:!0}});const $e=Qe,Je=m().add("WindPhysicsModel",$e);n().add({name:"ParticleSystems",concreteNodes:[j,Y,K,$,De,N,Ue,je,We,Je],abstractNodes:[w,U],browserContext:C});m().add("ParticleSystemsComponent",undefined)})();
|
|
1
|
+
/* X_ITE v12.1.9 */
|
|
2
|
+
const e=window[Symbol.for("X_ITE.X3D-12.1.9")];(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=e.Components;var n=t.n(i);const s=e.Fields;var o=t.n(s);const r=e.X3DFieldDefinition;var a=t.n(r);const c=e.FieldDefinitionArray;var l=t.n(c);const d=e.X3DNode;var u=t.n(d);const h=e.Namespace;var m=t.n(h);const _={forces:Symbol(),colors:Symbol(),texCoords:Symbol(),scales:Symbol()},p=m().add("ParticleSampler",_),f=e.GeometryType;var x=t.n(f);const g=e.X3DConstants;var v=t.n(g);const y=m().add("Line3.glsl","\n#if defined(X3D_BOUNDED_VOLUME)||defined(X3D_VOLUME_EMITTER)\nstruct Line3{vec3 point;vec3 direction;};bool intersects(const in Line3 line,const in vec3 a,const in vec3 b,const in vec3 c,out vec3 r){vec3 edge1=b-a;vec3 edge2=c-a;vec3 pvec=cross(line.direction,edge2);float det=dot(edge1,pvec);if(det==0.)return false;float inv_det=1./det;vec3 tvec=line.point-a;float u=dot(tvec,pvec)*inv_det;if(u<0.||u>1.)return false;vec3 qvec=cross(tvec,edge1);float v=dot(line.direction,qvec)*inv_det;if(v<0.||u+v>1.)return false;r=vec3(u,v,1.-u-v);return true;}\n#endif\n"),T=m().add("Plane3.glsl","\n#if defined(X3D_BOUNDED_VOLUME)||defined(X3D_VOLUME_EMITTER)\nstruct Plane3{vec3 normal;float distanceFromOrigin;};Plane3 plane3(const in vec3 point,const in vec3 normal){return Plane3(normal,dot(normal,point));}float plane_distance(const in Plane3 plane,const in vec3 point){return dot(point,plane.normal)-plane.distanceFromOrigin;}bool intersects(const in Plane3 plane,const in Line3 line,out vec3 point){float theta=dot(line.direction,plane.normal);if(theta==0.)return false;float t=(plane.distanceFromOrigin-dot(plane.normal,line.point))/theta;point=line.point+line.direction*t;return true;}void sort(inout vec4 points[ARRAY_SIZE],const in int count,const in Plane3 plane){const float shrink=1./1.3;int gap=count;bool exchanged=true;while(exchanged){gap=int(float(gap)*shrink);if(gap<=1){exchanged=false;gap=1;}for(int i=0,l=count-gap;i<l;++i){int j=gap+i;if(plane_distance(plane,points[i].xyz)>plane_distance(plane,points[j].xyz)){vec4 tmp1=points[i];points[i]=points[j];points[j]=tmp1;exchanged=true;}}}}int min_index(const in vec4 points[ARRAY_SIZE],const in int count,const in float value,const in Plane3 plane){int index=-1;float dist=1000000.;for(int i=0;i<count;++i){float d=plane_distance(plane,points[i].xyz);if(d>=value&&d<dist){dist=d;index=i;}}return index;}\n#endif\n"),E=m().add("Box3.glsl","\n#if defined(X3D_VOLUME_EMITTER)||defined(X3D_BOUNDED_VOLUME)\nbool intersects(const in vec3 min,const in vec3 max,const in Line3 line){vec3 intersection;if(intersects(plane3(max,vec3(0.,0.,1.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(min,vec3(0.,0.,-1.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(max,vec3(0.,1.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(min,vec3(0.,-1.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(max,vec3(1.,0.,0.)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.yz,max.yz),vec4(min.yz,intersection.yz))))return true;}return false;}\n#endif\n"),I=m().add("BVH.glsl","\n#if defined(X3D_VOLUME_EMITTER)||defined(X3D_BOUNDED_VOLUME)\n#define BVH_NODE 0\n#define BVH_TRIANGLE 1\n#define BVH_STACK_SIZE 32\nint bvhNodeIndex=0;void setBVHIndex(const in int index){bvhNodeIndex=index;}int getBVHRoot(const in sampler2D volume,const in int hierarchyIndex,const in int rootIndex){return int(texelFetch(volume,rootIndex,0).x)+hierarchyIndex;}int getBVHType(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).x);}vec3 getBVHMin(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+1,0).xyz;}vec3 getBVHMax(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+2,0).xyz;}int getBVHLeft(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).y)+hierarchyIndex;}int getBVHRight(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).z)+hierarchyIndex;}int getBVHTriangle(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).y);}\n#if defined(X3D_VOLUME_EMITTER)\nint getIntersections(const in sampler2D volume,const in int verticesIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r))points[count++]=vec4(r.z*a+r.x*b+r.y*c,1.);current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nint getIntersections(const in sampler2D volume,const in int verticesIndex,const in int normalsIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE],out vec3 normals[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r)){points[count]=vec4(r.z*a+r.x*b+r.y*c,1.);int n=normalsIndex+t;vec3 n0=texelFetch(volume,n,0).xyz;vec3 n1=texelFetch(volume,n+1,0).xyz;vec3 n2=texelFetch(volume,n+2,0).xyz;normals[count]=r.z*n0+r.x*n1+r.y*n2;++count;}current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}\n#endif\n#endif\n");function b(e){u().call(this,e),this.addType(v().X3DParticleEmitterNode),this.addChildObjects(v().outputOnly,"bbox_changed",new(o().SFTime)),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.defines=[],this.samplers=[],this.uniforms=new Map,this.callbacks=[],this.functions=[],this.programs=new Map}Object.assign(Object.setPrototypeOf(b.prototype,u().prototype),{initialize(){u().prototype.initialize.call(this);const e=this.getBrowser().getContext();this.transformFeedback=e.createTransformFeedback(),this._on.addInterest("set_on__",this),this._speed.addInterest("set_speed__",this),this._variation.addInterest("set_variation__",this),this._mass.addInterest("set_mass__",this),this._surfaceArea.addInterest("set_surfaceArea__",this),this.addSampler("boundedVolume");for(const e in p)this.addSampler(e);this.addUniform("speed","uniform float speed;"),this.addUniform("variation","uniform float variation;"),this.addCallback(this.set_speed__),this.addCallback(this.set_variation__),this.addFunction(y),this.addFunction(T),this.addFunction(E),this.addFunction(I),this.set_on__(),this.set_mass__(),this.set_surfaceArea__()},isExplosive:()=>!1,getMass(){return this.mass},getSurfaceArea(){return this.surfaceArea},set_on__(){this.on=this._on.getValue()},set_speed__(){this.setUniform("uniform1f","speed",Math.max(this._speed.getValue(),0))},set_variation__(){this.setUniform("uniform1f","variation",Math.max(this._variation.getValue(),0))},set_mass__(){this.mass=Math.max(this._mass.getValue(),0)},set_surfaceArea__(){this.surfaceArea=Math.max(this._surfaceArea.getValue(),0)},getRandomValue:(e,t)=>Math.random()*(t-e)+e,getRandomNormal(e){const t=this.getRandomValue(-1,1)*Math.PI,i=this.getRandomValue(-1,1),n=Math.acos(i),s=Math.sin(n);return e.set(Math.sin(t)*s,Math.cos(t)*s,i)},animate(e,t){const i=this.getBrowser(),n=i.getContext(),s=this.getProgram(e),o=e.inputParticles;n.useProgram(s),n.uniform1i(s.randomSeed,4294967295*Math.random()),n.uniform1f(s.particleLifetime,e.particleLifetime),n.uniform1f(s.lifetimeVariation,e.lifetimeVariation),n.uniform1f(s.deltaTime,t),n.uniform2f(s.particleSize,e._particleSize.x,e._particleSize.y),e.boundedHierarchyRoot>-1&&(n.uniform1i(s.boundedVerticesIndex,e.boundedVerticesIndex),n.uniform1i(s.boundedNormalsIndex,e.boundedNormalsIndex),n.uniform1i(s.boundedHierarchyIndex,e.boundedHierarchyIndex),n.uniform1i(s.boundedHierarchyRoot,e.boundedHierarchyRoot),n.activeTexture(n.TEXTURE0+s.boundedVolumeTextureUnit),n.bindTexture(n.TEXTURE_2D,e.boundedTexture));for(const t of e.samplers)n.activeTexture(n.TEXTURE0+s[t]),n.bindTexture(n.TEXTURE_2D,e[t]);if(this.activateTextures(n,s),o.vertexArrayObject.enable(s)){const{particlesStride:t,particleOffsets:i}=e;for(const[e,r]of s.inputs)n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(r),n.vertexAttribPointer(r,4,n.FLOAT,!1,t,i[e])}n.bindFramebuffer(n.FRAMEBUFFER,i.getDefaultFramebuffer()),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,this.transformFeedback),n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,0,e.outputParticles),n.enable(n.RASTERIZER_DISCARD),n.beginTransformFeedback(n.POINTS),n.drawArrays(n.POINTS,0,e.numParticles),n.endTransformFeedback(),n.disable(n.RASTERIZER_DISCARD),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,null)},addDefine(e){this.defines.push(e)},addSampler(e){this.samplers.push(e)},addUniform(e,t){this.uniforms.set(e,t)},setUniform(e,t,i,n,s){const o=this.getBrowser().getContext();for(const r of this.programs.values())o.useProgram(r),o[e](r[t],i,n,s)},addCallback(e){this.callbacks.push(e)},addFunction(e){this.functions.push(e)},getProgram(e){const{geometryType:t,createParticles:i,numColors:n,numTexCoords:s,texCoordCount:o,numScales:r,numForces:a,boundedHierarchyRoot:c}=e;let l="";return l+=t,l+=i&&this.on?1:0,l+=".",l+=n,l+=".",l+=s,l+=".",l+=o,l+=".",l+=r,l+=".",l+=a,l+=".",l+=c,this.programs.get(l)??this.createProgram(l,e)},createProgram(e,t){const i=this.getBrowser(),n=i.getContext(),s=this.defines.slice();s.push(`#define X3D_GEOMETRY_TYPE ${t.geometryType}`),s.push(""+(t.createParticles&&this.on?"#define X3D_CREATE_PARTICLES":"")),s.push(`#define X3D_NUM_COLORS ${t.numColors}`),s.push(`#define X3D_NUM_TEX_COORDS ${t.numTexCoords}`),s.push(`#define X3D_TEX_COORDS_COUNT ${t.texCoordCount}`),s.push(`#define X3D_NUM_SCALES ${t.numScales}`),s.push(`#define X3D_NUM_FORCES ${t.numForces}`),s.push(""+(t.boundedHierarchyRoot>-1?"#define X3D_BOUNDED_VOLUME":""));const o=`#version 300 es\nprecision highp float;precision highp int;precision highp sampler2D;\n${s.join("\n")}\nuniform int randomSeed;uniform float particleLifetime;uniform float lifetimeVariation;uniform float deltaTime;uniform vec2 particleSize;\n#if X3D_NUM_FORCES>0\nuniform sampler2D forces;\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nuniform int boundedVerticesIndex;uniform int boundedNormalsIndex;uniform int boundedHierarchyIndex;uniform int boundedHierarchyRoot;uniform sampler2D boundedVolume;\n#endif\n#if X3D_NUM_COLORS>0\nuniform sampler2D colors;\n#endif\n#if X3D_NUM_TEX_COORDS>0\nuniform sampler2D texCoords;\n#endif\n#if X3D_NUM_SCALES>0\nuniform sampler2D scales;\n#endif\n${Array.from(this.uniforms.values()).join("\n")}\nin vec4 input0;in vec4 input2;in vec4 input6;out vec4 output0;out vec4 output1;out vec4 output2;out vec4 output3;out vec4 output4;out vec4 output5;out vec4 output6;\n${Object.entries(x()).map(([e,t])=>`#define ${e} ${t}`).join("\n")}\nconst int ARRAY_SIZE=32;const float M_PI=3.14159265359;uniform float NaN;vec4 texelFetch(const in sampler2D sampler,const in int index,const in int lod){int x=textureSize(sampler,lod).x;ivec2 p=ivec2(index % x,index/x);vec4 t=texelFetch(sampler,p,lod);return t;}vec3 save_normalize(const in vec3 vector){float l=length(vector);if(l==0.)return vec3(0);return vector/l;}vec4 Quaternion(const in vec3 fromVector,const in vec3 toVector){vec3 from=save_normalize(fromVector);vec3 to=save_normalize(toVector);float cos_angle=dot(from,to);vec3 cross_vec=cross(from,to);float cross_len=length(cross_vec);if(cross_len==0.){if(cos_angle>0.){return vec4(0.,0.,0.,1.);}else{vec3 t=cross(from,vec3(1.,0.,0.));if(dot(t,t)==0.)t=cross(from,vec3(0.,1.,0.));t=save_normalize(t);return vec4(t,0.);}}else{float s=sqrt(abs(1.-cos_angle)*.5);cross_vec=save_normalize(cross_vec);return vec4(cross_vec*s,sqrt(abs(1.+cos_angle)*.5));}}vec3 multVecQuat(const in vec3 v,const in vec4 q){float a=q.w*q.w-q.x*q.x-q.y*q.y-q.z*q.z;float b=2.*(v.x*q.x+v.y*q.y+v.z*q.z);float c=2.*q.w;vec3 r=a*v.xyz+b*q.xyz+c*(q.yzx*v.zxy-q.zxy*v.yzx);return r;}mat3 Matrix3(const in vec4 quaternion){float x=quaternion.x;float y=quaternion.y;float z=quaternion.z;float w=quaternion.w;float A=y*y;float B=z*z;float C=x*y;float D=z*w;float E=z*x;float F=y*w;float G=x*x;float H=y*z;float I=x*w;return mat3(1.-2.*(A+B),2.*(C+D),2.*(E-F),2.*(C-D),1.-2.*(B+G),2.*(H+I),2.*(E+F),2.*(H-I),1.-2.*(A+G));}uint seed=1u;void srand(const in int value){seed=uint(value);}float random(){seed=seed*1103515245u+12345u;return float(seed)/4294967295.;}float getRandomValue(const in float min,const in float max){return min+random()*(max-min);}float getRandomLifetime(){float v=particleLifetime*lifetimeVariation;float min_=max(0.,particleLifetime-v);float max_=particleLifetime+v;return getRandomValue(min_,max_);}float getRandomSpeed(){float v=speed*variation;float min_=max(0.,speed-v);float max_=speed+v;return getRandomValue(min_,max_);}vec3 getRandomNormal(){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(-1.,1.);float r=sqrt(1.-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithAngle(const in float angle){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(cos(angle),1.);float r=sqrt(1.-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithDirectionAndAngle(const in vec3 direction,const in float angle){vec4 rotation=Quaternion(vec3(0.,0.,1.),direction);vec3 normal=getRandomNormalWithAngle(angle);return multVecQuat(normal,rotation);}vec3 getRandomSurfaceNormal(const in vec3 direction){float theta=getRandomValue(-M_PI,M_PI);float cphi=pow(random(),1./3.);float r=sqrt(1.-cphi*cphi);vec3 normal=vec3(sin(theta)*r,cos(theta)*r,cphi);vec4 rotation=Quaternion(vec3(0.,0.,1.),direction);return multVecQuat(normal,rotation);}vec3 getRandomSphericalVelocity(){vec3 normal=getRandomNormal();float speed=getRandomSpeed();return normal*speed;}int upperBound(const in sampler2D sampler,in int count,const in float value){int first=0;int step=0;while(count>0){int index=first;step=count>>1;index+=step;if(value<texelFetch(sampler,index,0).x){count=step;}else{first=++index;count-=step+1;}}return first;}\n#if X3D_NUM_TEX_COORDS>0\nvoid interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;}else{int index=upperBound(sampler,count,fraction);if(index<count)index0=index-1;else index0=0;}}\n#endif\n#if X3D_NUM_COLORS>0||X3D_NUM_SCALES>0||defined(X3D_POLYLINE_EMITTER)||defined(X3D_SURFACE_EMITTER)||defined(X3D_VOLUME_EMITTER)\nvoid interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0,out int index1,out float weight){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;index1=0;weight=0.;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;index1=count-1;weight=1.;}else{int index=upperBound(sampler,count,fraction);if(index<count){index1=index;index0=index-1;float key0=texelFetch(sampler,index0,0).x;float key1=texelFetch(sampler,index1,0).x;weight=clamp((fraction-key0)/(key1-key0),0.,1.);}else{index0=0;index1=0;weight=0.;}}}\n#endif\n#if defined(X3D_SURFACE_EMITTER)||defined(X3D_VOLUME_EMITTER)\nvec3 getRandomBarycentricCoord(){float u=random();float v=random();if(u+v>1.){u=1.-u;v=1.-v;}float t=1.-u-v;return vec3(t,u,v);}void getRandomPointOnSurface(const in sampler2D surface,const in int verticesIndex,const in int normalsIndex,out vec4 position,out vec3 normal){float lastAreaSoFar=texelFetch(surface,verticesIndex-1,0).x;float fraction=random()*lastAreaSoFar;int index0;int index1;int index2;float weight;interpolate(surface,verticesIndex,fraction,index0,index1,weight);index0*=3;index1=index0+1;index2=index0+2;vec4 vertex0=texelFetch(surface,verticesIndex+index0,0);vec4 vertex1=texelFetch(surface,verticesIndex+index1,0);vec4 vertex2=texelFetch(surface,verticesIndex+index2,0);vec3 normal0=texelFetch(surface,normalsIndex+index0,0).xyz;vec3 normal1=texelFetch(surface,normalsIndex+index1,0).xyz;vec3 normal2=texelFetch(surface,normalsIndex+index2,0).xyz;vec3 r=getRandomBarycentricCoord();position=r.z*vertex0+r.x*vertex1+r.y*vertex2;normal=save_normalize(r.z*normal0+r.x*normal1+r.y*normal2);}\n#endif\n${this.functions.join("\n")}\n#if X3D_NUM_TEX_COORDS>0\nint getTexCoordIndex0(const in float fraction){int index0=0;interpolate(texCoords,X3D_NUM_TEX_COORDS,fraction,index0);return X3D_NUM_TEX_COORDS+index0*X3D_TEX_COORDS_COUNT;}\n#else\n#define getTexCoordIndex0(fraction)(-1)\n#endif\n#if X3D_NUM_COLORS>0\nvec4 getColor(const in float fraction){int index0;int index1;float weight;interpolate(colors,X3D_NUM_COLORS,fraction,index0,index1,weight);vec4 color0=texelFetch(colors,X3D_NUM_COLORS+index0,0);vec4 color1=texelFetch(colors,X3D_NUM_COLORS+index1,0);return mix(color0,color1,weight);}\n#else\n#define getColor(fraction)(vec4(1))\n#endif\n#if X3D_NUM_SCALES>0\nvec3 getScale(const in float fraction){int index0;int index1;float weight;interpolate(scales,X3D_NUM_SCALES,fraction,index0,index1,weight);vec3 scale0=texelFetch(scales,X3D_NUM_SCALES+index0,0).xyz;vec3 scale1=texelFetch(scales,X3D_NUM_SCALES+index1,0).xyz;return mix(scale0,scale1,weight);}\n#else\n#define getScale(fraction)(vec3(1))\n#endif\n#if defined(X3D_BOUNDED_VOLUME)\nvoid bounce(const in float deltaTime,const in vec4 fromPosition,inout vec4 toPosition,inout vec3 velocity){Line3 line=Line3(fromPosition.xyz,save_normalize(velocity));vec4 points[ARRAY_SIZE];vec3 normals[ARRAY_SIZE];int numIntersections=getIntersections(boundedVolume,boundedVerticesIndex,boundedNormalsIndex,boundedHierarchyIndex,boundedHierarchyRoot,line,points,normals);if(numIntersections==0)return;Plane3 plane1=plane3(line.point,line.direction);int index=min_index(points,numIntersections,0.,plane1);if(index==-1)return;vec3 point=points[index].xyz;vec3 normal=save_normalize(normals[index]);Plane3 plane2=plane3(point,normal);if(sign(plane_distance(plane2,fromPosition.xyz))==sign(plane_distance(plane2,toPosition.xyz)))return;float damping=length(normals[index]);velocity=reflect(velocity,normal);toPosition=vec4(point+save_normalize(velocity)*.0001,1.);velocity*=damping;}\n#endif\nvoid main(){int life=int(input0[0]);float lifetime=input0[1];float elapsedTime=input0[2]+deltaTime;float fraction=elapsedTime/lifetime;srand((gl_VertexID+randomSeed)*randomSeed);if(elapsedTime>lifetime){lifetime=getRandomLifetime();elapsedTime=0.;fraction=0.;output0=vec4(max(life+1,1),lifetime,elapsedTime,getTexCoordIndex0(fraction));\n#if defined(X3D_CREATE_PARTICLES)\noutput1=getColor(fraction);output2=vec4(getRandomVelocity(),0.);output6=getRandomPosition();\n#else\noutput1=vec4(0);output2=vec4(0);output6=vec4(NaN);\n#endif\n}else{vec3 velocity=input2.xyz;vec4 position=input6;\n#if X3D_NUM_FORCES>0\nfor(int i=0;i<X3D_NUM_FORCES;++i){vec4 force=texelFetch(forces,i,0);float turbulence=force.w;vec3 normal=getRandomNormalWithDirectionAndAngle(force.xyz,turbulence);float speed=length(force.xyz);velocity+=normal*speed;}\n#endif\nposition.xyz+=velocity*deltaTime;\n#if defined(X3D_BOUNDED_VOLUME)\nbounce(deltaTime,input6,position,velocity);\n#endif\noutput0=vec4(life,lifetime,elapsedTime,getTexCoordIndex0(fraction));output1=getColor(fraction);output2=vec4(velocity,0.);output6=position;}vec3 scale=getScale(fraction);\n#if X3D_GEOMETRY_TYPE==POINT||X3D_GEOMETRY_TYPE==SPRITE||X3D_GEOMETRY_TYPE==GEOMETRY\noutput3=vec4(scale.x,0.,0.,0.);output4=vec4(0.,scale.y,0.,0.);output5=vec4(0.,0.,scale.z,0.);\n#elif X3D_GEOMETRY_TYPE==LINE\nmat3 m=Matrix3(Quaternion(vec3(0.,0.,1.),output2.xyz));\n#if X3D_NUM_SCALES>0\nm*=mat3(scale.x,0.,0.,0.,scale.y,0.,0.,0.,scale.z);\n#endif\noutput3=vec4(m[0],0.);output4=vec4(m[1],0.);output5=vec4(m[2],0.);\n#else\nvec2 s=particleSize*scale.xy;output3=vec4(s.x,0.,0.,0.);output4=vec4(0.,s.y,0.,0.);output5=vec4(0.,0.,scale.z,0.);\n#endif\n}`,r=n.createShader(n.VERTEX_SHADER);n.shaderSource(r,o),n.compileShader(r),n.getShaderParameter(r,n.COMPILE_STATUS)||console.error(n.getShaderInfoLog(r));const a=n.createShader(n.FRAGMENT_SHADER);n.shaderSource(a,"#version 300 es\nprecision highp float;void main(){}"),n.compileShader(a),n.getShaderParameter(a,n.COMPILE_STATUS)||console.error(n.getShaderInfoLog(a));const c=n.createProgram();n.attachShader(c,r),n.attachShader(c,a),n.transformFeedbackVaryings(c,Array.from({length:7},(e,t)=>"output"+t),n.INTERLEAVED_ATTRIBS),n.linkProgram(c),n.getProgramParameter(c,n.LINK_STATUS)||console.error(`Couldn't initialize particle shader: ${n.getProgramInfoLog(c)}`),this.programs.set(e,c),n.useProgram(c),c.inputs=[[0,n.getAttribLocation(c,"input0")],[2,n.getAttribLocation(c,"input2")],[6,n.getAttribLocation(c,"input6")]],c.randomSeed=n.getUniformLocation(c,"randomSeed"),c.particleLifetime=n.getUniformLocation(c,"particleLifetime"),c.lifetimeVariation=n.getUniformLocation(c,"lifetimeVariation"),c.deltaTime=n.getUniformLocation(c,"deltaTime"),c.particleSize=n.getUniformLocation(c,"particleSize"),c.boundedVerticesIndex=n.getUniformLocation(c,"boundedVerticesIndex"),c.boundedNormalsIndex=n.getUniformLocation(c,"boundedNormalsIndex"),c.boundedHierarchyIndex=n.getUniformLocation(c,"boundedHierarchyIndex"),c.boundedHierarchyRoot=n.getUniformLocation(c,"boundedHierarchyRoot"),c.boundedVolume=n.getUniformLocation(c,"boundedVolume");for(const e in p)c[e]=n.getUniformLocation(c,e);for(const e of this.uniforms.keys())c[e]=n.getUniformLocation(c,e);n.uniform1f(n.getUniformLocation(c,"NaN"),NaN);for(const e of this.samplers){const t=n.getUniformLocation(c,e);n.uniform1i(t,c[e+"TextureUnit"]=i.getTextureUnit())}for(const[e,t]of Object.entries(p))c[t]=c[e+"TextureUnit"];i.resetTextureUnits();for(const e of this.callbacks)e.call(this);return c},activateTextures(){},createTexture(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},getTextureUnit(e,t,i){const n=t[i];return void 0===n?t[i]=e.getTextureUnit():n}}),Object.defineProperties(b,u().getStaticProperties("X3DParticleEmitterNode","ParticleSystems",1));const R=b,w=m().add("X3DParticleEmitterNode",R),S=e.Vector3;var F=t.n(S);function O(e){w.call(this,e),this.addType(v().PointEmitter),this._position.setUnit("length")}Object.assign(Object.setPrototypeOf(O.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.addDefine("#define X3D_POINT_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addCallback(this.set_position__),this.addCallback(this.set_direction__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()},set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})()}),Object.defineProperties(O,{...u().getStaticProperties("PointEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const A=O,N=m().add("PointEmitter",A),P=Symbol();function D(){}Object.assign(D.prototype,{getDefaultEmitter(){return this[P]??=(()=>{const e=new N(this.getPrivateScene());return e.setup(),e})()}});const V=D,C=m().add("X3DParticleSystemsContext",V);function B(e){u().call(this,e),this.addType(v().X3DParticlePhysicsModelNode)}Object.assign(Object.setPrototypeOf(B.prototype,u().prototype),{addForce(){}}),Object.defineProperties(B,u().getStaticProperties("X3DParticlePhysicsModelNode","ParticleSystems",1));const M=B,U=m().add("X3DParticlePhysicsModelNode",M),z=e.X3DCast;var L=t.n(z);function X(e){U.call(this,e),this.addType(v().BoundedPhysicsModel)}Object.assign(Object.setPrototypeOf(X.prototype,U.prototype),{initialize(){U.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},getBBox(){return this.geometryNode?.getBBox()},set_geometry__(){this.geometryNode?._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=L()(v().X3DGeometryNode,this._geometry),this.geometryNode?._rebuild.addInterest("addNodeEvent",this)},addGeometry(e,t){if(!this.geometryNode)return;if(!this._enabled.getValue())return;const i=this._damping.getValue(),n=this.geometryNode.getNormals().getValue(),s=this.geometryNode.getVertices().getValue();for(const t of n)e.push(t*i);for(const e of s)t.push(e)}}),Object.defineProperties(X,{...u().getStaticProperties("BoundedPhysicsModel","ParticleSystems",2,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"damping",new(o().SFFloat)(1)),new(a())(v().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const k=X,j=m().add("BoundedPhysicsModel",k);function G(e){w.call(this,e),this.addType(v().ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle")}Object.assign(Object.setPrototypeOf(G.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.addDefine("#define X3D_CONE_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("angle","uniform float angle;"),this.addCallback(this.set_position__),this.addCallback(this.set_direction__),this.addCallback(this.set_angle__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n {\n return getRandomSphericalVelocity ();\n }\n else\n {\n vec3 normal = getRandomNormalWithDirectionAndAngle (direction, angle);\n float speed = getRandomSpeed ();\n\n return normal * speed;\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()},set_direction__(){const{x:e,y:t,z:i}=this._direction.getValue();this.setUniform("uniform3f","direction",e,t,i)},set_angle__(){this.setUniform("uniform1f","angle",this._angle.getValue())}}),Object.defineProperties(G,{...u().getStaticProperties("ConeEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"angle",new(o().SFFloat)(.785398)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const H=G,Y=m().add("ConeEmitter",H);function q(e){w.call(this,e),this.addType(v().ExplosionEmitter),this._position.setUnit("length")}Object.assign(Object.setPrototypeOf(q.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this.addDefine("#define X3D_EXPLOSION_EMITTER"),this.addUniform("position","uniform vec3 position;"),this.addCallback(this.set_position__),this.addFunction("vec3 getRandomVelocity ()\n {\n return getRandomSphericalVelocity ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this._position.getValue())}})(),isExplosive:()=>!0,set_position__(){const{x:e,y:t,z:i}=this._position.getValue();this.setUniform("uniform3f","position",e,t,i),this._bbox_changed.addEvent()}}),Object.defineProperties(q,{...u().getStaticProperties("ExplosionEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"position",new(o().SFVec3f)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const W=q,K=m().add("ExplosionEmitter",W);function Z(e){U.call(this,e),this.addType(v().ForcePhysicsModel),this._force.setUnit("force")}Object.assign(Object.setPrototypeOf(Z.prototype,U.prototype),{addForce:(()=>{const e=new(F());return function(t,i,n,s){return!!this._enabled.getValue()&&(s.set(e.assign(this._force.getValue()).multiply(n),4*t),s[4*t+3]=0,!0)}})()}),Object.defineProperties(Z,{...u().getStaticProperties("ForcePhysicsModel","ParticleSystems",1,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"force",new(o().SFVec3f)(0,-9.8,0))]),enumerable:!0}});const Q=Z,$=m().add("ForcePhysicsModel",Q),J=e.X3DShapeNode;var ee=t.n(J);const te=e.GeometryContext;var ie=t.n(te);const ne=e.VertexArray;var se=t.n(ne);const oe=e.AlphaMode;var re=t.n(oe);const ae=e.LineSet;var ce=t.n(ae);const le=e.Coordinate;var de=t.n(le);const ue=e.Matrix4;var he=t.n(ue);const me=e.Matrix3;var _e=t.n(me);const pe=e.Plane3;var fe=t.n(pe);const xe=e.QuickSort;var ge=t.n(xe);const ve=new(F()),ye=new(F()),Te=new(F()),Ee={u:0,v:0,t:0},Ie=[F().Z_AXIS,F().NEGATIVE_Z_AXIS,F().Y_AXIS,F().NEGATIVE_Y_AXIS,F().X_AXIS];function be(e,t){this.vertices=e.vertices,this.normals=e.normals,this.triangle=t,this.i4=12*t,this.i3=9*t}function Re(e,t,i,n){this.min=new(F()),this.max=new(F()),this.planes=[],this.intersection=new(F());const s=e.vertices,o=this.min,r=this.max,a=i+n;let c,l=12*t[i];o.set(s[l],s[l+1],s[l+2]),r.assign(o);for(let e=i;e<a;++e)l=12*t[e],ve.set(s[l],s[l+1],s[l+2]),ye.set(s[l+4],s[l+5],s[l+6]),Te.set(s[l+8],s[l+9],s[l+10]),o.min(ve,ye,Te),r.max(ve,ye,Te);for(let e=0;e<5;++e)this.planes[e]=new(fe())(e%2?o:r,Ie[e]);n>2?(e.sorter.compare.axis=this.getLongestAxis(o,r),e.sorter.sort(i,a),c=n>>>1):c=1;const d=n-c;this.left=c>1?new Re(e,t,i,c):new be(e,t[i]),this.right=d>1?new Re(e,t,i+c,d):new be(e,t[i+c])}function we(e,t){const i=e.length/12;switch(this.vertices=e,this.normals=t,i){case 0:this.root=null;break;case 1:this.root=new be(this,0);break;default:{const t=[];for(let e=0;e<i;++e)t.push(e);this.sorter=new(ge())(t,function(e,t){return function(i,n){return Math.min(e[i+t],e[i+4+t],e[i+8+t])<Math.min(e[n+t],e[n+4+t],e[n+8+t])}}(e,0)),this.root=new Re(this,t,0,i);break}}}Object.assign(be.prototype,{intersectsLine(e,t,i){const n=this.vertices,s=this.normals,o=this.i4,r=this.i3;if(ve.x=n[o],ve.y=n[o+1],ve.z=n[o+2],ye.x=n[o+4],ye.y=n[o+5],ye.z=n[o+6],Te.x=n[o+8],Te.y=n[o+9],Te.z=n[o+10],e.intersectsTriangle(ve,ye,Te,Ee)){const{u:e,v:a,t:c}=Ee,l=t.size++;l>=t.length&&t.push(new(F())),t[l].set(e*n[o]+a*n[o+4]+c*n[o+8],e*n[o+1]+a*n[o+5]+c*n[o+9],e*n[o+2]+a*n[o+6]+c*n[o+10]),i&&(l>=i.length&&i.push(new(F())),i[l].set(e*s[r]+a*s[r+3]+c*s[r+6],e*s[r+1]+a*s[r+4]+c*s[r+7],e*s[r+2]+a*s[r+5]+c*s[r+8]))}},toArray(e){const t=e.length/4;return e.push(1,3*this.triangle,0,0),t}}),Object.assign(Re.prototype,{intersectsLine(e,t,i){this.intersectsBBox(e)&&(this.left.intersectsLine(e,t,i),this.right.intersectsLine(e,t,i))},intersectsBBox(e){const t=this.planes,i=this.min,n=this.max,s=i.x,o=n.x,r=i.y,a=n.y,c=i.z,l=n.z,d=this.intersection;return!!(t[0].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.y>=r&&d.y<=a)||(!!(t[1].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.y>=r&&d.y<=a)||(!!(t[2].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.z>=c&&d.z<=l)||(!!(t[3].intersectsLine(e,d)&&d.x>=s&&d.x<=o&&d.z>=c&&d.z<=l)||!!(t[4].intersectsLine(e,d)&&d.y>=r&&d.y<=a&&d.z>=c&&d.z<=l))))},getLongestAxis(e,t){const i=t.x-e.x,n=t.y-e.y,s=t.z-e.z;return i<n?n<s?2:1:i<s?2:0},toArray(e){const t=this.left.toArray(e),i=this.right.toArray(e),n=this.min,s=this.max,o=e.length/4;return e.push(0,t,i,0,n.x,n.y,n.z,0,s.x,s.y,s.z,0),o}}),Object.assign(we.prototype,{intersectsLine(e,t,i){return t.size=0,this.root?(this.root.intersectsLine(e,t,i),t.size):0},toArray(e){if(this.root){const t=this.root.toArray(e);e.push(t,0,0,0)}return e}});const Se=we,Fe=m().add("BVH",Se),Oe=new Float32Array([0,0,0,1]),Ae=new Float32Array([0,0,0,1,1,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,1,-.5,-.5,0,1,.5,-.5,0,1,.5,.5,0,1,-.5,-.5,0,1,.5,.5,0,1,-.5,.5,0,1]);function Ne(e){ee().call(this,e),this.addType(v().ParticleSystem),this._particleSize.setUnit("length"),e.getSpecificationVersion()<=3.3&&(this.addAlias("colorRamp",this._color),this.addAlias("texCoordRamp",this._texCoord));const t=this.getBrowser();this.maxParticles=0,this.numParticles=0,this.spriteSize=new(F()),this.samplers=new Set,this.forcePhysicsModelNodes=[],this.forces=new Float32Array(4),this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.colorRamp=new Float32Array,this.texCoordRamp=new Float32Array,this.scaleRamp=new Float32Array,this.geometryContext=new(ie())({textureCoordinateNode:t.getDefaultTextureCoordinate()}),this.creationTime=0,this.pauseTime=0,this.deltaTime=0,this.particlesStride=7*Float32Array.BYTES_PER_ELEMENT*4,this.particleOffsets=Array.from({length:7},(e,t)=>4*Float32Array.BYTES_PER_ELEMENT*t),this.particleOffset=this.particleOffsets[0],this.colorOffset=this.particleOffsets[1],this.velocityOffset=this.particleOffsets[2],this.matrixOffset=this.particleOffsets[3],this.texCoordOffset=0,this.instancesStride=this.particlesStride}Object.assign(Object.setPrototypeOf(Ne.prototype,ee().prototype),{initialize(){ee().prototype.initialize.call(this);const e=this.getBrowser(),t=e.getContext();this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_enabled__",this),this._geometryType.addInterest("set_geometryType__",this),this._geometryType.addInterest("set_texCoord__",this),this._maxParticles.addInterest("set_enabled__",this),this._particleLifetime.addInterest("set_particleLifetime__",this),this._particleLifetime.addInterest("set_bbox__",this),this._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._lifetimeVariation.addInterest("set_bbox__",this),this._particleSize.addInterest("set_particleSize__",this),this._emitter.addInterest("set_emitter__",this),this._emitter.addInterest("set_bbox__",this),this._physics.addInterest("set_physics__",this),this._colorKey.addInterest("set_color__",this),this._color.addInterest("set_colorRamp__",this),this._texCoordKey.addInterest("set_texCoord__",this),this._texCoord.addInterest("set_texCoordRamp__",this),this._scaleKey.addInterest("set_scale__",this),this._scale.addInterest("set_scaleRamp__",this),this.inputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(se())(t),thickLinesVertexArrayObject:new(se())(t)}),this.outputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(se())(t),thickLinesVertexArrayObject:new(se())(t)}),this.boundedTexture=this.createTexture();for(const e of Object.values(p))this[e]=this.createTexture();this.geometryBuffer=this.createBuffer(),this.texCoordBuffers=new Array(e.getMaxTexCoords()).fill(this.geometryBuffer),this.lineGeometryNode=new(ce())(this.getExecutionContext()),this.lineCoordinateNode=new(de())(this.getExecutionContext()),this.lineCoordinateNode._point=[0,0,-.5,0,0,.5],this.lineGeometryNode._vertexCount=[2],this.lineGeometryNode._coord=this.lineCoordinateNode,this.lineCoordinateNode.setup(),this.lineGeometryNode.setup(),this.set_emitter__(),this.set_enabled__(),this.set_geometryType__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_particleSize__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__(),this.set_scaleRamp__(),this.set_bbox__()},getShapeKey(){return this.numTexCoords?2:1},getGeometryContext(){return this.geometryType===x().GEOMETRY?this.getGeometry():this.geometryContext},getGeometryType(){return this.geometryType},getNumInstances(){return this.numParticles},getInstances(){return this.outputParticles},set_bbox__(){if(this.isDefaultBBoxSize())if(this.boundedPhysicsModelNodes.length){this.bbox.set();for(const e of this.boundedPhysicsModelNodes){const t=e.getBBox();t&&this.bbox.add(t)}}else this.emitterNode?.getBBox(this.bbox,this);else this.bbox.set(this._bboxSize.getValue(),this._bboxCenter.getValue());this.bboxSize.assign(this.bbox.size),this.bboxCenter.assign(this.bbox.center)},set_transparent__(){const e=this.appearanceNode.getAlphaMode();e===re().AUTO?(this.setTransparent(this.getAppearance().isTransparent()||this.colorRampNode?.isTransparent()||this.geometryType===x().GEOMETRY&&this.geometryNode?.isTransparent()),this.setAlphaMode(this.isTransparent()?re().BLEND:re().OPAQUE)):(this.setTransparent(e===re().BLEND),this.setAlphaMode(e))},set_live__(){this.getLive().getValue()?this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime&&(this.creationTime+=Date.now()/1e3-this.pauseTime,this.pauseTime=0)):this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().removeInterest("animateParticles",this),0===this.pauseTime&&(this.pauseTime=Date.now()/1e3))},set_enabled__(){this._enabled.getValue()&&this._maxParticles.getValue()?this._isActive.getValue()||(this.getLive().getValue()?(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime=0):this.pauseTime=Date.now()/1e3,this._isActive=!0,delete this.traverse):this._isActive.getValue()&&(this.getLive().getValue()&&this.getBrowser().sensorEvents().removeInterest("animateParticles",this),this._isActive=!1,this.numParticles=0,this.traverse=Function.prototype),this.set_maxParticles__()},set_geometryType__(){const e=this.getBrowser().getContext();switch(this.geometryType=x().get(this._geometryType.getValue())??x().QUAD,this.geometryType){case x().POINT:this.geometryContext.geometryType=0,this.geometryContext.hasNormals=!1,this.texCoordCount=0,this.vertexCount=1,this.hasNormals=!1,this.verticesOffset=0,this.primitiveMode=e.POINTS,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,Oe,e.DYNAMIC_DRAW);break;case x().LINE:this.geometryContext.geometryType=1,this.geometryContext.hasNormals=!1,this.texCoordCount=0;break;case x().TRIANGLE:case x().QUAD:case x().SPRITE:this.geometryContext.geometryType=2,this.geometryContext.hasNormals=!0,this.texCoordCount=4,this.vertexCount=6,this.hasNormals=!0,this.texCoordsOffset=0,this.normalOffset=24*Float32Array.BYTES_PER_ELEMENT,this.verticesOffset=27*Float32Array.BYTES_PER_ELEMENT,this.primitiveMode=e.TRIANGLES,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,Ae,e.DYNAMIC_DRAW);break;case x().GEOMETRY:this.texCoordCount=0}this.geometryContext.updateGeometryKey(),this.updateVertexArrays(),this.set_objects__()},set_maxParticles__(){const e=this.numParticles,t=Math.max(0,this._maxParticles.getValue());this.maxParticles=t,this.numParticles=Math.min(e,t),this.emitterNode.isExplosive()||(this.creationTime=Date.now()/1e3),this.resizeBuffers(e),this.updateVertexArrays(),this.set_objects__()},set_particleLifetime__(){this.particleLifetime=Math.max(this._particleLifetime.getValue(),0)},set_lifetimeVariation__(){this.lifetimeVariation=Math.max(this._lifetimeVariation.getValue(),0)},set_particleSize__(){this.lineCoordinateNode._point[0].z=-this._particleSize.y/2,this.lineCoordinateNode._point[1].z=+this._particleSize.y/2,this.spriteSize.set(...this._particleSize)},set_emitter__(){this.emitterNode?._bbox_changed.removeInterest("set_bbox__",this),this.emitterNode=L()(v().X3DParticleEmitterNode,this._emitter)??this.getBrowser().getDefaultEmitter(),this.emitterNode._bbox_changed.addInterest("set_bbox__",this)},set_physics__(){const e=this._physics.getValue(),t=this.forcePhysicsModelNodes,i=this.boundedPhysicsModelNodes;for(const e of i)e.removeInterest("set_boundedPhysics__",this),e.removeInterest("set_bbox__",this);t.length=0,i.length=0;for(let n=0,s=e.length;n<s;++n)try{const s=e[n].getValue().getInnerNode(),o=s.getType();for(let e=o.length-1;e>=0;--e){switch(o[e]){case v().ForcePhysicsModel:case v().WindPhysicsModel:t.push(s);break;case v().BoundedPhysicsModel:i.push(s);break;default:continue}break}}catch{}for(const e of i)e.addInterest("set_boundedPhysics__",this),e.addInterest("set_bbox__",this);this.set_boundedPhysics__()},set_boundedPhysics__(){const e=this.getBrowser().getContext(),t=this.boundedPhysicsModelNodes,i=this.boundedNormals,n=this.boundedVertices;i.length=0,n.length=0;for(let e=0,s=t.length;e<s;++e)t[e].addGeometry(i,n);const s=new Fe(n,i).toArray([]),o=n.length/4,r=i.length/3,a=s.length/4,c=Math.ceil(Math.sqrt(o+r+a)),l=new Float32Array(c*c*4);this.boundedVerticesIndex=0,this.boundedNormalsIndex=o,this.boundedHierarchyIndex=this.boundedNormalsIndex+r,this.boundedHierarchyRoot=this.boundedHierarchyIndex+a-1,l.set(n);for(let e=4*this.boundedNormalsIndex,t=0,n=i.length;t<n;e+=4,t+=3)l[e+0]=i[t+0],l[e+1]=i[t+1],l[e+2]=i[t+2];l.set(s,4*this.boundedHierarchyIndex),c&&(e.bindTexture(e.TEXTURE_2D,this.boundedTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,c,c,0,e.RGBA,e.FLOAT,l))},set_colorRamp__(){this.colorRampNode?.removeInterest("set_color__",this),this.colorRampNode=L()(v().X3DColorNode,this._color),this.colorRampNode?.addInterest("set_color__",this),this.set_color__(),this.set_transparent__()},set_color__(){const e=this.getBrowser().getContext(),t=this._colorKey,i=t.length,n=Math.ceil(Math.sqrt(2*i));let s=this.colorRamp;n*n*4>s.length&&(s=this.colorRamp=new Float32Array(n*n*4));for(let e=0;e<i;++e)s[4*e]=t[e];this.colorRampNode?s.set(this.colorRampNode.addColors([],i).slice(0,4*i),4*i):s.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.colors]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numColors=i,this.geometryContext.colorMaterial=!(!i||!this.colorRampNode),i?this.samplers.add(p.colors):this.samplers.delete(p.colors),this.geometryContext.updateGeometryKey(),this.updateVertexArrays()},set_texCoordRamp__(){this.texCoordRampNode?.removeInterest("set_texCoord__",this),this.texCoordRampNode=L()(v().X3DTextureCoordinateNode,this._texCoord),this.texCoordRampNode?.addInterest("set_texCoord__",this),this.set_texCoord__()},set_texCoord__(){const e=this.getBrowser().getContext(),t=this._texCoordKey,i=t.length,n=Math.ceil(Math.sqrt(i+i*this.texCoordCount));let s=this.texCoordRamp;n*n*4>s.length?s=this.texCoordRamp=new Float32Array(n*n*4):s.fill(0);for(let e=0;e<i;++e)s[4*e]=t[e];this.texCoordRampNode&&s.set(this.texCoordRampNode.addPoints([]).slice(0,i*this.texCoordCount*4),4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.texCoords]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numTexCoords=this.texCoordRampNode?i:0,i?this.samplers.add(p.texCoords):this.samplers.delete(p.texCoords),this.updateVertexArrays()},set_scaleRamp__(){this.scaleRampNode?.removeInterest("set_scale__",this),this.scaleRampNode=L()(v().Coordinate,this._scale),this.scaleRampNode?.addInterest("set_scale__",this),this.set_scale__()},set_scale__(){const e=this.getBrowser().getContext(),t=this._scaleKey,i=t.length,n=Math.ceil(Math.sqrt(2*i));let s=this.scaleRamp;n*n*4>s.length?s=this.scaleRamp=new Float32Array(n*n*4):s.fill(0);for(let e=0;e<i;++e)s[4*e]=t[e];this.scaleRampNode?s.set(this.scaleRampNode.addPoints([],i).slice(0,4*i),4*i):s.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this[p.scales]),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,s)),this.numScales=i,i?this.samplers.add(p.scales):this.samplers.delete(p.scales),this.updateVertexArrays()},updateVertexArrays(){this.inputParticles.vertexArrayObject.update(),this.outputParticles.vertexArrayObject.update(),this.inputParticles.thickLinesVertexArrayObject.update(),this.outputParticles.thickLinesVertexArrayObject.update()},createTexture(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},createBuffer(){const e=this.getBrowser().getContext(),t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Uint32Array,e.DYNAMIC_DRAW),t},resizeBuffers(e){const t=this.getBrowser().getContext(),i=this.maxParticles,n=this.particlesStride,s=Object.assign(t.createBuffer(),this.outputParticles),o=new Uint8Array(i*n);t.bindBuffer(t.ARRAY_BUFFER,this.inputParticles),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW),t.bindBuffer(t.COPY_READ_BUFFER,this.outputParticles),t.bindBuffer(t.ARRAY_BUFFER,s),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW),t.copyBufferSubData(t.COPY_READ_BUFFER,t.ARRAY_BUFFER,0,0,Math.min(i*n,e*n)),t.deleteBuffer(this.outputParticles),this.outputParticles=s},animateParticles(){const e=this.getBrowser(),t=e.getContext(),i=this.emitterNode,n=1/Math.max(this.getBrowser().getCurrentFrameRate(),10);let s=this.deltaTime=(14*this.deltaTime+n)/15;if(i.isExplosive()){const e=Date.now()/1e3,t=this.particleLifetime+this.particleLifetime*this.lifetimeVariation;e-this.creationTime>t?(this.creationTime=e,this.numParticles=this.maxParticles,this.createParticles=this._createParticles.getValue(),s=Number.POSITIVE_INFINITY,this.set_objects__()):this.createParticles=!1}else if(this.createParticles=this._createParticles.getValue(),this.numParticles<this.maxParticles){const e=Date.now()/1e3,t=Math.max(0,Math.floor((e-this.creationTime)*this.maxParticles/this.particleLifetime));t&&(this.creationTime=e),this.numParticles=Math.min(this.maxParticles,this.numParticles+t),this.set_objects__()}if(i.getMass()){const e=this.forcePhysicsModelNodes;let n=e.length,o=this.forces,r=s/i.getMass();4*n>o.length&&(o=this.forces=new Float32Array(4*n));let a=0;for(let t=0;t<n;++t)a+=!e[t].addForce(t-a,i,r,o);this.numForces=n-=a,n?(t.bindTexture(t.TEXTURE_2D,this[p.forces]),t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,n,1,0,t.RGBA,t.FLOAT,o),this.samplers.add(p.forces)):this.samplers.delete(p.forces)}else this.numForces=0,this.samplers.delete(p.forces);const o=this.outputParticles;this.outputParticles=this.inputParticles,this.inputParticles=o,i.animate(this,s),e.addBrowserEvent()},updateSprite:(()=>{const e=new Float32Array(Ae),t=[new(F())(-.5,-.5,0),new(F())(.5,-.5,0),new(F())(.5,.5,0),new(F())(-.5,-.5,0),new(F())(.5,.5,0),new(F())(-.5,.5,0)],i=new(F());return function(n,s){for(let t=0;t<3;++t)e[24+t]=s[6+t];const o=this.spriteSize;for(let n=0;n<6;++n){const r=27+4*n;s.multVecMatrix(i.assign(t[n]).multVec(o)),e.set(i,r)}n.bindBuffer(n.ARRAY_BUFFER,this.geometryBuffer),n.bufferData(n.ARRAY_BUFFER,e,n.DYNAMIC_DRAW)}})(),displaySimple(e,t,i){switch(this.geometryType){case x().LINE:this.lineGeometryNode.displaySimpleInstanced(e,i,this);break;case x().GEOMETRY:this.getGeometry().displaySimpleInstanced(e,i,this);break;case x().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));default:{const t=this.outputParticles;if(t.vertexArrayObject.enable(i.getProgram())){const n=this.particlesStride;i.enableParticleAttribute(e,t,n,this.particleOffset,1),i.enableInstanceMatrixAttribute(e,t,n,this.matrixOffset,1),i.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(this.primitiveMode,0,this.vertexCount,this.numParticles);break}}},display(e,t){switch(this.geometryType){case x().LINE:this.lineGeometryNode.displayInstanced(e,t,this);break;case x().GEOMETRY:this.getGeometry().displayInstanced(e,t,this);break;case x().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));case x().QUAD:case x().TRIANGLE:{const i=he().prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(i?e.CCW:e.CW),e.enable(e.CULL_FACE)}default:{const i=t.viewport,n=this.getBrowser(),s=this.getAppearance(),o=s.getRenderModes(),r=s.getShader(this.geometryContext,t),a=n.getPrimitiveMode(this.primitiveMode);this.geometryType!==x().POINT||t.transparent||e.enable(e.SAMPLE_ALPHA_TO_COVERAGE),e.viewport(...i);for(const t of o)t.enable(e);if(r.enable(e),r.setUniforms(e,t,this.geometryContext),this.numTexCoords){const t=n.getTextureUnit();e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this[p.texCoords]),e.uniform1i(r.x3d_TexCoordRamp,t)}const c=this.outputParticles;if(c.vertexArrayObject.enable(r.getProgram())){const{particlesStride:t}=this;r.enableParticleAttribute(e,c,t,this.particleOffset,1),r.enableParticleVelocityAttribute(e,c,t,this.velocityOffset,1),r.enableInstanceMatrixAttribute(e,c,t,this.matrixOffset,1),this.geometryContext.colorMaterial&&(r.enableColorAttribute(e,c,t,this.colorOffset),r.colorAttributeDivisor(e,1)),this.texCoordCount&&r.enableTexCoordAttribute(e,this.texCoordBuffers,0,this.texCoordOffset),this.hasNormals&&(r.enableNormalAttribute(e,this.geometryBuffer,0,this.normalOffset),r.normalAttributeDivisor(e,this.maxParticles)),r.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(a,0,this.vertexCount,this.numParticles);for(const t of o)t.disable(e);n.resetTextureUnits(),this.geometryType!==x().POINT||t.transparent||e.disable(e.SAMPLE_ALPHA_TO_COVERAGE);break}}},getScreenAlignedRotation:(()=>{const e=new(he()),t=new(F()),i=new(F()),n=new(F()),s=new(_e());return function(o){return e.assign(o).inverse(),e.multDirMatrix(t.assign(F().Y_AXIS)),e.multDirMatrix(n.assign(F().Z_AXIS)),t.cross(n),i.assign(n).cross(t),t.normalize(),i.normalize(),n.normalize(),s.set(...t,...i,...n),s}})()}),Object.defineProperties(Ne,{...u().getStaticProperties("ParticleSystem","ParticleSystems",2,"children","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().initializeOnly,"geometryType",new(o().SFString)("QUAD")),new(a())(v().inputOutput,"createParticles",new(o().SFBool)(!0)),new(a())(v().inputOutput,"maxParticles",new(o().SFInt32)(200)),new(a())(v().inputOutput,"particleLifetime",new(o().SFFloat)(5)),new(a())(v().inputOutput,"lifetimeVariation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"particleSize",new(o().SFVec2f)(.02,.02)),new(a())(v().initializeOnly,"emitter",new(o().SFNode)),new(a())(v().initializeOnly,"physics",new(o().MFNode)),new(a())(v().initializeOnly,"colorKey",new(o().MFFloat)),new(a())(v().initializeOnly,"color",new(o().SFNode)),new(a())(v().initializeOnly,"texCoordKey",new(o().MFFloat)),new(a())(v().initializeOnly,"texCoord",new(o().SFNode)),new(a())(v().initializeOnly,"scaleKey",new(o().MFFloat)),new(a())(v().initializeOnly,"scale",new(o().SFNode)),new(a())(v().outputOnly,"isActive",new(o().SFBool)),new(a())(v().inputOutput,"pointerEvents",new(o().SFBool)(!0)),new(a())(v().inputOutput,"castShadow",new(o().SFBool)(!0)),new(a())(v().inputOutput,"visible",new(o().SFBool)(!0)),new(a())(v().inputOutput,"bboxDisplay",new(o().SFBool)),new(a())(v().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(a())(v().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(a())(v().inputOutput,"appearance",new(o().SFNode)),new(a())(v().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const Pe=Ne,De=m().add("ParticleSystem",Pe),Ve=e.IndexedLineSet;var Ce=t.n(Ve);function Be(e){w.call(this,e),this.addType(v().PolylineEmitter),this.verticesIndex=-1,this.polylinesNode=new(Ce())(e),this.polylinesArray=new Float32Array}Object.assign(Object.setPrototypeOf(Be.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.polylinesTexture=this.createTexture(),this._direction.addInterest("set_direction__",this),this._set_coordIndex.addFieldInterest(this._coordIndex),this._coordIndex.addFieldInterest(this.polylinesNode._coordIndex),this._coord.addFieldInterest(this.polylinesNode._coord),this.polylinesNode._coordIndex=this._coordIndex,this.polylinesNode._coord=this._coord,this.polylinesNode.setPrivate(!0),this.polylinesNode.setup(),this.polylinesNode._rebuild.addInterest("set_polylines__",this),this.addDefine("#define X3D_POLYLINE_EMITTER"),this.addSampler("polylines"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("polylines","uniform sampler2D polylines;"),this.addCallback(this.set_direction__),this.addCallback(this.set_verticesIndex__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (verticesIndex < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n // Determine index0, index1 and weight.\n\n float lastLengthSoFar = texelFetch (polylines, verticesIndex - 1, 0) .x;\n float fraction = random () * lastLengthSoFar;\n\n int index0 = 0;\n int index1 = 0;\n float weight = 0.0;\n\n interpolate (polylines, verticesIndex, fraction, index0, index1, weight);\n\n // Interpolate and return position.\n\n index0 *= 2;\n index1 = index0 + 1;\n\n vec4 vertex0 = texelFetch (polylines, verticesIndex + index0, 0);\n vec4 vertex1 = texelFetch (polylines, verticesIndex + index1, 0);\n\n return mix (vertex0, vertex1, weight);\n }\n }"),this.set_polylines__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.polylinesNode.getBBox().center).add(this.polylinesNode.getBBox())}})(),set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})(),set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_polylines__:(()=>{const e=new(F()),t=new(F());return function(){const i=this.getBrowser().getContext(),n=this.polylinesNode.getVertices().getValue(),s=n.length/4,o=s/2+1,r=Math.ceil(Math.sqrt(o+s)),a=o;let c=this.polylinesArray;c.length<r*r*4&&(c=this.polylinesArray=new Float32Array(r*r*4));let l=0;for(let i=0,s=n.length;i<s;i+=8)e.set(n[i],n[i+1],n[i+2]),t.set(n[i+4],n[i+5],n[i+6]),c[i/2+4]=l+=t.subtract(e).norm();c.set(n,4*a),this.verticesIndex=s?a:-1,r&&(i.bindTexture(i.TEXTURE_2D,this.polylinesTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,r,r,0,i.RGBA,i.FLOAT,c)),this.set_verticesIndex__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.polylinesTextureUnit),e.bindTexture(e.TEXTURE_2D,this.polylinesTexture)}}),Object.defineProperties(Be,{...u().getStaticProperties("PolylineEmitter","ParticleSystems",1,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOnly,"set_coordIndex",new(o().MFInt32)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(a())(v().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const Me=Be,Ue=m().add("PolylineEmitter",Me),ze=e.Triangle3;var Le=t.n(ze);function Xe(e){w.call(this,e),this.addType(v().SurfaceEmitter),this.verticesIndex=-1,this.normalsIndex=-1,this.surfaceArray=new Float32Array}Object.assign(Object.setPrototypeOf(Xe.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.surfaceTexture=this.createTexture(),this._surface.addInterest("set_surface__",this),this.addDefine("#define X3D_SURFACE_EMITTER"),this.addSampler("surface"),this.addUniform("solid","uniform bool solid;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("surface","uniform sampler2D surface;"),this.addCallback(this.set_solid__),this.addCallback(this.set_verticesIndex__),this.addCallback(this.set_normalsIndex__),this.addFunction("vec4 position; vec3 getRandomVelocity ()\n {\n if (verticesIndex < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n vec3 normal;\n\n getRandomPointOnSurface (surface, verticesIndex, normalsIndex, position, normal);\n\n if (solid == false && random () > 0.5)\n normal = -normal;\n\n return normal * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return verticesIndex < 0 ? vec4 (NaN) : position;\n }"),this.set_surface__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){if(!this.surfaceNode)return t.set();const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.surfaceNode.getBBox().center).add(this.surfaceNode.getBBox())}})(),set_surface__(){this.surfaceNode&&(this.surfaceNode._solid.removeInterest("set_solid__",this),this.surfaceNode._rebuild.removeInterest("set_geometry__",this)),this.surfaceNode=L()(v().X3DGeometryNode,this._surface),this.surfaceNode&&(this.surfaceNode._solid.addInterest("set_solid__",this),this.surfaceNode._rebuild.addInterest("set_geometry__",this)),this.set_solid__(),this.set_geometry__()},set_solid__(){this.setUniform("uniform1i","solid",this.surfaceNode?._solid.getValue()??!0)},set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_normalsIndex__(){this.setUniform("uniform1i","normalsIndex",this.normalsIndex)},set_geometry__:(()=>{const e=new(F()),t=new(F()),i=new(F());return function(){const n=this.getBrowser().getContext();if(this.surfaceNode){const s=this.surfaceNode.getVertices().getValue(),o=this.surfaceNode.getNormals().getValue(),r=s.length/4,a=r/3+1,c=Math.ceil(Math.sqrt(a+r+r)),l=a,d=l+r;let u=this.surfaceArray;u.length<c*c*4&&(u=this.surfaceArray=new Float32Array(c*c*4));let h=0;for(let n=0,o=s.length;n<o;n+=12)e.set(s[n],s[n+1],s[n+2]),t.set(s[n+4],s[n+5],s[n+6]),i.set(s[n+8],s[n+9],s[n+10]),u[n/3+4]=h+=Le().area(e,t,i);u.set(s,4*l);for(let e=4*d,t=0,i=o.length;t<i;e+=4,t+=3)u[e+0]=o[t+0],u[e+1]=o[t+1],u[e+2]=o[t+2];this.verticesIndex=r?l:-1,this.normalsIndex=r?d:-1,c&&(n.bindTexture(n.TEXTURE_2D,this.surfaceTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,c,c,0,n.RGBA,n.FLOAT,u))}else this.verticesIndex=-1,this.normalsIndex=-1;this.set_verticesIndex__(),this.set_normalsIndex__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.surfaceTextureUnit),e.bindTexture(e.TEXTURE_2D,this.surfaceTexture)}}),Object.defineProperties(Xe,{...u().getStaticProperties("SurfaceEmitter","ParticleSystems",2,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"surface",new(o().SFNode))]),enumerable:!0}});const ke=Xe,je=m().add("SurfaceEmitter",ke),Ge=e.IndexedFaceSet;var He=t.n(Ge);function Ye(e){w.call(this,e),this.addType(v().VolumeEmitter),this.verticesIndex=-1,this.normalsIndex=-1,this.hierarchyIndex=-1,this.hierarchyRoot=-1,this.volumeNode=new(He())(e),this.volumeArray=new Float32Array}Object.assign(Object.setPrototypeOf(Ye.prototype,w.prototype),{initialize(){w.prototype.initialize.call(this),this.volumeTexture=this.createTexture(),this._set_coordIndex.addFieldInterest(this._coordIndex),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.volumeNode._coordIndex),this._coord.addFieldInterest(this.volumeNode._coord),this.volumeNode._creaseAngle=Math.PI,this.volumeNode._convex=!1,this.volumeNode._coordIndex=this._coordIndex,this.volumeNode._coord=this._coord,this.volumeNode.setPrivate(!0),this.volumeNode.setup(),this.volumeNode._rebuild.addInterest("set_geometry__",this),this.addDefine("#define X3D_VOLUME_EMITTER"),this.addSampler("volume"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("hierarchyIndex","uniform int hierarchyIndex;"),this.addUniform("hierarchyRoot","uniform int hierarchyRoot;"),this.addUniform("volume","uniform sampler2D volume;"),this.addCallback(this.set_direction__),this.addCallback(this.set_verticesIndex__),this.addCallback(this.set_normalsIndex__),this.addCallback(this.set_hierarchyIndex__),this.addCallback(this.set_hierarchyRoot__),this.addFunction("vec3 getRandomVelocity ()\n {\n if (hierarchyRoot < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (hierarchyRoot < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n vec4 point;\n vec3 normal;\n\n getRandomPointOnSurface (volume, verticesIndex, normalsIndex, point, normal);\n\n Line3 line = Line3 (point .xyz, getRandomSurfaceNormal (normal));\n\n vec4 points [ARRAY_SIZE];\n\n int numIntersections = getIntersections (volume, verticesIndex, hierarchyIndex, hierarchyRoot, line, points);\n\n numIntersections -= numIntersections % 2; // We need an even count of intersections.\n\n switch (numIntersections)\n {\n case 0:\n return vec4 (0.0);\n case 2:\n break;\n default:\n sort (points, numIntersections, plane3 (line .point, line .direction));\n break;\n }\n\n int index = int (fract (random ()) * float (numIntersections / 2)) * 2; // Select random intersection.\n\n return mix (points [index], points [index + 1], random ());\n }\n }"),this.set_geometry__()},getBBox:(()=>{const e=new(F());return function(t,{particleLifetime:i,lifetimeVariation:n}){const s=i*(1+n)*(this._speed.getValue()*(1+this._variation.getValue()))*2;return t.set(e.set(s,s,s),this.volumeNode.getBBox().center).add(this.volumeNode.getBBox())}})(),set_direction__:(()=>{const e=new(F());return function(){const{x:t,y:i,z:n}=e.assign(this._direction.getValue()).normalize();this.setUniform("uniform3f","direction",t,i,n)}})(),set_verticesIndex__(){this.setUniform("uniform1i","verticesIndex",this.verticesIndex)},set_normalsIndex__(){this.setUniform("uniform1i","normalsIndex",this.normalsIndex)},set_hierarchyIndex__(){this.setUniform("uniform1i","hierarchyIndex",this.hierarchyIndex)},set_hierarchyRoot__(){this.setUniform("uniform1i","hierarchyRoot",this.hierarchyRoot)},set_geometry__:(()=>{const e=new(F()),t=new(F()),i=new(F());return function(){const n=this.getBrowser().getContext(),s=this.volumeNode.getVertices().getValue(),o=this.volumeNode.getNormals().getValue(),r=new Fe(s,o).toArray([]),a=s.length/4,c=o.length/3,l=a/3+1,d=r.length/4,u=Math.ceil(Math.sqrt(l+a+a+d)),h=l,m=h+a,_=m+c;let p=this.volumeArray;p.length<u*u*4&&(p=this.volumeArray=new Float32Array(u*u*4));let f=0;for(let n=0,o=s.length;n<o;n+=12)e.set(s[n],s[n+1],s[n+2]),t.set(s[n+4],s[n+5],s[n+6]),i.set(s[n+8],s[n+9],s[n+10]),p[n/3+4]=f+=Le().area(e,t,i);p.set(s,4*h);for(let e=4*m,t=0,i=o.length;t<i;e+=4,t+=3)p[e+0]=o[t+0],p[e+1]=o[t+1],p[e+2]=o[t+2];p.set(r,4*_),this.verticesIndex=h,this.normalsIndex=m,this.hierarchyIndex=_,this.hierarchyRoot=_+d-1,u&&(n.bindTexture(n.TEXTURE_2D,this.volumeTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,u,u,0,n.RGBA,n.FLOAT,p)),this.set_verticesIndex__(),this.set_normalsIndex__(),this.set_hierarchyIndex__(),this.set_hierarchyRoot__(),this._bbox_changed.addEvent()}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.volumeTextureUnit),e.bindTexture(e.TEXTURE_2D,this.volumeTexture)}}),Object.defineProperties(Ye,{...u().getStaticProperties("VolumeEmitter","ParticleSystems",2,"emitter","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOnly,"set_coordIndex",new(o().MFInt32)),new(a())(v().inputOutput,"on",new(o().SFBool)(!0)),new(a())(v().initializeOnly,"internal",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)),new(a())(v().inputOutput,"variation",new(o().SFFloat)(.25)),new(a())(v().inputOutput,"mass",new(o().SFFloat)),new(a())(v().inputOutput,"surfaceArea",new(o().SFFloat)),new(a())(v().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(a())(v().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const qe=Ye,We=m().add("VolumeEmitter",qe),Ke=e.Algorithm;var Ze=t.n(Ke);function Qe(e){U.call(this,e),this.addType(v().WindPhysicsModel),this._speed.setUnit("speed"),e.getSpecificationVersion()<=3.3&&(this._direction=new(F()))}Object.assign(Object.setPrototypeOf(Qe.prototype,U.prototype),{getRandomSpeed(e){const t=Math.max(this._speed.getValue(),0),i=t*Math.max(this._gustiness.getValue(),0);return e.getRandomValue(Math.max(0,t-i),t+i)},addForce:(()=>{const e=new(F());return function(t,i,n,s){if(this._enabled.getValue()){const o=i.getSurfaceArea(),r=this.getRandomSpeed(i),a=10**(2*Math.log(r))*.64615;return this._direction.getValue().equals(F().ZERO)?i.getRandomNormal(e):e.assign(this._direction.getValue()).normalize(),s.set(e.multiply(o*a*n),4*t),s[4*t+3]=Math.PI*Ze().clamp(this._turbulence.getValue(),0,1),!0}return!1}})()}),Object.defineProperties(Qe,{...u().getStaticProperties("WindPhysicsModel","ParticleSystems",1,"physics","3.2"),fieldDefinitions:{value:new(l())([new(a())(v().inputOutput,"metadata",new(o().SFNode)),new(a())(v().inputOutput,"enabled",new(o().SFBool)(!0)),new(a())(v().inputOutput,"direction",new(o().SFVec3f)(1,0,0)),new(a())(v().inputOutput,"speed",new(o().SFFloat)(.1)),new(a())(v().inputOutput,"gustiness",new(o().SFFloat)(.1)),new(a())(v().inputOutput,"turbulence",new(o().SFFloat))]),enumerable:!0}});const $e=Qe,Je=m().add("WindPhysicsModel",$e);n().add({name:"ParticleSystems",concreteNodes:[j,Y,K,$,De,N,Ue,je,We,Je],abstractNodes:[w,U],browserContext:C});m().add("ParticleSystemsComponent",undefined)})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* X_ITE v12.1.
|
|
2
|
-
const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-12.1.
|
|
1
|
+
/* X_ITE v12.1.9 */
|
|
2
|
+
const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-12.1.9")];
|
|
3
3
|
/******/ (() => { // webpackBootstrap
|
|
4
4
|
/******/ "use strict";
|
|
5
5
|
/******/ // The require scope
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* X_ITE v12.1.
|
|
2
|
-
const e=window[Symbol.for("X_ITE.X3D-12.1.7")];(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=e.Components;var n=t.n(i);const s=e.Fields;var o=t.n(s);const r=e.X3DFieldDefinition;var c=t.n(r);const a=e.FieldDefinitionArray;var p=t.n(a);const h=e.X3DNode;var d=t.n(h);const l=e.X3DSensorNode;var g=t.n(l);const u=e.X3DConstants;var y=t.n(u);const m=e.Namespace;var _=t.n(m);let w=0;const S={MATCH_ANY:w++,MATCH_EVERY:w++,MATCH_ONLY_ONE:w++},k=_().add("MatchCriterion",S);let f=0;const O={BOUNDS:f++,GEOMETRY:f++},b=_().add("IntersectionType",O);let T=0;const N={ANY:T++,CLOSEST:T++,ALL:T++,ALL_SORTED:T++},C=_().add("SortOrder",N),P=e.Matrix4;var M=t.n(P);const G=e.QuickSort;var v=t.n(G);const B=e.ObjectCache;const A=t.n(B)()(M());function F(e,t){return e.distance<t.distance}function j(e){g().call(this,e),this.addType(y().X3DPickSensorNode),this.objectType=new Set,this.intersectionType=b.BOUNDS,this.sortOrder=C.CLOSEST,this.pickTargetNodes=new Set,this.modelMatrices=[],this.targets=[],this.targets.size=0,this.pickedTargets=[],this.pickedTargetsSorter=new(v())(this.pickedTargets,F),this.pickedGeometries=new(o().MFNode)}Object.assign(Object.setPrototypeOf(j.prototype,g().prototype),{initialize(){this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_live__",this),this._objectType.addInterest("set_objectType__",this),this._matchCriterion.addInterest("set_matchCriterion__",this),this._intersectionType.addInterest("set_intersectionType__",this),this._sortOrder.addInterest("set_sortOrder__",this),this._pickTarget.addInterest("set_pickTarget__",this),this.set_objectType__(),this.set_matchCriterion__(),this.set_intersectionType__(),this.set_sortOrder__(),this.set_pickTarget__()},getObjectType(){return this.objectType},getMatchCriterion(){return this.matchCriterion},getIntersectionType(){return this.intersectionType},getSortOrder(){return this.sortOrder},getModelMatrices(){return this.modelMatrices},getTargets(){return this.targets},getPickShape:(()=>{const e=new WeakMap;return function(t){const i=e.get(t);if(void 0!==i)return i;const n=this.getBrowser().getPrivateScene(),s=n.createNode("Shape",!1),o=n.createNode("CollidableShape",!1);return s.setPrivate(!0),o.setPrivate(!0),o.setConvex(!0),s._geometry=t,o._shape=s,s.setup(),o.setup(),e.set(t,o),o}})(),getPickedGeometries(){const e=this.targets,t=e.size,i=this.pickedTargets,n=this.pickedGeometries;i.length=0;for(let n=0;n<t;++n){const t=e[n];t.intersected&&i.push(t)}if(0===i.length)return n.length=0,n;switch(this.sortOrder){case C.CLOSEST:this.pickedTargetsSorter.sort(0,i.length);case C.ANY:{n[0]=null;const e=i.length;for(let t=0;t<e&&!(n[0]=this.getPickedGeometry(i[t]));++t);n.length=1;break}case C.ALL_SORTED:this.pickedTargetsSorter.sort(0,i.length);case C.ALL:{const e=i.length;for(let t=0;t<e;++t)n[t]=this.getPickedGeometry(i[t]);n.length=e;break}}return n.assign(n.filter(e=>e)),n},getPickedGeometry(e){const t=e.geometryNode;return t.isPrivate()||t.getExecutionContext().isPrivate()?null:t},getPickedTargets(){return this.pickedTargets},set_live__(){this.getLive().getValue()&&this._enabled.getValue()&&!this.objectType.has("NONE")?(this.getBrowser().addPickSensor(this),this.setPickableObject(!0)):(this.getBrowser().removePickSensor(this),this.setPickableObject(!1))},set_objectType__(){this.objectType.clear();for(const e of this._objectType)this.objectType.add(e);this.set_live__()},set_matchCriterion__:(()=>{const e=new Map([["MATCH_ANY",k.MATCH_ANY],["MATCH_EVERY",k.MATCH_EVERY],["MATCH_ONLY_ONE",k.MATCH_ONLY_ONE]]);return function(){this.matchCriterion=e.get(this._matchCriterion.getValue())??k.MATCH_ANY}})(),set_intersectionType__:(()=>{const e=new Map([["BOUNDS",b.BOUNDS],["GEOMETRY",b.GEOMETRY]]);return function(){this.intersectionType=e.get(this._intersectionType.getValue())??b.BOUNDS}})(),set_sortOrder__:(()=>{const e=new Map([["ANY",C.ANY],["CLOSEST",C.CLOSEST],["ALL",C.ALL],["ALL_SORTED",C.ALL_SORTED]]);return function(){this.sortOrder=e.get(this._sortOrder.getValue())??C.CLOSEST}})(),set_pickTarget__(){this.pickTargetNodes.clear();for(const e of this._pickTarget)try{const t=e.getValue().getInnerNode(),i=t.getType();for(let e=i.length-1;e>=0;--e)switch(i[e]){case y().Inline:case y().Shape:case y().X3DGroupingNode:this.pickTargetNodes.add(t);break;default:continue}}catch{}},traverse(e,t){this.modelMatrices.push(A.pop().assign(t.getModelViewMatrix().get()))},collect(e,t,i){const n=this.pickTargetNodes;if(!i.some(e=>n.has(e)))return;const s=this.targets;let o;s.size<s.length?o=s[s.size]:s.push(o={modelMatrix:new(M()),pickedPoint:[],intersections:[]}),++s.size,o.intersected=!1,o.geometryNode=e,o.pickedPoint.length=0,o.intersections.length=0,o.modelMatrix.assign(t)},process(){for(const e of this.modelMatrices)A.push(e);this.modelMatrices.length=0,this.targets.size=0}}),Object.defineProperties(j,d().getStaticProperties("X3DPickSensorNode","Picking",1));const x=j,L=_().add("X3DPickSensorNode",x),V=e.Vector3;var D=t.n(V);const E=e.Box3;var z=t.n(E);const I=e.Line3;var R=t.n(I);function Y(e){L.call(this,e),this.addType(y().LinePickSensor)}Object.assign(Object.setPrototypeOf(Y.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=null;try{const e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType();for(let i=t.length-1;i>=0;--i)switch(t[i]){case y().IndexedLineSet:case y().LineSet:this.pickingGeometryNode=e;break;default:continue}}catch{}},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D()),s=new(M()),r=new(D()),c=new(D()),a=new(R()),p=new(D()),h=new(D()),d=[],l=new(D()),g=new(o().MFVec3f),u=new(o().MFVec3f),y=new(o().MFVec3f);return function(){if(this.pickingGeometryNode){const o=this.getModelMatrices(),m=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const s of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(const s of m)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const s=this.getPickedGeometries(),r=!!s.length;r!==this._isActive.getValue()&&(this._isActive=r),this._pickedGeometry.equals(s)||(this._pickedGeometry=s);break}case b.GEOMETRY:{for(const l of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(l);for(const o of m){const g=o.geometryNode,u=this.pickingGeometryNode.getVertices(),y=u.length;t.assign(g.getBBox()).multRight(o.modelMatrix),s.assign(o.modelMatrix).inverse().multLeft(l);for(let e=0;e<y;e+=8)if(s.multVecMatrix(r.set(u[e+0],u[e+1],u[e+2])),s.multVecMatrix(c.set(u[e+4],u[e+5],u[e+6])),a.setPoints(r,c),d.length=0,g.intersectsLine(a,o.modelMatrix,d))for(const e of d){p.assign(e.point).subtract(r),h.assign(e.point).subtract(c);p.add(h).norm()<=r.distance(c)&&o.intersections.push(e)}o.intersections.length&&(i.assign(e.center),n.assign(t.center),o.intersected=!0,o.distance=i.distance(n))}}const _=this.getPickedGeometries(),w=!!_.length;_.assign(_.filter(e=>e)),w!==this._isActive.getValue()&&(this._isActive=w),this._pickedGeometry.equals(_)||(this._pickedGeometry=_);const S=this.getPickedTargets();g.length=0,u.length=0,y.length=0;for(const e of S){const t=e.intersections;for(const e of t){const t=e.texCoord;l.set(t.x,t.y,t.z).divide(t.w),g.push(l),u.push(e.normal),y.push(e.point)}}this._pickedTextureCoordinate.equals(g)||(this._pickedTextureCoordinate=g),this._pickedNormal.equals(u)||(this._pickedNormal=u),this._pickedPoint.equals(y)||(this._pickedPoint=y);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(Y,{...d().getStaticProperties("LinePickSensor","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedTextureCoordinate",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedNormal",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedPoint",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const H=Y,X=_().add("LinePickSensor",H),U=e.X3DGroupingNode;var q=t.n(U);function W(e){this.addType(y().X3DPickableObject),this.objectType=new Set}Object.assign(W.prototype,{initialize(){this._objectType.addInterest("set_objectType__",this),this.set_objectType__()},getObjectType(){return this.objectType},set_objectType__(){this.objectType.clear();for(const e of this._objectType)this.objectType.add(e)},dispose(){}}),Object.defineProperties(W,d().getStaticProperties("X3DPickableObject","Picking",1));const K=W,Q=_().add("X3DPickableObject",K),J=e.TraverseType;var Z=t.n(J);function $(e){q().call(this,e),Q.call(this,e),this.addType(y().PickableGroup),this.pickSensorNodes=new Set}Object.assign(Object.setPrototypeOf($.prototype,q().prototype),Q.prototype,{initialize(){q().prototype.initialize.call(this),Q.prototype.initialize.call(this),this._pickable.addInterest("set_pickableObjects__",this)},set_pickableObjects__(){this.setPickableObject(this._pickable.getValue()||this.getTransformSensors().size)},traverse(e,t){if(e!==Z().PICKING)return void q().prototype.traverse.call(this,e,t);if(!this._pickable.getValue()){if(this.getTransformSensors().size){const e=t.getModelViewMatrix().get();for(const t of this.getTransformSensors())t.collect(e)}return}if(this.getObjectType().has("NONE"))return;const i=this.getBrowser(),n=i.getPickable();if(this.getObjectType().has("ALL"))return n.push(!0),q().prototype.traverse.call(this,e,t),void n.pop();const s=this.pickSensorNodes,o=i.getPickSensors();for(const e of o.at(-1)){if(!e.getObjectType().has("ALL")){let t=0;for(const i of this.getObjectType())if(e.getObjectType().has(i)){++t;break}switch(e.getMatchCriterion()){case k.MATCH_ANY:if(0===t)continue;break;case k.MATCH_EVERY:if(t!==pickSensor.getObjectType().size)continue;break;case k.MATCH_ONLY_ONE:if(1!==t)continue}}s.add(e)}n.push(!0),o.push(s),q().prototype.traverse.call(this,e,t),o.pop(),n.pop(),s.clear()},dispose(){Q.prototype.dispose.call(this),q().prototype.dispose.call(this)}}),Object.defineProperties($,{...d().getStaticProperties("PickableGroup","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"pickable",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"visible",new(o().SFBool)(!0)),new(c())(y().inputOutput,"bboxDisplay",new(o().SFBool)),new(c())(y().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(c())(y().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(c())(y().inputOnly,"addChildren",new(o().MFNode)),new(c())(y().inputOnly,"removeChildren",new(o().MFNode)),new(c())(y().inputOutput,"children",new(o().MFNode))]),enumerable:!0}});const ee=$,te=_().add("PickableGroup",ee),ie=e.X3DCast;var ne=t.n(ie);const se=e.Rotation4;var oe=t.n(se);const re=e.AmmoClass;var ce=t.n(re);function ae(){this.broadphase=new(ce().btDbvtBroadphase),this.collisionConfiguration=new(ce().btDefaultCollisionConfiguration),this.dispatcher=new(ce().btCollisionDispatcher)(this.collisionConfiguration),this.collisionWorld=new(ce().btCollisionWorld)(this.dispatcher,this.broadphase,this.collisionConfiguration),this.compoundShape1=new(ce().btCompoundShape),this.motionState1=new(ce().btDefaultMotionState),this.constructionInfo1=new(ce().btRigidBodyConstructionInfo)(0,this.motionState1,this.compoundShape1),this.rigidBody1=new(ce().btRigidBody)(this.constructionInfo1),this.compoundShape2=new(ce().btCompoundShape),this.motionState2=new(ce().btDefaultMotionState),this.constructionInfo2=new(ce().btRigidBodyConstructionInfo)(0,this.motionState2,this.compoundShape2),this.rigidBody2=new(ce().btRigidBody)(this.constructionInfo2),this.collisionWorld.addCollisionObject(this.rigidBody1),this.collisionWorld.addCollisionObject(this.rigidBody2)}Object.assign(ae.prototype,{constuctor:ae,setChildShape1(e,t){this.setChildShape(this.compoundShape1,e,t)},setChildShape2(e,t){this.setChildShape(this.compoundShape2,e,t)},setChildShape1Components(e,t,i){this.setChildShapeComponents(this.compoundShape1,e,t,i)},setChildShape2Components(e,t,i){this.setChildShapeComponents(this.compoundShape2,e,t,i)},setChildShape:(()=>{const e=new(D()),t=new(oe()),i=new(D())(1),n=new(ce().btVector3)(0,0,0);return function(s,o,r){s.getNumChildShapes()&&s.removeChildShapeByIndex(0),r.getNumChildShapes()&&(o.get(e,t,i),n.setValue(i.x,i.y,i.z),r.setLocalScaling(n),s.addChildShape(this.getTransform(e,t),r))}})(),setChildShapeComponents(e,t,i,n){e.getNumChildShapes()&&e.removeChildShapeByIndex(0),n.getNumChildShapes()&&(n.setLocalScaling(i),e.addChildShape(t,n))},contactTest(){this.collisionWorld.performDiscreteCollisionDetection();const e=this.dispatcher.getNumManifolds();for(let t=0;t<e;++t){const e=this.dispatcher.getManifoldByIndexInternal(t),i=e.getNumContacts();for(let t=0;t<i;++t){if(e.getContactPoint(t).getDistance()<=0)return!0}}return!1},getTransform:(()=>{const e=new(ce().btTransform),t=new(ce().btVector3)(0,0,0),i=new(M());return function(n,s,o){const r=o||e;return i.set(n,s),t.setValue(i[12],i[13],i[14]),r.getBasis().setValue(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),r.setOrigin(t),r}})()});const pe=ae,he=_().add("VolumePicker",pe);function de(e){L.call(this,e),this.addType(y().PointPickSensor),this.picker=new he,this.compoundShapes=[]}Object.assign(Object.setPrototypeOf(de.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode?._rebuild.removeInterest("set_geometry__",this),this.pickingGeometryNode=ne()(y().PointSet,this._pickingGeometry),this.pickingGeometryNode?._rebuild.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:(()=>{const e=new(ce().btVector3)(1,1,1),t=new(ce().btVector3),i=new(ce().btTransform);return function(){const n=this.compoundShapes,s=this.pickingGeometryNode?.getCoord(),o=s?.getSize()??0;for(let r=0;r<o;++r)if(r<n.length){const o=n[r],c=s.get1Point(r,o.point);t.setValue(c.x,c.y,c.z),i.setOrigin(t),o.setLocalScaling(e),o.updateChildTransform(0,i)}else{const e=new(ce().btCompoundShape),o=new(ce().btSphereShape)(0),c=s.get1Point(r,new(D()));e.point=c,t.setValue(c.x,c.y,c.z),i.setOrigin(t),e.addChildShape(i,o),n.push(e)}n.length=o}})(),process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D()),s=new(ce().btTransform),r=new(ce().btVector3),c=new(D()),a=new(oe()),p=new(D())(1),h=new(o().MFVec3f);return function(){if(this.pickingGeometryNode){const o=this.getModelMatrices(),d=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const s of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(const s of d)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const s=this.getPickedGeometries(),r=!!s.length;s.assign(s.filter(e=>e)),r!==this._isActive.getValue()&&(this._isActive=r),this._pickedGeometry.equals(s)||(this._pickedGeometry=s);break}case b.GEOMETRY:{const l=this.picker,g=this.compoundShapes;for(const h of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(h),h.get(c,a,p),l.getTransform(c,a,s),r.setValue(p.x,p.y,p.z);for(const o of g){l.setChildShape1Components(s,r,o);for(const s of d){const r=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),l.setChildShape2(s.modelMatrix,r.getCompoundShape()),l.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n),s.pickedPoint.push(o.point))}}}const u=this.getPickedGeometries(),y=!!u.length;u.assign(u.filter(e=>e)),y!==this._isActive.getValue()&&(this._isActive=y),this._pickedGeometry.equals(u)||(this._pickedGeometry=u);const m=this.getPickedTargets();h.length=0;for(const e of m)for(const t of e.pickedPoint)h.push(t);this._pickedPoint.equals(h)||(this._pickedPoint=h);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(de,{...d().getStaticProperties("PointPickSensor","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedPoint",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const le=de,ge=_().add("PointPickSensor",le);function ue(e){L.call(this,e),this.addType(y().PrimitivePickSensor),this.picker=new he}Object.assign(Object.setPrototypeOf(ue.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=null;try{const e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType();for(let i=t.length-1;i>=0;--i)switch(t[i]){case y().Box:case y().Cone:case y().Cylinder:case y().Sphere:this.pickingGeometryNode=e;break;default:continue}}catch{}},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D());return function(){if(this.pickingGeometryNode){const s=this.getModelMatrices(),o=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const r of s){e.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(const s of o)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const r=this.getPickedGeometries(),c=!!r.length;r.assign(r.filter(e=>e)),c!==this._isActive.getValue()&&(this._isActive=c),this._pickedGeometry.equals(r)||(this._pickedGeometry=r);break}case b.GEOMETRY:{const r=this.picker;for(const c of s){const s=this.getPickShape(this.pickingGeometryNode);e.assign(this.pickingGeometryNode.getBBox()).multRight(c),r.setChildShape1(c,s.getCompoundShape());for(const s of o){const o=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),r.setChildShape2(s.modelMatrix,o.getCompoundShape()),r.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}}const c=this.getPickedGeometries(),a=!!c.length;c.assign(c.filter(e=>e)),a!==this._isActive.getValue()&&(this._isActive=a),this._pickedGeometry.equals(c)||(this._pickedGeometry=c);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(ue,{...d().getStaticProperties("PrimitivePickSensor","Picking",2,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const ye=ue,me=_().add("PrimitivePickSensor",ye);function _e(e){L.call(this,e),this.addType(y().VolumePickSensor),this.picker=new he}Object.assign(Object.setPrototypeOf(_e.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=ne()(y().X3DGeometryNode,this._pickingGeometry)},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D());return function(){if(this.pickingGeometryNode){const s=this.getModelMatrices(),o=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const r of s){e.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(const s of o)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const r=this.getPickedGeometries(),c=!!r.length;r.assign(r.filter(e=>e)),c!==this._isActive.getValue()&&(this._isActive=c),this._pickedGeometry.equals(r)||(this._pickedGeometry=r);break}case b.GEOMETRY:{const r=this.picker;for(const c of s){const s=this.getPickShape(this.pickingGeometryNode);e.assign(this.pickingGeometryNode.getBBox()).multRight(c),r.setChildShape1(c,s.getCompoundShape());for(const s of o){const o=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),r.setChildShape2(s.modelMatrix,o.getCompoundShape()),r.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}}const c=this.getPickedGeometries(),a=!!c.length;c.assign(c.filter(e=>e)),a!==this._isActive.getValue()&&(this._isActive=a),this._pickedGeometry.equals(c)||(this._pickedGeometry=c);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(_e,{...d().getStaticProperties("VolumePickSensor","Picking",3,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const we=_e,Se=_().add("VolumePickSensor",we);n().add({name:"Picking",concreteNodes:[X,te,ge,me,Se],abstractNodes:[L,Q]});_().add("PickingComponent",undefined)})();
|
|
1
|
+
/* X_ITE v12.1.9 */
|
|
2
|
+
const e=window[Symbol.for("X_ITE.X3D-12.1.9")];(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=e.Components;var n=t.n(i);const s=e.Fields;var o=t.n(s);const r=e.X3DFieldDefinition;var c=t.n(r);const a=e.FieldDefinitionArray;var p=t.n(a);const h=e.X3DNode;var d=t.n(h);const l=e.X3DSensorNode;var g=t.n(l);const u=e.X3DConstants;var y=t.n(u);const m=e.Namespace;var _=t.n(m);let w=0;const S={MATCH_ANY:w++,MATCH_EVERY:w++,MATCH_ONLY_ONE:w++},k=_().add("MatchCriterion",S);let f=0;const O={BOUNDS:f++,GEOMETRY:f++},b=_().add("IntersectionType",O);let T=0;const N={ANY:T++,CLOSEST:T++,ALL:T++,ALL_SORTED:T++},C=_().add("SortOrder",N),P=e.Matrix4;var M=t.n(P);const G=e.QuickSort;var v=t.n(G);const B=e.ObjectCache;const A=t.n(B)()(M());function F(e,t){return e.distance<t.distance}function j(e){g().call(this,e),this.addType(y().X3DPickSensorNode),this.objectType=new Set,this.intersectionType=b.BOUNDS,this.sortOrder=C.CLOSEST,this.pickTargetNodes=new Set,this.modelMatrices=[],this.targets=[],this.targets.size=0,this.pickedTargets=[],this.pickedTargetsSorter=new(v())(this.pickedTargets,F),this.pickedGeometries=new(o().MFNode)}Object.assign(Object.setPrototypeOf(j.prototype,g().prototype),{initialize(){this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_live__",this),this._objectType.addInterest("set_objectType__",this),this._matchCriterion.addInterest("set_matchCriterion__",this),this._intersectionType.addInterest("set_intersectionType__",this),this._sortOrder.addInterest("set_sortOrder__",this),this._pickTarget.addInterest("set_pickTarget__",this),this.set_objectType__(),this.set_matchCriterion__(),this.set_intersectionType__(),this.set_sortOrder__(),this.set_pickTarget__()},getObjectType(){return this.objectType},getMatchCriterion(){return this.matchCriterion},getIntersectionType(){return this.intersectionType},getSortOrder(){return this.sortOrder},getModelMatrices(){return this.modelMatrices},getTargets(){return this.targets},getPickShape:(()=>{const e=new WeakMap;return function(t){const i=e.get(t);if(void 0!==i)return i;const n=this.getBrowser().getPrivateScene(),s=n.createNode("Shape",!1),o=n.createNode("CollidableShape",!1);return s.setPrivate(!0),o.setPrivate(!0),o.setConvex(!0),s._geometry=t,o._shape=s,s.setup(),o.setup(),e.set(t,o),o}})(),getPickedGeometries(){const e=this.targets,t=e.size,i=this.pickedTargets,n=this.pickedGeometries;i.length=0;for(let n=0;n<t;++n){const t=e[n];t.intersected&&i.push(t)}if(0===i.length)return n.length=0,n;switch(this.sortOrder){case C.CLOSEST:this.pickedTargetsSorter.sort(0,i.length);case C.ANY:{n[0]=null;const e=i.length;for(let t=0;t<e&&!(n[0]=this.getPickedGeometry(i[t]));++t);n.length=1;break}case C.ALL_SORTED:this.pickedTargetsSorter.sort(0,i.length);case C.ALL:{const e=i.length;for(let t=0;t<e;++t)n[t]=this.getPickedGeometry(i[t]);n.length=e;break}}return n.assign(n.filter(e=>e)),n},getPickedGeometry(e){const t=e.geometryNode;return t.isPrivate()||t.getExecutionContext().isPrivate()?null:t},getPickedTargets(){return this.pickedTargets},set_live__(){this.getLive().getValue()&&this._enabled.getValue()&&!this.objectType.has("NONE")?(this.getBrowser().addPickSensor(this),this.setPickableObject(!0)):(this.getBrowser().removePickSensor(this),this.setPickableObject(!1))},set_objectType__(){this.objectType.clear();for(const e of this._objectType)this.objectType.add(e);this.set_live__()},set_matchCriterion__:(()=>{const e=new Map([["MATCH_ANY",k.MATCH_ANY],["MATCH_EVERY",k.MATCH_EVERY],["MATCH_ONLY_ONE",k.MATCH_ONLY_ONE]]);return function(){this.matchCriterion=e.get(this._matchCriterion.getValue())??k.MATCH_ANY}})(),set_intersectionType__:(()=>{const e=new Map([["BOUNDS",b.BOUNDS],["GEOMETRY",b.GEOMETRY]]);return function(){this.intersectionType=e.get(this._intersectionType.getValue())??b.BOUNDS}})(),set_sortOrder__:(()=>{const e=new Map([["ANY",C.ANY],["CLOSEST",C.CLOSEST],["ALL",C.ALL],["ALL_SORTED",C.ALL_SORTED]]);return function(){this.sortOrder=e.get(this._sortOrder.getValue())??C.CLOSEST}})(),set_pickTarget__(){this.pickTargetNodes.clear();for(const e of this._pickTarget)try{const t=e.getValue().getInnerNode(),i=t.getType();for(let e=i.length-1;e>=0;--e)switch(i[e]){case y().Inline:case y().Shape:case y().X3DGroupingNode:this.pickTargetNodes.add(t);break;default:continue}}catch{}},traverse(e,t){this.modelMatrices.push(A.pop().assign(t.getModelViewMatrix().get()))},collect(e,t,i){const n=this.pickTargetNodes;if(!i.some(e=>n.has(e)))return;const s=this.targets;let o;s.size<s.length?o=s[s.size]:s.push(o={modelMatrix:new(M()),pickedPoint:[],intersections:[]}),++s.size,o.intersected=!1,o.geometryNode=e,o.pickedPoint.length=0,o.intersections.length=0,o.modelMatrix.assign(t)},process(){for(const e of this.modelMatrices)A.push(e);this.modelMatrices.length=0,this.targets.size=0}}),Object.defineProperties(j,d().getStaticProperties("X3DPickSensorNode","Picking",1));const x=j,L=_().add("X3DPickSensorNode",x),V=e.Vector3;var D=t.n(V);const E=e.Box3;var z=t.n(E);const I=e.Line3;var R=t.n(I);function Y(e){L.call(this,e),this.addType(y().LinePickSensor)}Object.assign(Object.setPrototypeOf(Y.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=null;try{const e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType();for(let i=t.length-1;i>=0;--i)switch(t[i]){case y().IndexedLineSet:case y().LineSet:this.pickingGeometryNode=e;break;default:continue}}catch{}},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D()),s=new(M()),r=new(D()),c=new(D()),a=new(R()),p=new(D()),h=new(D()),d=[],l=new(D()),g=new(o().MFVec3f),u=new(o().MFVec3f),y=new(o().MFVec3f);return function(){if(this.pickingGeometryNode){const o=this.getModelMatrices(),m=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const s of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(const s of m)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const s=this.getPickedGeometries(),r=!!s.length;r!==this._isActive.getValue()&&(this._isActive=r),this._pickedGeometry.equals(s)||(this._pickedGeometry=s);break}case b.GEOMETRY:{for(const l of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(l);for(const o of m){const g=o.geometryNode,u=this.pickingGeometryNode.getVertices(),y=u.length;t.assign(g.getBBox()).multRight(o.modelMatrix),s.assign(o.modelMatrix).inverse().multLeft(l);for(let e=0;e<y;e+=8)if(s.multVecMatrix(r.set(u[e+0],u[e+1],u[e+2])),s.multVecMatrix(c.set(u[e+4],u[e+5],u[e+6])),a.setPoints(r,c),d.length=0,g.intersectsLine(a,o.modelMatrix,d))for(const e of d){p.assign(e.point).subtract(r),h.assign(e.point).subtract(c);p.add(h).norm()<=r.distance(c)&&o.intersections.push(e)}o.intersections.length&&(i.assign(e.center),n.assign(t.center),o.intersected=!0,o.distance=i.distance(n))}}const _=this.getPickedGeometries(),w=!!_.length;_.assign(_.filter(e=>e)),w!==this._isActive.getValue()&&(this._isActive=w),this._pickedGeometry.equals(_)||(this._pickedGeometry=_);const S=this.getPickedTargets();g.length=0,u.length=0,y.length=0;for(const e of S){const t=e.intersections;for(const e of t){const t=e.texCoord;l.set(t.x,t.y,t.z).divide(t.w),g.push(l),u.push(e.normal),y.push(e.point)}}this._pickedTextureCoordinate.equals(g)||(this._pickedTextureCoordinate=g),this._pickedNormal.equals(u)||(this._pickedNormal=u),this._pickedPoint.equals(y)||(this._pickedPoint=y);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(Y,{...d().getStaticProperties("LinePickSensor","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedTextureCoordinate",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedNormal",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedPoint",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const H=Y,X=_().add("LinePickSensor",H),U=e.X3DGroupingNode;var q=t.n(U);function W(e){this.addType(y().X3DPickableObject),this.objectType=new Set}Object.assign(W.prototype,{initialize(){this._objectType.addInterest("set_objectType__",this),this.set_objectType__()},getObjectType(){return this.objectType},set_objectType__(){this.objectType.clear();for(const e of this._objectType)this.objectType.add(e)},dispose(){}}),Object.defineProperties(W,d().getStaticProperties("X3DPickableObject","Picking",1));const K=W,Q=_().add("X3DPickableObject",K),J=e.TraverseType;var Z=t.n(J);function $(e){q().call(this,e),Q.call(this,e),this.addType(y().PickableGroup),this.pickSensorNodes=new Set}Object.assign(Object.setPrototypeOf($.prototype,q().prototype),Q.prototype,{initialize(){q().prototype.initialize.call(this),Q.prototype.initialize.call(this),this._pickable.addInterest("set_pickableObjects__",this)},set_pickableObjects__(){this.setPickableObject(this._pickable.getValue()||this.getTransformSensors().size)},traverse(e,t){if(e!==Z().PICKING)return void q().prototype.traverse.call(this,e,t);if(!this._pickable.getValue()){if(this.getTransformSensors().size){const e=t.getModelViewMatrix().get();for(const t of this.getTransformSensors())t.collect(e)}return}if(this.getObjectType().has("NONE"))return;const i=this.getBrowser(),n=i.getPickable();if(this.getObjectType().has("ALL"))return n.push(!0),q().prototype.traverse.call(this,e,t),void n.pop();const s=this.pickSensorNodes,o=i.getPickSensors();for(const e of o.at(-1)){if(!e.getObjectType().has("ALL")){let t=0;for(const i of this.getObjectType())if(e.getObjectType().has(i)){++t;break}switch(e.getMatchCriterion()){case k.MATCH_ANY:if(0===t)continue;break;case k.MATCH_EVERY:if(t!==pickSensor.getObjectType().size)continue;break;case k.MATCH_ONLY_ONE:if(1!==t)continue}}s.add(e)}n.push(!0),o.push(s),q().prototype.traverse.call(this,e,t),o.pop(),n.pop(),s.clear()},dispose(){Q.prototype.dispose.call(this),q().prototype.dispose.call(this)}}),Object.defineProperties($,{...d().getStaticProperties("PickableGroup","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"pickable",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"visible",new(o().SFBool)(!0)),new(c())(y().inputOutput,"bboxDisplay",new(o().SFBool)),new(c())(y().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(c())(y().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(c())(y().inputOnly,"addChildren",new(o().MFNode)),new(c())(y().inputOnly,"removeChildren",new(o().MFNode)),new(c())(y().inputOutput,"children",new(o().MFNode))]),enumerable:!0}});const ee=$,te=_().add("PickableGroup",ee),ie=e.X3DCast;var ne=t.n(ie);const se=e.Rotation4;var oe=t.n(se);const re=e.AmmoClass;var ce=t.n(re);function ae(){this.broadphase=new(ce().btDbvtBroadphase),this.collisionConfiguration=new(ce().btDefaultCollisionConfiguration),this.dispatcher=new(ce().btCollisionDispatcher)(this.collisionConfiguration),this.collisionWorld=new(ce().btCollisionWorld)(this.dispatcher,this.broadphase,this.collisionConfiguration),this.compoundShape1=new(ce().btCompoundShape),this.motionState1=new(ce().btDefaultMotionState),this.constructionInfo1=new(ce().btRigidBodyConstructionInfo)(0,this.motionState1,this.compoundShape1),this.rigidBody1=new(ce().btRigidBody)(this.constructionInfo1),this.compoundShape2=new(ce().btCompoundShape),this.motionState2=new(ce().btDefaultMotionState),this.constructionInfo2=new(ce().btRigidBodyConstructionInfo)(0,this.motionState2,this.compoundShape2),this.rigidBody2=new(ce().btRigidBody)(this.constructionInfo2),this.collisionWorld.addCollisionObject(this.rigidBody1),this.collisionWorld.addCollisionObject(this.rigidBody2)}Object.assign(ae.prototype,{constuctor:ae,setChildShape1(e,t){this.setChildShape(this.compoundShape1,e,t)},setChildShape2(e,t){this.setChildShape(this.compoundShape2,e,t)},setChildShape1Components(e,t,i){this.setChildShapeComponents(this.compoundShape1,e,t,i)},setChildShape2Components(e,t,i){this.setChildShapeComponents(this.compoundShape2,e,t,i)},setChildShape:(()=>{const e=new(D()),t=new(oe()),i=new(D())(1),n=new(ce().btVector3)(0,0,0);return function(s,o,r){s.getNumChildShapes()&&s.removeChildShapeByIndex(0),r.getNumChildShapes()&&(o.get(e,t,i),n.setValue(i.x,i.y,i.z),r.setLocalScaling(n),s.addChildShape(this.getTransform(e,t),r))}})(),setChildShapeComponents(e,t,i,n){e.getNumChildShapes()&&e.removeChildShapeByIndex(0),n.getNumChildShapes()&&(n.setLocalScaling(i),e.addChildShape(t,n))},contactTest(){this.collisionWorld.performDiscreteCollisionDetection();const e=this.dispatcher.getNumManifolds();for(let t=0;t<e;++t){const e=this.dispatcher.getManifoldByIndexInternal(t),i=e.getNumContacts();for(let t=0;t<i;++t){if(e.getContactPoint(t).getDistance()<=0)return!0}}return!1},getTransform:(()=>{const e=new(ce().btTransform),t=new(ce().btVector3)(0,0,0),i=new(M());return function(n,s,o){const r=o||e;return i.set(n,s),t.setValue(i[12],i[13],i[14]),r.getBasis().setValue(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),r.setOrigin(t),r}})()});const pe=ae,he=_().add("VolumePicker",pe);function de(e){L.call(this,e),this.addType(y().PointPickSensor),this.picker=new he,this.compoundShapes=[]}Object.assign(Object.setPrototypeOf(de.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode?._rebuild.removeInterest("set_geometry__",this),this.pickingGeometryNode=ne()(y().PointSet,this._pickingGeometry),this.pickingGeometryNode?._rebuild.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:(()=>{const e=new(ce().btVector3)(1,1,1),t=new(ce().btVector3),i=new(ce().btTransform);return function(){const n=this.compoundShapes,s=this.pickingGeometryNode?.getCoord(),o=s?.getSize()??0;for(let r=0;r<o;++r)if(r<n.length){const o=n[r],c=s.get1Point(r,o.point);t.setValue(c.x,c.y,c.z),i.setOrigin(t),o.setLocalScaling(e),o.updateChildTransform(0,i)}else{const e=new(ce().btCompoundShape),o=new(ce().btSphereShape)(0),c=s.get1Point(r,new(D()));e.point=c,t.setValue(c.x,c.y,c.z),i.setOrigin(t),e.addChildShape(i,o),n.push(e)}n.length=o}})(),process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D()),s=new(ce().btTransform),r=new(ce().btVector3),c=new(D()),a=new(oe()),p=new(D())(1),h=new(o().MFVec3f);return function(){if(this.pickingGeometryNode){const o=this.getModelMatrices(),d=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const s of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(const s of d)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const s=this.getPickedGeometries(),r=!!s.length;s.assign(s.filter(e=>e)),r!==this._isActive.getValue()&&(this._isActive=r),this._pickedGeometry.equals(s)||(this._pickedGeometry=s);break}case b.GEOMETRY:{const l=this.picker,g=this.compoundShapes;for(const h of o){e.assign(this.pickingGeometryNode.getBBox()).multRight(h),h.get(c,a,p),l.getTransform(c,a,s),r.setValue(p.x,p.y,p.z);for(const o of g){l.setChildShape1Components(s,r,o);for(const s of d){const r=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),l.setChildShape2(s.modelMatrix,r.getCompoundShape()),l.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n),s.pickedPoint.push(o.point))}}}const u=this.getPickedGeometries(),y=!!u.length;u.assign(u.filter(e=>e)),y!==this._isActive.getValue()&&(this._isActive=y),this._pickedGeometry.equals(u)||(this._pickedGeometry=u);const m=this.getPickedTargets();h.length=0;for(const e of m)for(const t of e.pickedPoint)h.push(t);this._pickedPoint.equals(h)||(this._pickedPoint=h);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(de,{...d().getStaticProperties("PointPickSensor","Picking",1,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedPoint",new(o().MFVec3f)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const le=de,ge=_().add("PointPickSensor",le);function ue(e){L.call(this,e),this.addType(y().PrimitivePickSensor),this.picker=new he}Object.assign(Object.setPrototypeOf(ue.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=null;try{const e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType();for(let i=t.length-1;i>=0;--i)switch(t[i]){case y().Box:case y().Cone:case y().Cylinder:case y().Sphere:this.pickingGeometryNode=e;break;default:continue}}catch{}},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D());return function(){if(this.pickingGeometryNode){const s=this.getModelMatrices(),o=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const r of s){e.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(const s of o)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const r=this.getPickedGeometries(),c=!!r.length;r.assign(r.filter(e=>e)),c!==this._isActive.getValue()&&(this._isActive=c),this._pickedGeometry.equals(r)||(this._pickedGeometry=r);break}case b.GEOMETRY:{const r=this.picker;for(const c of s){const s=this.getPickShape(this.pickingGeometryNode);e.assign(this.pickingGeometryNode.getBBox()).multRight(c),r.setChildShape1(c,s.getCompoundShape());for(const s of o){const o=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),r.setChildShape2(s.modelMatrix,o.getCompoundShape()),r.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}}const c=this.getPickedGeometries(),a=!!c.length;c.assign(c.filter(e=>e)),a!==this._isActive.getValue()&&(this._isActive=a),this._pickedGeometry.equals(c)||(this._pickedGeometry=c);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(ue,{...d().getStaticProperties("PrimitivePickSensor","Picking",2,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const ye=ue,me=_().add("PrimitivePickSensor",ye);function _e(e){L.call(this,e),this.addType(y().VolumePickSensor),this.picker=new he}Object.assign(Object.setPrototypeOf(_e.prototype,L.prototype),{initialize(){L.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__(){this.pickingGeometryNode=ne()(y().X3DGeometryNode,this._pickingGeometry)},process:(()=>{const e=new(z()),t=new(z()),i=new(D()),n=new(D());return function(){if(this.pickingGeometryNode){const s=this.getModelMatrices(),o=this.getTargets();switch(this.getIntersectionType()){case b.BOUNDS:{for(const r of s){e.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(const s of o)t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),e.intersectsBox(t)&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}const r=this.getPickedGeometries(),c=!!r.length;r.assign(r.filter(e=>e)),c!==this._isActive.getValue()&&(this._isActive=c),this._pickedGeometry.equals(r)||(this._pickedGeometry=r);break}case b.GEOMETRY:{const r=this.picker;for(const c of s){const s=this.getPickShape(this.pickingGeometryNode);e.assign(this.pickingGeometryNode.getBBox()).multRight(c),r.setChildShape1(c,s.getCompoundShape());for(const s of o){const o=this.getPickShape(s.geometryNode);t.assign(s.geometryNode.getBBox()).multRight(s.modelMatrix),r.setChildShape2(s.modelMatrix,o.getCompoundShape()),r.contactTest()&&(i.assign(e.center),n.assign(t.center),s.intersected=!0,s.distance=i.distance(n))}}const c=this.getPickedGeometries(),a=!!c.length;c.assign(c.filter(e=>e)),a!==this._isActive.getValue()&&(this._isActive=a),this._pickedGeometry.equals(c)||(this._pickedGeometry=c);break}}}L.prototype.process.call(this)}})()}),Object.defineProperties(_e,{...d().getStaticProperties("VolumePickSensor","Picking",3,"children","3.2"),fieldDefinitions:{value:new(p())([new(c())(y().inputOutput,"metadata",new(o().SFNode)),new(c())(y().inputOutput,"description",new(o().SFString)),new(c())(y().inputOutput,"enabled",new(o().SFBool)(!0)),new(c())(y().inputOutput,"objectType",new(o().MFString)("ALL")),new(c())(y().inputOutput,"matchCriterion",new(o().SFString)("MATCH_ANY")),new(c())(y().initializeOnly,"intersectionType",new(o().SFString)("BOUNDS")),new(c())(y().initializeOnly,"sortOrder",new(o().SFString)("CLOSEST")),new(c())(y().inputOutput,"pickingGeometry",new(o().SFNode)),new(c())(y().inputOutput,"pickTarget",new(o().MFNode)),new(c())(y().outputOnly,"isActive",new(o().SFBool)),new(c())(y().outputOnly,"pickedGeometry",new(o().MFNode))]),enumerable:!0}});const we=_e,Se=_().add("VolumePickSensor",we);n().add({name:"Picking",concreteNodes:[X,te,ge,me,Se],abstractNodes:[L,Q]});_().add("PickingComponent",undefined)})();
|