@wolffo/three-fire 1.0.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.
@@ -0,0 +1,457 @@
1
+ import { Vector4, Vector3, Matrix4, Color, Mesh, BoxGeometry, ShaderMaterial, LinearFilter, ClampToEdgeWrapping, TextureLoader } from 'three';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
4
+ import { extend, useLoader, useFrame } from '@react-three/fiber';
5
+
6
+ /**
7
+ * Volumetric fire shader using ray marching and simplex noise
8
+ *
9
+ * Based on "Real-Time procedural volumetric fire" by Alfred et al.
10
+ * Uses simplex noise for turbulence and ray marching for volume rendering.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const material = new ShaderMaterial({
15
+ * defines: FireShader.defines,
16
+ * uniforms: FireShader.uniforms,
17
+ * vertexShader: FireShader.vertexShader,
18
+ * fragmentShader: FireShader.fragmentShader,
19
+ * transparent: true
20
+ * })
21
+ * ```
22
+ */
23
+ const FireShader = {
24
+ defines: {
25
+ ITERATIONS: '20',
26
+ OCTAVES: '3',
27
+ },
28
+ uniforms: {
29
+ fireTex: { value: null },
30
+ color: { value: new Color(0xeeeeee) },
31
+ time: { value: 0.0 },
32
+ seed: { value: 0.0 },
33
+ invModelMatrix: { value: new Matrix4() },
34
+ scale: { value: new Vector3(1, 1, 1) },
35
+ noiseScale: { value: new Vector4(1, 2, 1, 0.3) },
36
+ magnitude: { value: 1.3 },
37
+ lacunarity: { value: 2.0 },
38
+ gain: { value: 0.5 },
39
+ },
40
+ vertexShader: /* glsl */ `
41
+ varying vec3 vWorldPos;
42
+
43
+ void main() {
44
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
45
+ vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;
46
+ }
47
+ `,
48
+ fragmentShader: /* glsl */ `
49
+ uniform vec3 color;
50
+ uniform float time;
51
+ uniform float seed;
52
+ uniform mat4 invModelMatrix;
53
+ uniform vec3 scale;
54
+ uniform vec4 noiseScale;
55
+ uniform float magnitude;
56
+ uniform float lacunarity;
57
+ uniform float gain;
58
+ uniform sampler2D fireTex;
59
+
60
+ varying vec3 vWorldPos;
61
+
62
+ // GLSL simplex noise function by ashima
63
+ vec3 mod289(vec3 x) {
64
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
65
+ }
66
+
67
+ vec4 mod289(vec4 x) {
68
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
69
+ }
70
+
71
+ vec4 permute(vec4 x) {
72
+ return mod289(((x * 34.0) + 1.0) * x);
73
+ }
74
+
75
+ vec4 taylorInvSqrt(vec4 r) {
76
+ return 1.79284291400159 - 0.85373472095314 * r;
77
+ }
78
+
79
+ float snoise(vec3 v) {
80
+ const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);
81
+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
82
+
83
+ vec3 i = floor(v + dot(v, C.yyy));
84
+ vec3 x0 = v - i + dot(i, C.xxx);
85
+
86
+ vec3 g = step(x0.yzx, x0.xyz);
87
+ vec3 l = 1.0 - g;
88
+ vec3 i1 = min(g.xyz, l.zxy);
89
+ vec3 i2 = max(g.xyz, l.zxy);
90
+
91
+ vec3 x1 = x0 - i1 + C.xxx;
92
+ vec3 x2 = x0 - i2 + C.yyy;
93
+ vec3 x3 = x0 - D.yyy;
94
+
95
+ i = mod289(i);
96
+ vec4 p = permute(permute(permute(
97
+ i.z + vec4(0.0, i1.z, i2.z, 1.0))
98
+ + i.y + vec4(0.0, i1.y, i2.y, 1.0))
99
+ + i.x + vec4(0.0, i1.x, i2.x, 1.0));
100
+
101
+ float n_ = 0.142857142857;
102
+ vec3 ns = n_ * D.wyz - D.xzx;
103
+
104
+ vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
105
+
106
+ vec4 x_ = floor(j * ns.z);
107
+ vec4 y_ = floor(j - 7.0 * x_);
108
+
109
+ vec4 x = x_ * ns.x + ns.yyyy;
110
+ vec4 y = y_ * ns.x + ns.yyyy;
111
+ vec4 h = 1.0 - abs(x) - abs(y);
112
+
113
+ vec4 b0 = vec4(x.xy, y.xy);
114
+ vec4 b1 = vec4(x.zw, y.zw);
115
+
116
+ vec4 s0 = floor(b0) * 2.0 + 1.0;
117
+ vec4 s1 = floor(b1) * 2.0 + 1.0;
118
+ vec4 sh = -step(h, vec4(0.0));
119
+
120
+ vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
121
+ vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
122
+
123
+ vec3 p0 = vec3(a0.xy, h.x);
124
+ vec3 p1 = vec3(a0.zw, h.y);
125
+ vec3 p2 = vec3(a1.xy, h.z);
126
+ vec3 p3 = vec3(a1.zw, h.w);
127
+
128
+ vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
129
+ p0 *= norm.x;
130
+ p1 *= norm.y;
131
+ p2 *= norm.z;
132
+ p3 *= norm.w;
133
+
134
+ vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);
135
+ m = m * m;
136
+ return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
137
+ }
138
+
139
+ float turbulence(vec3 p) {
140
+ float sum = 0.0;
141
+ float freq = 1.0;
142
+ float amp = 1.0;
143
+
144
+ for(int i = 0; i < OCTAVES; i++) {
145
+ sum += abs(snoise(p * freq)) * amp;
146
+ freq *= lacunarity;
147
+ amp *= gain;
148
+ }
149
+
150
+ return sum;
151
+ }
152
+
153
+ vec4 samplerFire(vec3 p, vec4 scale) {
154
+ vec2 st = vec2(sqrt(dot(p.xz, p.xz)), p.y);
155
+
156
+ if(st.x <= 0.0 || st.x >= 1.0 || st.y <= 0.0 || st.y >= 1.0) {
157
+ return vec4(0.0);
158
+ }
159
+
160
+ p.y -= (seed + time) * scale.w;
161
+ p *= scale.xyz;
162
+
163
+ st.y += sqrt(st.y) * magnitude * turbulence(p);
164
+
165
+ if(st.y <= 0.0 || st.y >= 1.0) {
166
+ return vec4(0.0);
167
+ }
168
+
169
+ return texture2D(fireTex, st);
170
+ }
171
+
172
+ vec3 localize(vec3 p) {
173
+ return (invModelMatrix * vec4(p, 1.0)).xyz;
174
+ }
175
+
176
+ void main() {
177
+ vec3 rayPos = vWorldPos;
178
+ vec3 rayDir = normalize(rayPos - cameraPosition);
179
+ float rayLen = 0.0288 * length(scale.xyz);
180
+
181
+ vec4 col = vec4(0.0);
182
+
183
+ for(int i = 0; i < ITERATIONS; i++) {
184
+ rayPos += rayDir * rayLen;
185
+ vec3 lp = localize(rayPos);
186
+ lp.y += 0.5;
187
+ lp.xz *= 2.0;
188
+ col += samplerFire(lp, noiseScale);
189
+ }
190
+
191
+ // Apply color tint to the fire
192
+ col.rgb *= color;
193
+ col.a = col.r;
194
+ gl_FragColor = col;
195
+ }
196
+ `,
197
+ };
198
+
199
+ /**
200
+ * Volumetric fire effect using ray marching shaders
201
+ *
202
+ * Creates a procedural fire effect that renders as a translucent volume.
203
+ * The fire shape is defined by a grayscale texture, with white areas being
204
+ * the most dense part of the fire.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * const texture = textureLoader.load('fire.png')
209
+ * const fire = new Fire({
210
+ * fireTex: texture,
211
+ * color: 0xff4400,
212
+ * magnitude: 1.5
213
+ * })
214
+ * scene.add(fire)
215
+ *
216
+ * // In animation loop
217
+ * fire.update(time)
218
+ * ```
219
+ */
220
+ class Fire extends Mesh {
221
+ /**
222
+ * Creates a new Fire instance
223
+ *
224
+ * @param props - Configuration options for the fire effect
225
+ */
226
+ constructor({ fireTex, color = 0xeeeeee, iterations = 20, octaves = 3, noiseScale = [1, 2, 1, 0.3], magnitude = 1.3, lacunarity = 2.0, gain = 0.5, }) {
227
+ const geometry = new BoxGeometry(1, 1, 1);
228
+ const material = new ShaderMaterial({
229
+ defines: {
230
+ ITERATIONS: iterations.toString(),
231
+ OCTAVES: octaves.toString(),
232
+ },
233
+ uniforms: {
234
+ fireTex: { value: fireTex },
235
+ color: { value: color instanceof Color ? color : new Color(color) },
236
+ time: { value: 0.0 },
237
+ seed: { value: Math.random() * 19.19 },
238
+ invModelMatrix: { value: new Matrix4() },
239
+ scale: { value: new Vector3(1, 1, 1) },
240
+ noiseScale: { value: new Vector4(...noiseScale) },
241
+ magnitude: { value: magnitude },
242
+ lacunarity: { value: lacunarity },
243
+ gain: { value: gain },
244
+ },
245
+ vertexShader: FireShader.vertexShader,
246
+ fragmentShader: FireShader.fragmentShader,
247
+ transparent: true,
248
+ depthWrite: false,
249
+ depthTest: false,
250
+ });
251
+ super(geometry, material);
252
+ this._time = 0;
253
+ // Configure texture
254
+ fireTex.magFilter = fireTex.minFilter = LinearFilter;
255
+ fireTex.wrapS = fireTex.wrapT = ClampToEdgeWrapping;
256
+ }
257
+ /**
258
+ * Updates the fire animation and matrix uniforms
259
+ *
260
+ * Call this method in your animation loop to animate the fire effect.
261
+ *
262
+ * @param time - Current time in seconds (optional)
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * function animate() {
267
+ * fire.update(performance.now() / 1000)
268
+ * renderer.render(scene, camera)
269
+ * requestAnimationFrame(animate)
270
+ * }
271
+ * ```
272
+ */
273
+ update(time) {
274
+ if (time !== undefined) {
275
+ this._time = time;
276
+ this.material.uniforms.time.value = time;
277
+ }
278
+ this.updateMatrixWorld();
279
+ this.material.uniforms.invModelMatrix.value.copy(this.matrixWorld).invert();
280
+ this.material.uniforms.scale.value.copy(this.scale);
281
+ }
282
+ /**
283
+ * Current animation time in seconds
284
+ */
285
+ get time() {
286
+ return this._time;
287
+ }
288
+ set time(value) {
289
+ this._time = value;
290
+ this.material.uniforms.time.value = value;
291
+ }
292
+ /**
293
+ * Fire color tint
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * fire.fireColor = 'orange'
298
+ * fire.fireColor = 0xff4400
299
+ * fire.fireColor = new Color(1, 0.5, 0)
300
+ * ```
301
+ */
302
+ get fireColor() {
303
+ return this.material.uniforms.color.value;
304
+ }
305
+ set fireColor(color) {
306
+ this.material.uniforms.color.value = color instanceof Color ? color : new Color(color);
307
+ }
308
+ /**
309
+ * Fire shape intensity
310
+ *
311
+ * Higher values create more dramatic fire shapes.
312
+ * Range: 0.5 - 3.0, Default: 1.3
313
+ */
314
+ get magnitude() {
315
+ return this.material.uniforms.magnitude.value;
316
+ }
317
+ set magnitude(value) {
318
+ this.material.uniforms.magnitude.value = value;
319
+ }
320
+ /**
321
+ * Noise lacunarity (frequency multiplier)
322
+ *
323
+ * Controls how much the frequency increases for each noise octave.
324
+ * Range: 1.0 - 4.0, Default: 2.0
325
+ */
326
+ get lacunarity() {
327
+ return this.material.uniforms.lacunarity.value;
328
+ }
329
+ set lacunarity(value) {
330
+ this.material.uniforms.lacunarity.value = value;
331
+ }
332
+ /**
333
+ * Noise gain (amplitude multiplier)
334
+ *
335
+ * Controls how much the amplitude decreases for each noise octave.
336
+ * Range: 0.1 - 1.0, Default: 0.5
337
+ */
338
+ get gain() {
339
+ return this.material.uniforms.gain.value;
340
+ }
341
+ set gain(value) {
342
+ this.material.uniforms.gain.value = value;
343
+ }
344
+ }
345
+
346
+ /**
347
+ * Helper hook for texture loading (alternative to @react-three/drei)
348
+ */
349
+ const useTexture = (url) => useLoader(TextureLoader, url);
350
+ // Extend R3F with our Fire class
351
+ extend({ Fire: Fire });
352
+ /**
353
+ * React Three Fiber component for volumetric fire effect
354
+ *
355
+ * Creates a procedural fire effect that can be easily integrated into R3F scenes.
356
+ * The component automatically handles texture loading, animation updates, and
357
+ * provides props for all fire parameters.
358
+ *
359
+ * @example
360
+ * ```tsx
361
+ * <Canvas>
362
+ * <Fire
363
+ * texture="/fire.png"
364
+ * color="orange"
365
+ * magnitude={1.5}
366
+ * scale={[2, 3, 2]}
367
+ * position={[0, 0, 0]}
368
+ * />
369
+ * </Canvas>
370
+ * ```
371
+ *
372
+ * @example With custom animation
373
+ * ```tsx
374
+ * <Fire
375
+ * texture="/fire.png"
376
+ * onUpdate={(fire, time) => {
377
+ * fire.fireColor.setHSL((time * 0.1) % 1, 1, 0.5)
378
+ * }}
379
+ * />
380
+ * ```
381
+ */
382
+ const FireComponent = forwardRef(({ texture, color = 0xeeeeee, iterations = 20, octaves = 3, noiseScale = [1, 2, 1, 0.3], magnitude = 1.3, lacunarity = 2.0, gain = 0.5, autoUpdate = true, onUpdate, children, ...props }, ref) => {
383
+ const fireRef = useRef(null);
384
+ // Load texture if string is provided
385
+ const loadedTexture = useTexture(typeof texture === 'string' ? texture : '');
386
+ const finalTexture = typeof texture === 'string' ? loadedTexture : texture;
387
+ // Memoize fire props to prevent unnecessary recreations
388
+ const fireProps = useMemo(() => ({
389
+ fireTex: finalTexture,
390
+ color: color instanceof Color ? color : new Color(color),
391
+ iterations,
392
+ octaves,
393
+ noiseScale,
394
+ magnitude,
395
+ lacunarity,
396
+ gain,
397
+ }), [finalTexture, color, iterations, octaves, noiseScale, magnitude, lacunarity, gain]);
398
+ // Auto-update with useFrame
399
+ useFrame((state) => {
400
+ if (fireRef.current && autoUpdate) {
401
+ const time = state.clock.getElapsedTime();
402
+ fireRef.current.update(time);
403
+ onUpdate?.(fireRef.current, time);
404
+ }
405
+ });
406
+ // Expose imperative handle
407
+ useImperativeHandle(ref, () => ({
408
+ get fire() {
409
+ return fireRef.current;
410
+ },
411
+ update: (time) => {
412
+ if (fireRef.current) {
413
+ fireRef.current.update(time);
414
+ }
415
+ },
416
+ }), []);
417
+ return (jsx("fire", { ref: fireRef, args: [fireProps], ...props, children: children }));
418
+ });
419
+ FireComponent.displayName = 'Fire';
420
+ /**
421
+ * Hook for easier access to fire instance and controls
422
+ *
423
+ * Provides a ref and helper methods for controlling fire imperatively.
424
+ *
425
+ * @returns Object with ref, fire instance, and update method
426
+ *
427
+ * @example
428
+ * ```tsx
429
+ * function MyComponent() {
430
+ * const fireRef = useFire()
431
+ *
432
+ * const handleClick = () => {
433
+ * if (fireRef.fire) {
434
+ * fireRef.fire.magnitude = 2.0
435
+ * }
436
+ * }
437
+ *
438
+ * return (
439
+ * <Fire ref={fireRef.ref} texture="/fire.png" />
440
+ * )
441
+ * }
442
+ * ```
443
+ */
444
+ const useFire = () => {
445
+ const ref = useRef(null);
446
+ return {
447
+ /** Ref to pass to Fire component */
448
+ ref,
449
+ /** Fire mesh instance (null until mounted) */
450
+ fire: ref.current?.fire || null,
451
+ /** Update fire animation manually */
452
+ update: (time) => ref.current?.update(time),
453
+ };
454
+ };
455
+
456
+ export { FireComponent as Fire, FireComponent, Fire as FireMesh, FireShader, useFire };
457
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/FireShader.ts","../src/Fire.ts","../src/FireComponent.tsx"],"sourcesContent":[null,null,null],"names":["FireMesh","_jsx"],"mappings":";;;;;AA4BA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,UAAU,GAAG;AACxB,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,IAAI;AAChB,QAAA,OAAO,EAAE,GAAG;AACb,KAAA;AAED,IAAA,QAAQ,EAAE;AACR,QAAA,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;QACxB,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;AACrC,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;AACpB,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;AACpB,QAAA,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,EAAE;AACxC,QAAA,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;AACtC,QAAA,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EA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