hz-particles 1.4.3 → 1.5.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/README.md +11 -3
- package/dist-lib/hz-particles-r3f.cjs +2 -2
- package/dist-lib/hz-particles-r3f.mjs +119 -117
- package/dist-lib/hz-particles.cjs +143 -14
- package/dist-lib/hz-particles.d.ts +7 -0
- package/dist-lib/hz-particles.mjs +1384 -973
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,9 +55,12 @@ HZ editor (manual or prompt) → preset (JSON / .hzfx) → faithful WebGPU r
|
|
|
55
55
|
- **GLB model support** — use 3D models as particle shapes, with automatic texture extraction
|
|
56
56
|
- **Skeletal animations** — animated GLB models with full animation control
|
|
57
57
|
- **20+ emitter shapes** — volumes & surfaces: sphere, cube, cylinder, cone, torus, capsule,
|
|
58
|
-
frustum, hemisphere, disc, annulus, arc, spiral, polygon, `cubeSurface`,
|
|
59
|
-
`boxFrame`, and more
|
|
58
|
+
frustum, `frustumSurface`, hemisphere, disc, annulus, arc, spiral, polygon, `cubeSurface`,
|
|
59
|
+
`sphereSurface`, `boxFrame`, and more
|
|
60
|
+
- **Shape contour strokes** — render a textured ribbon along the full contour of planar emitters
|
|
61
|
+
(`circle`, `disc`, `annulus`, `arc`, `square`, `rectangle`, `plain`, `line`, `polygon`)
|
|
60
62
|
- **Real-time physics** — gravity, attractors, drag, velocity, lifetime
|
|
63
|
+
- **Reverse attractors** — the same attractor API can repel away from a point (`reverse=true`)
|
|
61
64
|
- **Particle orientation modes** — `billboard` (fixed/random/velocity-aligned), `oriented` (a fixed
|
|
62
65
|
world angle via Euler `orientX/Y/Z`), and `cylindrical` (upright, faces the camera horizontally)
|
|
63
66
|
- **Keyframe animation** — animate per-system parameters over time with curves + easing
|
|
@@ -291,7 +294,7 @@ Presets are plain `SceneData`. A few key per-system fields:
|
|
|
291
294
|
| `particleCount` | `number` | Number of active particles |
|
|
292
295
|
| `lifetime` | `number` | Particle lifetime in seconds |
|
|
293
296
|
| `emissionRate` | `number` | Particles emitted per second |
|
|
294
|
-
| `emissionShape` | `string` | Emitter shape (default `cube`). Volumes: `cube`/`box`, `sphere`, `cylinder`, `cone`, `torus`, `capsule`, `frustum`, `hemisphere`, `spiral`. Flat: `circle`, `square`, `rectangle`, `disc`, `annulus`, `arc`, `polygon`, `plain`, `line`. Surfaces: `cubeSurface`, `sphereSurface`, `boxFrame` |
|
|
297
|
+
| `emissionShape` | `string` | Emitter shape (default `cube`). Volumes: `cube`/`box`, `sphere`, `cylinder`, `cone`, `torus`, `capsule`, `frustum`, `hemisphere`, `spiral`. Flat: `circle`, `square`, `rectangle`, `disc`, `annulus`, `arc`, `polygon`, `plain`, `line`. Surfaces: `frustumSurface`, `cubeSurface`, `sphereSurface`, `boxFrame` |
|
|
295
298
|
| `particleSize` | `number` | Base size of each particle |
|
|
296
299
|
| `colors` | `string[]` | Hex colors interpolated over lifetime |
|
|
297
300
|
| `fadeIn` | `number` | Opacity fade-in duration (0–1, fraction of lifetime) |
|
|
@@ -307,6 +310,11 @@ Presets are plain `SceneData`. A few key per-system fields:
|
|
|
307
310
|
| `emissionTrailEnabled` | `boolean` | Enable particle trail rendering |
|
|
308
311
|
| `emissionTrailDuration` | `number` | How long trail segments persist (seconds) |
|
|
309
312
|
| `emissionTrailWidth` | `number` | Width of the emission trail |
|
|
313
|
+
| `shapeStrokeEnabled` | `boolean` | Draw a contour ribbon along supported emitter shapes |
|
|
314
|
+
| `shapeStrokeWidth` | `number` | World-space width of the contour ribbon |
|
|
315
|
+
| `shapeStrokeSegments` | `number` | Sampling resolution of the contour path |
|
|
316
|
+
| `shapeStrokeShape` | `string` | Stroke deformation: `straight`, `zigzag`, `sine`, `spiral` |
|
|
317
|
+
| `shapeStrokeAmplitude` / `shapeStrokeFrequency` / `shapeStrokeSpeed` | `number` | Stroke deformation amplitude, tiling frequency, and animation speed. In `straight`, `shapeStrokeSpeed` scrolls the stroke along the contour |
|
|
310
318
|
|
|
311
319
|
`serializeSystemConfig(config)` is the single source of truth for the full set of serializable
|
|
312
320
|
fields (used by `saveScene` and the editor's code export).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),Z=require("@react-three/fiber"),N=require("hz-particles"),Q=require("react/jsx-runtime"),Y=require("three");function $(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const l in r)if(l!=="default"){const e=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(t,l,e.get?e:{enumerable:!0,get:()=>r[l]})}}return t.default=r,Object.freeze(t)}const p=$(Y);function K(r,t){if(t===1)return r;const l=(e,o)=>e!=null?e*t:o*t;return{...r,systems:r.systems.map(e=>({...e,particleSize:l(e.particleSize,.5),minSize:e.minSize!=null?e.minSize*t:void 0,maxSize:e.maxSize!=null?e.maxSize*t:void 0,particleSpeed:(e.particleSpeed??1)*t,minSpeed:e.minSpeed!=null?e.minSpeed*t:void 0,maxSpeed:e.maxSpeed!=null?e.maxSpeed*t:void 0,cubeLength:e.cubeLength!=null?e.cubeLength*t:void 0,outerLength:e.outerLength!=null?e.outerLength*t:void 0,innerLength:e.innerLength!=null?e.innerLength*t:void 0,outerRadius:e.outerRadius!=null?e.outerRadius*t:void 0,innerRadius:e.innerRadius!=null?e.innerRadius*t:void 0,squareSize:e.squareSize!=null?e.squareSize*t:void 0,squareInnerSize:e.squareInnerSize!=null?e.squareInnerSize*t:void 0,circleInnerRadius:e.circleInnerRadius!=null?e.circleInnerRadius*t:void 0,circleOuterRadius:e.circleOuterRadius!=null?e.circleOuterRadius*t:void 0,cylinderInnerRadius:e.cylinderInnerRadius!=null?e.cylinderInnerRadius*t:void 0,cylinderOuterRadius:e.cylinderOuterRadius!=null?e.cylinderOuterRadius*t:void 0,cylinderHeight:e.cylinderHeight!=null?e.cylinderHeight*t:void 0,rectangleWidth:e.rectangleWidth!=null?e.rectangleWidth*t:void 0,rectangleHeight:e.rectangleHeight!=null?e.rectangleHeight*t:void 0,coneOuterRadius:e.coneOuterRadius!=null?e.coneOuterRadius*t:void 0,coneInnerRadius:e.coneInnerRadius!=null?e.coneInnerRadius*t:void 0,coneHeight:e.coneHeight!=null?e.coneHeight*t:void 0,torusMajorRadius:e.torusMajorRadius!=null?e.torusMajorRadius*t:void 0,torusMinorRadius:e.torusMinorRadius!=null?e.torusMinorRadius*t:void 0,lineLength:e.lineLength!=null?e.lineLength*t:void 0,hemisphereOuterRadius:e.hemisphereOuterRadius!=null?e.hemisphereOuterRadius*t:void 0,hemisphereInnerRadius:e.hemisphereInnerRadius!=null?e.hemisphereInnerRadius*t:void 0,discRadius:e.discRadius!=null?e.discRadius*t:void 0,annulusInnerRadius:e.annulusInnerRadius!=null?e.annulusInnerRadius*t:void 0,annulusOuterRadius:e.annulusOuterRadius!=null?e.annulusOuterRadius*t:void 0,capsuleRadius:e.capsuleRadius!=null?e.capsuleRadius*t:void 0,capsuleHeight:e.capsuleHeight!=null?e.capsuleHeight*t:void 0,arcInnerRadius:e.arcInnerRadius!=null?e.arcInnerRadius*t:void 0,arcOuterRadius:e.arcOuterRadius!=null?e.arcOuterRadius*t:void 0,spiralRadiusStart:e.spiralRadiusStart!=null?e.spiralRadiusStart*t:void 0,spiralRadiusEnd:e.spiralRadiusEnd!=null?e.spiralRadiusEnd*t:void 0,spiralHeight:e.spiralHeight!=null?e.spiralHeight*t:void 0,frustumRadiusNear:e.frustumRadiusNear!=null?e.frustumRadiusNear*t:void 0,frustumRadiusFar:e.frustumRadiusFar!=null?e.frustumRadiusFar*t:void 0,frustumHeight:e.frustumHeight!=null?e.frustumHeight*t:void 0,cubeSurfaceSize:e.cubeSurfaceSize!=null?e.cubeSurfaceSize*t:void 0,sphereSurfaceRadius:e.sphereSurfaceRadius!=null?e.sphereSurfaceRadius*t:void 0,boxFrameSize:e.boxFrameSize!=null?e.boxFrameSize*t:void 0,polygonRadius:e.polygonRadius!=null?e.polygonRadius*t:void 0,emissionTrailWidth:(e.emissionTrailWidth??.3)*t,emissionTrailDuration:(e.emissionTrailDuration??1)*t,emissionTrailMinDistance:e.emissionTrailMinDistance!=null?e.emissionTrailMinDistance*t:void 0,emissionTrailShapeAmplitude:e.emissionTrailShapeAmplitude!=null?e.emissionTrailShapeAmplitude*t:void 0,shapeStrokeWidth:e.shapeStrokeWidth!=null?e.shapeStrokeWidth*t:void 0,shapeStrokeAmplitude:e.shapeStrokeAmplitude!=null?e.shapeStrokeAmplitude*t:void 0}))}}function y({preset:r,positionRef:t,position:l=[0,0,0],scale:e=1,active:o=!0,renderPriority:z=1,noOcclusion:O=!1,respectReducedMotion:w=!0}){const v=d.useRef(null),g=d.useRef(null),A=d.useRef(!1),L=d.useRef(0),H=d.useRef(o);H.current=o;const C=d.useRef(l);C.current=l;const P=d.useRef(!1),q=d.useMemo(()=>e&&e!==1?K(r,e):r,[r,e]),V=i=>t?i.addMovingEmitter(q,{getPosition:()=>{const u=t.current;return H.current&&u?[u.x,u.y,u.z]:null}}):i.addEmitter(q,C.current);return d.useEffect(()=>{var c,m;const i=v.current;if(!i)return;let u=!1;return(m=(c=g.current)==null?void 0:c.remove)==null||m.call(c),g.current=null,V(i).then(s=>{var x;u?(x=s==null?void 0:s.remove)==null||x.call(s):g.current=s}),()=>{u=!0}},[q]),d.useEffect(()=>{var c;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia("(prefers-reduced-motion: reduce)"),u=()=>{P.current=i.matches};return u(),(c=i.addEventListener)==null||c.call(i,"change",u),()=>{var m;return(m=i.removeEventListener)==null?void 0:m.call(i,"change",u)}},[]),d.useEffect(()=>()=>{var i,u,c,m;(u=(i=g.current)==null?void 0:i.remove)==null||u.call(i),(m=(c=v.current)==null?void 0:c.destroy)==null||m.call(c),v.current=null,g.current=null,A.current=!1},[]),Z.useFrame(i=>{var n,h;i.gl.render(i.scene,i.camera);const u=performance.now(),c=L.current?Math.min(.05,(u-L.current)/1e3):.016;L.current=u;const m=i.gl,s=m.backend,x=(s==null?void 0:s.context)||((h=(n=m.domElement)==null?void 0:n.getContext)==null?void 0:h.call(n,"webgpu"));!v.current&&!A.current&&(s!=null&&s.device)&&x&&(A.current=!0,N.initHzFxOverlay({device:s.device,context:x,canvas:m.domElement},{getSceneDepth:O?()=>null:N.makeThreeSceneDepth(m)}).then(f=>(v.current=f,V(f))).then(f=>{g.current=f}).catch(f=>console.error("[HZFaithfulFX] init failed:",f)));const F=v.current;if(F){const f=i.camera;F.setCamera(f.projectionMatrix.elements,f.matrixWorldInverse.elements,f.position),w&&P.current||F.render(c)}},z),null}const ee=`
|
|
2
2
|
attribute vec4 aColor;
|
|
3
3
|
varying vec4 vColor;
|
|
4
4
|
void main() {
|
|
@@ -10,4 +10,4 @@ varying vec4 vColor;
|
|
|
10
10
|
void main() {
|
|
11
11
|
gl_FragColor = vColor;
|
|
12
12
|
}
|
|
13
|
-
`;function ne({positionRef:r,duration:t=1,width:l=.3,color:e=[1,1,1],maxPoints:o=256,minDistance:z=.05,opacity:O=1,blending:w=p.AdditiveBlending,visible:v=!0}){const{camera:
|
|
13
|
+
`;function ne({positionRef:r,duration:t=1,width:l=.3,color:e=[1,1,1],maxPoints:o=256,minDistance:z=.05,opacity:O=1,blending:w=p.AdditiveBlending,visible:v=!0}){const{camera:g}=Z.useThree(),A=d.useRef(null),L=d.useRef({positions:new Float32Array(o*3),times:new Float32Array(o),head:0,count:0,lastPos:new p.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:H,posAttr:C,colorAttr:P,indexBuf:q}=d.useMemo(()=>{const x=o*2,F=new Float32Array(x*3),n=new Float32Array(x*4),h=new p.BufferGeometry,f=new p.BufferAttribute(F,3);f.setUsage(p.DynamicDrawUsage),h.setAttribute("position",f);const I=new p.BufferAttribute(n,4);I.setUsage(p.DynamicDrawUsage),h.setAttribute("aColor",I);const b=(o-1)*6,R=new Uint32Array(b);for(let T=0;T<o-1;T++){const a=T*2,M=T*6;R[M]=a,R[M+1]=a+1,R[M+2]=a+2,R[M+3]=a+1,R[M+4]=a+3,R[M+5]=a+2}const E=new p.BufferAttribute(R,1);return h.setIndex(E),h.setDrawRange(0,0),{geometry:h,posAttr:f,colorAttr:I,indexBuf:E}},[o]),V=d.useMemo(()=>new p.ShaderMaterial({vertexShader:ee,fragmentShader:te,transparent:!0,depthWrite:!1,side:p.DoubleSide,blending:w}),[w]),i=d.useMemo(()=>new p.Vector3,[]),u=d.useMemo(()=>new p.Vector3,[]),c=d.useMemo(()=>new p.Vector3,[]),m=d.useMemo(()=>new p.Vector3(0,1,0),[]),s=d.useMemo(()=>new p.Vector3,[]);return Z.useFrame((x,F)=>{if(!A.current)return;const n=L.current;if(n.elapsed+=F,!v){n.count=0,n.head=0,n.lastPos.set(1/0,1/0,1/0),H.setDrawRange(0,0);return}const h=r.current;if(!h)return;if(n.lastPos.distanceTo(h)>=z){const a=(n.head+n.count)%o;n.positions[a*3]=h.x,n.positions[a*3+1]=h.y,n.positions[a*3+2]=h.z,n.times[a]=n.elapsed,n.count<o?n.count++:n.head=(n.head+1)%o,n.lastPos.copy(h)}for(;n.count>0;){const a=n.head;if(n.elapsed-n.times[a]>t)n.head=(n.head+1)%o,n.count--;else break}if(n.count<2){H.setDrawRange(0,0);return}const I=C.array,b=P.array;let R=null;const E=n.count;for(let a=0;a<E;a++){const M=(n.head+a)%o,W=n.positions[M*3],B=n.positions[M*3+1],U=n.positions[M*3+2],k=1-(n.elapsed-n.times[M])/t;if(a<E-1){const _=(n.head+a+1)%o;i.set(n.positions[_*3]-W,n.positions[_*3+1]-B,n.positions[_*3+2]-U);const J=i.length();J>1e-6?i.divideScalar(J):R&&i.copy(R)}else R&&i.copy(R);c.set(g.position.x-W,g.position.y-B,g.position.z-U),u.crossVectors(i,c);let j=u.length();j<1e-6&&(s.crossVectors(i,m),u.copy(s),j=u.length(),j<1e-6&&(u.set(1,0,0),j=1)),u.divideScalar(j);const D=l*k,G=O*k*k,S=a*2;I[S*3]=W+u.x*D,I[S*3+1]=B+u.y*D,I[S*3+2]=U+u.z*D,I[(S+1)*3]=W-u.x*D,I[(S+1)*3+1]=B-u.y*D,I[(S+1)*3+2]=U-u.z*D,b[S*4]=e[0],b[S*4+1]=e[1],b[S*4+2]=e[2],b[S*4+3]=G,b[(S+1)*4]=e[0],b[(S+1)*4+1]=e[1],b[(S+1)*4+2]=e[2],b[(S+1)*4+3]=G,R=R||new p.Vector3,R.copy(i)}const T=(E-1)*6;H.setDrawRange(0,T),C.needsUpdate=!0,P.needsUpdate=!0}),Q.jsx("mesh",{ref:A,geometry:H,material:V,frustumCulled:!1,renderOrder:101,visible:v})}function X(r){return Math.abs(Math.sin(r*12.9898)*43758.5453)%1}function re(r){const t=Math.sin(r*54321.67)*43758.5453%1;return t<0?t+1:t}function ie(r,t,l,e){if(l<=0)return 0;const o=t/l;let z=r.particleSize??.5;if(r.randomSize){const w=r.minSize??.1,v=r.maxSize??.5;z=w+(v-w)*re(l)}const O=Math.max(.01,Math.min(10,r.sizeLifetimeSpeed??1));if(r.fadeSizeEnabled&&(z*=1-Math.pow(o,1/O)),r.increaseSizeEnabled&&(z*=1+Math.pow(o,1/O)),r.pulseEnabled){const w=r.pulseAmplitude??.5,v=r.pulseFrequency??1,A=(r.pulsePhaseRandom??0)*X(e)*Math.PI*2;z*=1+w*Math.sin(t*v*Math.PI*2+A)}return Math.max(0,z)}function ue(r,t,l,e){if(l<=0)return 0;let o=r.opacity??1;const z=t/l;if(r.fadeEnabled&&(o*=Math.max(0,1-z)),r.pulseEnabled&&r.pulseOpacity){const O=r.pulseAmplitude??.5,w=r.pulseFrequency??1,g=(r.pulsePhaseRandom??0)*X(e)*Math.PI*2;o*=Math.max(0,1+O*Math.sin(t*w*Math.PI*2+g))}return Math.max(0,Math.min(1,o))}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>N.fetchPreset});exports.HZFaithfulFX=y;exports.HZTrailRibbon=ne;exports.computeParticleOpacity=ue;exports.computeParticleSize=ie;exports.particleHash=X;exports.scalePreset=K;
|
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
import { useRef as A, useMemo as O, useEffect as
|
|
1
|
+
import { useRef as A, useMemo as O, useEffect as _ } from "react";
|
|
2
2
|
import { useFrame as J, useThree as Q } from "@react-three/fiber";
|
|
3
3
|
import { initHzFxOverlay as Y, makeThreeSceneDepth as $ } from "hz-particles";
|
|
4
4
|
import { fetchPreset as fe } from "hz-particles";
|
|
5
5
|
import { jsx as y } from "react/jsx-runtime";
|
|
6
6
|
import * as c from "three";
|
|
7
|
-
function ee(r,
|
|
8
|
-
if (
|
|
9
|
-
const v = (e, o) => e != null ? e *
|
|
7
|
+
function ee(r, t) {
|
|
8
|
+
if (t === 1) return r;
|
|
9
|
+
const v = (e, o) => e != null ? e * t : o * t;
|
|
10
10
|
return {
|
|
11
11
|
...r,
|
|
12
12
|
systems: r.systems.map((e) => ({
|
|
13
13
|
...e,
|
|
14
14
|
// Particle visual size
|
|
15
15
|
particleSize: v(e.particleSize, 0.5),
|
|
16
|
-
minSize: e.minSize != null ? e.minSize *
|
|
17
|
-
maxSize: e.maxSize != null ? e.maxSize *
|
|
16
|
+
minSize: e.minSize != null ? e.minSize * t : void 0,
|
|
17
|
+
maxSize: e.maxSize != null ? e.maxSize * t : void 0,
|
|
18
18
|
// Speed
|
|
19
|
-
particleSpeed: (e.particleSpeed ?? 1) *
|
|
20
|
-
minSpeed: e.minSpeed != null ? e.minSpeed *
|
|
21
|
-
maxSpeed: e.maxSpeed != null ? e.maxSpeed *
|
|
19
|
+
particleSpeed: (e.particleSpeed ?? 1) * t,
|
|
20
|
+
minSpeed: e.minSpeed != null ? e.minSpeed * t : void 0,
|
|
21
|
+
maxSpeed: e.maxSpeed != null ? e.maxSpeed * t : void 0,
|
|
22
22
|
// Emission shape dimensions
|
|
23
|
-
cubeLength: e.cubeLength != null ? e.cubeLength *
|
|
24
|
-
outerLength: e.outerLength != null ? e.outerLength *
|
|
25
|
-
innerLength: e.innerLength != null ? e.innerLength *
|
|
26
|
-
outerRadius: e.outerRadius != null ? e.outerRadius *
|
|
27
|
-
innerRadius: e.innerRadius != null ? e.innerRadius *
|
|
28
|
-
squareSize: e.squareSize != null ? e.squareSize *
|
|
29
|
-
squareInnerSize: e.squareInnerSize != null ? e.squareInnerSize *
|
|
30
|
-
circleInnerRadius: e.circleInnerRadius != null ? e.circleInnerRadius *
|
|
31
|
-
circleOuterRadius: e.circleOuterRadius != null ? e.circleOuterRadius *
|
|
32
|
-
cylinderInnerRadius: e.cylinderInnerRadius != null ? e.cylinderInnerRadius *
|
|
33
|
-
cylinderOuterRadius: e.cylinderOuterRadius != null ? e.cylinderOuterRadius *
|
|
34
|
-
cylinderHeight: e.cylinderHeight != null ? e.cylinderHeight *
|
|
35
|
-
rectangleWidth: e.rectangleWidth != null ? e.rectangleWidth *
|
|
36
|
-
rectangleHeight: e.rectangleHeight != null ? e.rectangleHeight *
|
|
37
|
-
coneOuterRadius: e.coneOuterRadius != null ? e.coneOuterRadius *
|
|
38
|
-
coneInnerRadius: e.coneInnerRadius != null ? e.coneInnerRadius *
|
|
39
|
-
coneHeight: e.coneHeight != null ? e.coneHeight *
|
|
40
|
-
torusMajorRadius: e.torusMajorRadius != null ? e.torusMajorRadius *
|
|
41
|
-
torusMinorRadius: e.torusMinorRadius != null ? e.torusMinorRadius *
|
|
42
|
-
lineLength: e.lineLength != null ? e.lineLength *
|
|
43
|
-
hemisphereOuterRadius: e.hemisphereOuterRadius != null ? e.hemisphereOuterRadius *
|
|
44
|
-
hemisphereInnerRadius: e.hemisphereInnerRadius != null ? e.hemisphereInnerRadius *
|
|
45
|
-
discRadius: e.discRadius != null ? e.discRadius *
|
|
46
|
-
annulusInnerRadius: e.annulusInnerRadius != null ? e.annulusInnerRadius *
|
|
47
|
-
annulusOuterRadius: e.annulusOuterRadius != null ? e.annulusOuterRadius *
|
|
48
|
-
capsuleRadius: e.capsuleRadius != null ? e.capsuleRadius *
|
|
49
|
-
capsuleHeight: e.capsuleHeight != null ? e.capsuleHeight *
|
|
50
|
-
arcInnerRadius: e.arcInnerRadius != null ? e.arcInnerRadius *
|
|
51
|
-
arcOuterRadius: e.arcOuterRadius != null ? e.arcOuterRadius *
|
|
52
|
-
spiralRadiusStart: e.spiralRadiusStart != null ? e.spiralRadiusStart *
|
|
53
|
-
spiralRadiusEnd: e.spiralRadiusEnd != null ? e.spiralRadiusEnd *
|
|
54
|
-
spiralHeight: e.spiralHeight != null ? e.spiralHeight *
|
|
55
|
-
frustumRadiusNear: e.frustumRadiusNear != null ? e.frustumRadiusNear *
|
|
56
|
-
frustumRadiusFar: e.frustumRadiusFar != null ? e.frustumRadiusFar *
|
|
57
|
-
frustumHeight: e.frustumHeight != null ? e.frustumHeight *
|
|
58
|
-
cubeSurfaceSize: e.cubeSurfaceSize != null ? e.cubeSurfaceSize *
|
|
59
|
-
sphereSurfaceRadius: e.sphereSurfaceRadius != null ? e.sphereSurfaceRadius *
|
|
60
|
-
boxFrameSize: e.boxFrameSize != null ? e.boxFrameSize *
|
|
61
|
-
polygonRadius: e.polygonRadius != null ? e.polygonRadius *
|
|
23
|
+
cubeLength: e.cubeLength != null ? e.cubeLength * t : void 0,
|
|
24
|
+
outerLength: e.outerLength != null ? e.outerLength * t : void 0,
|
|
25
|
+
innerLength: e.innerLength != null ? e.innerLength * t : void 0,
|
|
26
|
+
outerRadius: e.outerRadius != null ? e.outerRadius * t : void 0,
|
|
27
|
+
innerRadius: e.innerRadius != null ? e.innerRadius * t : void 0,
|
|
28
|
+
squareSize: e.squareSize != null ? e.squareSize * t : void 0,
|
|
29
|
+
squareInnerSize: e.squareInnerSize != null ? e.squareInnerSize * t : void 0,
|
|
30
|
+
circleInnerRadius: e.circleInnerRadius != null ? e.circleInnerRadius * t : void 0,
|
|
31
|
+
circleOuterRadius: e.circleOuterRadius != null ? e.circleOuterRadius * t : void 0,
|
|
32
|
+
cylinderInnerRadius: e.cylinderInnerRadius != null ? e.cylinderInnerRadius * t : void 0,
|
|
33
|
+
cylinderOuterRadius: e.cylinderOuterRadius != null ? e.cylinderOuterRadius * t : void 0,
|
|
34
|
+
cylinderHeight: e.cylinderHeight != null ? e.cylinderHeight * t : void 0,
|
|
35
|
+
rectangleWidth: e.rectangleWidth != null ? e.rectangleWidth * t : void 0,
|
|
36
|
+
rectangleHeight: e.rectangleHeight != null ? e.rectangleHeight * t : void 0,
|
|
37
|
+
coneOuterRadius: e.coneOuterRadius != null ? e.coneOuterRadius * t : void 0,
|
|
38
|
+
coneInnerRadius: e.coneInnerRadius != null ? e.coneInnerRadius * t : void 0,
|
|
39
|
+
coneHeight: e.coneHeight != null ? e.coneHeight * t : void 0,
|
|
40
|
+
torusMajorRadius: e.torusMajorRadius != null ? e.torusMajorRadius * t : void 0,
|
|
41
|
+
torusMinorRadius: e.torusMinorRadius != null ? e.torusMinorRadius * t : void 0,
|
|
42
|
+
lineLength: e.lineLength != null ? e.lineLength * t : void 0,
|
|
43
|
+
hemisphereOuterRadius: e.hemisphereOuterRadius != null ? e.hemisphereOuterRadius * t : void 0,
|
|
44
|
+
hemisphereInnerRadius: e.hemisphereInnerRadius != null ? e.hemisphereInnerRadius * t : void 0,
|
|
45
|
+
discRadius: e.discRadius != null ? e.discRadius * t : void 0,
|
|
46
|
+
annulusInnerRadius: e.annulusInnerRadius != null ? e.annulusInnerRadius * t : void 0,
|
|
47
|
+
annulusOuterRadius: e.annulusOuterRadius != null ? e.annulusOuterRadius * t : void 0,
|
|
48
|
+
capsuleRadius: e.capsuleRadius != null ? e.capsuleRadius * t : void 0,
|
|
49
|
+
capsuleHeight: e.capsuleHeight != null ? e.capsuleHeight * t : void 0,
|
|
50
|
+
arcInnerRadius: e.arcInnerRadius != null ? e.arcInnerRadius * t : void 0,
|
|
51
|
+
arcOuterRadius: e.arcOuterRadius != null ? e.arcOuterRadius * t : void 0,
|
|
52
|
+
spiralRadiusStart: e.spiralRadiusStart != null ? e.spiralRadiusStart * t : void 0,
|
|
53
|
+
spiralRadiusEnd: e.spiralRadiusEnd != null ? e.spiralRadiusEnd * t : void 0,
|
|
54
|
+
spiralHeight: e.spiralHeight != null ? e.spiralHeight * t : void 0,
|
|
55
|
+
frustumRadiusNear: e.frustumRadiusNear != null ? e.frustumRadiusNear * t : void 0,
|
|
56
|
+
frustumRadiusFar: e.frustumRadiusFar != null ? e.frustumRadiusFar * t : void 0,
|
|
57
|
+
frustumHeight: e.frustumHeight != null ? e.frustumHeight * t : void 0,
|
|
58
|
+
cubeSurfaceSize: e.cubeSurfaceSize != null ? e.cubeSurfaceSize * t : void 0,
|
|
59
|
+
sphereSurfaceRadius: e.sphereSurfaceRadius != null ? e.sphereSurfaceRadius * t : void 0,
|
|
60
|
+
boxFrameSize: e.boxFrameSize != null ? e.boxFrameSize * t : void 0,
|
|
61
|
+
polygonRadius: e.polygonRadius != null ? e.polygonRadius * t : void 0,
|
|
62
62
|
// Trail
|
|
63
|
-
emissionTrailWidth: (e.emissionTrailWidth ?? 0.3) *
|
|
64
|
-
emissionTrailDuration: (e.emissionTrailDuration ?? 1) *
|
|
65
|
-
emissionTrailMinDistance: e.emissionTrailMinDistance != null ? e.emissionTrailMinDistance *
|
|
66
|
-
emissionTrailShapeAmplitude: e.emissionTrailShapeAmplitude != null ? e.emissionTrailShapeAmplitude *
|
|
63
|
+
emissionTrailWidth: (e.emissionTrailWidth ?? 0.3) * t,
|
|
64
|
+
emissionTrailDuration: (e.emissionTrailDuration ?? 1) * t,
|
|
65
|
+
emissionTrailMinDistance: e.emissionTrailMinDistance != null ? e.emissionTrailMinDistance * t : void 0,
|
|
66
|
+
emissionTrailShapeAmplitude: e.emissionTrailShapeAmplitude != null ? e.emissionTrailShapeAmplitude * t : void 0,
|
|
67
|
+
shapeStrokeWidth: e.shapeStrokeWidth != null ? e.shapeStrokeWidth * t : void 0,
|
|
68
|
+
shapeStrokeAmplitude: e.shapeStrokeAmplitude != null ? e.shapeStrokeAmplitude * t : void 0
|
|
67
69
|
}))
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
function le({
|
|
71
73
|
preset: r,
|
|
72
|
-
positionRef:
|
|
74
|
+
positionRef: t,
|
|
73
75
|
position: v = [0, 0, 0],
|
|
74
76
|
scale: e = 1,
|
|
75
77
|
active: o = !0,
|
|
@@ -77,63 +79,63 @@ function le({
|
|
|
77
79
|
noOcclusion: H = !1,
|
|
78
80
|
respectReducedMotion: I = !0
|
|
79
81
|
}) {
|
|
80
|
-
const f = A(null),
|
|
82
|
+
const f = A(null), S = A(null), b = A(!1), C = A(0), F = A(o);
|
|
81
83
|
F.current = o;
|
|
82
84
|
const V = A(v);
|
|
83
85
|
V.current = v;
|
|
84
|
-
const
|
|
86
|
+
const W = A(!1), U = O(
|
|
85
87
|
() => e && e !== 1 ? ee(r, e) : r,
|
|
86
88
|
[r, e]
|
|
87
|
-
), q = (i) =>
|
|
89
|
+
), q = (i) => t ? i.addMovingEmitter(U, {
|
|
88
90
|
getPosition: () => {
|
|
89
|
-
const u =
|
|
91
|
+
const u = t.current;
|
|
90
92
|
return F.current && u ? [u.x, u.y, u.z] : null;
|
|
91
93
|
}
|
|
92
|
-
}) : i.addEmitter(
|
|
93
|
-
return
|
|
94
|
+
}) : i.addEmitter(U, V.current);
|
|
95
|
+
return _(() => {
|
|
94
96
|
var d, p;
|
|
95
97
|
const i = f.current;
|
|
96
98
|
if (!i) return;
|
|
97
99
|
let u = !1;
|
|
98
|
-
return (p = (d =
|
|
100
|
+
return (p = (d = S.current) == null ? void 0 : d.remove) == null || p.call(d), S.current = null, q(i).then((l) => {
|
|
99
101
|
var x;
|
|
100
|
-
u ? (x = l == null ? void 0 : l.remove) == null || x.call(l) :
|
|
102
|
+
u ? (x = l == null ? void 0 : l.remove) == null || x.call(l) : S.current = l;
|
|
101
103
|
}), () => {
|
|
102
104
|
u = !0;
|
|
103
105
|
};
|
|
104
|
-
}, [
|
|
106
|
+
}, [U]), _(() => {
|
|
105
107
|
var d;
|
|
106
108
|
if (typeof window > "u" || !window.matchMedia) return;
|
|
107
109
|
const i = window.matchMedia("(prefers-reduced-motion: reduce)"), u = () => {
|
|
108
|
-
|
|
110
|
+
W.current = i.matches;
|
|
109
111
|
};
|
|
110
112
|
return u(), (d = i.addEventListener) == null || d.call(i, "change", u), () => {
|
|
111
113
|
var p;
|
|
112
114
|
return (p = i.removeEventListener) == null ? void 0 : p.call(i, "change", u);
|
|
113
115
|
};
|
|
114
|
-
}, []),
|
|
116
|
+
}, []), _(() => () => {
|
|
115
117
|
var i, u, d, p;
|
|
116
|
-
(u = (i =
|
|
118
|
+
(u = (i = S.current) == null ? void 0 : i.remove) == null || u.call(i), (p = (d = f.current) == null ? void 0 : d.destroy) == null || p.call(d), f.current = null, S.current = null, b.current = !1;
|
|
117
119
|
}, []), J((i) => {
|
|
118
|
-
var
|
|
120
|
+
var n, s;
|
|
119
121
|
i.gl.render(i.scene, i.camera);
|
|
120
122
|
const u = performance.now(), d = C.current ? Math.min(0.05, (u - C.current) / 1e3) : 0.016;
|
|
121
123
|
C.current = u;
|
|
122
|
-
const p = i.gl, l = p.backend, x = (l == null ? void 0 : l.context) || ((s = (
|
|
124
|
+
const p = i.gl, l = p.backend, x = (l == null ? void 0 : l.context) || ((s = (n = p.domElement) == null ? void 0 : n.getContext) == null ? void 0 : s.call(n, "webgpu"));
|
|
123
125
|
!f.current && !b.current && (l != null && l.device) && x && (b.current = !0, Y(
|
|
124
126
|
{ device: l.device, context: x, canvas: p.domElement },
|
|
125
127
|
{ getSceneDepth: H ? () => null : $(p) }
|
|
126
128
|
).then((m) => (f.current = m, q(m))).then((m) => {
|
|
127
|
-
|
|
129
|
+
S.current = m;
|
|
128
130
|
}).catch((m) => console.error("[HZFaithfulFX] init failed:", m)));
|
|
129
131
|
const E = f.current;
|
|
130
132
|
if (E) {
|
|
131
133
|
const m = i.camera;
|
|
132
|
-
E.setCamera(m.projectionMatrix.elements, m.matrixWorldInverse.elements, m.position), I &&
|
|
134
|
+
E.setCamera(m.projectionMatrix.elements, m.matrixWorldInverse.elements, m.position), I && W.current || E.render(d);
|
|
133
135
|
}
|
|
134
136
|
}, z), null;
|
|
135
137
|
}
|
|
136
|
-
const
|
|
138
|
+
const te = (
|
|
137
139
|
/* glsl */
|
|
138
140
|
`
|
|
139
141
|
attribute vec4 aColor;
|
|
@@ -143,7 +145,7 @@ void main() {
|
|
|
143
145
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
144
146
|
}
|
|
145
147
|
`
|
|
146
|
-
),
|
|
148
|
+
), ne = (
|
|
147
149
|
/* glsl */
|
|
148
150
|
`
|
|
149
151
|
varying vec4 vColor;
|
|
@@ -154,7 +156,7 @@ void main() {
|
|
|
154
156
|
);
|
|
155
157
|
function ce({
|
|
156
158
|
positionRef: r,
|
|
157
|
-
duration:
|
|
159
|
+
duration: t = 1,
|
|
158
160
|
width: v = 0.3,
|
|
159
161
|
color: e = [1, 1, 1],
|
|
160
162
|
maxPoints: o = 256,
|
|
@@ -163,28 +165,28 @@ function ce({
|
|
|
163
165
|
blending: I = c.AdditiveBlending,
|
|
164
166
|
visible: f = !0
|
|
165
167
|
}) {
|
|
166
|
-
const { camera:
|
|
168
|
+
const { camera: S } = Q(), b = A(null), C = A({
|
|
167
169
|
positions: new Float32Array(o * 3),
|
|
168
170
|
times: new Float32Array(o),
|
|
169
171
|
head: 0,
|
|
170
172
|
count: 0,
|
|
171
173
|
lastPos: new c.Vector3(1 / 0, 1 / 0, 1 / 0),
|
|
172
174
|
elapsed: 0
|
|
173
|
-
}), { geometry: F, posAttr: V, colorAttr:
|
|
174
|
-
const x = o * 2, E = new Float32Array(x * 3),
|
|
175
|
+
}), { geometry: F, posAttr: V, colorAttr: W, indexBuf: U } = O(() => {
|
|
176
|
+
const x = o * 2, E = new Float32Array(x * 3), n = new Float32Array(x * 4), s = new c.BufferGeometry(), m = new c.BufferAttribute(E, 3);
|
|
175
177
|
m.setUsage(c.DynamicDrawUsage), s.setAttribute("position", m);
|
|
176
|
-
const M = new c.BufferAttribute(
|
|
178
|
+
const M = new c.BufferAttribute(n, 4);
|
|
177
179
|
M.setUsage(c.DynamicDrawUsage), s.setAttribute("aColor", M);
|
|
178
180
|
const w = (o - 1) * 6, h = new Uint32Array(w);
|
|
179
181
|
for (let D = 0; D < o - 1; D++) {
|
|
180
|
-
const a = D * 2,
|
|
181
|
-
h[
|
|
182
|
+
const a = D * 2, g = D * 6;
|
|
183
|
+
h[g] = a, h[g + 1] = a + 1, h[g + 2] = a + 2, h[g + 3] = a + 1, h[g + 4] = a + 3, h[g + 5] = a + 2;
|
|
182
184
|
}
|
|
183
185
|
const T = new c.BufferAttribute(h, 1);
|
|
184
186
|
return s.setIndex(T), s.setDrawRange(0, 0), { geometry: s, posAttr: m, colorAttr: M, indexBuf: T };
|
|
185
187
|
}, [o]), q = O(() => new c.ShaderMaterial({
|
|
186
|
-
vertexShader:
|
|
187
|
-
fragmentShader:
|
|
188
|
+
vertexShader: te,
|
|
189
|
+
fragmentShader: ne,
|
|
188
190
|
transparent: !0,
|
|
189
191
|
depthWrite: !1,
|
|
190
192
|
side: c.DoubleSide,
|
|
@@ -192,55 +194,55 @@ function ce({
|
|
|
192
194
|
}), [I]), i = O(() => new c.Vector3(), []), u = O(() => new c.Vector3(), []), d = O(() => new c.Vector3(), []), p = O(() => new c.Vector3(0, 1, 0), []), l = O(() => new c.Vector3(), []);
|
|
193
195
|
return J((x, E) => {
|
|
194
196
|
if (!b.current) return;
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
|
|
197
|
+
const n = C.current;
|
|
198
|
+
if (n.elapsed += E, !f) {
|
|
199
|
+
n.count = 0, n.head = 0, n.lastPos.set(1 / 0, 1 / 0, 1 / 0), F.setDrawRange(0, 0);
|
|
198
200
|
return;
|
|
199
201
|
}
|
|
200
202
|
const s = r.current;
|
|
201
203
|
if (!s) return;
|
|
202
|
-
if (
|
|
203
|
-
const a = (
|
|
204
|
-
|
|
204
|
+
if (n.lastPos.distanceTo(s) >= z) {
|
|
205
|
+
const a = (n.head + n.count) % o;
|
|
206
|
+
n.positions[a * 3] = s.x, n.positions[a * 3 + 1] = s.y, n.positions[a * 3 + 2] = s.z, n.times[a] = n.elapsed, n.count < o ? n.count++ : n.head = (n.head + 1) % o, n.lastPos.copy(s);
|
|
205
207
|
}
|
|
206
|
-
for (;
|
|
207
|
-
const a =
|
|
208
|
-
if (
|
|
209
|
-
|
|
208
|
+
for (; n.count > 0; ) {
|
|
209
|
+
const a = n.head;
|
|
210
|
+
if (n.elapsed - n.times[a] > t)
|
|
211
|
+
n.head = (n.head + 1) % o, n.count--;
|
|
210
212
|
else
|
|
211
213
|
break;
|
|
212
214
|
}
|
|
213
|
-
if (
|
|
215
|
+
if (n.count < 2) {
|
|
214
216
|
F.setDrawRange(0, 0);
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
|
-
const M = V.array, w =
|
|
219
|
+
const M = V.array, w = W.array;
|
|
218
220
|
let h = null;
|
|
219
|
-
const T =
|
|
221
|
+
const T = n.count;
|
|
220
222
|
for (let a = 0; a < T; a++) {
|
|
221
|
-
const
|
|
223
|
+
const g = (n.head + a) % o, j = n.positions[g * 3], k = n.positions[g * 3 + 1], P = n.positions[g * 3 + 2], N = 1 - (n.elapsed - n.times[g]) / t;
|
|
222
224
|
if (a < T - 1) {
|
|
223
|
-
const
|
|
225
|
+
const Z = (n.head + a + 1) % o;
|
|
224
226
|
i.set(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
n.positions[Z * 3] - j,
|
|
228
|
+
n.positions[Z * 3 + 1] - k,
|
|
229
|
+
n.positions[Z * 3 + 2] - P
|
|
228
230
|
);
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
+
const G = i.length();
|
|
232
|
+
G > 1e-6 ? i.divideScalar(G) : h && i.copy(h);
|
|
231
233
|
} else h && i.copy(h);
|
|
232
234
|
d.set(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
S.position.x - j,
|
|
236
|
+
S.position.y - k,
|
|
237
|
+
S.position.z - P
|
|
236
238
|
), u.crossVectors(i, d);
|
|
237
|
-
let
|
|
238
|
-
|
|
239
|
-
const L = v *
|
|
240
|
-
M[R * 3] = j + u.x * L, M[R * 3 + 1] =
|
|
239
|
+
let B = u.length();
|
|
240
|
+
B < 1e-6 && (l.crossVectors(i, p), u.copy(l), B = u.length(), B < 1e-6 && (u.set(1, 0, 0), B = 1)), u.divideScalar(B);
|
|
241
|
+
const L = v * N, X = H * N * N, R = a * 2;
|
|
242
|
+
M[R * 3] = j + u.x * L, M[R * 3 + 1] = k + u.y * L, M[R * 3 + 2] = P + u.z * L, M[(R + 1) * 3] = j - u.x * L, M[(R + 1) * 3 + 1] = k - u.y * L, M[(R + 1) * 3 + 2] = P - u.z * L, w[R * 4] = e[0], w[R * 4 + 1] = e[1], w[R * 4 + 2] = e[2], w[R * 4 + 3] = X, w[(R + 1) * 4] = e[0], w[(R + 1) * 4 + 1] = e[1], w[(R + 1) * 4 + 2] = e[2], w[(R + 1) * 4 + 3] = X, h = h || new c.Vector3(), h.copy(i);
|
|
241
243
|
}
|
|
242
244
|
const D = (T - 1) * 6;
|
|
243
|
-
F.setDrawRange(0, D), V.needsUpdate = !0,
|
|
245
|
+
F.setDrawRange(0, D), V.needsUpdate = !0, W.needsUpdate = !0;
|
|
244
246
|
}), /* @__PURE__ */ y(
|
|
245
247
|
"mesh",
|
|
246
248
|
{
|
|
@@ -257,12 +259,12 @@ function K(r) {
|
|
|
257
259
|
return Math.abs(Math.sin(r * 12.9898) * 43758.5453) % 1;
|
|
258
260
|
}
|
|
259
261
|
function re(r) {
|
|
260
|
-
const
|
|
261
|
-
return
|
|
262
|
+
const t = Math.sin(r * 54321.67) * 43758.5453 % 1;
|
|
263
|
+
return t < 0 ? t + 1 : t;
|
|
262
264
|
}
|
|
263
|
-
function pe(r,
|
|
265
|
+
function pe(r, t, v, e) {
|
|
264
266
|
if (v <= 0) return 0;
|
|
265
|
-
const o =
|
|
267
|
+
const o = t / v;
|
|
266
268
|
let z = r.particleSize ?? 0.5;
|
|
267
269
|
if (r.randomSize) {
|
|
268
270
|
const I = r.minSize ?? 0.1, f = r.maxSize ?? 0.5;
|
|
@@ -271,17 +273,17 @@ function pe(r, n, v, e) {
|
|
|
271
273
|
const H = Math.max(0.01, Math.min(10, r.sizeLifetimeSpeed ?? 1));
|
|
272
274
|
if (r.fadeSizeEnabled && (z *= 1 - Math.pow(o, 1 / H)), r.increaseSizeEnabled && (z *= 1 + Math.pow(o, 1 / H)), r.pulseEnabled) {
|
|
273
275
|
const I = r.pulseAmplitude ?? 0.5, f = r.pulseFrequency ?? 1, b = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
|
|
274
|
-
z *= 1 + I * Math.sin(
|
|
276
|
+
z *= 1 + I * Math.sin(t * f * Math.PI * 2 + b);
|
|
275
277
|
}
|
|
276
278
|
return Math.max(0, z);
|
|
277
279
|
}
|
|
278
|
-
function se(r,
|
|
280
|
+
function se(r, t, v, e) {
|
|
279
281
|
if (v <= 0) return 0;
|
|
280
282
|
let o = r.opacity ?? 1;
|
|
281
|
-
const z =
|
|
283
|
+
const z = t / v;
|
|
282
284
|
if (r.fadeEnabled && (o *= Math.max(0, 1 - z)), r.pulseEnabled && r.pulseOpacity) {
|
|
283
|
-
const H = r.pulseAmplitude ?? 0.5, I = r.pulseFrequency ?? 1,
|
|
284
|
-
o *= Math.max(0, 1 + H * Math.sin(
|
|
285
|
+
const H = r.pulseAmplitude ?? 0.5, I = r.pulseFrequency ?? 1, S = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
|
|
286
|
+
o *= Math.max(0, 1 + H * Math.sin(t * I * Math.PI * 2 + S));
|
|
285
287
|
}
|
|
286
288
|
return Math.max(0, Math.min(1, o));
|
|
287
289
|
}
|