@3driseai/3drise-viewer 0.1.18 → 0.1.20

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.
Files changed (62) hide show
  1. package/dist/components/AnimatedObject.d.ts.map +1 -1
  2. package/dist/components/AnimatedObject.js +3 -2
  3. package/dist/components/CreatedObject.d.ts.map +1 -1
  4. package/dist/components/CreatedObject.js +18 -14
  5. package/dist/components/ModelMaterialPassContext.d.ts +7 -0
  6. package/dist/components/ModelMaterialPassContext.d.ts.map +1 -0
  7. package/dist/components/ModelMaterialPassContext.js +7 -0
  8. package/dist/components/ModelPrimitive.d.ts.map +1 -1
  9. package/dist/components/ModelPrimitive.js +7 -1
  10. package/dist/components/ObjectNode.d.ts.map +1 -1
  11. package/dist/components/ObjectNode.js +10 -6
  12. package/dist/components/ParticlesGenerator.d.ts.map +1 -1
  13. package/dist/components/ParticlesGenerator.js +11 -5
  14. package/dist/components/particles/BioluminescentWakeParticles.d.ts +5 -2
  15. package/dist/components/particles/BioluminescentWakeParticles.d.ts.map +1 -1
  16. package/dist/components/particles/BioluminescentWakeParticles.js +28 -6
  17. package/dist/components/particles/BrownianDustParticles.d.ts +5 -2
  18. package/dist/components/particles/BrownianDustParticles.d.ts.map +1 -1
  19. package/dist/components/particles/BrownianDustParticles.js +28 -6
  20. package/dist/components/particles/ChladniSandParticles.d.ts +15 -0
  21. package/dist/components/particles/ChladniSandParticles.d.ts.map +1 -0
  22. package/dist/components/particles/ChladniSandParticles.js +912 -0
  23. package/dist/components/particles/ElectronOrbitalsParticles.d.ts +5 -2
  24. package/dist/components/particles/ElectronOrbitalsParticles.d.ts.map +1 -1
  25. package/dist/components/particles/ElectronOrbitalsParticles.js +28 -6
  26. package/dist/components/particles/FaradayPowderParticles.d.ts +15 -0
  27. package/dist/components/particles/FaradayPowderParticles.d.ts.map +1 -0
  28. package/dist/components/particles/FaradayPowderParticles.js +783 -0
  29. package/dist/components/particles/GrinderSparksParticles.d.ts +5 -2
  30. package/dist/components/particles/GrinderSparksParticles.d.ts.map +1 -1
  31. package/dist/components/particles/GrinderSparksParticles.js +37 -13
  32. package/dist/components/particles/NeonRainParticles.d.ts +15 -0
  33. package/dist/components/particles/NeonRainParticles.d.ts.map +1 -0
  34. package/dist/components/particles/NeonRainParticles.js +716 -0
  35. package/dist/components/particles/TidalStreamParticles.d.ts +5 -2
  36. package/dist/components/particles/TidalStreamParticles.d.ts.map +1 -1
  37. package/dist/components/particles/TidalStreamParticles.js +28 -6
  38. package/dist/components/particles/index.d.ts +6 -0
  39. package/dist/components/particles/index.d.ts.map +1 -1
  40. package/dist/components/particles/index.js +3 -0
  41. package/dist/constants.d.ts.map +1 -1
  42. package/dist/constants.js +2 -1
  43. package/dist/hooks/index.d.ts +3 -0
  44. package/dist/hooks/index.d.ts.map +1 -1
  45. package/dist/hooks/index.js +2 -0
  46. package/dist/hooks/useConfigLive.d.ts +54 -0
  47. package/dist/hooks/useConfigLive.d.ts.map +1 -0
  48. package/dist/hooks/useConfigLive.js +100 -0
  49. package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
  50. package/dist/hooks/useMaterialApplication.js +1 -0
  51. package/dist/hooks/useNodeOverrides.d.ts +13 -0
  52. package/dist/hooks/useNodeOverrides.d.ts.map +1 -0
  53. package/dist/hooks/useNodeOverrides.js +254 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -0
  57. package/dist/utils/configAnimations.d.ts +43 -0
  58. package/dist/utils/configAnimations.d.ts.map +1 -0
  59. package/dist/utils/configAnimations.js +73 -0
  60. package/dist/utils/particleTrails.d.ts.map +1 -1
  61. package/dist/utils/particleTrails.js +17 -8
  62. package/package.json +2 -2
@@ -1,11 +1,14 @@
1
1
  import React from 'react';
2
- import type { AnimationOptions, GrinderSparksParticlesConfig } from '@3driseai/3drise-core';
2
+ import type { ObjectAnimations, GrinderSparksParticlesConfig } from '@3driseai/3drise-core';
3
3
  import type { ObjectReadyProps } from '../../types/objectReady';
4
4
  export interface GrinderSparksParticlesProps extends ObjectReadyProps {
5
+ /** Scene object id: the controller finds the live-edit handle by it. */
6
+ id?: string;
5
7
  /** World size of the object (units); the object's transform scales it further. */
6
8
  size: number;
7
9
  config: GrinderSparksParticlesConfig;
8
- animations?: AnimationOptions[];
10
+ /** Per-domain keyframes; the `particles` domain drives this object's config knobs. */
11
+ animations?: ObjectAnimations;
9
12
  }
10
13
  declare const GrinderSparksParticles: React.FC<GrinderSparksParticlesProps>;
11
14
  export default GrinderSparksParticles;
@@ -1 +1 @@
1
- {"version":3,"file":"GrinderSparksParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/GrinderSparksParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAG3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAK5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACjE,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,4BAA4B,CAAC;IACrC,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAspBD,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA6BjE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"GrinderSparksParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/GrinderSparksParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAM5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACjE,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,4BAA4B,CAAC;IACrC,sFAAsF;IACtF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC;AA8pBD,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAiDjE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
2
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
3
3
  import * as THREE from 'three';
4
4
  import { useFrame } from '@react-three/fiber';
5
- import { applyGenerativeAnimations } from '../../utils/handleGenerativeEffectsAnimations.js';
5
+ import { GENERATIVE_PARTICLES_ANIMATABLE } from '@3driseai/3drise-core';
6
+ import { applyConfigKeyframeAnimations } from '../../utils/configAnimations.js';
6
7
  import { createPointerUniforms, stepPointerField, usePointerField } from '../../utils/pointerField.js';
7
8
  import { createTrailUniforms, applyTrailConfig, createCpuTrail } from '../../utils/particleTrails.js';
8
9
  import { useObjectReady } from '../../hooks/useObjectReady.js';
10
+ import { useConfigLiveHandle } from '../../hooks/useConfigLive.js';
9
11
  /**
10
12
  * Grinder Sparks — Slow-motion grinder sparks: drag-limited ballistics, radiative cooling on the blackbody scale, carbon bursts, floor bounces and reflections; the cursor moves the grinder, aims the spray or sweeps the air. Use for industrial and cinematic scenes.
11
13
  */
@@ -133,9 +135,11 @@ const SLOWMO = 0.2; // physics seconds per shown second (a high-speed camera)
133
135
  const H_STEP = 1 / 120; // shown-time step (physics step = H_STEP * SLOWMO)
134
136
  const TR = 0.006; // physics seconds per trail unit (the shutter) for streaks
135
137
  const TR_MODE = { streak: TR, comet: 0.03, echo: 0.04 }; // arcs and smoulder look back further
136
- const C0 = [-0.8, 0.95, 0]; // contact point at rest (m)
137
- const SPRAY_MID = [0.1, 0.6, 0];
138
- const BOUNDS = { center: [0.2, 0.7, 0], radius: 2.3 };
138
+ // The rig is laid out so the spray (wheel on the left, sparks flying right) straddles the object origin:
139
+ // the editor's selection box and gizmo centre on the visible spray, not on the wheel.
140
+ const C0 = [-1.3, 0.95, 0]; // contact point at rest (m)
141
+ const SPRAY_MID = [-0.4, 0.6, 0];
142
+ const BOUNDS = { center: [-0.2, 0.7, 0], radius: 2.3 };
139
143
  const RHO_C = 7800 * 600; // steel density x heat capacity
140
144
  const SIGMA = 5.67e-8, EPS = 0.8, T_AIR = 300;
141
145
  const EL0 = -0.26; // rest elevation of the fan (rad)
@@ -223,7 +227,7 @@ void main() {
223
227
  vec4 mv = modelViewMatrix * vec4(p * uSize, 1.0);
224
228
  float lum = dot(L, vec3(0.3, 0.5, 0.2));
225
229
  float px = uSize * uViewH * (0.0045 + 0.004 * aD) * (1.0 + 0.8 * min(lum, 2.0)) / -mv.z;
226
- ${mirror ? 'px *= 1.6; float fade = uFloorReflect * 0.45 * exp(-position.y * 1.2) * smoothstep(3.0, 1.5, length(position.xz - vec2(0.4, 0.0)));' : 'float fade = 1.0;'}
230
+ ${mirror ? 'px *= 1.6; float fade = uFloorReflect * 0.45 * exp(-position.y * 1.2) * smoothstep(3.0, 1.5, length(position.xz - vec2(-0.1, 0.0)));' : 'float fade = 1.0;'}
227
231
  vCol = L * uIntensity;
228
232
  vA = uOpacity * fade * step(600.0, aT);
229
233
  gl_PointSize = clamp(px, 1.0, 40.0) * step(0.001, vA);
@@ -263,7 +267,7 @@ void main() {
263
267
  float r2 = dot(d, d);
264
268
  float E = uContact.w * max(d.y, 0.0) / pow(r2 + 0.02, 1.5);
265
269
  vec3 c = blackbody(2100.0); c /= max(max(c.r, c.g), c.b);
266
- float edge = smoothstep(2.8, 1.8, length(vP.xz - vec2(0.3, 0.0)));
270
+ float edge = smoothstep(2.8, 1.8, length(vP.xz - vec2(-0.2, 0.0)));
267
271
  vec3 rgb = c * uColor * E * 0.14 * uIntensity * edge;
268
272
  float I = max(max(rgb.r, rgb.g), rgb.b);
269
273
  if (I < 0.001) discard;
@@ -538,7 +542,7 @@ function build(u, c, size) {
538
542
  vel[j] = vx;
539
543
  vel[j + 1] = vy;
540
544
  vel[j + 2] = vz;
541
- if (t < 700 || age[i] > 6 || x > 3.5 || x < -2.5 || Math.abs(z) > 3 || y > 3.5) {
545
+ if (t < 700 || age[i] > 6 || x > 3.0 || x < -3.0 || Math.abs(z) > 3 || y > 3.5) {
542
546
  st[i] = 2;
543
547
  hold[i] = 0.05;
544
548
  T[i] = 0;
@@ -571,7 +575,7 @@ function build(u, c, size) {
571
575
  mirror.frustumCulled = false;
572
576
  const fgeo = new THREE.CircleGeometry(2.8, 64);
573
577
  fgeo.rotateX(-Math.PI / 2);
574
- fgeo.translate(0.3, 0.002, 0);
578
+ fgeo.translate(-0.2, 0.002, 0);
575
579
  const fmat = new THREE.ShaderMaterial({
576
580
  uniforms: u, vertexShader: floorVertex, fragmentShader: floorFragment,
577
581
  transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
@@ -718,9 +722,12 @@ const DEFAULTS = {
718
722
  trailColor: '#ff7a2e',
719
723
  trailShare: 1,
720
724
  };
721
- const GrinderSparksParticles = ({ size, config, animations, onObjectReady, onObjectDispose }) => {
725
+ /** Knobs that rebuild the simulation: they change on commit, never through the live path. */
726
+ const STRUCTURAL = ['particleCount', 'seed', 'quality'];
727
+ /** Knobs an animation (or mouse move) may drive per frame — generated from applyConfig. */
728
+ const ANIMATABLE = new Set(GENERATIVE_PARTICLES_ANIMATABLE.grinderSparks.map((p) => p.value));
729
+ const GrinderSparksParticles = ({ id, size, config, animations, onObjectReady, onObjectDispose }) => {
722
730
  const rootRef = useRef(null);
723
- const animCache = useRef({});
724
731
  useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
725
732
  const s = size > 0 ? size : 1;
726
733
  const cfg = useMemo(() => ({ ...DEFAULTS, ...config }), [config]);
@@ -733,11 +740,28 @@ const GrinderSparksParticles = ({ size, config, animations, onObjectReady, onObj
733
740
  applyConfig(uniforms, cfg, s);
734
741
  instance.apply(cfg);
735
742
  }, [instance, uniforms, cfg, s]);
743
+ // Slider drags and keyframe animations are both overrides on the committed config.
744
+ // This is the one place they are merged and pushed, so they compose instead of
745
+ // overwriting each other; the animation wins, because it is the active driver.
746
+ const keyframes = animations?.particles?.animations;
747
+ const animOverride = useRef({});
748
+ const animFrom = useRef({});
749
+ const animStart = useRef(0);
750
+ // Editing a keyframe restarts its cycle rather than dropping the user mid-way.
751
+ useEffect(() => { animStart.current = performance.now(); animFrom.current = {}; }, [keyframes]);
752
+ const push = useCallback((overrides) => {
753
+ const merged = { ...cfg, ...overrides, ...animOverride.current };
754
+ const z = merged.size;
755
+ applyConfig(uniforms, merged, z && z > 0 ? z : s);
756
+ }, [cfg, uniforms, s]);
757
+ const live = useConfigLiveHandle(rootRef, id, 'particles', cfg, STRUCTURAL, push);
736
758
  const pointer = usePointerField();
737
759
  useFrame((state, delta) => {
738
760
  instance.update(Math.min(delta, 0.1), state.camera, pointer);
739
- if (animations?.length)
740
- applyGenerativeAnimations(instance.materials, animations, animCache.current, Date.now(), false);
761
+ if (keyframes?.length) {
762
+ applyConfigKeyframeAnimations(keyframes, animFrom.current, cfg, animOverride.current, performance.now() - animStart.current, ANIMATABLE);
763
+ push(live.current);
764
+ }
741
765
  });
742
766
  return (_jsx("group", { ref: rootRef, children: _jsx("primitive", { object: instance.object }) }));
743
767
  };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { ObjectAnimations, NeonRainParticlesConfig } from '@3driseai/3drise-core';
3
+ import type { ObjectReadyProps } from '../../types/objectReady';
4
+ export interface NeonRainParticlesProps extends ObjectReadyProps {
5
+ /** Scene object id: the controller finds the live-edit handle by it. */
6
+ id?: string;
7
+ /** World size of the object (units); the object's transform scales it further. */
8
+ size: number;
9
+ config: NeonRainParticlesConfig;
10
+ /** Per-domain keyframes; the `particles` domain drives this object's config knobs. */
11
+ animations?: ObjectAnimations;
12
+ }
13
+ declare const NeonRainParticles: React.FC<NeonRainParticlesProps>;
14
+ export default NeonRainParticles;
15
+ //# sourceMappingURL=NeonRainParticles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NeonRainParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/NeonRainParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC5D,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,uBAAuB,CAAC;IAChC,sFAAsF;IACtF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAinBD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAiDvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}