@adatechnology/game-vfx-three 0.10.15 → 0.11.1

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/dist/index.d.ts CHANGED
@@ -4,6 +4,9 @@ import { LightBudget } from '@adatechnology/game-render-three';
4
4
  import { VfxWorld, ScreenState, VfxOptions, VfxProfileName, GroundField, SpriteKindSystem, MarkEvent, WaterEffects } from '@adatechnology/game-vfx';
5
5
  export { BenchText, VfxTestModuleOptions, benchText, benchTexts, createVfxTestModule } from './testing.js';
6
6
 
7
+ /** How a puff is drawn (`VfxRendererOptions.puffStyle`). */
8
+ type PuffStyle = 'faceted' | 'soft';
9
+
7
10
  /** The only three.js members the renderer needs at runtime. Pass your own `THREE` instance (the whole namespace works). */
8
11
  type ThreeLib = Pick<typeof THREE_NS, 'AdditiveBlending' | 'BufferAttribute' | 'BufferGeometry' | 'BoxGeometry' | 'CanvasTexture' | 'CircleGeometry' | 'Color' | 'ConeGeometry' | 'DodecahedronGeometry' | 'DynamicDrawUsage' | 'Euler' | 'Float32BufferAttribute' | 'Group' | 'IcosahedronGeometry' | 'InstancedBufferAttribute' | 'InstancedBufferGeometry' | 'InstancedMesh' | 'LineBasicMaterial' | 'LineSegments' | 'LinearSRGBColorSpace' | 'Matrix4' | 'Mesh' | 'MeshBasicMaterial' | 'MeshStandardMaterial' | 'NormalBlending' | 'PlaneGeometry' | 'Points' | 'PointLight' | 'Quaternion' | 'RepeatWrapping' | 'RingGeometry' | 'SRGBColorSpace' | 'DoubleSide' | 'ShaderMaterial' | 'SphereGeometry' | 'Vector3'>;
9
12
  /** A canvas the marks draw their textures on. A browser has one; a test supplies a fake. */
@@ -45,6 +48,11 @@ interface VfxRendererOptions {
45
48
  reducedMotion?: boolean;
46
49
  /** Canvas factory for the textures of the marks. Default `document.createElement('canvas')`. */
47
50
  createCanvas?: () => CanvasLike;
51
+ /**
52
+ * How flames, fireballs and smoke puffs are drawn: `faceted` (default), the Lab's solid low-poly volumes with banded light and a heat ramp in bands, dissolved by noise as
53
+ * they age; `soft`, round translucent puffs that thin out at the edge and with age.
54
+ */
55
+ puffStyle?: PuffStyle;
48
56
  /** Direction towards the light the puffs are shaded with. Default the Lab's moon. */
49
57
  lightDirection?: readonly [number, number, number];
50
58
  /** Pixels of point size per metre at a distance of one metre for the sprite kinds; roughly `viewportHeight / (2 * tan(fov / 2))`. Default 700. */
@@ -163,13 +171,20 @@ interface MarkLayerOptions {
163
171
  declare function createMarkLayer(THREE: ThreeLib, options: MarkLayerOptions): MarkLayer;
164
172
 
165
173
  /**
166
- * The puff shader, from the Lab's (L130-192): a noise-swollen sphere per puff, the Lab's heat ramp for what still burns. Smoke is soft and seen through: its normal is
174
+ * The faceted puff shader, the default style (`VfxRendererOptions.puffStyle: 'faceted'`): the puff shader of the Lab (L130-192), verbatim: a faceted icosahedron per puff, a five-band posterised heat ramp, a noise dissolve and banded light.
175
+ * Two changes: the r160 colour-space chunk (`encodings_fragment` of r128 is `colorspace_fragment` now), and soot (a black smoke) keeps a floor of albedo and a rim
176
+ * lit by the sky, so it reads as a cloud and not as a flat black blob.
177
+ */
178
+ declare const PUFF_VERTEX = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nattribute vec4 aP;attribute vec4 aD;attribute vec3 aC;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;\nvoid main(){\n vec3 p=position;\n float s=aD.z;\n float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));\n p*=0.78+0.5*n;\n float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;\n vL=p;\n vec3 wp=aP.xyz+p*aP.w;\n vWP=wp;vD=aD;vC=aC;\n gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);\n}";
179
+ declare const PUFF_FRAGMENT = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nuniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;\nvec3 L(vec3 c){return pow(c,vec3(2.2));}\nvec3 ramp(float h){\n vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));\n if(h<.25)return mix(c0,c1,h/.25);\n if(h<.5)return mix(c1,c2,(h-.25)/.25);\n if(h<.8)return mix(c2,c3,(h-.5)/.3);\n return mix(c3,c4,clamp((h-.8)/.4,0.,1.));\n}\nvoid main(){\n vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));\n float age=vD.x,heat=vD.y,kind=vD.w;\n float n=vn(vL*2.4+vD.z*13.0);\n float diss=smoothstep(.5,1.,age);\n if(n<diss*1.08-.04)discard;\n float lam=max(dot(N,uLight),0.);\n float band=lam>.55?1.:lam>.15?.68:.42;\n // soot: a dark smoke still scatters some light, so it never goes flat black, and its rim takes the sky so its volume reads (only the dark puffs; the rest as the Lab)\n float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));\n vec3 alb=max(vC,vec3(.055)*dark);\n vec3 col=alb*(vec3(.5,.56,.7)*band*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));\n float rim=pow(1.-clamp(abs(dot(N,normalize(cameraPosition-vWP))),0.,1.),2.);\n col+=dark*rim*(uSky*.9+alb);\n vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;\n float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));\n col+=uGlowCol*gi*alb*1.6;\n float h=heat*(.72+.56*n)+heat*(-N.y)*.18;\n if(h>.05){\n float hq=floor(h*5.+.5)/5.;\n vec3 fc=ramp(clamp(hq,0.,1.2))*(1.1+3.1*hq);\n col=mix(col,fc,smoothstep(.04,.2,h));\n }\n if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}\n gl_FragColor=vec4(col,1.);\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
180
+ /**
181
+ * The soft puff shader (`VfxRendererOptions.puffStyle: 'soft'`), from the Lab's (L130-192): a noise-swollen sphere per puff, the Lab's heat ramp for what still burns. Smoke is soft and seen through: its normal is
167
182
  * the sphere's, roughened by noise (never the flat facets, which read as a grey rock), its light continuous, its edge thins to nothing where the camera grazes it,
168
183
  * and it thins out as it ages instead of being cut away. The hot core of a fireball stays opaque. Soot (a black smoke) keeps a floor of albedo and a rim lit by the
169
184
  * sky, so it reads as a cloud and not as a flat black blob. The r160 colour-space chunk (`encodings_fragment` of r128 is `colorspace_fragment` now).
170
185
  */
171
- declare const PUFF_VERTEX = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nattribute vec4 aP;attribute vec4 aD;attribute vec3 aC;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;\nvoid main(){\n vec3 p=position;\n vec3 q=normalize(position);\n float s=aD.z;\n float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));\n p*=0.78+0.5*n;\n float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;q.xz=mat2(c,-si,si,c)*q.xz;\n vL=p;vN=q;\n vec3 wp=aP.xyz+p*aP.w;\n vWP=wp;vD=aD;vC=aC;\n gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);\n}";
172
- declare const PUFF_FRAGMENT = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nuniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;\nvec3 L(vec3 c){return pow(c,vec3(2.2));}\nvec3 ramp(float h){\n vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));\n if(h<.25)return mix(c0,c1,h/.25);\n if(h<.5)return mix(c1,c2,(h-.25)/.25);\n if(h<.8)return mix(c2,c3,(h-.5)/.3);\n return mix(c3,c4,clamp((h-.8)/.4,0.,1.));\n}\nvoid main(){\n float age=vD.x,heat=vD.y,kind=vD.w;\n float n=vn(vL*2.4+vD.z*13.0);\n // the sphere's own normal, roughened by the noise: a billowing cloud, never facets\n vec3 g=vec3(vn(vL*3.1+vD.z*5.0),vn(vL*3.1+vD.z*5.0+7.3),vn(vL*3.1+vD.z*5.0+13.7))-.5;\n vec3 N=normalize(normalize(vN)+g*.9);\n vec3 V=normalize(cameraPosition-vWP);\n float lam=max(dot(N,uLight),0.);\n float light=.42+.62*smoothstep(-.1,.9,lam);\n float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));\n vec3 alb=max(vC,vec3(.055)*dark);\n vec3 col=alb*(vec3(.5,.56,.7)*light*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));\n float rim=pow(1.-clamp(abs(dot(normalize(vN),V)),0.,1.),2.);\n col+=dark*rim*(uSky*.9+alb);\n vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;\n float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));\n col+=uGlowCol*gi*alb*1.6;\n // seen through: thin where the camera grazes the puff, thicker where the noise is, thinning out with age\n float facing=abs(dot(normalize(vN),V));\n float alpha=smoothstep(.0,.75,facing)*(.35+.65*smoothstep(.2,.8,n))*(1.-smoothstep(.3,1.,age))*.78;\n float h=heat*(.72+.56*n)+heat*(-N.y)*.18;\n if(h>.05){\n vec3 fc=ramp(clamp(h,0.,1.2))*(1.1+3.1*h);\n float hot=smoothstep(.04,.2,h);\n col=mix(col,fc,hot);\n alpha=max(alpha,hot*smoothstep(.0,.45,facing)*(1.-smoothstep(.5,1.,age)));\n }\n if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}\n if(alpha<.01)discard;\n gl_FragColor=vec4(col,alpha);\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
186
+ declare const SOFT_PUFF_VERTEX = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nattribute vec4 aP;attribute vec4 aD;attribute vec3 aC;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;\nvoid main(){\n vec3 p=position;\n vec3 q=normalize(position);\n float s=aD.z;\n float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));\n p*=0.78+0.5*n;\n float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;q.xz=mat2(c,-si,si,c)*q.xz;\n vL=p;vN=q;\n vec3 wp=aP.xyz+p*aP.w;\n vWP=wp;vD=aD;vC=aC;\n gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);\n}";
187
+ declare const SOFT_PUFF_FRAGMENT = "\nfloat h3(vec3 p){p=fract(p*.3183099+.1);p*=17.0;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);\n return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),\n mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}\n\nuniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;\nvarying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;\nvec3 L(vec3 c){return pow(c,vec3(2.2));}\nvec3 ramp(float h){\n vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));\n if(h<.25)return mix(c0,c1,h/.25);\n if(h<.5)return mix(c1,c2,(h-.25)/.25);\n if(h<.8)return mix(c2,c3,(h-.5)/.3);\n return mix(c3,c4,clamp((h-.8)/.4,0.,1.));\n}\nvoid main(){\n float age=vD.x,heat=vD.y,kind=vD.w;\n float n=vn(vL*2.4+vD.z*13.0);\n // the sphere's own normal, roughened by the noise: a billowing cloud, never facets\n vec3 g=vec3(vn(vL*3.1+vD.z*5.0),vn(vL*3.1+vD.z*5.0+7.3),vn(vL*3.1+vD.z*5.0+13.7))-.5;\n vec3 N=normalize(normalize(vN)+g*.9);\n vec3 V=normalize(cameraPosition-vWP);\n float lam=max(dot(N,uLight),0.);\n float light=.42+.62*smoothstep(-.1,.9,lam);\n float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));\n vec3 alb=max(vC,vec3(.055)*dark);\n vec3 col=alb*(vec3(.5,.56,.7)*light*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));\n float rim=pow(1.-clamp(abs(dot(normalize(vN),V)),0.,1.),2.);\n col+=dark*rim*(uSky*.9+alb);\n vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;\n float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));\n col+=uGlowCol*gi*alb*1.6;\n // seen through: thin where the camera grazes the puff, thicker where the noise is, thinning out with age\n float facing=abs(dot(normalize(vN),V));\n float alpha=smoothstep(.0,.75,facing)*(.35+.65*smoothstep(.2,.8,n))*(1.-smoothstep(.3,1.,age))*.78;\n float h=heat*(.72+.56*n)+heat*(-N.y)*.18;\n if(h>.05){\n vec3 fc=ramp(clamp(h,0.,1.2))*(1.1+3.1*h);\n float hot=smoothstep(.04,.2,h);\n col=mix(col,fc,hot);\n alpha=max(alpha,hot*smoothstep(.0,.45,facing)*(1.-smoothstep(.5,1.,age)));\n }\n if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}\n if(alpha<.01)discard;\n gl_FragColor=vec4(col,alpha);\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
173
188
 
174
189
  /** The streak shader of shrapnel, sparks and embers (Lab L255-275), verbatim except for the r160 colour-space chunk. */
175
190
  declare const SPARK_VERTEX = "\nattribute vec3 aPos;attribute vec3 aVel;attribute vec4 aE;varying vec2 vU;varying vec4 vE;\nvoid main(){\n float sp=length(aVel)+1e-4;vec3 d=aVel/sp;\n vec3 tc=normalize(cameraPosition-aPos);\n vec3 sd=normalize(cross(d,tc)+vec3(1e-5));\n float len=max(aE.y*2.5,min(sp*aE.z,2.2));\n vec3 wp=aPos+sd*position.x*aE.y-d*position.y*len;\n vU=position.xy;vE=aE;\n gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);\n}";
@@ -215,4 +230,4 @@ declare const WATER_SPRITE_FRAGMENT = "uniform vec3 uFoam;uniform vec3 uDeep;var
215
230
  declare const WATER_COLUMN_VERTEX = "attribute vec4 aP;attribute vec4 aD;attribute vec2 aK;varying float vY;varying float vA;varying vec2 vK;varying float vF;float wHash(vec2 p){return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);}\nfloat wNoise(vec2 p){vec2 i=floor(p);vec2 f=fract(p);f=f*f*(3.-2.*f);return mix(mix(wHash(i),wHash(i+vec2(1.,0.)),f.x),mix(wHash(i+vec2(0.,1.)),wHash(i+vec2(1.,1.)),f.x),f.y);}\nvoid main(){vY=position.y;float ang=atan(position.z,position.x);vK=aK;\nfloat dome=aK.x;float s=aK.y;float h=position.y;\nfloat jag=.8+.4*wNoise(vec2(ang*3.+s*17.,h*4.+s));\nfloat flare=dome>.5?1.:(.55+.9*h*h)*jag;\nvec3 p=vec3(position.x*aP.w*flare,position.y*aD.x,position.z*aP.w*flare);\np.x+=aD.z*aD.x*h*h;p.z+=aD.w*aD.x*h*h;\nvec3 w=aP.xyz+p;vec3 n=normalize(vec3(position.x,dome>.5?position.y:.25,position.z));\nvec3 v=normalize(cameraPosition-w);vF=abs(dot(n,v));\nvA=aD.y;gl_Position=projectionMatrix*viewMatrix*vec4(w,1.);}";
216
231
  declare const WATER_COLUMN_FRAGMENT = "uniform vec3 uFoam;uniform vec3 uDeep;varying float vY;varying float vA;varying vec2 vK;varying float vF;float wHash(vec2 p){return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);}\nfloat wNoise(vec2 p){vec2 i=floor(p);vec2 f=fract(p);f=f*f*(3.-2.*f);return mix(mix(wHash(i),wHash(i+vec2(1.,0.)),f.x),mix(wHash(i+vec2(0.,1.)),wHash(i+vec2(1.,1.)),f.x),f.y);}\nvoid main(){float dome=vK.x;float s=vK.y;\nfloat streak=wNoise(vec2(gl_FragCoord.x*.05+s*31.,vY*6.+s));\nfloat body=dome>.5?mix(.95,.5,vY)*(.6+.4*(1.-vF)):(1.-smoothstep(.55,1.,vY))*(.45+.55*streak)*(.55+.45*(1.-vF*.6));\nvec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)discard;gl_FragColor=vec4(c,alpha);\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
217
232
 
218
- export { type CanvasContextLike, type CanvasLike, GLOW_FRAGMENT, GLOW_VERTEX, type GroundPatch, type GroundPatchOptions, type MarkLayer, type MarkLayerOptions, PUFF_FRAGMENT, PUFF_VERTEX, RING_FRAGMENT, RING_VERTEX, SHELL_FRAGMENT, SHELL_VERTEX, SPARK_FRAGMENT, SPARK_VERTEX, SPRITE_FRAGMENT, SPRITE_VERTEX, type ScreenOverlay, type SpriteLayer, type ThreeLib, VFX_LAYERS, type VfxRenderer, type VfxRendererOptions, type VfxRendererStats, WATER_COLUMN_FRAGMENT, WATER_COLUMN_VERTEX, WATER_SPRITE_FRAGMENT, WATER_SPRITE_VERTEX, WATER_SURFACE_FRAGMENT, WATER_SURFACE_VERTEX, type WaterLayer, type WaterLayerOptions, type WaterThree, createGroundPatch, createMarkLayer, createScreenOverlay, createSpriteLayer, createVfxRenderer, createWaterEffectsLayer };
233
+ export { type CanvasContextLike, type CanvasLike, GLOW_FRAGMENT, GLOW_VERTEX, type GroundPatch, type GroundPatchOptions, type MarkLayer, type MarkLayerOptions, PUFF_FRAGMENT, PUFF_VERTEX, type PuffStyle, RING_FRAGMENT, RING_VERTEX, SHELL_FRAGMENT, SHELL_VERTEX, SOFT_PUFF_FRAGMENT, SOFT_PUFF_VERTEX, SPARK_FRAGMENT, SPARK_VERTEX, SPRITE_FRAGMENT, SPRITE_VERTEX, type ScreenOverlay, type SpriteLayer, type ThreeLib, VFX_LAYERS, type VfxRenderer, type VfxRendererOptions, type VfxRendererStats, WATER_COLUMN_FRAGMENT, WATER_COLUMN_VERTEX, WATER_SPRITE_FRAGMENT, WATER_SPRITE_VERTEX, WATER_SURFACE_FRAGMENT, WATER_SURFACE_VERTEX, type WaterLayer, type WaterLayerOptions, type WaterThree, createGroundPatch, createMarkLayer, createScreenOverlay, createSpriteLayer, createVfxRenderer, createWaterEffectsLayer };
@@ -29,6 +29,8 @@ var GameVfxThree = (() => {
29
29
  RING_VERTEX: () => RING_VERTEX,
30
30
  SHELL_FRAGMENT: () => SHELL_FRAGMENT,
31
31
  SHELL_VERTEX: () => SHELL_VERTEX,
32
+ SOFT_PUFF_FRAGMENT: () => SOFT_PUFF_FRAGMENT,
33
+ SOFT_PUFF_VERTEX: () => SOFT_PUFF_VERTEX,
32
34
  SPARK_FRAGMENT: () => SPARK_FRAGMENT,
33
35
  SPARK_VERTEX: () => SPARK_VERTEX,
34
36
  SPRITE_FRAGMENT: () => SPRITE_FRAGMENT,
@@ -1486,6 +1488,57 @@ var GameVfxThree = (() => {
1486
1488
  return lehmer(mixEventSeed(eventSeed));
1487
1489
  }
1488
1490
  var SKIN = 5e-3;
1491
+ var Solids = class {
1492
+ constructor() {
1493
+ __publicField(this, "queries", /* @__PURE__ */ new Map());
1494
+ __publicField(this, "list", []);
1495
+ __publicField(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
1496
+ }
1497
+ get empty() {
1498
+ return this.list.length === 0;
1499
+ }
1500
+ /** Declares or (with `null`) ends the solids `id` answers for. */
1501
+ set(id, query2) {
1502
+ if (query2) this.queries.set(id, query2);
1503
+ else this.queries.delete(id);
1504
+ this.list = [...this.queries.values()];
1505
+ }
1506
+ clear() {
1507
+ this.queries.clear();
1508
+ this.list = [];
1509
+ }
1510
+ /**
1511
+ * Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
1512
+ * the surface's normal. Answers whether the step was stopped.
1513
+ */
1514
+ stop(move, pad, out) {
1515
+ const dx = move.x1 - move.x0;
1516
+ const dy = move.y1 - move.y0;
1517
+ const dz = move.z1 - move.z0;
1518
+ const length = Math.hypot(dx, dy, dz);
1519
+ if (!(length > 0)) return false;
1520
+ let nearest = Infinity;
1521
+ for (const query2 of this.list) {
1522
+ if (!query2(move, this.hit)) continue;
1523
+ const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
1524
+ if (reached >= nearest) continue;
1525
+ nearest = reached;
1526
+ out.x = this.hit.x;
1527
+ out.y = this.hit.y;
1528
+ out.z = this.hit.z;
1529
+ out.nx = this.hit.nx;
1530
+ out.ny = this.hit.ny;
1531
+ out.nz = this.hit.nz;
1532
+ }
1533
+ if (nearest === Infinity) return false;
1534
+ const back = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
1535
+ out.x -= dx / length * back;
1536
+ out.y -= dy / length * back;
1537
+ out.z -= dz / length * back;
1538
+ return true;
1539
+ }
1540
+ };
1541
+ var SKIN2 = 5e-3;
1489
1542
  var MAX_PAD = 0.45;
1490
1543
  function rotation(q) {
1491
1544
  const [x, y, z, w] = q ?? [0, 0, 0, 1];
@@ -1517,10 +1570,15 @@ var GameVfxThree = (() => {
1517
1570
  __publicField(this, "q", new Float64Array(3));
1518
1571
  __publicField(this, "h", new Float64Array(3));
1519
1572
  __publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
1573
+ __publicField(this, "solids", new Solids());
1520
1574
  this.random = lehmer(seed);
1521
1575
  }
1522
1576
  get empty() {
1523
- return this.list.length === 0;
1577
+ return this.list.length === 0 && this.solids.empty;
1578
+ }
1579
+ /** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
1580
+ solid(id, query2) {
1581
+ this.solids.set(id, query2);
1524
1582
  }
1525
1583
  get size() {
1526
1584
  return this.list.length;
@@ -1603,6 +1661,10 @@ var GameVfxThree = (() => {
1603
1661
  return this.confineMove(move, dt);
1604
1662
  }
1605
1663
  confineMove(move, dt) {
1664
+ if (this.confineSpaces(move, dt)) return true;
1665
+ return !this.solids.empty && this.solids.stop(move, Math.min(Math.max(0, move.pad), MAX_PAD), this.out);
1666
+ }
1667
+ confineSpaces(move, dt) {
1606
1668
  const list = this.list;
1607
1669
  if (list.length === 0) return false;
1608
1670
  const { x0, y0, z0, x1, y1, z1 } = move;
@@ -1643,7 +1705,7 @@ var GameVfxThree = (() => {
1643
1705
  }
1644
1706
  }
1645
1707
  sign = l1[axis2] < 0 ? -1 : 1;
1646
- for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN, Math.max(-(h[a] - SKIN), l1[a]));
1708
+ for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
1647
1709
  sign = -sign;
1648
1710
  } else {
1649
1711
  const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
@@ -1660,7 +1722,7 @@ var GameVfxThree = (() => {
1660
1722
  }
1661
1723
  }
1662
1724
  sign = l0[axis2] < 0 ? -1 : 1;
1663
- l1[axis2] = sign * (h[axis2] + bound + SKIN);
1725
+ l1[axis2] = sign * (h[axis2] + bound + SKIN2);
1664
1726
  }
1665
1727
  const r = s.r;
1666
1728
  const out = this.out;
@@ -1911,6 +1973,7 @@ var GameVfxThree = (() => {
1911
1973
  y: 0,
1912
1974
  z: 0,
1913
1975
  r: 0.6,
1976
+ h: 0,
1914
1977
  r0: 0.6,
1915
1978
  grow: 0,
1916
1979
  life: 6,
@@ -1936,6 +1999,7 @@ var GameVfxThree = (() => {
1936
1999
  fire.y = init.y ?? 0;
1937
2000
  fire.z = init.z ?? 0;
1938
2001
  fire.r = init.r ?? 0.6;
2002
+ fire.h = init.h ?? 0;
1939
2003
  fire.r0 = init.startRadius ?? fire.r;
1940
2004
  fire.grow = init.grow ?? 0;
1941
2005
  fire.life = init.life ?? 6;
@@ -1960,19 +2024,23 @@ var GameVfxThree = (() => {
1960
2024
  core.trace?.fire?.(fire);
1961
2025
  return fire;
1962
2026
  }
2027
+ var FLAMES_PER_HEIGHT = 1.5;
2028
+ var SMOKE_PER_HEIGHT = 2;
1963
2029
  function positionOf(follow) {
1964
2030
  return "position" in follow ? follow.position : follow;
1965
2031
  }
2032
+ var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
2033
+ var isBody = (follow) => "radius" in follow && "height" in follow;
1966
2034
  function emitFlames(core, fire, radius, dt) {
1967
2035
  const random = fire.rng;
1968
- fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
2036
+ fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
1969
2037
  while (fire.acc >= 1) {
1970
2038
  fire.acc -= 1;
1971
2039
  const angle = random.next() * Math.PI * 2;
1972
2040
  const distance = Math.sqrt(random.next()) * radius;
1973
2041
  addPuff(core, random, {
1974
2042
  x: fire.x + Math.cos(angle) * distance,
1975
- y: fire.y + 0.05,
2043
+ y: fire.y + 0.05 + heightOf(fire),
1976
2044
  z: fire.z + Math.sin(angle) * distance,
1977
2045
  vx: random.between(-0.2, 0.2),
1978
2046
  vy: random.between(0.6, 1.4),
@@ -1994,12 +2062,12 @@ var GameVfxThree = (() => {
1994
2062
  }
1995
2063
  function emitSmoke(core, fire, radius, dt) {
1996
2064
  const random = fire.rng;
1997
- fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
2065
+ fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
1998
2066
  while (fire.smokeAcc >= 1 && core.layers.smoke) {
1999
2067
  fire.smokeAcc -= 1;
2000
2068
  addPuff(core, random, {
2001
2069
  x: fire.x + random.between(-radius, radius) * 0.5,
2002
- y: fire.y + 0.6 + radius * 0.3,
2070
+ y: fire.y + fire.h + 0.6 + radius * 0.3,
2003
2071
  z: fire.z + random.between(-radius, radius) * 0.5,
2004
2072
  vy: random.between(0.8, 1.5),
2005
2073
  s0: 0.25,
@@ -2021,7 +2089,7 @@ var GameVfxThree = (() => {
2021
2089
  if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
2022
2090
  addSpark(core, {
2023
2091
  x: fire.x + random.between(-radius, radius) * 0.6,
2024
- y: fire.y + 0.4,
2092
+ y: fire.y + 0.4 + heightOf(fire),
2025
2093
  z: fire.z + random.between(-radius, radius) * 0.6,
2026
2094
  vx: random.between(-0.4, 0.4),
2027
2095
  vy: random.between(1.5, 3.2),
@@ -2045,6 +2113,10 @@ var GameVfxThree = (() => {
2045
2113
  fire.x = point.x + fire.fx;
2046
2114
  fire.y = point.y + fire.fy;
2047
2115
  fire.z = point.z + fire.fz;
2116
+ if (isBody(fire.follow)) {
2117
+ fire.r = fire.follow.radius;
2118
+ fire.h = fire.follow.height;
2119
+ }
2048
2120
  }
2049
2121
  const radius = fire.grow ? lerp(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
2050
2122
  fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
@@ -5637,6 +5709,24 @@ var GameVfxThree = (() => {
5637
5709
  screen2.flashDecay = 0.5;
5638
5710
  }
5639
5711
  }
5712
+ var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
5713
+ function bornFrom(core, puff3, ox, oy, oz) {
5714
+ const confiner = core.confiner;
5715
+ if (confiner.empty) return;
5716
+ BIRTH.x0 = ox;
5717
+ BIRTH.y0 = oy;
5718
+ BIRTH.z0 = oz;
5719
+ BIRTH.x1 = puff3.x;
5720
+ BIRTH.y1 = puff3.y;
5721
+ BIRTH.z1 = puff3.z;
5722
+ BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
5723
+ if (!confiner.confineMove(BIRTH, 0)) return;
5724
+ const out = confiner.out;
5725
+ puff3.x = out.x;
5726
+ puff3.y = out.y;
5727
+ puff3.z = out.z;
5728
+ slideInto(out, puff3);
5729
+ }
5640
5730
  function composeFireballs(context) {
5641
5731
  const { core, def, random, x, y, z, size, scale, direction } = context;
5642
5732
  if (!core.layers.fire || !def.fireballs) return;
@@ -5653,7 +5743,7 @@ var GameVfxThree = (() => {
5653
5743
  const life = random.between(def.smoke.life * 0.7, def.smoke.life);
5654
5744
  const h0 = random.between(1.05, 1.35) * heat;
5655
5745
  const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
5656
- addPuff(core, random, {
5746
+ const fireball = addPuff(core, random, {
5657
5747
  x: x + d.x * size * 0.15,
5658
5748
  y: y + size * 0.25 + d.y * size * 0.1,
5659
5749
  z: z + d.z * size * 0.15,
@@ -5672,6 +5762,7 @@ var GameVfxThree = (() => {
5672
5762
  color: context.smokeColor,
5673
5763
  kind: 0
5674
5764
  });
5765
+ bornFrom(core, fireball, x, y, z);
5675
5766
  }
5676
5767
  }
5677
5768
  function composeSmoke(context) {
@@ -5685,7 +5776,7 @@ var GameVfxThree = (() => {
5685
5776
  const s1 = size * random.between(0.55, 0.85);
5686
5777
  const sg = size * random.between(0.18, 0.3);
5687
5778
  const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
5688
- addPuff(core, random, {
5779
+ const smoke = addPuff(core, random, {
5689
5780
  x: x + d.x * size * 0.6,
5690
5781
  y: y + size * 0.4 + d.y * size * 0.5,
5691
5782
  z: z + d.z * size * 0.6,
@@ -5704,6 +5795,7 @@ var GameVfxThree = (() => {
5704
5795
  color: context.smokeColor,
5705
5796
  kind: def.smoke.kind ?? 0
5706
5797
  });
5798
+ bornFrom(core, smoke, x, y, z);
5707
5799
  }
5708
5800
  }
5709
5801
  function composeShock(context) {
@@ -5728,7 +5820,7 @@ var GameVfxThree = (() => {
5728
5820
  const s1 = size * random.between(0.5, 0.8);
5729
5821
  const sg = size * random.between(0.2, 0.35);
5730
5822
  const life = random.between(2.2, 4);
5731
- addPuff(core, random, {
5823
+ const dust = addPuff(core, random, {
5732
5824
  x: x + Math.cos(angle) * 0.3,
5733
5825
  y: 0.15,
5734
5826
  z: z + Math.sin(angle) * 0.3,
@@ -5745,6 +5837,7 @@ var GameVfxThree = (() => {
5745
5837
  color,
5746
5838
  kind: 1
5747
5839
  });
5840
+ bornFrom(core, dust, x, 0.15, z);
5748
5841
  }
5749
5842
  }
5750
5843
  function coneAngle(context) {
@@ -7816,6 +7909,7 @@ var GameVfxThree = (() => {
7816
7909
  });
7817
7910
  const core = {
7818
7911
  profile,
7912
+ confiner: enclosures,
7819
7913
  puffs: createPuffPool(profile.puffs),
7820
7914
  sparks: createSparkPool(profile.sparks),
7821
7915
  glows: createGlowPool(profile.glows),
@@ -7924,10 +8018,11 @@ var GameVfxThree = (() => {
7924
8018
  },
7925
8019
  fire(fireOptions) {
7926
8020
  const handle = ++handles.next;
7927
- const { point, offset, seed, radius, smokeColor, ...rest } = fireOptions;
8021
+ const { point, offset, seed, radius, height, smokeColor, ...rest } = fireOptions;
7928
8022
  addFire(core, streamOf(seed), {
7929
8023
  ...rest,
7930
8024
  r: radius,
8025
+ ...height !== void 0 ? { h: height } : {},
7931
8026
  x: point[0],
7932
8027
  y: point[1],
7933
8028
  z: point[2],
@@ -7955,6 +8050,9 @@ var GameVfxThree = (() => {
7955
8050
  enclose(id, enclosure) {
7956
8051
  enclosures.set(id, enclosure);
7957
8052
  },
8053
+ solid(id, query2) {
8054
+ enclosures.solid(id, query2);
8055
+ },
7958
8056
  enclosures: () => enclosures,
7959
8057
  stop(handle) {
7960
8058
  player?.stop(handle);
@@ -8893,6 +8991,59 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
8893
8991
  // src/shaders/puff.ts
8894
8992
  var PUFF_VERTEX = `${GL_NOISE}
8895
8993
  attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
8994
+ varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
8995
+ void main(){
8996
+ vec3 p=position;
8997
+ float s=aD.z;
8998
+ float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
8999
+ p*=0.78+0.5*n;
9000
+ float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
9001
+ vL=p;
9002
+ vec3 wp=aP.xyz+p*aP.w;
9003
+ vWP=wp;vD=aD;vC=aC;
9004
+ gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
9005
+ }`;
9006
+ var PUFF_FRAGMENT = `${GL_NOISE}
9007
+ uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
9008
+ varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
9009
+ vec3 L(vec3 c){return pow(c,vec3(2.2));}
9010
+ vec3 ramp(float h){
9011
+ vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
9012
+ if(h<.25)return mix(c0,c1,h/.25);
9013
+ if(h<.5)return mix(c1,c2,(h-.25)/.25);
9014
+ if(h<.8)return mix(c2,c3,(h-.5)/.3);
9015
+ return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
9016
+ }
9017
+ void main(){
9018
+ vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
9019
+ float age=vD.x,heat=vD.y,kind=vD.w;
9020
+ float n=vn(vL*2.4+vD.z*13.0);
9021
+ float diss=smoothstep(.5,1.,age);
9022
+ if(n<diss*1.08-.04)discard;
9023
+ float lam=max(dot(N,uLight),0.);
9024
+ float band=lam>.55?1.:lam>.15?.68:.42;
9025
+ // soot: a dark smoke still scatters some light, so it never goes flat black, and its rim takes the sky so its volume reads (only the dark puffs; the rest as the Lab)
9026
+ float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));
9027
+ vec3 alb=max(vC,vec3(.055)*dark);
9028
+ vec3 col=alb*(vec3(.5,.56,.7)*band*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));
9029
+ float rim=pow(1.-clamp(abs(dot(N,normalize(cameraPosition-vWP))),0.,1.),2.);
9030
+ col+=dark*rim*(uSky*.9+alb);
9031
+ vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;
9032
+ float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));
9033
+ col+=uGlowCol*gi*alb*1.6;
9034
+ float h=heat*(.72+.56*n)+heat*(-N.y)*.18;
9035
+ if(h>.05){
9036
+ float hq=floor(h*5.+.5)/5.;
9037
+ vec3 fc=ramp(clamp(hq,0.,1.2))*(1.1+3.1*hq);
9038
+ col=mix(col,fc,smoothstep(.04,.2,h));
9039
+ }
9040
+ if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}
9041
+ gl_FragColor=vec4(col,1.);
9042
+ #include <tonemapping_fragment>
9043
+ #include <colorspace_fragment>
9044
+ }`;
9045
+ var SOFT_PUFF_VERTEX = `${GL_NOISE}
9046
+ attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
8896
9047
  varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
8897
9048
  void main(){
8898
9049
  vec3 p=position;
@@ -8906,7 +9057,7 @@ void main(){
8906
9057
  vWP=wp;vD=aD;vC=aC;
8907
9058
  gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
8908
9059
  }`;
8909
- var PUFF_FRAGMENT = `${GL_NOISE}
9060
+ var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
8910
9061
  uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
8911
9062
  varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
8912
9063
  vec3 L(vec3 c){return pow(c,vec3(2.2));}
@@ -8985,11 +9136,11 @@ void main(){
8985
9136
  function dynamic(THREE, array, size) {
8986
9137
  return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
8987
9138
  }
8988
- var PUFF_DETAIL = 2;
8989
- function createPuffLayer(THREE, pool, uniforms) {
9139
+ var PUFF_DETAIL = { faceted: 1, soft: 2 };
9140
+ function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
8990
9141
  const capacity = pool.capacity;
8991
9142
  const geometry = new THREE.InstancedBufferGeometry();
8992
- geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL).getAttribute("position"));
9143
+ geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL[style]).getAttribute("position"));
8993
9144
  const a = new Float32Array(capacity * 4);
8994
9145
  const d = new Float32Array(capacity * 4);
8995
9146
  const c = new Float32Array(capacity * 3);
@@ -8998,7 +9149,7 @@ void main(){
8998
9149
  geometry.setAttribute("aD", attributes[1]);
8999
9150
  geometry.setAttribute("aC", attributes[2]);
9000
9151
  geometry.instanceCount = 0;
9001
- const material2 = new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT, transparent: true, depthWrite: false });
9152
+ const material2 = style === "faceted" ? new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT }) : new THREE.ShaderMaterial({ uniforms, vertexShader: SOFT_PUFF_VERTEX, fragmentShader: SOFT_PUFF_FRAGMENT, transparent: true, depthWrite: false });
9002
9153
  const mesh2 = new THREE.Mesh(geometry, material2);
9003
9154
  mesh2.name = "vfx-puffs";
9004
9155
  mesh2.frustumCulled = false;
@@ -9686,6 +9837,7 @@ void main(){
9686
9837
  }
9687
9838
 
9688
9839
  // src/screen-overlay.ts
9840
+ var SHOWN_FIELDS = 6;
9689
9841
  var clamp5 = (value, min2, max2) => value < min2 ? min2 : value > max2 ? max2 : value;
9690
9842
  function layer(container, name, blend) {
9691
9843
  const element = container.ownerDocument.createElement("div");
@@ -9703,8 +9855,20 @@ void main(){
9703
9855
  const sides = layer(container, "sides");
9704
9856
  const gas = layer(container, "gas");
9705
9857
  const elements = [flash2, white, red, sides, gas];
9858
+ const shown = new Float64Array(SHOWN_FIELDS).fill(Number.NaN);
9859
+ const isShown = (state) => {
9860
+ const same = shown[0] === state.flash && shown[1] === state.white && shown[2] === state.red && shown[3] === state.directionLeft && shown[4] === state.directionRight && shown[5] === state.gas;
9861
+ shown[0] = state.flash;
9862
+ shown[1] = state.white;
9863
+ shown[2] = state.red;
9864
+ shown[3] = state.directionLeft;
9865
+ shown[4] = state.directionRight;
9866
+ shown[5] = state.gas;
9867
+ return same;
9868
+ };
9706
9869
  return {
9707
9870
  update(state) {
9871
+ if (isShown(state)) return;
9708
9872
  flash2.style.opacity = clamp5(state.flash, 0, 1).toFixed(3);
9709
9873
  white.style.opacity = "1";
9710
9874
  white.style.background = `rgba(235,240,255,${clamp5(state.white, 0, 1).toFixed(2)})`;
@@ -10360,7 +10524,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
10360
10524
  uGlowI: { value: 0 },
10361
10525
  uTime: { value: 0 }
10362
10526
  };
10363
- const puffs = createPuffLayer(THREE, pools.puffs, uniforms);
10527
+ const puffs = createPuffLayer(THREE, pools.puffs, uniforms, options.puffStyle ?? "faceted");
10364
10528
  const sparks2 = createSparkLayer(THREE, pools.sparks);
10365
10529
  const glows = createGlowLayer(THREE, pools.glows);
10366
10530
  const rockGeometry = new THREE.DodecahedronGeometry(0.5, 0);