r3f-vfx 0.0.3 → 0.0.5
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 +27 -39
- package/dist/index.js +13 -145
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as THREE from 'three/webgpu';
|
|
3
|
+
import { CoreState } from 'core-vfx';
|
|
2
4
|
|
|
3
5
|
declare const Appearance: Readonly<{
|
|
4
6
|
DEFAULT: "default";
|
|
@@ -6,10 +8,10 @@ declare const Appearance: Readonly<{
|
|
|
6
8
|
CIRCULAR: "circular";
|
|
7
9
|
}>;
|
|
8
10
|
declare const Blending: Readonly<{
|
|
9
|
-
NORMAL:
|
|
10
|
-
ADDITIVE:
|
|
11
|
-
MULTIPLY:
|
|
12
|
-
SUBTRACTIVE:
|
|
11
|
+
NORMAL: 1;
|
|
12
|
+
ADDITIVE: 2;
|
|
13
|
+
MULTIPLY: 4;
|
|
14
|
+
SUBTRACTIVE: 3;
|
|
13
15
|
}>;
|
|
14
16
|
declare const EmitterShape: Readonly<{
|
|
15
17
|
POINT: 0;
|
|
@@ -35,8 +37,8 @@ declare const Lighting: Readonly<{
|
|
|
35
37
|
PHYSICAL: "physical";
|
|
36
38
|
}>;
|
|
37
39
|
declare function bakeCurveToArray(curveData: any, resolution?: number): Float32Array<ArrayBuffer>;
|
|
38
|
-
declare function createCombinedCurveTexture(sizeCurve: any, opacityCurve: any, velocityCurve: any, rotationSpeedCurve: any):
|
|
39
|
-
declare const VFXParticles: any
|
|
40
|
+
declare function createCombinedCurveTexture(sizeCurve: any, opacityCurve: any, velocityCurve: any, rotationSpeedCurve: any): THREE.DataTexture;
|
|
41
|
+
declare const VFXParticles: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* Higher-order hook for programmatic emitter control
|
|
@@ -51,14 +53,21 @@ declare const VFXParticles: any;
|
|
|
51
53
|
* burst([0, 0, 0], 100, { colorStart: ["#ff0000"] });
|
|
52
54
|
*/
|
|
53
55
|
declare function useVFXEmitter(name: any): {
|
|
54
|
-
emit:
|
|
55
|
-
burst:
|
|
56
|
-
start:
|
|
57
|
-
stop:
|
|
58
|
-
clear:
|
|
59
|
-
isEmitting:
|
|
60
|
-
getUniforms:
|
|
61
|
-
getParticles: () =>
|
|
56
|
+
emit: (position?: number[], count?: number, overrides?: null) => boolean;
|
|
57
|
+
burst: (position?: number[], count?: number, overrides?: null) => boolean;
|
|
58
|
+
start: () => boolean;
|
|
59
|
+
stop: () => boolean;
|
|
60
|
+
clear: () => boolean;
|
|
61
|
+
isEmitting: () => boolean;
|
|
62
|
+
getUniforms: () => Record<string, unknown> | null;
|
|
63
|
+
getParticles: () => {
|
|
64
|
+
spawn: (x: number, y: number, z: number, count: number, overrides?: Record<string, unknown> | null) => void;
|
|
65
|
+
start: () => void;
|
|
66
|
+
stop: () => void;
|
|
67
|
+
clear: () => void;
|
|
68
|
+
isEmitting: boolean;
|
|
69
|
+
uniforms: Record<string, unknown>;
|
|
70
|
+
} | null;
|
|
62
71
|
};
|
|
63
72
|
/**
|
|
64
73
|
* VFXEmitter - A reusable emitter component that links to a VFXParticles system
|
|
@@ -104,30 +113,9 @@ declare function useVFXEmitter(name: any): {
|
|
|
104
113
|
* @param {object} [props.overrides] - Per-spawn overrides (size, speed, colors, etc.)
|
|
105
114
|
* @param {function} [props.onEmit] - Callback fired after each emission
|
|
106
115
|
*/
|
|
107
|
-
declare const VFXEmitter: any
|
|
116
|
+
declare const VFXEmitter: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
* Allows multiple VFXEmitter components to share a single VFXParticles instance,
|
|
113
|
-
* avoiding extra draw calls while enabling emission from multiple positions.
|
|
114
|
-
*
|
|
115
|
-
* Usage:
|
|
116
|
-
*
|
|
117
|
-
* // Register a particle system
|
|
118
|
-
* <VFXParticles ref={(ref) => registerParticles("sparks", ref)} ... />
|
|
119
|
-
*
|
|
120
|
-
* // Or use the VFXParticles name prop with auto-registration
|
|
121
|
-
* <VFXParticles name="sparks" ... />
|
|
122
|
-
*
|
|
123
|
-
* // Emit from anywhere using VFXEmitter (no extra draw calls!)
|
|
124
|
-
* <VFXEmitter name="sparks" position={[1, 0, 0]} emitCount={10} />
|
|
125
|
-
* <VFXEmitter name="sparks" position={[-1, 0, 0]} emitCount={5} />
|
|
126
|
-
*
|
|
127
|
-
* // Or emit programmatically
|
|
128
|
-
* const emit = useVFXStore(s => s.emit);
|
|
129
|
-
* emit("sparks", { x: 0, y: 1, z: 0, count: 20 });
|
|
130
|
-
*/
|
|
131
|
-
declare const useVFXStore: zustand.UseBoundStore<zustand.StoreApi<any>>;
|
|
118
|
+
declare function useVFXStore(): CoreState;
|
|
119
|
+
declare function useVFXStore<T>(selector: (state: CoreState) => T): T;
|
|
132
120
|
|
|
133
121
|
export { Appearance, AttractorType, Blending, Easing, EmitterShape, Lighting, VFXEmitter, VFXParticles, bakeCurveToArray, createCombinedCurveTexture, useVFXEmitter, useVFXStore };
|
package/dist/index.js
CHANGED
|
@@ -18,19 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
21
|
var __esm = (fn, res) => function __init() {
|
|
35
22
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
36
23
|
};
|
|
@@ -39,134 +26,15 @@ var __export = (target, all) => {
|
|
|
39
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
27
|
};
|
|
41
28
|
|
|
42
|
-
// src/
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
// src/react-store.ts
|
|
30
|
+
import { coreStore } from "core-vfx";
|
|
31
|
+
import { useStore } from "zustand";
|
|
32
|
+
function useVFXStore(selector) {
|
|
33
|
+
return useStore(coreStore, selector);
|
|
34
|
+
}
|
|
35
|
+
var init_react_store = __esm({
|
|
36
|
+
"src/react-store.ts"() {
|
|
47
37
|
"use strict";
|
|
48
|
-
useVFXStore = create((set, get) => ({
|
|
49
|
-
// Registered particle systems: { name: ref }
|
|
50
|
-
particles: {},
|
|
51
|
-
/**
|
|
52
|
-
* Register a VFXParticles instance by name
|
|
53
|
-
* @param {string} name - Unique identifier for this particle system
|
|
54
|
-
* @param {object} ref - The ref object from VFXParticles (with spawn, start, stop methods)
|
|
55
|
-
*/
|
|
56
|
-
registerParticles: (name, ref) => {
|
|
57
|
-
if (!name || !ref) return;
|
|
58
|
-
set((state) => ({
|
|
59
|
-
particles: __spreadProps(__spreadValues({}, state.particles), { [name]: ref })
|
|
60
|
-
}));
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* Unregister a VFXParticles instance
|
|
64
|
-
* @param {string} name - Name of the particle system to unregister
|
|
65
|
-
*/
|
|
66
|
-
unregisterParticles: (name) => {
|
|
67
|
-
set((state) => {
|
|
68
|
-
const _a = state.particles, { [name]: _ } = _a, rest = __objRest(_a, [__restKey(name)]);
|
|
69
|
-
return { particles: rest };
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
/**
|
|
73
|
-
* Get a registered particle system by name
|
|
74
|
-
* @param {string} name - Name of the particle system
|
|
75
|
-
* @returns {object|null} The particle system ref or null
|
|
76
|
-
*/
|
|
77
|
-
getParticles: (name) => {
|
|
78
|
-
return get().particles[name] || null;
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Emit particles from a registered system
|
|
82
|
-
* @param {string} name - Name of the particle system
|
|
83
|
-
* @param {object} options - Emission options
|
|
84
|
-
* @param {number} [options.x=0] - X position offset
|
|
85
|
-
* @param {number} [options.y=0] - Y position offset
|
|
86
|
-
* @param {number} [options.z=0] - Z position offset
|
|
87
|
-
* @param {number} [options.count=20] - Number of particles to emit
|
|
88
|
-
* @param {object} [options.overrides] - Spawn parameter overrides
|
|
89
|
-
* @returns {boolean} True if emission was successful
|
|
90
|
-
*/
|
|
91
|
-
emit: (name, { x = 0, y = 0, z = 0, count = 20, overrides = null } = {}) => {
|
|
92
|
-
const particles = get().particles[name];
|
|
93
|
-
if (!(particles == null ? void 0 : particles.spawn)) {
|
|
94
|
-
console.warn(
|
|
95
|
-
`VFXStore: No particle system registered with name "${name}"`
|
|
96
|
-
);
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
particles.spawn(x, y, z, count, overrides);
|
|
100
|
-
return true;
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* Start auto-emission on a registered particle system
|
|
104
|
-
* @param {string} name - Name of the particle system
|
|
105
|
-
* @returns {boolean} True if successful
|
|
106
|
-
*/
|
|
107
|
-
start: (name) => {
|
|
108
|
-
const particles = get().particles[name];
|
|
109
|
-
if (!(particles == null ? void 0 : particles.start)) {
|
|
110
|
-
console.warn(
|
|
111
|
-
`VFXStore: No particle system registered with name "${name}"`
|
|
112
|
-
);
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
particles.start();
|
|
116
|
-
return true;
|
|
117
|
-
},
|
|
118
|
-
/**
|
|
119
|
-
* Stop auto-emission on a registered particle system
|
|
120
|
-
* @param {string} name - Name of the particle system
|
|
121
|
-
* @returns {boolean} True if successful
|
|
122
|
-
*/
|
|
123
|
-
stop: (name) => {
|
|
124
|
-
const particles = get().particles[name];
|
|
125
|
-
if (!(particles == null ? void 0 : particles.stop)) {
|
|
126
|
-
console.warn(
|
|
127
|
-
`VFXStore: No particle system registered with name "${name}"`
|
|
128
|
-
);
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
particles.stop();
|
|
132
|
-
return true;
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* Clear all particles from a registered system
|
|
136
|
-
* @param {string} name - Name of the particle system
|
|
137
|
-
* @returns {boolean} True if successful
|
|
138
|
-
*/
|
|
139
|
-
clear: (name) => {
|
|
140
|
-
const particles = get().particles[name];
|
|
141
|
-
if (!(particles == null ? void 0 : particles.clear)) {
|
|
142
|
-
console.warn(
|
|
143
|
-
`VFXStore: No particle system registered with name "${name}"`
|
|
144
|
-
);
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
particles.clear();
|
|
148
|
-
return true;
|
|
149
|
-
},
|
|
150
|
-
/**
|
|
151
|
-
* Check if a particle system is currently emitting
|
|
152
|
-
* @param {string} name - Name of the particle system
|
|
153
|
-
* @returns {boolean} True if emitting
|
|
154
|
-
*/
|
|
155
|
-
isEmitting: (name) => {
|
|
156
|
-
var _a;
|
|
157
|
-
const particles = get().particles[name];
|
|
158
|
-
return (_a = particles == null ? void 0 : particles.isEmitting) != null ? _a : false;
|
|
159
|
-
},
|
|
160
|
-
/**
|
|
161
|
-
* Get the uniforms object for direct manipulation
|
|
162
|
-
* @param {string} name - Name of the particle system
|
|
163
|
-
* @returns {object|null} The uniforms object or null
|
|
164
|
-
*/
|
|
165
|
-
getUniforms: (name) => {
|
|
166
|
-
const particles = get().particles[name];
|
|
167
|
-
return (particles == null ? void 0 : particles.uniforms) || null;
|
|
168
|
-
}
|
|
169
|
-
}));
|
|
170
38
|
}
|
|
171
39
|
});
|
|
172
40
|
|
|
@@ -184,7 +52,7 @@ __export(VFXParticlesDebugPanel_exports, {
|
|
|
184
52
|
import { createRoot } from "react-dom/client";
|
|
185
53
|
import { useState, useCallback, useRef, useEffect } from "react";
|
|
186
54
|
import * as THREE from "three";
|
|
187
|
-
import { create
|
|
55
|
+
import { create } from "zustand";
|
|
188
56
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
189
57
|
function renderDebugPanel(values, onChange) {
|
|
190
58
|
currentValues = values;
|
|
@@ -355,7 +223,7 @@ var init_VFXParticlesDebugPanel = __esm({
|
|
|
355
223
|
"src/VFXParticlesDebugPanel.jsx"() {
|
|
356
224
|
"use strict";
|
|
357
225
|
init_VFXParticles();
|
|
358
|
-
useDebugPanelStore =
|
|
226
|
+
useDebugPanelStore = create(() => ({
|
|
359
227
|
flushChangesRef: { current: null }
|
|
360
228
|
}));
|
|
361
229
|
getFlushChanges = () => useDebugPanelStore.getState().flushChangesRef.current;
|
|
@@ -5298,7 +5166,7 @@ var Appearance, Blending, EmitterShape, AttractorType, Easing, Lighting, MAX_ATT
|
|
|
5298
5166
|
var init_VFXParticles = __esm({
|
|
5299
5167
|
"src/VFXParticles.jsx"() {
|
|
5300
5168
|
"use strict";
|
|
5301
|
-
|
|
5169
|
+
init_react_store();
|
|
5302
5170
|
Appearance = Object.freeze({
|
|
5303
5171
|
DEFAULT: "default",
|
|
5304
5172
|
GRADIENT: "gradient",
|
|
@@ -7540,7 +7408,7 @@ var init_VFXParticles = __esm({
|
|
|
7540
7408
|
init_VFXParticles();
|
|
7541
7409
|
|
|
7542
7410
|
// src/VFXEmitter.jsx
|
|
7543
|
-
|
|
7411
|
+
init_react_store();
|
|
7544
7412
|
import {
|
|
7545
7413
|
useRef as useRef3,
|
|
7546
7414
|
useEffect as useEffect3,
|
|
@@ -7743,7 +7611,7 @@ function useVFXEmitter(name) {
|
|
|
7743
7611
|
}
|
|
7744
7612
|
|
|
7745
7613
|
// src/index.ts
|
|
7746
|
-
|
|
7614
|
+
init_react_store();
|
|
7747
7615
|
export {
|
|
7748
7616
|
Appearance,
|
|
7749
7617
|
AttractorType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "r3f-vfx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -20,13 +20,18 @@
|
|
|
20
20
|
"dev": "tsup --watch",
|
|
21
21
|
"build": "tsup",
|
|
22
22
|
"typecheck": "tsc",
|
|
23
|
-
"copy-readme": "cp
|
|
23
|
+
"copy-readme": "cp ../../README.md README.md",
|
|
24
24
|
"prepublishOnly": "bun run typecheck && bun run build && bun run copy-readme"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"core-vfx": "0.0.2",
|
|
27
28
|
"zustand": "5.0.10"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
31
|
+
"@react-three/fiber": "9.5.0",
|
|
32
|
+
"@types/react": "19.2.10",
|
|
33
|
+
"@types/three": "0.182.0",
|
|
34
|
+
"three": "0.182.0",
|
|
30
35
|
"tsup": "8.5.1",
|
|
31
36
|
"typescript": "5.9.3"
|
|
32
37
|
},
|