@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, ElectronOrbitalsParticlesConfig } from '@3driseai/3drise-core';
2
+ import type { ObjectAnimations, ElectronOrbitalsParticlesConfig } from '@3driseai/3drise-core';
3
3
  import type { ObjectReadyProps } from '../../types/objectReady';
4
4
  export interface ElectronOrbitalsParticlesProps 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: ElectronOrbitalsParticlesConfig;
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 ElectronOrbitalsParticles: React.FC<ElectronOrbitalsParticlesProps>;
11
14
  export default ElectronOrbitalsParticles;
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronOrbitalsParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/ElectronOrbitalsParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAG3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAK/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,8BAA+B,SAAQ,gBAAgB;IACpE,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,+BAA+B,CAAC;IACxC,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAoxBD,QAAA,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CA6BvE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"ElectronOrbitalsParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/ElectronOrbitalsParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAM/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,8BAA+B,SAAQ,gBAAgB;IACpE,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,+BAA+B,CAAC;IACxC,sFAAsF;IACtF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC;AA0xBD,QAAA,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CAiDvE,CAAC;AAEF,eAAe,yBAAyB,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
  * Quantum Orbitals — A hydrogen electron cloud as Bohmian trajectories: a superposition of two orbitals breathing at the Bohr frequency, coloured by quantum phase; the cursor is a photon, a magnet or a detector. Use for science and tech scenes.
11
13
  */
@@ -918,9 +920,12 @@ const DEFAULTS = {
918
920
  trailColor: '#7a8cff',
919
921
  trailShare: 0.3,
920
922
  };
921
- const ElectronOrbitalsParticles = ({ size, config, animations, onObjectReady, onObjectDispose }) => {
923
+ /** Knobs that rebuild the simulation: they change on commit, never through the live path. */
924
+ const STRUCTURAL = ['particleCount', 'stateA', 'stateB', 'seed', 'quality'];
925
+ /** Knobs an animation (or mouse move) may drive per frame — generated from applyConfig. */
926
+ const ANIMATABLE = new Set(GENERATIVE_PARTICLES_ANIMATABLE.electronOrbitals.map((p) => p.value));
927
+ const ElectronOrbitalsParticles = ({ id, size, config, animations, onObjectReady, onObjectDispose }) => {
922
928
  const rootRef = useRef(null);
923
- const animCache = useRef({});
924
929
  useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
925
930
  const s = size > 0 ? size : 1;
926
931
  const cfg = useMemo(() => ({ ...DEFAULTS, ...config }), [config]);
@@ -933,11 +938,28 @@ const ElectronOrbitalsParticles = ({ size, config, animations, onObjectReady, on
933
938
  applyConfig(uniforms, cfg, s);
934
939
  instance.apply(cfg);
935
940
  }, [instance, uniforms, cfg, s]);
941
+ // Slider drags and keyframe animations are both overrides on the committed config.
942
+ // This is the one place they are merged and pushed, so they compose instead of
943
+ // overwriting each other; the animation wins, because it is the active driver.
944
+ const keyframes = animations?.particles?.animations;
945
+ const animOverride = useRef({});
946
+ const animFrom = useRef({});
947
+ const animStart = useRef(0);
948
+ // Editing a keyframe restarts its cycle rather than dropping the user mid-way.
949
+ useEffect(() => { animStart.current = performance.now(); animFrom.current = {}; }, [keyframes]);
950
+ const push = useCallback((overrides) => {
951
+ const merged = { ...cfg, ...overrides, ...animOverride.current };
952
+ const z = merged.size;
953
+ applyConfig(uniforms, merged, z && z > 0 ? z : s);
954
+ }, [cfg, uniforms, s]);
955
+ const live = useConfigLiveHandle(rootRef, id, 'particles', cfg, STRUCTURAL, push);
936
956
  const pointer = usePointerField();
937
957
  useFrame((state, delta) => {
938
958
  instance.update(Math.min(delta, 0.1), state.camera, pointer);
939
- if (animations?.length)
940
- applyGenerativeAnimations(instance.materials, animations, animCache.current, Date.now(), false);
959
+ if (keyframes?.length) {
960
+ applyConfigKeyframeAnimations(keyframes, animFrom.current, cfg, animOverride.current, performance.now() - animStart.current, ANIMATABLE);
961
+ push(live.current);
962
+ }
941
963
  });
942
964
  return (_jsx("group", { ref: rootRef, children: _jsx("primitive", { object: instance.object }) }));
943
965
  };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { ObjectAnimations, FaradayPowderParticlesConfig } from '@3driseai/3drise-core';
3
+ import type { ObjectReadyProps } from '../../types/objectReady';
4
+ export interface FaradayPowderParticlesProps 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: FaradayPowderParticlesConfig;
10
+ /** Per-domain keyframes; the `particles` domain drives this object's config knobs. */
11
+ animations?: ObjectAnimations;
12
+ }
13
+ declare const FaradayPowderParticles: React.FC<FaradayPowderParticlesProps>;
14
+ export default FaradayPowderParticles;
15
+ //# sourceMappingURL=FaradayPowderParticles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FaradayPowderParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/FaradayPowderParticles.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;AAypBD,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAiDjE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}