@3driseai/3drise-viewer 0.1.14 → 0.1.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TerrainSurface.d.ts","sourceRoot":"","sources":["../../../src/components/terrain/TerrainSurface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAU1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgG/C,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"TerrainSurface.d.ts","sourceRoot":"","sources":["../../../src/components/terrain/TerrainSurface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAW1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAqG/C,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -4,6 +4,7 @@ import { useFrame } from '@react-three/fiber';
4
4
  import { useObjectReady } from '../../hooks/useObjectReady.js';
5
5
  import { useTerrainClipmap } from '../../hooks/useTerrainClipmap.js';
6
6
  import { useCloudSun } from '../../hooks/useCloudSun.js';
7
+ import { useLiveTransitionEvents } from '../../hooks/useLiveTransitionEvents.js';
7
8
  import { TERRAIN_LIVE_KEY } from '../../hooks/useTerrainLive.js';
8
9
  import { TerrainMaterial } from '../../shaders/terrain/TerrainMaterial.js';
9
10
  import { applySunUniforms } from '../../utils/cloudUniforms.js';
@@ -58,6 +59,10 @@ const TerrainSurface = ({ id = '3drise-terrain', config, quality, skySettings, t
58
59
  return () => { delete root.userData[TERRAIN_LIVE_KEY]; };
59
60
  }, [id, liveHandle]);
60
61
  useObjectReady(rootRef, { id, type: 'terrain', config, quality }, onObjectReady, onObjectDispose);
62
+ // Sequence-authored transitions (`transition.state === 'terrain'`) — liveConfig
63
+ // is the same ref a controller's live handle writes into, merged last over
64
+ // the config each frame below.
65
+ useLiveTransitionEvents('terrain', liveConfig, config, rootRef);
61
66
  useFrame((state) => {
62
67
  const camera = state.camera;
63
68
  updateSun();
@@ -1 +1 @@
1
- {"version":3,"file":"VolumetricCloudsPass.d.ts","sourceRoot":"","sources":["../../../src/components/volumetricClouds/VolumetricCloudsPass.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvH,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAErF;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,6EAA6E;IAC7E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC;IAC7B;oDACgD;IAChD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,6DAA6D;IAC7D,SAAS,C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AoB,CAAC"}
@@ -5,6 +5,7 @@ import { useFrame, useThree } from '@react-three/fiber';
5
5
  import { useFrameRenderer } from '../../hooks/useFrameRenderer.js';
6
6
  import { useThunder } from '../../hooks/useThunder.js';
7
7
  import { useObjectReady } from '../../hooks/useObjectReady.js';
8
+ import { useLiveTransitionEvents } from '../../hooks/useLiveTransitionEvents.js';
8
9
  import { CLOUD_LIVE_KEY } from '../../hooks/useCloudLive.js';
9
10
  import { useCloudNoise } from '../../hooks/useCloudNoise.js';
10
11
  import { useCloudSun } from '../../hooks/useCloudSun.js';
@@ -154,6 +155,11 @@ const VolumetricCloudsPass = ({ id = '3drise-clouds', deck, cirrus, quality, thu
154
155
  // ObjectReadySource's union is widened by Record<string, any>, but spelling the
155
156
  // cast out keeps the intent: this reports the layer's settings, not a mesh's.
156
157
  useObjectReady(rootRef, { id, type: 'clouds', deck, cirrus, quality }, onObjectReady, onObjectDispose);
158
+ // Sequence-authored transitions (`transition.state === 'clouds'`), on top of
159
+ // whatever the deck's own keyframe/mouse-move animations are already doing —
160
+ // liveDeck is the same ref a controller's live handle writes into, and it is
161
+ // already merged last, over both, each frame.
162
+ useLiveTransitionEvents('clouds', liveDeck, deck, rootRef);
157
163
  // Only a resolution change genuinely invalidates the history — the buffers are
158
164
  // reallocated and nothing in them maps to the new grid.
159
165
  //
@@ -0,0 +1,18 @@
1
+ import type { RefObject } from 'react';
2
+ import type { Object3D } from 'three';
3
+ /**
4
+ * Drives sequence-step transitions (see `useAnimationEvents`) into a
5
+ * renderer's existing live-override ref — the same ref a controller's live
6
+ * handle (`useCloudLive`/`useTerrainLive`/`useOceanLive`) already writes into
7
+ * on every slider drag, and which the renderer already merges over its config
8
+ * each frame. That merge order is what makes a transition win over whatever
9
+ * the settings currently say, with no extra "is animating" flag needed.
10
+ *
11
+ * Matches `SkyController`'s pattern (capture current value, lerp to target
12
+ * over the step's duration) but generically: any `to` key that is a number or
13
+ * number[] animates smoothly via `useNumericAnimation`; anything else
14
+ * (booleans, strings) switches immediately, the same way `visible` does.
15
+ */
16
+ export declare function useLiveTransitionEvents(stateName: string, liveRef: React.MutableRefObject<Record<string, any>>, currentConfig?: Record<string, any> | null, rootRef?: RefObject<Object3D | null>): void;
17
+ export default useLiveTransitionEvents;
18
+ //# sourceMappingURL=useLiveTransitionEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveTransitionEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiveTransitionEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EACpD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAC1C,OAAO,CAAC,EAAE,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,GACrC,IAAI,CAwCN;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { useAnimationEvents } from './useAnimationEvents.js';
2
+ import { useNumericAnimation } from './useNumericAnimation.js';
3
+ /**
4
+ * Drives sequence-step transitions (see `useAnimationEvents`) into a
5
+ * renderer's existing live-override ref — the same ref a controller's live
6
+ * handle (`useCloudLive`/`useTerrainLive`/`useOceanLive`) already writes into
7
+ * on every slider drag, and which the renderer already merges over its config
8
+ * each frame. That merge order is what makes a transition win over whatever
9
+ * the settings currently say, with no extra "is animating" flag needed.
10
+ *
11
+ * Matches `SkyController`'s pattern (capture current value, lerp to target
12
+ * over the step's duration) but generically: any `to` key that is a number or
13
+ * number[] animates smoothly via `useNumericAnimation`; anything else
14
+ * (booleans, strings) switches immediately, the same way `visible` does.
15
+ */
16
+ export function useLiveTransitionEvents(stateName, liveRef, currentConfig, rootRef) {
17
+ const { animateNumeric } = useNumericAnimation();
18
+ useAnimationEvents({
19
+ onStepStart: (event) => {
20
+ if (!event.step?.transitions)
21
+ return;
22
+ for (const transition of event.step.transitions) {
23
+ if (transition.state !== stateName)
24
+ continue;
25
+ const toProps = transition.properties.to || {};
26
+ const fromProps = transition.properties.from || {};
27
+ // Immediate boolean switch, not animated — mirrors SkyController's `visible`.
28
+ if (toProps.visible !== undefined && rootRef?.current) {
29
+ rootRef.current.visible = toProps.visible;
30
+ }
31
+ const from = {};
32
+ const to = {};
33
+ for (const key of Object.keys(toProps)) {
34
+ if (key === 'visible')
35
+ continue;
36
+ const toVal = toProps[key];
37
+ if (toVal === undefined)
38
+ continue;
39
+ if (typeof toVal === 'number' || Array.isArray(toVal)) {
40
+ to[key] = toVal;
41
+ from[key] = fromProps[key] ?? liveRef.current[key] ?? currentConfig?.[key] ?? toVal;
42
+ }
43
+ else {
44
+ // Nothing to interpolate for a string/boolean — apply straight away.
45
+ liveRef.current[key] = toVal;
46
+ }
47
+ }
48
+ if (Object.keys(to).length > 0) {
49
+ animateNumeric(from, to, (updated) => {
50
+ Object.assign(liveRef.current, updated);
51
+ }, () => { }, event.step?.duration);
52
+ }
53
+ }
54
+ },
55
+ });
56
+ }
57
+ export default useLiveTransitionEvents;
@@ -1 +1 @@
1
- {"version":3,"file":"useOceanMaterial.d.ts","sourceRoot":"","sources":["../../src/hooks/useOceanMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAI7E,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAA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ACpB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;gFAE4E;IAC5E,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACtF;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B;0DACsD;IACtD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAChD;AAED,wBAAgB,gBAAgB,CAAC,EAC7B,EAAE,EACF,MAAM,EACN,OAAO,EACP,WAAW,EACX,YAAY,EACZ,YAAgB,EAChB,OAAO,GACV,EAAE,uBAAuB,GAAG,mBAAmB,CAuE/C;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useMemo, useRef } from 'react';
2
2
  import { useFrame } from '@react-three/fiber';
3
3
  import { useCloudSun } from './useCloudSun.js';
4
+ import { useLiveTransitionEvents } from './useLiveTransitionEvents.js';
4
5
  import { OCEAN_LIVE_KEY } from './useOceanLive.js';
5
6
  import { OceanSurfaceMaterial } from '../shaders/ocean/OceanSurfaceMaterial.js';
6
7
  import { applySunUniforms } from '../utils/cloudUniforms.js';
@@ -35,6 +36,10 @@ export function useOceanMaterial({ id, config, quality, skySettings, timeSetting
35
36
  root.userData[OCEAN_LIVE_KEY] = liveHandle;
36
37
  return () => { delete root.userData[OCEAN_LIVE_KEY]; };
37
38
  }, [id, liveHandle]);
39
+ // Sequence-authored transitions (`transition.state === 'ocean'`) — shared by
40
+ // both hosts (OceanSurface, WaterBody), the same way the material and the
41
+ // live handle already are.
42
+ useLiveTransitionEvents('ocean', liveConfig, config, rootRef);
38
43
  useFrame((state) => {
39
44
  const shader = material;
40
45
  updateSun();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3driseai/3drise-viewer",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",