@wolffo/three-fire 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,8 @@
1
1
  # Three fire
2
2
 
3
- [![CI](https://github.com/username/threeFire/workflows/CI/badge.svg)](https://github.com/username/threeFire/actions)
4
- [![npm version](https://badge.fury.io/js/@wolffo%2Fthree-fire.svg)](https://badge.fury.io/js/@wolffo%2Fthree-fire)
3
+ [![CI](https://github.com/typeWolffo/THREE.Fire/workflows/CI/badge.svg)](https://github.com/typeWolffo/THREE.Fire/actions)
4
+ [![npm version](https://img.shields.io/npm/v/@wolffo/three-fire.svg)](https://www.npmjs.com/package/@wolffo/three-fire)
5
+ [![npm downloads](https://img.shields.io/npm/dm/@wolffo/three-fire.svg)](https://www.npmjs.com/package/@wolffo/three-fire)
5
6
 
6
7
  Modern TypeScript volumetric fire effect for Three.js and React Three Fiber.
7
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolffo/three-fire",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Modern TypeScript volumetric fire effect for Three.js and React Three Fiber",
6
6
  "main": "dist/index.js",
@@ -67,5 +67,8 @@
67
67
  "src",
68
68
  "README.md",
69
69
  "LICENSE"
70
- ]
70
+ ],
71
+ "publishConfig": {
72
+ "access": "public"
73
+ }
71
74
  }
package/dist/Fire.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { Mesh, ShaderMaterial, Texture, Color } from 'three';
2
- import { FireShaderUniforms } from './FireShader';
3
- export interface FireProps {
4
- fireTex: Texture;
5
- color?: Color | string | number;
6
- iterations?: number;
7
- octaves?: number;
8
- noiseScale?: [number, number, number, number];
9
- magnitude?: number;
10
- lacunarity?: number;
11
- gain?: number;
12
- }
13
- export declare class Fire extends Mesh {
14
- material: ShaderMaterial & {
15
- uniforms: FireShaderUniforms;
16
- };
17
- private _time;
18
- constructor({ fireTex, color, iterations, octaves, noiseScale, magnitude, lacunarity, gain, }: FireProps);
19
- update(time?: number): void;
20
- get time(): number;
21
- set time(value: number);
22
- get fireColor(): Color;
23
- set fireColor(color: Color | string | number);
24
- get magnitude(): number;
25
- set magnitude(value: number);
26
- get lacunarity(): number;
27
- set lacunarity(value: number);
28
- get gain(): number;
29
- set gain(value: number);
30
- }
31
- //# sourceMappingURL=Fire.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Fire.d.ts","sourceRoot":"","sources":["../src/Fire.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,cAAc,EACd,OAAO,EACP,KAAK,EAMN,MAAM,OAAO,CAAA;AACd,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,IAAK,SAAQ,IAAI;IACb,QAAQ,EAAE,cAAc,GAAG;QAAE,QAAQ,EAAE,kBAAkB,CAAA;KAAE,CAAA;IAC1E,OAAO,CAAC,KAAK,CAAI;gBAEL,EACV,OAAO,EACP,KAAgB,EAChB,UAAe,EACf,OAAW,EACX,UAA2B,EAC3B,SAAe,EACf,UAAgB,EAChB,IAAU,GACX,EAAE,SAAS;IAkCL,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,CAAC,KAAK,EAAE,MAAM,EAG5B;IAED,IAAW,SAAS,IAAI,KAAK,CAE5B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,EAElD;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,MAAM,EAEjC;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,UAAU,CAAC,KAAK,EAAE,MAAM,EAElC;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,CAAC,KAAK,EAAE,MAAM,EAE5B;CACF"}
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { ReactThreeFiber } from '@react-three/fiber';
3
- import { Fire as FireMesh, FireProps as FireMeshProps } from './Fire';
4
- declare module '@react-three/fiber' {
5
- interface ThreeElements {
6
- fire: ReactThreeFiber.Object3DNode<FireMesh, typeof FireMesh>;
7
- }
8
- }
9
- export interface FireProps extends Omit<FireMeshProps, 'fireTex'> {
10
- /** Fire texture URL or texture object */
11
- texture: string | THREE.Texture;
12
- /** Auto-update time from useFrame (default: true) */
13
- autoUpdate?: boolean;
14
- /** Custom update function */
15
- onUpdate?: (fire: FireMesh, time: number) => void;
16
- children?: React.ReactNode;
17
- }
18
- export interface FireRef {
19
- /** Fire mesh instance */
20
- fire: FireMesh | null;
21
- /** Update fire manually */
22
- update: (time?: number) => void;
23
- }
24
- export declare const FireComponent: React.ForwardRefExoticComponent<FireProps & React.RefAttributes<FireRef>>;
25
- export declare const useFire: () => {
26
- ref: React.RefObject<FireRef>;
27
- fire: FireMesh | null;
28
- update: (time?: number) => void | undefined;
29
- };
30
- //# sourceMappingURL=FireComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FireComponent.d.ts","sourceRoot":"","sources":["../src/FireComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAA;AAC/E,OAAO,EAAoB,eAAe,EAAa,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAA;AASrE,OAAO,QAAQ,oBAAoB,CAAC;IAClC,UAAU,aAAa;QACrB,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,QAAQ,CAAC,CAAA;KAC9D;CACF;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC;IAC/D,yCAAyC;IACzC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,CAAA;IAC/B,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,MAAM,WAAW,OAAO;IACtB,yBAAyB;IACzB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IACrB,2BAA2B;IAC3B,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,aAAa,2EAsEzB,CAAA;AAKD,eAAO,MAAM,OAAO;;;oBAKA,MAAM;CAEzB,CAAA"}
@@ -1,43 +0,0 @@
1
- import { Vector3, Vector4, Color, Matrix4, Texture } from 'three';
2
- export interface FireShaderUniforms {
3
- fireTex: {
4
- value: Texture | null;
5
- };
6
- color: {
7
- value: Color;
8
- };
9
- time: {
10
- value: number;
11
- };
12
- seed: {
13
- value: number;
14
- };
15
- invModelMatrix: {
16
- value: Matrix4;
17
- };
18
- scale: {
19
- value: Vector3;
20
- };
21
- noiseScale: {
22
- value: Vector4;
23
- };
24
- magnitude: {
25
- value: number;
26
- };
27
- lacunarity: {
28
- value: number;
29
- };
30
- gain: {
31
- value: number;
32
- };
33
- }
34
- export declare const FireShader: {
35
- readonly defines: {
36
- readonly ITERATIONS: "20";
37
- readonly OCTAVES: "3";
38
- };
39
- readonly uniforms: FireShaderUniforms;
40
- readonly vertexShader: "\n varying vec3 vWorldPos;\n\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;\n }\n ";
41
- readonly fragmentShader: "\n uniform vec3 color;\n uniform float time;\n uniform float seed;\n uniform mat4 invModelMatrix;\n uniform vec3 scale;\n uniform vec4 noiseScale;\n uniform float magnitude;\n uniform float lacunarity;\n uniform float gain;\n uniform sampler2D fireTex;\n\n varying vec3 vWorldPos;\n\n // GLSL simplex noise function by ashima\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec4 permute(vec4 x) {\n return mod289(((x * 34.0) + 1.0) * x);\n }\n\n vec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n }\n\n float snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod289(i);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 0.142857142857;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n }\n\n float turbulence(vec3 p) {\n float sum = 0.0;\n float freq = 1.0;\n float amp = 1.0;\n\n for(int i = 0; i < OCTAVES; i++) {\n sum += abs(snoise(p * freq)) * amp;\n freq *= lacunarity;\n amp *= gain;\n }\n\n return sum;\n }\n\n vec4 samplerFire(vec3 p, vec4 scale) {\n vec2 st = vec2(sqrt(dot(p.xz, p.xz)), p.y);\n\n if(st.x <= 0.0 || st.x >= 1.0 || st.y <= 0.0 || st.y >= 1.0) {\n return vec4(0.0);\n }\n\n p.y -= (seed + time) * scale.w;\n p *= scale.xyz;\n\n st.y += sqrt(st.y) * magnitude * turbulence(p);\n\n if(st.y <= 0.0 || st.y >= 1.0) {\n return vec4(0.0);\n }\n\n return texture2D(fireTex, st);\n }\n\n vec3 localize(vec3 p) {\n return (invModelMatrix * vec4(p, 1.0)).xyz;\n }\n\n void main() {\n vec3 rayPos = vWorldPos;\n vec3 rayDir = normalize(rayPos - cameraPosition);\n float rayLen = 0.0288 * length(scale.xyz);\n\n vec4 col = vec4(0.0);\n\n for(int i = 0; i < ITERATIONS; i++) {\n rayPos += rayDir * rayLen;\n vec3 lp = localize(rayPos);\n lp.y += 0.5;\n lp.xz *= 2.0;\n col += samplerFire(lp, noiseScale);\n }\n\n col.a = col.r;\n gl_FragColor = col;\n }\n ";
42
- };
43
- //# sourceMappingURL=FireShader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FireShader.d.ts","sourceRoot":"","sources":["../src/FireShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEjE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAA;IAClC,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAA;IACvB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,cAAc,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;IAClC,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;IACzB,UAAU,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;IAC9B,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5B,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7B,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CACxB;AAED,eAAO,MAAM,UAAU;;;;;uBAiBhB,kBAAkB;;;CA8Jf,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGlE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGtF,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAA"}