x_ite 9.5.0 → 9.5.2
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 +1 -1
- package/dist/assets/components/Annotation.js +13 -13
- package/dist/assets/components/Annotation.min.js +1 -1
- package/dist/assets/components/CADGeometry.js +14 -14
- package/dist/assets/components/CADGeometry.min.js +1 -1
- package/dist/assets/components/CubeMapTexturing.js +25 -25
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -13
- package/dist/assets/components/DIS.min.js +1 -1
- package/dist/assets/components/EventUtilities.js +9 -9
- package/dist/assets/components/EventUtilities.min.js +1 -1
- package/dist/assets/components/Geometry2D.js +18 -18
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +33 -33
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +32 -34
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +9 -9
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +28 -28
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +25 -27
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +101 -66
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +20 -22
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +19 -21
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +38 -38
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +24 -24
- package/dist/assets/components/Text.min.js +1 -1
- package/dist/assets/components/TextureProjection.js +15 -15
- package/dist/assets/components/TextureProjection.min.js +1 -1
- package/dist/assets/components/Texturing3D.js +40 -36
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +19 -19
- package/dist/assets/components/VolumeRendering.min.js +1 -1
- package/dist/assets/components/X_ITE.js +97 -44
- package/dist/assets/components/X_ITE.min.js +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.d.ts +1 -1
- package/dist/x_ite.js +862 -653
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.min.mjs +1 -1
- package/dist/x_ite.mjs +862 -653
- package/dist/x_ite.zip +0 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
/* X_ITE v9.5.0 */(()=>{"use strict";var e={823:e=>{e.exports=window[Symbol.for("X_ITE.X3D-9.5.0")].require("lib/jquery")}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Components");var t=i.n(e);const n=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Fields");var o=i.n(n);const r=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Base/X3DFieldDefinition");var s=i.n(r);const a=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Base/FieldDefinitionArray");var c=i.n(a);const l=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Components/Core/X3DNode");var d=i.n(l);const u=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Browser/ParticleSystems/GeometryTypes");var m=i.n(u);const h=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Base/X3DConstants");var p=i.n(h);const f=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Namespace");var x=i.n(f);const _="struct 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.0)return false;float inv_det=1.0/det;vec3 tvec=line.point-a;float u=dot(tvec,pvec)*inv_det;if(u<0.0||u>1.0)return false;vec3 qvec=cross(tvec,edge1);float v=dot(line.direction,qvec)*inv_det;if(v<0.0||u+v>1.0)return false;r=vec3(u,v,1.0-u-v);return true;}";x().add("Line3.glsl","x_ite/Browser/ParticleSystems/Line3.glsl",_);const y=_,v="struct 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.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.0/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.0;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;}";x().add("Plane3.glsl","x_ite/Browser/ParticleSystems/Plane3.glsl",v);const g=v,b="bool intersects(const in vec3 min,const in vec3 max,const in Line3 line){vec3 intersection;if(intersects(plane3(max,vec3(0.0,0.0,1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(min,vec3(0.0,0.0,-1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(max,vec3(0.0,1.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(min,vec3(0.0,-1.0,0.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.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.yz,max.yz),vec4(min.yz,intersection.yz))))return true;}return false;}";x().add("Box3.glsl","x_ite/Browser/ParticleSystems/Box3.glsl",b);const w=b,T="#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);}int 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.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.0);current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}int 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.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.0);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]=save_normalize(r.z*n0+r.x*n1+r.y*n2);++count;}current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}";x().add("BVH.glsl","x_ite/Browser/ParticleSystems/BVH.glsl",T);const R=T;function I(e){d().call(this,e),this.addType(p().X3DParticleEmitterNode),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.samplers=[],this.uniforms={},this.functions=[],this.program=null,this.addSampler("forces"),this.addSampler("boundedVolume"),this.addSampler("colorRamp"),this.addSampler("texCoordRamp"),this.addUniform("speed","uniform float speed;"),this.addUniform("variation","uniform float variation;"),this.addFunction(y),this.addFunction(g),this.addFunction(w),this.addFunction(R)}Object.assign(Object.setPrototypeOf(I.prototype,d().prototype),{initialize(){d().prototype.initialize.call(this);const e=this.getBrowser().getContext();e.getVersion()<2||(this.program=this.createProgram(),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.set_on__(),this.set_speed__(),this.set_variation__(),this.set_mass__())},isExplosive:()=>!1,getMass(){return this.mass},set_on__(){this.on=this._on.getValue()},set_speed__(){this.setUniform("uniform1f","speed",this._speed.getValue())},set_variation__(){this.setUniform("uniform1f","variation",this._variation.getValue())},set_mass__(){this.mass=this._mass.getValue()},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),o=Math.sin(n);return e.set(Math.sin(t)*o,Math.cos(t)*o,i)},animate(e,t){const i=this.getBrowser().getContext(),n=e.inputParticles,o=e.particlesStride,r=e.particleOffsets,s=this.program;if(i.useProgram(s),i.uniform1i(s.randomSeed,4294967295*Math.random()),i.uniform1i(s.geometryType,e.geometryType),i.uniform1i(s.createParticles,e.createParticles&&this.on),i.uniform1f(s.particleLifetime,e.particleLifetime),i.uniform1f(s.lifetimeVariation,e.lifetimeVariation),i.uniform1f(s.deltaTime,t),i.uniform2f(s.particleSize,e._particleSize.x,e._particleSize.y),i.uniform1i(s.numForces,e.numForces),e.numForces&&(i.activeTexture(i.TEXTURE0+s.forcesTextureUnit),i.bindTexture(i.TEXTURE_2D,e.forcesTexture)),e.boundedHierarchyRoot<0?i.uniform1i(s.boundedHierarchyRoot,-1):(i.uniform1i(s.boundedVerticesIndex,e.boundedVerticesIndex),i.uniform1i(s.boundedNormalsIndex,e.boundedNormalsIndex),i.uniform1i(s.boundedHierarchyIndex,e.boundedHierarchyIndex),i.uniform1i(s.boundedHierarchyRoot,e.boundedHierarchyRoot),i.activeTexture(i.TEXTURE0+s.boundedVolumeTextureUnit),i.bindTexture(i.TEXTURE_2D,e.boundedTexture)),i.uniform1i(s.numColors,e.numColors),e.numColors&&(i.activeTexture(i.TEXTURE0+s.colorRampTextureUnit),i.bindTexture(i.TEXTURE_2D,e.colorRampTexture)),i.uniform1i(s.numTexCoords,e.numTexCoords),e.numTexCoords&&(i.uniform1i(s.texCoordCount,e.texCoordCount),i.activeTexture(i.TEXTURE0+s.texCoordRampTextureUnit),i.bindTexture(i.TEXTURE_2D,e.texCoordRampTexture)),this.activateTextures(i,s),n.vertexArrayObject.enable(s)){for(const[e,t]of s.inputs)i.bindBuffer(i.ARRAY_BUFFER,n),i.enableVertexAttribArray(t),i.vertexAttribPointer(t,4,i.FLOAT,!1,o,r[e]);i.bindBuffer(i.ARRAY_BUFFER,null)}i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,this.transformFeedback),i.bindBufferBase(i.TRANSFORM_FEEDBACK_BUFFER,0,e.outputParticles),i.enable(i.RASTERIZER_DISCARD),i.beginTransformFeedback(i.POINTS),i.drawArrays(i.POINTS,0,e.numParticles),i.endTransformFeedback(),i.disable(i.RASTERIZER_DISCARD),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null)},addSampler(e){this.samplers.push(e)},addUniform(e,t){this.uniforms[e]=t},setUniform(e,t,i,n,o){const r=this.getBrowser().getContext(),s=this.program;r.useProgram(s),r[e](s[t],i,n,o)},addFunction(e){this.functions.push(e)},createProgram(){const e=this.getBrowser(),t=e.getContext(),i=`#version 300 es\nprecision highp float;precision highp int;precision highp sampler2D;uniform int randomSeed;uniform int geometryType;uniform bool createParticles;uniform float particleLifetime;uniform float lifetimeVariation;uniform float deltaTime;uniform vec2 particleSize;uniform int numForces;uniform sampler2D forces;uniform int boundedVerticesIndex;uniform int boundedNormalsIndex;uniform int boundedHierarchyIndex;uniform int boundedHierarchyRoot;uniform sampler2D boundedVolume;uniform int numColors;uniform sampler2D colorRamp;uniform int texCoordCount;uniform int numTexCoords;uniform sampler2D texCoordRamp;\n${Object.values(this.uniforms).join("\n")}\n in 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(m()).map((([e,t])=>`#define ${e} ${t}`)).join("\n")}\n const 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.0)return vec3(0.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.0){if(cos_angle>0.0){return vec4(0.0,0.0,0.0,1.0);}else{vec3 t=cross(from,vec3(1.0,0.0,0.0));if(dot(t,t)==0.0)t=cross(from,vec3(0.0,1.0,0.0));t=save_normalize(t);return vec4(t,0.0);}}else{float s=sqrt(abs(1.0-cos_angle)*0.5);cross_vec=save_normalize(cross_vec);return vec4(cross_vec*s,sqrt(abs(1.0+cos_angle)*0.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.0*(v.x*q.x+v.y*q.y+v.z*q.z);float c=2.0*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.0-2.0*(A+B),2.0*(C+D),2.0*(E-F),2.0*(C-D),1.0-2.0*(B+G),2.0*(H+I),2.0*(E+F),2.0*(H-I),1.0-2.0*(A+G));}uint seed=1u;void srand(const in int value){seed=uint(value);}float random(){seed=seed*1103515245u+12345u;return float(seed)/4294967295.0;}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.0,particleLifetime-v);float max_=particleLifetime+v;return getRandomValue(min_,max_);}float getRandomSpeed(){float v=speed*variation;float min_=max(0.0,speed-v);float max_=speed+v;return getRandomValue(min_,max_);}vec3 getRandomNormal(){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(-1.0,1.0);float r=sqrt(1.0-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.0);float r=sqrt(1.0-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,0.0,1.0),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.0/3.0);float r=sqrt(1.0-cphi*cphi);vec3 normal=vec3(sin(theta)*r,cos(theta)*r,cphi);vec4 rotation=Quaternion(vec3(0.0,0.0,1.0),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;}void 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.0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;index1=count-1;weight=1.0;}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.0,1.0);}else{index0=0;index1=0;weight=0.0;}}}void 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;}}vec3 getRandomBarycentricCoord(){float u=random();float v=random();if(u+v>1.0){u=1.0-u;v=1.0-v;}float t=1.0-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${this.functions.join("\n")}\n vec4 getColor(const in float lifetime,const in float elapsedTime){if(numColors>0){float fraction=elapsedTime/lifetime;int index0;int index1;float weight;interpolate(colorRamp,numColors,fraction,index0,index1,weight);vec4 color0=texelFetch(colorRamp,numColors+index0,0);vec4 color1=texelFetch(colorRamp,numColors+index1,0);return mix(color0,color1,weight);}else{return vec4(1.0);}}void bounce(const in vec4 fromPosition,inout vec4 toPosition,inout vec3 velocity){if(boundedHierarchyRoot<0)return;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.0,plane1);if(index==-1)return;Plane3 plane2=plane3(points[index].xyz,normals[index]);if(sign(plane_distance(plane2,fromPosition.xyz))==sign(plane_distance(plane2,toPosition.xyz)))return;velocity=reflect(velocity,normals[index]);toPosition=vec4(points[index].xyz+reflect(points[index].xyz-fromPosition.xyz,normals[index]),1.0);}int getTexCoordIndex0(const in float lifetime,const in float elapsedTime){if(numTexCoords==0){return-1;}else{float fraction=elapsedTime/lifetime;int index0=0;interpolate(texCoordRamp,numTexCoords,fraction,index0);return numTexCoords+index0*texCoordCount;}}void main(){int life=int(input0[0]);float lifetime=input0[1];float elapsedTime=input0[2]+deltaTime;srand((gl_VertexID+randomSeed)*randomSeed);if(elapsedTime>lifetime){lifetime=getRandomLifetime();elapsedTime=0.0;output0=vec4(max(life+1,1),lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));if(createParticles){output1=getColor(lifetime,elapsedTime);output2=vec4(getRandomVelocity(),0.0);output6=getRandomPosition();}else{output1=vec4(0.0);output2=vec4(0.0);output6=vec4(NaN);}}else{vec3 velocity=input2.xyz;vec4 position=input6;for(int i=0;i<numForces;++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;}position.xyz+=velocity*deltaTime;bounce(input6,position,velocity);output0=vec4(life,lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));output1=getColor(lifetime,elapsedTime);output2=vec4(velocity,0.0);output6=position;}switch(geometryType){case POINT:case SPRITE:case GEOMETRY:{output3=vec4(1.0,0.0,0.0,0.0);output4=vec4(0.0,1.0,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}case LINE:{mat3 r=Matrix3(Quaternion(vec3(0.0,0.0,1.0),output2.xyz));mat3 s=mat3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,particleSize.y);mat3 m=r*s;output3=vec4(m[0],0.0);output4=vec4(m[1],0.0);output5=vec4(m[2],0.0);break;}default:{output3=vec4(particleSize.x,0.0,0.0,0.0);output4=vec4(0.0,particleSize.y,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}}}`,n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)||console.error(t.getShaderInfoLog(n));const o=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(o,"#version 300 es\nprecision highp float;void main(){}"),t.compileShader(o),t.getShaderParameter(o,t.COMPILE_STATUS)||console.error(t.getShaderInfoLog(o));const r=t.createProgram();t.attachShader(r,n),t.attachShader(r,o),t.transformFeedbackVaryings(r,Array.from({length:7},((e,t)=>"output"+t)),t.INTERLEAVED_ATTRIBS),t.linkProgram(r),t.getProgramParameter(r,t.LINK_STATUS)||console.error("Couldn't initialize particle shader: "+t.getProgramInfoLog(r)),r.inputs=[[0,t.getAttribLocation(r,"input0")],[2,t.getAttribLocation(r,"input2")],[6,t.getAttribLocation(r,"input6")]],r.randomSeed=t.getUniformLocation(r,"randomSeed"),r.geometryType=t.getUniformLocation(r,"geometryType"),r.createParticles=t.getUniformLocation(r,"createParticles"),r.particleLifetime=t.getUniformLocation(r,"particleLifetime"),r.lifetimeVariation=t.getUniformLocation(r,"lifetimeVariation"),r.deltaTime=t.getUniformLocation(r,"deltaTime"),r.particleSize=t.getUniformLocation(r,"particleSize"),r.numForces=t.getUniformLocation(r,"numForces"),r.forces=t.getUniformLocation(r,"forces"),r.boundedVerticesIndex=t.getUniformLocation(r,"boundedVerticesIndex"),r.boundedNormalsIndex=t.getUniformLocation(r,"boundedNormalsIndex"),r.boundedHierarchyIndex=t.getUniformLocation(r,"boundedHierarchyIndex"),r.boundedHierarchyRoot=t.getUniformLocation(r,"boundedHierarchyRoot"),r.boundedVolume=t.getUniformLocation(r,"boundedVolume"),r.numColors=t.getUniformLocation(r,"numColors"),r.colorRamp=t.getUniformLocation(r,"colorRamp"),r.texCoordCount=t.getUniformLocation(r,"texCoordCount"),r.numTexCoords=t.getUniformLocation(r,"numTexCoords"),r.texCoordRamp=t.getUniformLocation(r,"texCoordRamp");for(const e of Object.keys(this.uniforms))r[e]=t.getUniformLocation(r,e);r.NaN=t.getUniformLocation(r,"NaN"),t.useProgram(r);for(const i of this.samplers){const n=t.getUniformLocation(r,i);t.uniform1i(n,r[i+"TextureUnit"]=e.getTexture2DUnit())}return t.uniform1f(r.NaN,NaN),e.resetTextureUnits(),r},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},getTexture2DUnit(e,t,i){const n=t[i];return void 0===n?t[i]=e.getTexture2DUnit():n}}),Object.defineProperties(I,{typeName:{value:"X3DParticleEmitterNode",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0}});const F=I;x().add("X3DParticleEmitterNode","x_ite/Components/ParticleSystems/X3DParticleEmitterNode",F);const E=F,S=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Numbers/Vector3");var P=i.n(S);function A(e){E.call(this,e),this.addType(p().PointEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 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 }")}Object.assign(Object.setPrototypeOf(A.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.set_position__(),this.set_direction__())},set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})()}),Object.defineProperties(A,{typeName:{value:"PointEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const O=A;x().add("PointEmitter","x_ite/Components/ParticleSystems/PointEmitter",O);const N=O,C=Symbol();function B(){}Object.assign(B.prototype,{getDefaultEmitter(){return this[C]=new N(this.getPrivateScene()),this[C].setPrivate(!0),this[C].setup(),this.getDefaultEmitter=function(){return this[C]},Object.defineProperty(this,"getDefaultEmitter",{enumerable:!1}),this[C]}});const V=B;x().add("X3DParticleSystemsContext","x_ite/Browser/ParticleSystems/X3DParticleSystemsContext",V);const D=V;function z(e){d().call(this,e),this.addType(p().X3DParticlePhysicsModelNode)}Object.assign(Object.setPrototypeOf(z.prototype,d().prototype),{addForce(){}}),Object.defineProperties(z,{typeName:{value:"X3DParticlePhysicsModelNode",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0}});const U=z;x().add("X3DParticlePhysicsModelNode","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",U);const M=U,L=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Base/X3DCast");var X=i.n(L);function j(e){M.call(this,e),this.addType(p().BoundedPhysicsModel)}Object.assign(Object.setPrototypeOf(j.prototype,M.prototype),{initialize(){M.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__(){this.geometryNode&&this.geometryNode._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=X()(p().X3DGeometryNode,this._geometry),this.geometryNode&&this.geometryNode._rebuild.addInterest("addNodeEvent",this)},addGeometry(e,t){if(this.geometryNode&&this._enabled.getValue()){const i=this.geometryNode.getNormals().getValue(),n=this.geometryNode.getVertices().getValue();for(const t of i)e.push(t);for(const e of n)t.push(e)}}}),Object.defineProperties(j,{typeName:{value:"BoundedPhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const q=j;x().add("BoundedPhysicsModel","x_ite/Components/ParticleSystems/BoundedPhysicsModel",q);const H=q;function k(e){E.call(this,e),this.addType(p().ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("angle","uniform float 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 }")}Object.assign(Object.setPrototypeOf(k.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.set_position__(),this.set_direction__(),this.set_angle__())},set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__(){const e=this._direction.getValue();this.setUniform("uniform3f","direction",e.x,e.y,e.z)},set_angle__(){this.setUniform("uniform1f","angle",this._angle.getValue())}}),Object.defineProperties(k,{typeName:{value:"ConeEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"angle",new(o().SFFloat)(.785398)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const G=k;x().add("ConeEmitter","x_ite/Components/ParticleSystems/ConeEmitter",G);const Y=G;function W(e){E.call(this,e),this.addType(p().ExplosionEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addFunction("vec3 getRandomVelocity ()\n {\n return getRandomSphericalVelocity ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")}Object.assign(Object.setPrototypeOf(W.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this.set_position__())},isExplosive:()=>!0,set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)}}),Object.defineProperties(W,{typeName:{value:"ExplosionEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const K=W;x().add("ExplosionEmitter","x_ite/Components/ParticleSystems/ExplosionEmitter",K);const Z=K;function Q(e){M.call(this,e),this.addType(p().ForcePhysicsModel),this._force.setUnit("force")}Object.assign(Object.setPrototypeOf(Q.prototype,M.prototype),{addForce:(()=>{const e=new(P());return function(t,i,n,o){return!!this._enabled.getValue()&&(o.set(e.assign(this._force.getValue()).multiply(n),4*t),o[4*t+3]=0,!0)}})()}),Object.defineProperties(Q,{typeName:{value:"ForcePhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"force",new(o().SFVec3f)(0,-9.8,0))]),enumerable:!0}});const $=Q;x().add("ForcePhysicsModel","x_ite/Components/ParticleSystems/ForcePhysicsModel",$);const J=$,ee=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Components/Shape/X3DShapeNode");var te=i.n(ee);const ie=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Browser/Rendering/GeometryContext");var ne=i.n(ie);const oe=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Rendering/VertexArray");var re=i.n(oe);const se=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Rendering/TraverseType");var ae=i.n(se);const ce=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Browser/Shape/AlphaMode");var le=i.n(ce);const de=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Numbers/Matrix4");var ue=i.n(de);const me=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Numbers/Matrix3");var he=i.n(me);const pe=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Geometry/Plane3");var fe=i.n(pe);function xe(e,t){this.array=e,t&&(this.compare=t)}Object.assign(xe.prototype,{compare:(e,t)=>e<t,sort(e,t){t-e>1&&this.quicksort(e,t-1)},quicksort(e,t){let i=e,n=t;const{array:o,compare:r}=this,s=o[e+t>>>1];for(;;){for(;r(o[i],s);)++i;for(;r(s,o[n]);)--n;if(!(i<n)){i===n&&(++i,--n);break}{const e=o[i];o[i]=o[n],o[n]=e,i++,n--}}e<n&&this.quicksort(e,n),i<t&&this.quicksort(i,t)}});const _e=xe;x().add("QuickSort","standard/Math/Algorithms/QuickSort",_e);const ye=_e,ve=new(P()),ge=new(P()),be=new(P()),we={u:0,v:0,t:0},Te=[new(P())(0,0,1),new(P())(0,0,-1),new(P())(0,1,0),new(P())(0,-1,0),new(P())(1,0,0)];function Re(e,t){this.vertices=e.vertices,this.normals=e.normals,this.triangle=t,this.i4=12*t,this.i3=9*t}function Ie(e,t,i,n){this.min=new(P()),this.max=new(P()),this.planes=[],this.intersection=new(P());const o=e.vertices,r=this.min,s=this.max,a=i+n;let c=12*t[i];r.set(o[c],o[c+1],o[c+2]),s.assign(r);for(let e=i;e<a;++e)c=12*t[e],ve.set(o[c],o[c+1],o[c+2]),ge.set(o[c+4],o[c+5],o[c+6]),be.set(o[c+8],o[c+9],o[c+10]),r.min(ve,ge,be),s.max(ve,ge,be);for(let e=0;e<5;++e)this.planes[e]=new(fe())(e%2?r:s,Te[e]);if(n>2){e.sorter.compare.axis=this.getLongestAxis(r,s),e.sorter.sort(i,a);var l=n>>>1}else l=1;const d=n-l;this.left=l>1?new Ie(e,t,i,l):new Re(e,t[i]),this.right=d>1?new Ie(e,t,i+l,d):new Re(e,t[i+l])}function Fe(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 Re(this,0);break;default:{const t=[];for(let e=0;e<i;++e)t.push(e);this.sorter=new ye(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 Ie(this,t,0,i);break}}}Object.assign(Re.prototype,{intersectsLine(e,t,i){const n=this.vertices,o=this.normals,r=this.i4,s=this.i3;if(ve.x=n[r],ve.y=n[r+1],ve.z=n[r+2],ge.x=n[r+4],ge.y=n[r+5],ge.z=n[r+6],be.x=n[r+8],be.y=n[r+9],be.z=n[r+10],e.intersectsTriangle(ve,ge,be,we)){const e=we.u,a=we.v,c=1-e-a,l=t.size++;l>=t.length&&t.push(new(P())),t[l].set(c*n[r]+e*n[r+4]+a*n[r+8],c*n[r+1]+e*n[r+5]+a*n[r+9],c*n[r+2]+e*n[r+6]+a*n[r+10]),i&&(l>=i.length&&i.push(new(P())),i[l].set(c*o[s]+e*o[s+3]+a*o[s+6],c*o[s+1]+e*o[s+4]+a*o[s+7],c*o[s+2]+e*o[s+5]+a*o[s+8]))}},toArray(e){const t=e.length/4;return e.push(1,3*this.triangle,0,0),t}}),Object.assign(Ie.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,o=i.x,r=n.x,s=i.y,a=n.y,c=i.z,l=n.z,d=this.intersection;return!!(t[0].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.y>=s&&d.y<=a)||(!!(t[1].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.y>=s&&d.y<=a)||(!!(t[2].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.z>=c&&d.z<=l)||(!!(t[3].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.z>=c&&d.z<=l)||!!(t[4].intersectsLine(e,d)&&d.y>=s&&d.y<=a&&d.z>=c&&d.z<=l))))},getLongestAxis(e,t){const i=t.x-e.x,n=t.y-e.y,o=t.z-e.z;return i<n?n<o?2:1:i<o?2:0},toArray(e){const t=this.left.toArray(e),i=this.right.toArray(e),n=this.min,o=this.max,r=e.length/4;return e.push(0,t,i,0,n.x,n.y,n.z,0,o.x,o.y,o.z,0),r}}),Object.assign(Fe.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 Ee=Fe;x().add("BVH","standard/Math/Utility/BVH",Ee);const Se=Ee;var Pe=i(823);const Ae=new Float32Array([0,0,0,1]),Oe=new Float32Array([0,0,0,1,1,0,0,1,0,0,-.5,1,0,0,.5,1]),Ne=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 Ce(e){te().call(this,e),this.addType(p().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.forcePhysicsModelNodes=[],this.forces=new Float32Array(4),this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.colorRamp=new Float32Array,this.texCoordRamp=new Float32Array,this.geometryContext=new(ne())({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.matrixOffset=this.particleOffsets[3],this.texCoordOffset=0,this.instancesStride=this.particlesStride}Object.assign(Object.setPrototypeOf(Ce.prototype,te().prototype),{initialize(){te().prototype.initialize.call(this);const e=this.getBrowser(),t=e.getContext();e.getContext().getVersion()<2||(this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_enabled__",this),this._createParticles.addInterest("set_createParticles__",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._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._emitter.addInterest("set_emitter__",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.inputParticles=this.createBuffer(),this.outputParticles=this.createBuffer(),this.inputParticles.vertexArrayObject=new(re())(t),this.outputParticles.vertexArrayObject=new(re())(t),this.forcesTexture=this.createTexture(),this.boundedTexture=this.createTexture(),this.colorRampTexture=this.createTexture(),this.texCoordRampTexture=this.createTexture(),this.geometryBuffer=this.createBuffer(),this.texCoordBuffers=new Array(e.getMaxTexCoords()).fill(this.geometryBuffer),this.set_emitter__(),this.set_enabled__(),this.set_geometryType__(),this.set_createParticles__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__())},getShapeKey(){return this.numTexCoords?2:1},getGeometryContext(){return this.geometryType===m().GEOMETRY?this.getGeometry():this.geometryContext},getGeometryType(){return this.geometryType},getNumInstances(){return this.numParticles},getInstances(){return this.outputParticles},set_bbox__(){this._bboxSize.getValue().equals(this.getDefaultBBoxSize())?this.bbox.set(P().One,P().Zero):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();if(e===le().AUTO){if(this.geometryType===m().POINT)this.setTransparent(!0);else this.setTransparent(this.getAppearance().isTransparent()||this.colorRampNode?.isTransparent()||this.geometryType===m().GEOMETRY&&this.geometryNode?.isTransparent());this.setAlphaMode(this.isTransparent()?le().BLEND:le().OPAQUE)}else this.setTransparent(e===le().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_createParticles__(){this.createParticles=this._createParticles.getValue()},set_geometryType__(){const e=this.getBrowser().getContext();switch(this.geometryType=Pe.enum(m(),this._geometryType.getValue(),m().QUAD),this.geometryType){case m().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,Ae,e.DYNAMIC_DRAW);break;case m().LINE:this.geometryContext.geometryType=1,this.geometryContext.hasNormals=!1,this.texCoordCount=2,this.vertexCount=2,this.hasNormals=!1,this.texCoordsOffset=0,this.verticesOffset=8*Float32Array.BYTES_PER_ELEMENT,this.primitiveMode=e.LINES,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,Oe,e.DYNAMIC_DRAW);break;case m().TRIANGLE:case m().QUAD:case m().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,Ne,e.DYNAMIC_DRAW);break;case m().GEOMETRY:this.texCoordCount=0}this.geometryContext.updateGeometryKey(),this.updateVertexArrays(),this.set_transparent__()},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()},set_particleLifetime__(){this.particleLifetime=this._particleLifetime.getValue()},set_lifetimeVariation__(){this.lifetimeVariation=this._lifetimeVariation.getValue()},set_emitter__(){this.emitterNode=X()(p().X3DParticleEmitterNode,this._emitter),this.emitterNode||(this.emitterNode=this.getBrowser().getDefaultEmitter()),this.createParticles=this._createParticles.getValue()},set_physics__(){const e=this._physics.getValue(),t=this.forcePhysicsModelNodes,i=this.boundedPhysicsModelNodes;for(let e=0,t=i.length;e<t;++e)i[e].removeInterest("set_boundedPhysics__",this);t.length=0,i.length=0;for(let n=0,o=e.length;n<o;++n)try{const o=e[n].getValue().getInnerNode(),r=o.getType();for(let e=r.length-1;e>=0;--e){switch(r[e]){case p().ForcePhysicsModel:case p().WindPhysicsModel:t.push(o);break;case p().BoundedPhysicsModel:o.addInterest("set_boundedPhysics__",this),i.push(o);break;default:continue}break}}catch{}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,o=t.length;e<o;++e)t[e].addGeometry(i,n);const o=new Se(n,i).toArray([]),r=n.length/4,s=i.length/3,a=o.length/4,c=Math.ceil(Math.sqrt(r+s+a)),l=new Float32Array(c*c*4);this.boundedVerticesIndex=0,this.boundedNormalsIndex=r,this.boundedHierarchyIndex=this.boundedNormalsIndex+s,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(o,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&&this.colorRampNode.removeInterest("set_color__",this),this.colorRampNode=X()(p().X3DColorNode,this._color),this.colorRampNode&&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 o=this.colorRamp;n*n*4>o.length&&(o=this.colorRamp=new Float32Array(n*n*4));for(let e=0;e<i;++e)o[4*e]=t[e];this.colorRampNode?o.set(this.colorRampNode.addColors([],i).slice(0,4*i),4*i):o.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this.colorRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,o)),this.numColors=i,this.geometryContext.colorMaterial=!(!i||!this.colorRampNode),this.geometryContext.updateGeometryKey(),this.updateVertexArrays()},set_texCoordRamp__(){this.texCoordRampNode&&this.texCoordRampNode.removeInterest("set_texCoord__",this),this.texCoordRampNode=X()(p().X3DTextureCoordinateNode,this._texCoord),this.texCoordRampNode&&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 o=this.texCoordRamp;n*n*4>o.length?o=this.texCoordRamp=new Float32Array(n*n*4):o.fill(0);for(let e=0;e<i;++e)o[4*e]=t[e];this.texCoordRampNode&&o.set(this.texCoordRampNode.addPoints([]).slice(0,i*this.texCoordCount*4),4*i),n&&(e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,o)),this.numTexCoords=this.texCoordRampNode?i:0,this.updateVertexArrays()},updateVertexArrays(){this.inputParticles.vertexArrayObject.update(),this.outputParticles.vertexArrayObject.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,o=Object.assign(t.createBuffer(),this.outputParticles),r=new Uint8Array(i*n);t.bindBuffer(t.ARRAY_BUFFER,this.inputParticles),t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.bindBuffer(t.COPY_READ_BUFFER,this.outputParticles),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,r,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=o},animateParticles(){const e=this.getBrowser(),t=e.getContext(),i=this.emitterNode,n=1/Math.max(10,this.getBrowser().getCurrentFrameRate());let o=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(),o=Number.POSITIVE_INFINITY):this.createParticles=!1}else if(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)}if(i.getMass()){const e=this.forcePhysicsModelNodes;let n=e.length,r=this.forces,s=o/i.getMass();4*n>r.length&&(r=this.forces=new Float32Array(4*n));let a=0;for(let t=0;t<n;++t)a+=!e[t].addForce(t-a,i,s,r);this.numForces=n-=a,n&&(t.bindTexture(t.TEXTURE_2D,this.forcesTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,n,1,0,t.RGBA,t.FLOAT,r))}else this.numForces=0;const r=this.outputParticles;this.outputParticles=this.inputParticles,this.inputParticles=r,i.animate(this,o),e.addBrowserEvent()},updateSprite:(()=>{const e=new Float32Array(Ne),t=[new(P())(-.5,-.5,0),new(P())(.5,-.5,0),new(P())(.5,.5,0),new(P())(-.5,-.5,0),new(P())(.5,.5,0),new(P())(-.5,.5,0)],i=new(P()),n=new(P());return function(o,r){for(let t=0;t<3;++t)e[24+t]=r[6+t];n.set(this._particleSize.x,this._particleSize.y,1);for(let o=0;o<6;++o){const s=27+4*o;r.multVecMatrix(i.assign(t[o]).multVec(n)),e[s+0]=i.x,e[s+1]=i.y,e[s+2]=i.z}o.bindBuffer(o.ARRAY_BUFFER,this.geometryBuffer),o.bufferData(o.ARRAY_BUFFER,e,o.DYNAMIC_DRAW)}})(),intersectsBox(e,t){},traverse(e,t){if(this.numParticles){switch(e){case ae().POINTER:this._pointerEvents.getValue()&&t.addPointingShape(this);break;case ae().PICKING:case ae().COLLISION:break;case ae().SHADOW:this._castShadow.getValue()&&t.addShadowShape(this);break;case ae().DISPLAY:t.addDisplayShape(this)&&this.getAppearance().traverse(e,t)}this.geometryType===m().GEOMETRY&&this.getGeometry()?.traverse(e,t)}},displaySimple(e,t,i){switch(this.geometryType){case m().GEOMETRY:this.getGeometry()?.displaySimpleInstanced(e,i,this);break;case m().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 m().GEOMETRY:this.getGeometry()?.displayInstanced(e,t,this);break;case m().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));case m().QUAD:case m().TRIANGLE:{const i=ue().prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(i?e.CCW:e.CW),e.enable(e.CULL_FACE)}default:{const i=this.getBrowser(),n=this.getAppearance(),o=n.getRenderModes(),r=n.getShader(this.geometryContext,t),s=i.getPrimitiveMode(this.primitiveMode);for(const t of o)t.enable(e);if(r.enable(e),r.setUniforms(e,this.geometryContext,t),this.numTexCoords){const t=i.getTexture2DUnit();e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.uniform1i(r.x3d_TexCoordRamp,t)}const a=this.outputParticles;if(a.vertexArrayObject.enable(r.getProgram())){const t=this.particlesStride;r.enableParticleAttribute(e,a,t,this.particleOffset,1),r.enableInstanceMatrixAttribute(e,a,t,this.matrixOffset,1),this.geometryContext.colorMaterial&&(r.enableColorAttribute(e,a,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(s,0,this.vertexCount,this.numParticles);for(const t of o)t.disable(e);break}}},getScreenAlignedRotation:(()=>{const e=new(ue()),t=new(P()),i=new(P()),n=new(P()),o=new(he())(9);return function(r){e.assign(r).inverse(),e.multDirMatrix(t.assign(P().zAxis)),e.multDirMatrix(i.assign(P().yAxis));const s=i.cross(t);n.assign(t).cross(s);const a=t;return s.normalize(),n.normalize(),a.normalize(),o.set(s.x,s.y,s.z,n.x,n.y,n.z,a.x,a.y,a.z),o}})()}),Object.defineProperties(Ce,{typeName:{value:"ParticleSystem",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"children",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"createParticles",new(o().SFBool)(!0)),new(s())(p().initializeOnly,"geometryType",new(o().SFString)("QUAD")),new(s())(p().inputOutput,"maxParticles",new(o().SFInt32)(200)),new(s())(p().inputOutput,"particleLifetime",new(o().SFFloat)(5)),new(s())(p().inputOutput,"lifetimeVariation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"particleSize",new(o().SFVec2f)(.02,.02)),new(s())(p().initializeOnly,"emitter",new(o().SFNode)),new(s())(p().initializeOnly,"physics",new(o().MFNode)),new(s())(p().initializeOnly,"colorKey",new(o().MFFloat)),new(s())(p().initializeOnly,"color",new(o().SFNode)),new(s())(p().initializeOnly,"texCoordKey",new(o().MFFloat)),new(s())(p().initializeOnly,"texCoord",new(o().SFNode)),new(s())(p().outputOnly,"isActive",new(o().SFBool)),new(s())(p().inputOutput,"pointerEvents",new(o().SFBool)(!0)),new(s())(p().inputOutput,"castShadow",new(o().SFBool)(!0)),new(s())(p().inputOutput,"visible",new(o().SFBool)(!0)),new(s())(p().inputOutput,"bboxDisplay",new(o().SFBool)),new(s())(p().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(s())(p().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(s())(p().inputOutput,"appearance",new(o().SFNode)),new(s())(p().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const Be=Ce;x().add("ParticleSystem","x_ite/Components/ParticleSystems/ParticleSystem",Be);const Ve=Be,De=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Components/Rendering/IndexedLineSet");var ze=i.n(De);function Ue(e){E.call(this,e),this.addType(p().PolylineEmitter),this.polylinesNode=new(ze())(e),this.polylinesArray=new Float32Array,this.addSampler("polylines"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("polylines","uniform sampler2D polylines;"),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 }")}Object.assign(Object.setPrototypeOf(Ue.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(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._rebuild.addInterest("set_polyline",this),this.polylinesNode.setPrivate(!0),this.polylinesNode.setup(),this.set_direction__(),this.set_polyline())},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})(),set_polyline:(()=>{const e=new(P()),t=new(P());return function(){const i=this.getBrowser().getContext(),n=this.polylinesNode.getVertices().getValue(),o=n.length/4,r=o/2+1,s=Math.ceil(Math.sqrt(r+o)),a=r;let c=this.polylinesArray;c.length<s*s*4&&(c=this.polylinesArray=new Float32Array(s*s*4));let l=0;for(let i=0,o=n.length;i<o;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).magnitude();c.set(n,4*a),this.setUniform("uniform1i","verticesIndex",o?a:-1),s&&(i.bindTexture(i.TEXTURE_2D,this.polylinesTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,s,s,0,i.RGBA,i.FLOAT,c))}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.polylinesTextureUnit),e.bindTexture(e.TEXTURE_2D,this.polylinesTexture)}}),Object.defineProperties(Ue,{typeName:{value:"PolylineEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOnly,"set_coordIndex",new(o().MFInt32)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(s())(p().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const Me=Ue;x().add("PolylineEmitter","x_ite/Components/ParticleSystems/PolylineEmitter",Me);const Le=Me,Xe=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Geometry/Triangle3");var je=i.n(Xe);function qe(e){E.call(this,e),this.addType(p().SurfaceEmitter),this.surfaceNode=null,this.surfaceArray=new Float32Array,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.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 }")}Object.assign(Object.setPrototypeOf(qe.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(this.surfaceTexture=this.createTexture(),this._surface.addInterest("set_surface__",this),this.set_surface__())},set_surface__(){this.surfaceNode&&(this.surfaceNode._solid.removeInterest("set_solid__",this),this.surfaceNode._rebuild.removeInterest("set_geometry__",this)),this.surfaceNode=X()(p().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.surfaceNode&&this.setUniform("uniform1i","solid",this.surfaceNode._solid.getValue())},set_geometry__:(()=>{const e=new(P()),t=new(P()),i=new(P());return function(){const n=this.getBrowser().getContext();if(this.surfaceNode){const o=this.surfaceNode.getVertices().getValue(),r=this.surfaceNode.getNormals().getValue(),s=o.length/4,a=s/3+1,c=Math.ceil(Math.sqrt(a+s+s)),l=a,d=l+s;let u=this.surfaceArray;u.length<c*c*4&&(u=this.surfaceArray=new Float32Array(c*c*4));let m=0;for(let n=0,r=o.length;n<r;n+=12)e.set(o[n],o[n+1],o[n+2]),t.set(o[n+4],o[n+5],o[n+6]),i.set(o[n+8],o[n+9],o[n+10]),u[n/3+4]=m+=je().area(e,t,i);u.set(o,4*l);for(let e=4*d,t=0,i=r.length;t<i;e+=4,t+=3)u[e+0]=r[t+0],u[e+1]=r[t+1],u[e+2]=r[t+2];this.setUniform("uniform1i","verticesIndex",s?l:-1),this.setUniform("uniform1i","normalsIndex",s?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.setUniform("uniform1i","verticesIndex",-1),this.setUniform("uniform1i","normalsIndex",-1)}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.surfaceTextureUnit),e.bindTexture(e.TEXTURE_2D,this.surfaceTexture)}}),Object.defineProperties(qe,{typeName:{value:"SurfaceEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"surface",new(o().SFNode))]),enumerable:!0}});const He=qe;x().add("SurfaceEmitter","x_ite/Components/ParticleSystems/SurfaceEmitter",He);const ke=He,Ge=window[Symbol.for("X_ITE.X3D-9.5.0")].require("x_ite/Components/Geometry3D/IndexedFaceSet");var Ye=i.n(Ge);function We(e){E.call(this,e),this.addType(p().VolumeEmitter),this.volumeNode=new(Ye())(e),this.volumeArray=new Float32Array,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.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 }")}Object.assign(Object.setPrototypeOf(We.prototype,E.prototype),{initialize(){E.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(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._rebuild.addInterest("set_geometry__",this),this.volumeNode.setPrivate(!0),this.volumeNode.setup(),this.set_direction__(),this.set_geometry__())},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})(),set_geometry__:(()=>{const e=new(P()),t=new(P()),i=new(P());return function(){const n=this.getBrowser().getContext(),o=this.volumeNode.getVertices().getValue(),r=this.volumeNode.getNormals().getValue(),s=new Se(o,r).toArray([]),a=o.length/4,c=r.length/3,l=a/3+1,d=s.length/4,u=Math.ceil(Math.sqrt(l+a+a+d)),m=l,h=m+a,p=h+c;let f=this.volumeArray;f.length<u*u*4&&(f=this.volumeArray=new Float32Array(u*u*4));let x=0;for(let n=0,r=o.length;n<r;n+=12)e.set(o[n],o[n+1],o[n+2]),t.set(o[n+4],o[n+5],o[n+6]),i.set(o[n+8],o[n+9],o[n+10]),f[n/3+4]=x+=je().area(e,t,i);f.set(o,4*m);for(let e=4*h,t=0,i=r.length;t<i;e+=4,t+=3)f[e+0]=r[t+0],f[e+1]=r[t+1],f[e+2]=r[t+2];f.set(s,4*p),this.setUniform("uniform1i","verticesIndex",m),this.setUniform("uniform1i","normalsIndex",h),this.setUniform("uniform1i","hierarchyIndex",p),this.setUniform("uniform1i","hierarchyRoot",p+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,f))}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.volumeTextureUnit),e.bindTexture(e.TEXTURE_2D,this.volumeTexture)}}),Object.defineProperties(We,{typeName:{value:"VolumeEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOnly,"set_coordIndex",new(o().MFInt32)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().initializeOnly,"internal",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(s())(p().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const Ke=We;x().add("VolumeEmitter","x_ite/Components/ParticleSystems/VolumeEmitter",Ke);const Ze=Ke,Qe=window[Symbol.for("X_ITE.X3D-9.5.0")].require("standard/Math/Algorithm");var $e=i.n(Qe);function Je(e){M.call(this,e),this.addType(p().WindPhysicsModel),this._speed.setUnit("speed"),e.getSpecificationVersion()<=3.3&&(this._direction=new(P()))}Object.assign(Object.setPrototypeOf(Je.prototype,M.prototype),{getRandomSpeed(e){const t=Math.max(0,this._speed.getValue()),i=t*Math.max(0,this._gustiness.getValue());return e.getRandomValue(Math.max(0,t-i),t+i)},addForce:(()=>{const e=new(P());return function(t,i,n,o){if(this._enabled.getValue()){const r=i._surfaceArea.getValue(),s=this.getRandomSpeed(i),a=10**(2*Math.log(s))*.64615;return this._direction.getValue().equals(P().Zero)?i.getRandomNormal(e):e.assign(this._direction.getValue()).normalize(),o.set(e.multiply(r*a*n),4*t),o[4*t+3]=Math.PI*$e().clamp(this._turbulence.getValue(),0,1),!0}return!1}})()}),Object.defineProperties(Je,{typeName:{value:"WindPhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(1,0,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)(.1)),new(s())(p().inputOutput,"gustiness",new(o().SFFloat)(.1)),new(s())(p().inputOutput,"turbulence",new(o().SFFloat))]),enumerable:!0}});const et=Je;x().add("WindPhysicsModel","x_ite/Components/ParticleSystems/WindPhysicsModel",et);const tt=et;t().add({name:"ParticleSystems",concreteNodes:[H,Y,Z,J,Ve,N,Le,ke,Ze,tt],abstractNodes:[E,M],browserContext:D});const it=void 0;x().add("ParticleSystems","assets/components/ParticleSystems",it)})()})();
|
|
1
|
+
/* X_ITE v9.5.2 */(()=>{"use strict";var e={823:e=>{e.exports=window[Symbol.for("X_ITE.X3D-9.5.2")].require("lib/jquery")}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components");var t=i.n(e);const n=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Fields");var o=i.n(n);const r=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Base/X3DFieldDefinition");var s=i.n(r);const a=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Base/FieldDefinitionArray");var c=i.n(a);const l=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Core/X3DNode");var d=i.n(l);const u=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Browser/ParticleSystems/GeometryTypes");var m=i.n(u);const h=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Base/X3DConstants");var p=i.n(h);const f=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Namespace");var x=i.n(f);const _="struct 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.0)return false;float inv_det=1.0/det;vec3 tvec=line.point-a;float u=dot(tvec,pvec)*inv_det;if(u<0.0||u>1.0)return false;vec3 qvec=cross(tvec,edge1);float v=dot(line.direction,qvec)*inv_det;if(v<0.0||u+v>1.0)return false;r=vec3(u,v,1.0-u-v);return true;}";x().add("Line3.glsl","x_ite/Browser/ParticleSystems/Line3.glsl",_);const y=_,v="struct 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.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.0/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.0;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;}";x().add("Plane3.glsl","x_ite/Browser/ParticleSystems/Plane3.glsl",v);const g=v,b="bool intersects(const in vec3 min,const in vec3 max,const in Line3 line){vec3 intersection;if(intersects(plane3(max,vec3(0.0,0.0,1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(min,vec3(0.0,0.0,-1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(max,vec3(0.0,1.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(min,vec3(0.0,-1.0,0.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.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.yz,max.yz),vec4(min.yz,intersection.yz))))return true;}return false;}";x().add("Box3.glsl","x_ite/Browser/ParticleSystems/Box3.glsl",b);const w=b,T="#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);}int 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.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.0);current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}int 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.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.0);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;}";x().add("BVH.glsl","x_ite/Browser/ParticleSystems/BVH.glsl",T);const I=T;function R(e){d().call(this,e),this.addType(p().X3DParticleEmitterNode),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.samplers=[],this.uniforms={},this.functions=[],this.program=null,this.addSampler("forces"),this.addSampler("boundedVolume"),this.addSampler("colorRamp"),this.addSampler("texCoordRamp"),this.addUniform("speed","uniform float speed;"),this.addUniform("variation","uniform float variation;"),this.addFunction(y),this.addFunction(g),this.addFunction(w),this.addFunction(I)}Object.assign(Object.setPrototypeOf(R.prototype,d().prototype),{initialize(){d().prototype.initialize.call(this);const e=this.getBrowser().getContext();e.getVersion()<2||(this.program=this.createProgram(),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.set_on__(),this.set_speed__(),this.set_variation__(),this.set_mass__())},isExplosive:()=>!1,getMass(){return this.mass},set_on__(){this.on=this._on.getValue()},set_speed__(){this.setUniform("uniform1f","speed",this._speed.getValue())},set_variation__(){this.setUniform("uniform1f","variation",this._variation.getValue())},set_mass__(){this.mass=this._mass.getValue()},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),o=Math.sin(n);return e.set(Math.sin(t)*o,Math.cos(t)*o,i)},animate(e,t){const i=this.getBrowser().getContext(),n=e.inputParticles,o=e.particlesStride,r=e.particleOffsets,s=this.program;if(i.useProgram(s),i.uniform1i(s.randomSeed,4294967295*Math.random()),i.uniform1i(s.geometryType,e.geometryType),i.uniform1i(s.createParticles,e.createParticles&&this.on),i.uniform1f(s.particleLifetime,e.particleLifetime),i.uniform1f(s.lifetimeVariation,e.lifetimeVariation),i.uniform1f(s.deltaTime,t),i.uniform2f(s.particleSize,e._particleSize.x,e._particleSize.y),i.uniform1i(s.numForces,e.numForces),e.numForces&&(i.activeTexture(i.TEXTURE0+s.forcesTextureUnit),i.bindTexture(i.TEXTURE_2D,e.forcesTexture)),e.boundedHierarchyRoot<0?i.uniform1i(s.boundedHierarchyRoot,-1):(i.uniform1i(s.boundedVerticesIndex,e.boundedVerticesIndex),i.uniform1i(s.boundedNormalsIndex,e.boundedNormalsIndex),i.uniform1i(s.boundedHierarchyIndex,e.boundedHierarchyIndex),i.uniform1i(s.boundedHierarchyRoot,e.boundedHierarchyRoot),i.activeTexture(i.TEXTURE0+s.boundedVolumeTextureUnit),i.bindTexture(i.TEXTURE_2D,e.boundedTexture)),i.uniform1i(s.numColors,e.numColors),e.numColors&&(i.activeTexture(i.TEXTURE0+s.colorRampTextureUnit),i.bindTexture(i.TEXTURE_2D,e.colorRampTexture)),i.uniform1i(s.numTexCoords,e.numTexCoords),e.numTexCoords&&(i.uniform1i(s.texCoordCount,e.texCoordCount),i.activeTexture(i.TEXTURE0+s.texCoordRampTextureUnit),i.bindTexture(i.TEXTURE_2D,e.texCoordRampTexture)),this.activateTextures(i,s),n.vertexArrayObject.enable(s))for(const[e,t]of s.inputs)i.bindBuffer(i.ARRAY_BUFFER,n),i.enableVertexAttribArray(t),i.vertexAttribPointer(t,4,i.FLOAT,!1,o,r[e]);i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindBuffer(i.ARRAY_BUFFER,null),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,this.transformFeedback),i.bindBufferBase(i.TRANSFORM_FEEDBACK_BUFFER,0,e.outputParticles),i.enable(i.RASTERIZER_DISCARD),i.beginTransformFeedback(i.POINTS),i.drawArrays(i.POINTS,0,e.numParticles),i.endTransformFeedback(),i.disable(i.RASTERIZER_DISCARD),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null)},addSampler(e){this.samplers.push(e)},addUniform(e,t){this.uniforms[e]=t},setUniform(e,t,i,n,o){const r=this.getBrowser().getContext(),s=this.program;r.useProgram(s),r[e](s[t],i,n,o)},addFunction(e){this.functions.push(e)},createProgram(){const e=this.getBrowser(),t=e.getContext(),i=`#version 300 es\nprecision highp float;precision highp int;precision highp sampler2D;uniform int randomSeed;uniform int geometryType;uniform bool createParticles;uniform float particleLifetime;uniform float lifetimeVariation;uniform float deltaTime;uniform vec2 particleSize;uniform int numForces;uniform sampler2D forces;uniform int boundedVerticesIndex;uniform int boundedNormalsIndex;uniform int boundedHierarchyIndex;uniform int boundedHierarchyRoot;uniform sampler2D boundedVolume;uniform int numColors;uniform sampler2D colorRamp;uniform int texCoordCount;uniform int numTexCoords;uniform sampler2D texCoordRamp;\n${Object.values(this.uniforms).join("\n")}\n in 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(m()).map((([e,t])=>`#define ${e} ${t}`)).join("\n")}\n const 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.0)return vec3(0.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.0){if(cos_angle>0.0){return vec4(0.0,0.0,0.0,1.0);}else{vec3 t=cross(from,vec3(1.0,0.0,0.0));if(dot(t,t)==0.0)t=cross(from,vec3(0.0,1.0,0.0));t=save_normalize(t);return vec4(t,0.0);}}else{float s=sqrt(abs(1.0-cos_angle)*0.5);cross_vec=save_normalize(cross_vec);return vec4(cross_vec*s,sqrt(abs(1.0+cos_angle)*0.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.0*(v.x*q.x+v.y*q.y+v.z*q.z);float c=2.0*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.0-2.0*(A+B),2.0*(C+D),2.0*(E-F),2.0*(C-D),1.0-2.0*(B+G),2.0*(H+I),2.0*(E+F),2.0*(H-I),1.0-2.0*(A+G));}uint seed=1u;void srand(const in int value){seed=uint(value);}float random(){seed=seed*1103515245u+12345u;return float(seed)/4294967295.0;}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.0,particleLifetime-v);float max_=particleLifetime+v;return getRandomValue(min_,max_);}float getRandomSpeed(){float v=speed*variation;float min_=max(0.0,speed-v);float max_=speed+v;return getRandomValue(min_,max_);}vec3 getRandomNormal(){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(-1.0,1.0);float r=sqrt(1.0-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.0);float r=sqrt(1.0-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,0.0,1.0),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.0/3.0);float r=sqrt(1.0-cphi*cphi);vec3 normal=vec3(sin(theta)*r,cos(theta)*r,cphi);vec4 rotation=Quaternion(vec3(0.0,0.0,1.0),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;}void 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.0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;index1=count-1;weight=1.0;}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.0,1.0);}else{index0=0;index1=0;weight=0.0;}}}void 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;}}vec3 getRandomBarycentricCoord(){float u=random();float v=random();if(u+v>1.0){u=1.0-u;v=1.0-v;}float t=1.0-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${this.functions.join("\n")}\n vec4 getColor(const in float lifetime,const in float elapsedTime){if(numColors>0){float fraction=elapsedTime/lifetime;int index0;int index1;float weight;interpolate(colorRamp,numColors,fraction,index0,index1,weight);vec4 color0=texelFetch(colorRamp,numColors+index0,0);vec4 color1=texelFetch(colorRamp,numColors+index1,0);return mix(color0,color1,weight);}else{return vec4(1.0);}}void bounce(const in float deltaTime,const in vec4 fromPosition,inout vec4 toPosition,inout vec3 velocity){if(boundedHierarchyRoot<0)return;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.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)*0.0001,1.0);velocity*=damping;}int getTexCoordIndex0(const in float lifetime,const in float elapsedTime){if(numTexCoords==0){return-1;}else{float fraction=elapsedTime/lifetime;int index0=0;interpolate(texCoordRamp,numTexCoords,fraction,index0);return numTexCoords+index0*texCoordCount;}}void main(){int life=int(input0[0]);float lifetime=input0[1];float elapsedTime=input0[2]+deltaTime;srand((gl_VertexID+randomSeed)*randomSeed);if(elapsedTime>lifetime){lifetime=getRandomLifetime();elapsedTime=0.0;output0=vec4(max(life+1,1),lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));if(createParticles){output1=getColor(lifetime,elapsedTime);output2=vec4(getRandomVelocity(),0.0);output6=getRandomPosition();}else{output1=vec4(0.0);output2=vec4(0.0);output6=vec4(NaN);}}else{vec3 velocity=input2.xyz;vec4 position=input6;for(int i=0;i<numForces;++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;}position.xyz+=velocity*deltaTime;bounce(deltaTime,input6,position,velocity);output0=vec4(life,lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));output1=getColor(lifetime,elapsedTime);output2=vec4(velocity,0.0);output6=position;}switch(geometryType){case POINT:case SPRITE:case GEOMETRY:{output3=vec4(1.0,0.0,0.0,0.0);output4=vec4(0.0,1.0,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}case LINE:{mat3 m=Matrix3(Quaternion(vec3(0.0,0.0,1.0),output2.xyz));output3=vec4(m[0],0.0);output4=vec4(m[1],0.0);output5=vec4(m[2],0.0);break;}default:{output3=vec4(particleSize.x,0.0,0.0,0.0);output4=vec4(0.0,particleSize.y,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}}}`,n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)||console.error(t.getShaderInfoLog(n));const o=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(o,"#version 300 es\nprecision highp float;void main(){}"),t.compileShader(o),t.getShaderParameter(o,t.COMPILE_STATUS)||console.error(t.getShaderInfoLog(o));const r=t.createProgram();t.attachShader(r,n),t.attachShader(r,o),t.transformFeedbackVaryings(r,Array.from({length:7},((e,t)=>"output"+t)),t.INTERLEAVED_ATTRIBS),t.linkProgram(r),t.getProgramParameter(r,t.LINK_STATUS)||console.error("Couldn't initialize particle shader: "+t.getProgramInfoLog(r)),r.inputs=[[0,t.getAttribLocation(r,"input0")],[2,t.getAttribLocation(r,"input2")],[6,t.getAttribLocation(r,"input6")]],r.randomSeed=t.getUniformLocation(r,"randomSeed"),r.geometryType=t.getUniformLocation(r,"geometryType"),r.createParticles=t.getUniformLocation(r,"createParticles"),r.particleLifetime=t.getUniformLocation(r,"particleLifetime"),r.lifetimeVariation=t.getUniformLocation(r,"lifetimeVariation"),r.deltaTime=t.getUniformLocation(r,"deltaTime"),r.particleSize=t.getUniformLocation(r,"particleSize"),r.numForces=t.getUniformLocation(r,"numForces"),r.forces=t.getUniformLocation(r,"forces"),r.boundedVerticesIndex=t.getUniformLocation(r,"boundedVerticesIndex"),r.boundedNormalsIndex=t.getUniformLocation(r,"boundedNormalsIndex"),r.boundedHierarchyIndex=t.getUniformLocation(r,"boundedHierarchyIndex"),r.boundedHierarchyRoot=t.getUniformLocation(r,"boundedHierarchyRoot"),r.boundedVolume=t.getUniformLocation(r,"boundedVolume"),r.numColors=t.getUniformLocation(r,"numColors"),r.colorRamp=t.getUniformLocation(r,"colorRamp"),r.texCoordCount=t.getUniformLocation(r,"texCoordCount"),r.numTexCoords=t.getUniformLocation(r,"numTexCoords"),r.texCoordRamp=t.getUniformLocation(r,"texCoordRamp");for(const e of Object.keys(this.uniforms))r[e]=t.getUniformLocation(r,e);r.NaN=t.getUniformLocation(r,"NaN"),t.useProgram(r);for(const i of this.samplers){const n=t.getUniformLocation(r,i);t.uniform1i(n,r[i+"TextureUnit"]=e.getTexture2DUnit())}return t.uniform1f(r.NaN,NaN),e.resetTextureUnits(),r},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},getTexture2DUnit(e,t,i){const n=t[i];return void 0===n?t[i]=e.getTexture2DUnit():n}}),Object.defineProperties(R,{typeName:{value:"X3DParticleEmitterNode",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0}});const F=R;x().add("X3DParticleEmitterNode","x_ite/Components/ParticleSystems/X3DParticleEmitterNode",F);const S=F,E=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Numbers/Vector3");var P=i.n(E);function A(e){S.call(this,e),this.addType(p().PointEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 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 }")}Object.assign(Object.setPrototypeOf(A.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.set_position__(),this.set_direction__())},set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})()}),Object.defineProperties(A,{typeName:{value:"PointEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const O=A;x().add("PointEmitter","x_ite/Components/ParticleSystems/PointEmitter",O);const N=O,C=Symbol();function V(){}Object.assign(V.prototype,{getDefaultEmitter(){return this[C]=new N(this.getPrivateScene()),this[C].setPrivate(!0),this[C].setup(),this.getDefaultEmitter=function(){return this[C]},Object.defineProperty(this,"getDefaultEmitter",{enumerable:!1}),this[C]}});const B=V;x().add("X3DParticleSystemsContext","x_ite/Browser/ParticleSystems/X3DParticleSystemsContext",B);const D=B;function z(e){d().call(this,e),this.addType(p().X3DParticlePhysicsModelNode)}Object.assign(Object.setPrototypeOf(z.prototype,d().prototype),{addForce(){}}),Object.defineProperties(z,{typeName:{value:"X3DParticlePhysicsModelNode",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0}});const U=z;x().add("X3DParticlePhysicsModelNode","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",U);const M=U,L=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Base/X3DCast");var X=i.n(L);function j(e){M.call(this,e),this.addType(p().BoundedPhysicsModel)}Object.assign(Object.setPrototypeOf(j.prototype,M.prototype),{initialize(){M.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__(){this.geometryNode?._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=X()(p().X3DGeometryNode,this._geometry),this.geometryNode?._rebuild.addInterest("addNodeEvent",this)},addGeometry(e,t){const i=this._damping.getValue();if(this.geometryNode&&this._enabled.getValue()){const n=this.geometryNode.getNormals().getValue(),o=this.geometryNode.getVertices().getValue();for(const t of n)e.push(t*i);for(const e of o)t.push(e)}}}),Object.defineProperties(j,{typeName:{value:"BoundedPhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"damping",new(o().SFFloat)(1)),new(s())(p().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const q=j;x().add("BoundedPhysicsModel","x_ite/Components/ParticleSystems/BoundedPhysicsModel",q);const k=q;function G(e){S.call(this,e),this.addType(p().ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("angle","uniform float 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 }")}Object.assign(Object.setPrototypeOf(G.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.set_position__(),this.set_direction__(),this.set_angle__())},set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__(){const e=this._direction.getValue();this.setUniform("uniform3f","direction",e.x,e.y,e.z)},set_angle__(){this.setUniform("uniform1f","angle",this._angle.getValue())}}),Object.defineProperties(G,{typeName:{value:"ConeEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"angle",new(o().SFFloat)(.785398)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const H=G;x().add("ConeEmitter","x_ite/Components/ParticleSystems/ConeEmitter",H);const Y=H;function W(e){S.call(this,e),this.addType(p().ExplosionEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addFunction("vec3 getRandomVelocity ()\n {\n return getRandomSphericalVelocity ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")}Object.assign(Object.setPrototypeOf(W.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this.set_position__())},isExplosive:()=>!0,set_position__(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)}}),Object.defineProperties(W,{typeName:{value:"ExplosionEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"position",new(o().SFVec3f)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat))]),enumerable:!0}});const K=W;x().add("ExplosionEmitter","x_ite/Components/ParticleSystems/ExplosionEmitter",K);const Z=K;function Q(e){M.call(this,e),this.addType(p().ForcePhysicsModel),this._force.setUnit("force")}Object.assign(Object.setPrototypeOf(Q.prototype,M.prototype),{addForce:(()=>{const e=new(P());return function(t,i,n,o){return!!this._enabled.getValue()&&(o.set(e.assign(this._force.getValue()).multiply(n),4*t),o[4*t+3]=0,!0)}})()}),Object.defineProperties(Q,{typeName:{value:"ForcePhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"force",new(o().SFVec3f)(0,-9.8,0))]),enumerable:!0}});const $=Q;x().add("ForcePhysicsModel","x_ite/Components/ParticleSystems/ForcePhysicsModel",$);const J=$,ee=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Shape/X3DShapeNode");var te=i.n(ee);const ie=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Browser/Rendering/GeometryContext");var ne=i.n(ie);const oe=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Rendering/VertexArray");var re=i.n(oe);const se=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Rendering/TraverseType");var ae=i.n(se);const ce=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Browser/Shape/AlphaMode");var le=i.n(ce);const de=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Rendering/LineSet");var ue=i.n(de);const me=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Rendering/Coordinate");var he=i.n(me);const pe=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Numbers/Matrix4");var fe=i.n(pe);const xe=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Numbers/Matrix3");var _e=i.n(xe);const ye=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Geometry/Plane3");var ve=i.n(ye);function ge(e,t){this.array=e,t&&(this.compare=t)}Object.assign(ge.prototype,{compare:(e,t)=>e<t,sort(e,t){t-e>1&&this.quicksort(e,t-1)},quicksort(e,t){let i=e,n=t;const{array:o,compare:r}=this,s=o[e+t>>>1];for(;;){for(;r(o[i],s);)++i;for(;r(s,o[n]);)--n;if(!(i<n)){i===n&&(++i,--n);break}{const e=o[i];o[i]=o[n],o[n]=e,i++,n--}}e<n&&this.quicksort(e,n),i<t&&this.quicksort(i,t)}});const be=ge;x().add("QuickSort","standard/Math/Algorithms/QuickSort",be);const we=be,Te=new(P()),Ie=new(P()),Re=new(P()),Fe={u:0,v:0,t:0},Se=[new(P())(0,0,1),new(P())(0,0,-1),new(P())(0,1,0),new(P())(0,-1,0),new(P())(1,0,0)];function Ee(e,t){this.vertices=e.vertices,this.normals=e.normals,this.triangle=t,this.i4=12*t,this.i3=9*t}function Pe(e,t,i,n){this.min=new(P()),this.max=new(P()),this.planes=[],this.intersection=new(P());const o=e.vertices,r=this.min,s=this.max,a=i+n;let c=12*t[i];r.set(o[c],o[c+1],o[c+2]),s.assign(r);for(let e=i;e<a;++e)c=12*t[e],Te.set(o[c],o[c+1],o[c+2]),Ie.set(o[c+4],o[c+5],o[c+6]),Re.set(o[c+8],o[c+9],o[c+10]),r.min(Te,Ie,Re),s.max(Te,Ie,Re);for(let e=0;e<5;++e)this.planes[e]=new(ve())(e%2?r:s,Se[e]);if(n>2){e.sorter.compare.axis=this.getLongestAxis(r,s),e.sorter.sort(i,a);var l=n>>>1}else l=1;const d=n-l;this.left=l>1?new Pe(e,t,i,l):new Ee(e,t[i]),this.right=d>1?new Pe(e,t,i+l,d):new Ee(e,t[i+l])}function Ae(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 Ee(this,0);break;default:{const t=[];for(let e=0;e<i;++e)t.push(e);this.sorter=new we(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 Pe(this,t,0,i);break}}}Object.assign(Ee.prototype,{intersectsLine(e,t,i){const n=this.vertices,o=this.normals,r=this.i4,s=this.i3;if(Te.x=n[r],Te.y=n[r+1],Te.z=n[r+2],Ie.x=n[r+4],Ie.y=n[r+5],Ie.z=n[r+6],Re.x=n[r+8],Re.y=n[r+9],Re.z=n[r+10],e.intersectsTriangle(Te,Ie,Re,Fe)){const e=Fe.u,a=Fe.v,c=1-e-a,l=t.size++;l>=t.length&&t.push(new(P())),t[l].set(c*n[r]+e*n[r+4]+a*n[r+8],c*n[r+1]+e*n[r+5]+a*n[r+9],c*n[r+2]+e*n[r+6]+a*n[r+10]),i&&(l>=i.length&&i.push(new(P())),i[l].set(c*o[s]+e*o[s+3]+a*o[s+6],c*o[s+1]+e*o[s+4]+a*o[s+7],c*o[s+2]+e*o[s+5]+a*o[s+8]))}},toArray(e){const t=e.length/4;return e.push(1,3*this.triangle,0,0),t}}),Object.assign(Pe.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,o=i.x,r=n.x,s=i.y,a=n.y,c=i.z,l=n.z,d=this.intersection;return!!(t[0].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.y>=s&&d.y<=a)||(!!(t[1].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.y>=s&&d.y<=a)||(!!(t[2].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.z>=c&&d.z<=l)||(!!(t[3].intersectsLine(e,d)&&d.x>=o&&d.x<=r&&d.z>=c&&d.z<=l)||!!(t[4].intersectsLine(e,d)&&d.y>=s&&d.y<=a&&d.z>=c&&d.z<=l))))},getLongestAxis(e,t){const i=t.x-e.x,n=t.y-e.y,o=t.z-e.z;return i<n?n<o?2:1:i<o?2:0},toArray(e){const t=this.left.toArray(e),i=this.right.toArray(e),n=this.min,o=this.max,r=e.length/4;return e.push(0,t,i,0,n.x,n.y,n.z,0,o.x,o.y,o.z,0),r}}),Object.assign(Ae.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 Oe=Ae;x().add("BVH","standard/Math/Utility/BVH",Oe);const Ne=Oe;var Ce=i(823);const Ve=new Float32Array([0,0,0,1]),Be=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 De(e){te().call(this,e),this.addType(p().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.forcePhysicsModelNodes=[],this.forces=new Float32Array(4),this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.colorRamp=new Float32Array,this.texCoordRamp=new Float32Array,this.geometryContext=new(ne())({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(De.prototype,te().prototype),{initialize(){te().prototype.initialize.call(this);const e=this.getBrowser(),t=e.getContext();e.getContext().getVersion()<2||(this.getLive().addInterest("set_live__",this),this._enabled.addInterest("set_enabled__",this),this._createParticles.addInterest("set_createParticles__",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._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._particleSize.addInterest("set_particleSize__",this),this._emitter.addInterest("set_emitter__",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.inputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(re())(t),thickLinesVertexArrayObject:new(re())(t),lineTrianglesBuffer:t.createBuffer(),numLines:0}),this.outputParticles=Object.assign(t.createBuffer(),{vertexArrayObject:new(re())(t),thickLinesVertexArrayObject:new(re())(t),lineTrianglesBuffer:t.createBuffer(),numLines:0}),this.forcesTexture=this.createTexture(),this.boundedTexture=this.createTexture(),this.colorRampTexture=this.createTexture(),this.texCoordRampTexture=this.createTexture(),this.geometryBuffer=this.createBuffer(),this.texCoordBuffers=new Array(e.getMaxTexCoords()).fill(this.geometryBuffer),this.lineGeometryNode=new(ue())(this.getExecutionContext()),this.lineCoordinateNode=new(he())(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_createParticles__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_particleSize__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__())},getShapeKey(){return this.numTexCoords?2:1},getGeometryContext(){return this.geometryType===m().GEOMETRY?this.getGeometry():this.geometryContext},getGeometryType(){return this.geometryType},getNumInstances(){return this.numParticles},getInstances(){return this.outputParticles},set_bbox__(){this._bboxSize.getValue().equals(this.getDefaultBBoxSize())?this.bbox.set(P().One,P().Zero):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();if(e===le().AUTO){if(this.geometryType===m().POINT)this.setTransparent(!0);else this.setTransparent(this.getAppearance().isTransparent()||this.colorRampNode?.isTransparent()||this.geometryType===m().GEOMETRY&&this.geometryNode?.isTransparent());this.setAlphaMode(this.isTransparent()?le().BLEND:le().OPAQUE)}else this.setTransparent(e===le().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_createParticles__(){this.createParticles=this._createParticles.getValue()},set_geometryType__(){const e=this.getBrowser().getContext();switch(this.geometryType=Ce.enum(m(),this._geometryType.getValue(),m().QUAD),this.geometryType){case m().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,Ve,e.DYNAMIC_DRAW);break;case m().LINE:this.geometryContext.geometryType=1,this.geometryContext.hasNormals=!1,this.texCoordCount=0;break;case m().TRIANGLE:case m().QUAD:case m().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,Be,e.DYNAMIC_DRAW);break;case m().GEOMETRY:this.texCoordCount=0}this.geometryContext.updateGeometryKey(),this.updateVertexArrays(),this.set_transparent__()},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()},set_particleLifetime__(){this.particleLifetime=this._particleLifetime.getValue()},set_lifetimeVariation__(){this.lifetimeVariation=this._lifetimeVariation.getValue()},set_particleSize__(){this.lineCoordinateNode._point[0].z=-this._particleSize.y/2,this.lineCoordinateNode._point[1].z=+this._particleSize.y/2},set_emitter__(){this.emitterNode=X()(p().X3DParticleEmitterNode,this._emitter),this.emitterNode||(this.emitterNode=this.getBrowser().getDefaultEmitter()),this.createParticles=this._createParticles.getValue()},set_physics__(){const e=this._physics.getValue(),t=this.forcePhysicsModelNodes,i=this.boundedPhysicsModelNodes;for(let e=0,t=i.length;e<t;++e)i[e].removeInterest("set_boundedPhysics__",this);t.length=0,i.length=0;for(let n=0,o=e.length;n<o;++n)try{const o=e[n].getValue().getInnerNode(),r=o.getType();for(let e=r.length-1;e>=0;--e){switch(r[e]){case p().ForcePhysicsModel:case p().WindPhysicsModel:t.push(o);break;case p().BoundedPhysicsModel:o.addInterest("set_boundedPhysics__",this),i.push(o);break;default:continue}break}}catch{}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,o=t.length;e<o;++e)t[e].addGeometry(i,n);const o=new Ne(n,i).toArray([]),r=n.length/4,s=i.length/3,a=o.length/4,c=Math.ceil(Math.sqrt(r+s+a)),l=new Float32Array(c*c*4);this.boundedVerticesIndex=0,this.boundedNormalsIndex=r,this.boundedHierarchyIndex=this.boundedNormalsIndex+s,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(o,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&&this.colorRampNode.removeInterest("set_color__",this),this.colorRampNode=X()(p().X3DColorNode,this._color),this.colorRampNode&&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 o=this.colorRamp;n*n*4>o.length&&(o=this.colorRamp=new Float32Array(n*n*4));for(let e=0;e<i;++e)o[4*e]=t[e];this.colorRampNode?o.set(this.colorRampNode.addColors([],i).slice(0,4*i),4*i):o.fill(1,4*i),n&&(e.bindTexture(e.TEXTURE_2D,this.colorRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,o)),this.numColors=i,this.geometryContext.colorMaterial=!(!i||!this.colorRampNode),this.geometryContext.updateGeometryKey(),this.updateVertexArrays()},set_texCoordRamp__(){this.texCoordRampNode&&this.texCoordRampNode.removeInterest("set_texCoord__",this),this.texCoordRampNode=X()(p().X3DTextureCoordinateNode,this._texCoord),this.texCoordRampNode&&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 o=this.texCoordRamp;n*n*4>o.length?o=this.texCoordRamp=new Float32Array(n*n*4):o.fill(0);for(let e=0;e<i;++e)o[4*e]=t[e];this.texCoordRampNode&&o.set(this.texCoordRampNode.addPoints([]).slice(0,i*this.texCoordCount*4),4*i),n&&(e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,n,n,0,e.RGBA,e.FLOAT,o)),this.numTexCoords=this.texCoordRampNode?i:0,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,o=Object.assign(t.createBuffer(),this.outputParticles),r=new Uint8Array(i*n);t.bindBuffer(t.ARRAY_BUFFER,this.inputParticles),t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.bindBuffer(t.COPY_READ_BUFFER,this.outputParticles),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,r,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=o},animateParticles(){const e=this.getBrowser(),t=e.getContext(),i=this.emitterNode,n=1/Math.max(10,this.getBrowser().getCurrentFrameRate());let o=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(),o=Number.POSITIVE_INFINITY):this.createParticles=!1}else if(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)}if(i.getMass()){const e=this.forcePhysicsModelNodes;let n=e.length,r=this.forces,s=o/i.getMass();4*n>r.length&&(r=this.forces=new Float32Array(4*n));let a=0;for(let t=0;t<n;++t)a+=!e[t].addForce(t-a,i,s,r);this.numForces=n-=a,n&&(t.bindTexture(t.TEXTURE_2D,this.forcesTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,n,1,0,t.RGBA,t.FLOAT,r))}else this.numForces=0;const r=this.outputParticles;this.outputParticles=this.inputParticles,this.inputParticles=r,i.animate(this,o),e.addBrowserEvent()},updateSprite:(()=>{const e=new Float32Array(Be),t=[new(P())(-.5,-.5,0),new(P())(.5,-.5,0),new(P())(.5,.5,0),new(P())(-.5,-.5,0),new(P())(.5,.5,0),new(P())(-.5,.5,0)],i=new(P()),n=new(P());return function(o,r){for(let t=0;t<3;++t)e[24+t]=r[6+t];n.set(this._particleSize.x,this._particleSize.y,1);for(let o=0;o<6;++o){const s=27+4*o;r.multVecMatrix(i.assign(t[o]).multVec(n)),e[s+0]=i.x,e[s+1]=i.y,e[s+2]=i.z}o.bindBuffer(o.ARRAY_BUFFER,this.geometryBuffer),o.bufferData(o.ARRAY_BUFFER,e,o.DYNAMIC_DRAW)}})(),intersectsBox(e,t){},traverse(e,t){if(this.numParticles){switch(e){case ae().POINTER:this._pointerEvents.getValue()&&t.addPointingShape(this);break;case ae().PICKING:case ae().COLLISION:break;case ae().SHADOW:this._castShadow.getValue()&&t.addShadowShape(this);break;case ae().DISPLAY:t.addDisplayShape(this)&&this.getAppearance().traverse(e,t)}this.geometryType===m().GEOMETRY&&this.getGeometry()?.traverse(e,t)}},displaySimple(e,t,i){switch(this.geometryType){case m().LINE:this.lineGeometryNode.displaySimpleInstanced(e,i,this);break;case m().GEOMETRY:this.getGeometry()?.displaySimpleInstanced(e,i,this);break;case m().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 m().LINE:this.lineGeometryNode.displayInstanced(e,t,this);break;case m().GEOMETRY:this.getGeometry()?.displayInstanced(e,t,this);break;case m().SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));case m().QUAD:case m().TRIANGLE:{const i=fe().prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(i?e.CCW:e.CW),e.enable(e.CULL_FACE)}default:{const i=this.getBrowser(),n=this.getAppearance(),o=n.getRenderModes(),r=n.getShader(this.geometryContext,t),s=i.getPrimitiveMode(this.primitiveMode);for(const t of o)t.enable(e);if(r.enable(e),r.setUniforms(e,this.geometryContext,t),this.numTexCoords){const t=i.getTexture2DUnit();e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.uniform1i(r.x3d_TexCoordRamp,t)}const a=this.outputParticles;if(a.vertexArrayObject.enable(r.getProgram())){const{particlesStride:t}=this;r.enableParticleAttribute(e,a,t,this.particleOffset,1),r.enableParticleVelocityAttribute(e,a,t,this.velocityOffset,1),r.enableInstanceMatrixAttribute(e,a,t,this.matrixOffset,1),this.geometryContext.colorMaterial&&(r.enableColorAttribute(e,a,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(s,0,this.vertexCount,this.numParticles);for(const t of o)t.disable(e);break}}},getScreenAlignedRotation:(()=>{const e=new(fe()),t=new(P()),i=new(P()),n=new(P()),o=new(_e())(9);return function(r){e.assign(r).inverse(),e.multDirMatrix(t.assign(P().zAxis)),e.multDirMatrix(i.assign(P().yAxis));const s=i.cross(t);n.assign(t).cross(s);const a=t;return s.normalize(),n.normalize(),a.normalize(),o.set(s.x,s.y,s.z,n.x,n.y,n.z,a.x,a.y,a.z),o}})()}),Object.defineProperties(De,{typeName:{value:"ParticleSystem",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"children",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"createParticles",new(o().SFBool)(!0)),new(s())(p().initializeOnly,"geometryType",new(o().SFString)("QUAD")),new(s())(p().inputOutput,"maxParticles",new(o().SFInt32)(200)),new(s())(p().inputOutput,"particleLifetime",new(o().SFFloat)(5)),new(s())(p().inputOutput,"lifetimeVariation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"particleSize",new(o().SFVec2f)(.02,.02)),new(s())(p().initializeOnly,"emitter",new(o().SFNode)),new(s())(p().initializeOnly,"physics",new(o().MFNode)),new(s())(p().initializeOnly,"colorKey",new(o().MFFloat)),new(s())(p().initializeOnly,"color",new(o().SFNode)),new(s())(p().initializeOnly,"texCoordKey",new(o().MFFloat)),new(s())(p().initializeOnly,"texCoord",new(o().SFNode)),new(s())(p().outputOnly,"isActive",new(o().SFBool)),new(s())(p().inputOutput,"pointerEvents",new(o().SFBool)(!0)),new(s())(p().inputOutput,"castShadow",new(o().SFBool)(!0)),new(s())(p().inputOutput,"visible",new(o().SFBool)(!0)),new(s())(p().inputOutput,"bboxDisplay",new(o().SFBool)),new(s())(p().initializeOnly,"bboxSize",new(o().SFVec3f)(-1,-1,-1)),new(s())(p().initializeOnly,"bboxCenter",new(o().SFVec3f)),new(s())(p().inputOutput,"appearance",new(o().SFNode)),new(s())(p().inputOutput,"geometry",new(o().SFNode))]),enumerable:!0}});const ze=De;x().add("ParticleSystem","x_ite/Components/ParticleSystems/ParticleSystem",ze);const Ue=ze,Me=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Rendering/IndexedLineSet");var Le=i.n(Me);function Xe(e){S.call(this,e),this.addType(p().PolylineEmitter),this.polylinesNode=new(Le())(e),this.polylinesArray=new Float32Array,this.addSampler("polylines"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("polylines","uniform sampler2D polylines;"),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 }")}Object.assign(Object.setPrototypeOf(Xe.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(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.set_direction__(),this.set_polylines__())},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})(),set_polylines__:(()=>{const e=new(P()),t=new(P());return function(){const i=this.getBrowser().getContext(),n=this.polylinesNode.getVertices().getValue(),o=n.length/4,r=o/2+1,s=Math.ceil(Math.sqrt(r+o)),a=r;let c=this.polylinesArray;c.length<s*s*4&&(c=this.polylinesArray=new Float32Array(s*s*4));let l=0;for(let i=0,o=n.length;i<o;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).magnitude();c.set(n,4*a),this.setUniform("uniform1i","verticesIndex",o?a:-1),s&&(i.bindTexture(i.TEXTURE_2D,this.polylinesTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,s,s,0,i.RGBA,i.FLOAT,c))}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.polylinesTextureUnit),e.bindTexture(e.TEXTURE_2D,this.polylinesTexture)}}),Object.defineProperties(Xe,{typeName:{value:"PolylineEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOnly,"set_coordIndex",new(o().MFInt32)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(s())(p().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const je=Xe;x().add("PolylineEmitter","x_ite/Components/ParticleSystems/PolylineEmitter",je);const qe=je,ke=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Geometry/Triangle3");var Ge=i.n(ke);function He(e){S.call(this,e),this.addType(p().SurfaceEmitter),this.surfaceNode=null,this.surfaceArray=new Float32Array,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.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 }")}Object.assign(Object.setPrototypeOf(He.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(this.surfaceTexture=this.createTexture(),this._surface.addInterest("set_surface__",this),this.set_surface__())},set_surface__(){this.surfaceNode&&(this.surfaceNode._solid.removeInterest("set_solid__",this),this.surfaceNode._rebuild.removeInterest("set_geometry__",this)),this.surfaceNode=X()(p().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.surfaceNode&&this.setUniform("uniform1i","solid",this.surfaceNode._solid.getValue())},set_geometry__:(()=>{const e=new(P()),t=new(P()),i=new(P());return function(){const n=this.getBrowser().getContext();if(this.surfaceNode){const o=this.surfaceNode.getVertices().getValue(),r=this.surfaceNode.getNormals().getValue(),s=o.length/4,a=s/3+1,c=Math.ceil(Math.sqrt(a+s+s)),l=a,d=l+s;let u=this.surfaceArray;u.length<c*c*4&&(u=this.surfaceArray=new Float32Array(c*c*4));let m=0;for(let n=0,r=o.length;n<r;n+=12)e.set(o[n],o[n+1],o[n+2]),t.set(o[n+4],o[n+5],o[n+6]),i.set(o[n+8],o[n+9],o[n+10]),u[n/3+4]=m+=Ge().area(e,t,i);u.set(o,4*l);for(let e=4*d,t=0,i=r.length;t<i;e+=4,t+=3)u[e+0]=r[t+0],u[e+1]=r[t+1],u[e+2]=r[t+2];this.setUniform("uniform1i","verticesIndex",s?l:-1),this.setUniform("uniform1i","normalsIndex",s?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.setUniform("uniform1i","verticesIndex",-1),this.setUniform("uniform1i","normalsIndex",-1)}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.surfaceTextureUnit),e.bindTexture(e.TEXTURE_2D,this.surfaceTexture)}}),Object.defineProperties(He,{typeName:{value:"SurfaceEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"surface",new(o().SFNode))]),enumerable:!0}});const Ye=He;x().add("SurfaceEmitter","x_ite/Components/ParticleSystems/SurfaceEmitter",Ye);const We=Ye,Ke=window[Symbol.for("X_ITE.X3D-9.5.2")].require("x_ite/Components/Geometry3D/IndexedFaceSet");var Ze=i.n(Ke);function Qe(e){S.call(this,e),this.addType(p().VolumeEmitter),this.volumeNode=new(Ze())(e),this.volumeArray=new Float32Array,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.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 }")}Object.assign(Object.setPrototypeOf(Qe.prototype,S.prototype),{initialize(){S.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(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.set_direction__(),this.set_geometry__())},set_direction__:(()=>{const e=new(P());return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}})(),set_geometry__:(()=>{const e=new(P()),t=new(P()),i=new(P());return function(){const n=this.getBrowser().getContext(),o=this.volumeNode.getVertices().getValue(),r=this.volumeNode.getNormals().getValue(),s=new Ne(o,r).toArray([]),a=o.length/4,c=r.length/3,l=a/3+1,d=s.length/4,u=Math.ceil(Math.sqrt(l+a+a+d)),m=l,h=m+a,p=h+c;let f=this.volumeArray;f.length<u*u*4&&(f=this.volumeArray=new Float32Array(u*u*4));let x=0;for(let n=0,r=o.length;n<r;n+=12)e.set(o[n],o[n+1],o[n+2]),t.set(o[n+4],o[n+5],o[n+6]),i.set(o[n+8],o[n+9],o[n+10]),f[n/3+4]=x+=Ge().area(e,t,i);f.set(o,4*m);for(let e=4*h,t=0,i=r.length;t<i;e+=4,t+=3)f[e+0]=r[t+0],f[e+1]=r[t+1],f[e+2]=r[t+2];f.set(s,4*p),this.setUniform("uniform1i","verticesIndex",m),this.setUniform("uniform1i","normalsIndex",h),this.setUniform("uniform1i","hierarchyIndex",p),this.setUniform("uniform1i","hierarchyRoot",p+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,f))}})(),activateTextures(e,t){e.activeTexture(e.TEXTURE0+t.volumeTextureUnit),e.bindTexture(e.TEXTURE_2D,this.volumeTexture)}}),Object.defineProperties(Qe,{typeName:{value:"VolumeEmitter",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:2}),enumerable:!0},containerField:{value:"emitter",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOnly,"set_coordIndex",new(o().MFInt32)),new(s())(p().inputOutput,"on",new(o().SFBool)(!0)),new(s())(p().initializeOnly,"internal",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(0,1,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)),new(s())(p().inputOutput,"variation",new(o().SFFloat)(.25)),new(s())(p().inputOutput,"mass",new(o().SFFloat)),new(s())(p().inputOutput,"surfaceArea",new(o().SFFloat)),new(s())(p().initializeOnly,"coordIndex",new(o().MFInt32)(-1)),new(s())(p().inputOutput,"coord",new(o().SFNode))]),enumerable:!0}});const $e=Qe;x().add("VolumeEmitter","x_ite/Components/ParticleSystems/VolumeEmitter",$e);const Je=$e,et=window[Symbol.for("X_ITE.X3D-9.5.2")].require("standard/Math/Algorithm");var tt=i.n(et);function it(e){M.call(this,e),this.addType(p().WindPhysicsModel),this._speed.setUnit("speed"),e.getSpecificationVersion()<=3.3&&(this._direction=new(P()))}Object.assign(Object.setPrototypeOf(it.prototype,M.prototype),{getRandomSpeed(e){const t=Math.max(0,this._speed.getValue()),i=t*Math.max(0,this._gustiness.getValue());return e.getRandomValue(Math.max(0,t-i),t+i)},addForce:(()=>{const e=new(P());return function(t,i,n,o){if(this._enabled.getValue()){const r=i._surfaceArea.getValue(),s=this.getRandomSpeed(i),a=10**(2*Math.log(s))*.64615;return this._direction.getValue().equals(P().Zero)?i.getRandomNormal(e):e.assign(this._direction.getValue()).normalize(),o.set(e.multiply(r*a*n),4*t),o[4*t+3]=Math.PI*tt().clamp(this._turbulence.getValue(),0,1),!0}return!1}})()}),Object.defineProperties(it,{typeName:{value:"WindPhysicsModel",enumerable:!0},componentInfo:{value:Object.freeze({name:"ParticleSystems",level:1}),enumerable:!0},containerField:{value:"physics",enumerable:!0},specificationRange:{value:Object.freeze({from:"3.2",to:"Infinity"}),enumerable:!0},fieldDefinitions:{value:new(c())([new(s())(p().inputOutput,"metadata",new(o().SFNode)),new(s())(p().inputOutput,"enabled",new(o().SFBool)(!0)),new(s())(p().inputOutput,"direction",new(o().SFVec3f)(1,0,0)),new(s())(p().inputOutput,"speed",new(o().SFFloat)(.1)),new(s())(p().inputOutput,"gustiness",new(o().SFFloat)(.1)),new(s())(p().inputOutput,"turbulence",new(o().SFFloat))]),enumerable:!0}});const nt=it;x().add("WindPhysicsModel","x_ite/Components/ParticleSystems/WindPhysicsModel",nt);const ot=nt;t().add({name:"ParticleSystems",concreteNodes:[k,Y,Z,J,Ue,N,qe,We,Je,ot],abstractNodes:[S,M],browserContext:D});const rt=void 0;x().add("ParticleSystems","assets/components/ParticleSystems",rt)})()})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* X_ITE v9.5.
|
|
1
|
+
/* X_ITE v9.5.2 */(() => { // webpackBootstrap
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ // The require scope
|
|
4
4
|
/******/ var __webpack_require__ = {};
|
|
@@ -39,28 +39,28 @@ var __webpack_exports__ = {};
|
|
|
39
39
|
// UNUSED EXPORTS: default
|
|
40
40
|
|
|
41
41
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components\")"
|
|
42
|
-
const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
42
|
+
const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Components");
|
|
43
43
|
var Components_default = /*#__PURE__*/__webpack_require__.n(Components_namespaceObject);
|
|
44
44
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Fields\")"
|
|
45
|
-
const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
45
|
+
const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Fields");
|
|
46
46
|
var Fields_default = /*#__PURE__*/__webpack_require__.n(Fields_namespaceObject);
|
|
47
47
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DFieldDefinition\")"
|
|
48
|
-
const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
48
|
+
const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Base/X3DFieldDefinition");
|
|
49
49
|
var X3DFieldDefinition_default = /*#__PURE__*/__webpack_require__.n(X3DFieldDefinition_namespaceObject);
|
|
50
50
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/FieldDefinitionArray\")"
|
|
51
|
-
const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
51
|
+
const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Base/FieldDefinitionArray");
|
|
52
52
|
var FieldDefinitionArray_default = /*#__PURE__*/__webpack_require__.n(FieldDefinitionArray_namespaceObject);
|
|
53
53
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Core/X3DSensorNode\")"
|
|
54
|
-
const X3DSensorNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
54
|
+
const X3DSensorNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Components/Core/X3DSensorNode");
|
|
55
55
|
var X3DSensorNode_default = /*#__PURE__*/__webpack_require__.n(X3DSensorNode_namespaceObject);
|
|
56
56
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Rendering/TraverseType\")"
|
|
57
|
-
const TraverseType_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
57
|
+
const TraverseType_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Rendering/TraverseType");
|
|
58
58
|
var TraverseType_default = /*#__PURE__*/__webpack_require__.n(TraverseType_namespaceObject);
|
|
59
59
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DConstants\")"
|
|
60
|
-
const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
60
|
+
const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Base/X3DConstants");
|
|
61
61
|
var X3DConstants_default = /*#__PURE__*/__webpack_require__.n(X3DConstants_namespaceObject);
|
|
62
62
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Namespace\")"
|
|
63
|
-
const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
63
|
+
const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Namespace");
|
|
64
64
|
var Namespace_default = /*#__PURE__*/__webpack_require__.n(Namespace_namespaceObject);
|
|
65
65
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/Picking/MatchCriterion.js
|
|
66
66
|
/*******************************************************************************
|
|
@@ -249,7 +249,7 @@ const SortOrder_default_ = SortOrder;
|
|
|
249
249
|
Namespace_default().add ("SortOrder", "x_ite/Browser/Picking/SortOrder", SortOrder_default_);
|
|
250
250
|
/* harmony default export */ const Picking_SortOrder = (SortOrder_default_);
|
|
251
251
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Matrix4\")"
|
|
252
|
-
const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
252
|
+
const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Math/Numbers/Matrix4");
|
|
253
253
|
var Matrix4_default = /*#__PURE__*/__webpack_require__.n(Matrix4_namespaceObject);
|
|
254
254
|
;// CONCATENATED MODULE: ./src/standard/Math/Algorithms/QuickSort.js
|
|
255
255
|
/*******************************************************************************
|
|
@@ -363,7 +363,7 @@ const QuickSort_default_ = QuickSort;
|
|
|
363
363
|
Namespace_default().add ("QuickSort", "standard/Math/Algorithms/QuickSort", QuickSort_default_);
|
|
364
364
|
/* harmony default export */ const Algorithms_QuickSort = (QuickSort_default_);
|
|
365
365
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Utility/ObjectCache\")"
|
|
366
|
-
const ObjectCache_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
366
|
+
const ObjectCache_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Utility/ObjectCache");
|
|
367
367
|
var ObjectCache_default = /*#__PURE__*/__webpack_require__.n(ObjectCache_namespaceObject);
|
|
368
368
|
;// CONCATENATED MODULE: ./src/x_ite/Components/Picking/X3DPickSensorNode.js
|
|
369
369
|
/*******************************************************************************
|
|
@@ -812,13 +812,13 @@ const X3DPickSensorNode_default_ = X3DPickSensorNode;
|
|
|
812
812
|
Namespace_default().add ("X3DPickSensorNode", "x_ite/Components/Picking/X3DPickSensorNode", X3DPickSensorNode_default_);
|
|
813
813
|
/* harmony default export */ const Picking_X3DPickSensorNode = (X3DPickSensorNode_default_);
|
|
814
814
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Vector3\")"
|
|
815
|
-
const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
815
|
+
const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Math/Numbers/Vector3");
|
|
816
816
|
var Vector3_default = /*#__PURE__*/__webpack_require__.n(Vector3_namespaceObject);
|
|
817
817
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Geometry/Box3\")"
|
|
818
|
-
const Box3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
818
|
+
const Box3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Math/Geometry/Box3");
|
|
819
819
|
var Box3_default = /*#__PURE__*/__webpack_require__.n(Box3_namespaceObject);
|
|
820
820
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Geometry/Line3\")"
|
|
821
|
-
const Line3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
821
|
+
const Line3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Math/Geometry/Line3");
|
|
822
822
|
var Line3_default = /*#__PURE__*/__webpack_require__.n(Line3_namespaceObject);
|
|
823
823
|
;// CONCATENATED MODULE: ./src/x_ite/Components/Picking/LinePickSensor.js
|
|
824
824
|
/*******************************************************************************
|
|
@@ -1166,7 +1166,7 @@ const LinePickSensor_default_ = LinePickSensor;
|
|
|
1166
1166
|
Namespace_default().add ("LinePickSensor", "x_ite/Components/Picking/LinePickSensor", LinePickSensor_default_);
|
|
1167
1167
|
/* harmony default export */ const Picking_LinePickSensor = (LinePickSensor_default_);
|
|
1168
1168
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Grouping/X3DGroupingNode\")"
|
|
1169
|
-
const X3DGroupingNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
1169
|
+
const X3DGroupingNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Components/Grouping/X3DGroupingNode");
|
|
1170
1170
|
var X3DGroupingNode_default = /*#__PURE__*/__webpack_require__.n(X3DGroupingNode_namespaceObject);
|
|
1171
1171
|
;// CONCATENATED MODULE: ./src/x_ite/Components/Picking/X3DPickableObject.js
|
|
1172
1172
|
/*******************************************************************************
|
|
@@ -1497,13 +1497,13 @@ const PickableGroup_default_ = PickableGroup;
|
|
|
1497
1497
|
Namespace_default().add ("PickableGroup", "x_ite/Components/Picking/PickableGroup", PickableGroup_default_);
|
|
1498
1498
|
/* harmony default export */ const Picking_PickableGroup = (PickableGroup_default_);
|
|
1499
1499
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DCast\")"
|
|
1500
|
-
const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
1500
|
+
const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("x_ite/Base/X3DCast");
|
|
1501
1501
|
var X3DCast_default = /*#__PURE__*/__webpack_require__.n(X3DCast_namespaceObject);
|
|
1502
1502
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Rotation4\")"
|
|
1503
|
-
const Rotation4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
1503
|
+
const Rotation4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("standard/Math/Numbers/Rotation4");
|
|
1504
1504
|
var Rotation4_default = /*#__PURE__*/__webpack_require__.n(Rotation4_namespaceObject);
|
|
1505
1505
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"lib/ammojs/AmmoClass\")"
|
|
1506
|
-
const AmmoClass_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.
|
|
1506
|
+
const AmmoClass_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.2")] .require ("lib/ammojs/AmmoClass");
|
|
1507
1507
|
var AmmoClass_default = /*#__PURE__*/__webpack_require__.n(AmmoClass_namespaceObject);
|
|
1508
1508
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/Picking/VolumePicker.js
|
|
1509
1509
|
/*******************************************************************************
|
|
@@ -1771,13 +1771,11 @@ Object .assign (Object .setPrototypeOf (PointPickSensor .prototype, Picking_X3DP
|
|
|
1771
1771
|
},
|
|
1772
1772
|
set_pickingGeometry__ ()
|
|
1773
1773
|
{
|
|
1774
|
-
|
|
1775
|
-
this .pickingGeometryNode ._rebuild .removeInterest ("set_geometry__", this);
|
|
1774
|
+
this .pickingGeometryNode ?._rebuild .removeInterest ("set_geometry__", this);
|
|
1776
1775
|
|
|
1777
1776
|
this .pickingGeometryNode = X3DCast_default() ((X3DConstants_default()).PointSet, this ._pickingGeometry);
|
|
1778
1777
|
|
|
1779
|
-
|
|
1780
|
-
this .pickingGeometryNode ._rebuild .addInterest ("set_geometry__", this);
|
|
1778
|
+
this .pickingGeometryNode ?._rebuild .addInterest ("set_geometry__", this);
|
|
1781
1779
|
|
|
1782
1780
|
this .set_geometry__ ();
|
|
1783
1781
|
},
|