@3driseai/3drise-viewer 0.1.5 → 0.1.6
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 +225 -0
- package/dist/components/AdvancedGrid.d.ts +16 -0
- package/dist/components/AdvancedGrid.d.ts.map +1 -0
- package/dist/components/AdvancedGrid.js +63 -0
- package/dist/components/AnimatedObject.d.ts.map +1 -1
- package/dist/components/AnimatedObject.js +6 -4
- package/dist/components/CameraController.d.ts.map +1 -1
- package/dist/components/CameraController.js +0 -6
- package/dist/components/CircuitGrid.d.ts +22 -0
- package/dist/components/CircuitGrid.d.ts.map +1 -0
- package/dist/components/CircuitGrid.js +69 -0
- package/dist/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +0 -5
- package/dist/components/ContourGrid.d.ts +25 -0
- package/dist/components/ContourGrid.d.ts.map +1 -0
- package/dist/components/ContourGrid.js +74 -0
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +3 -6
- package/dist/components/CustomPrimitive.d.ts.map +1 -1
- package/dist/components/CustomPrimitive.js +0 -5
- package/dist/components/EffectsGenerator.d.ts.map +1 -1
- package/dist/components/EffectsGenerator.js +0 -2
- package/dist/components/EffectsGroup.d.ts +6 -0
- package/dist/components/EffectsGroup.d.ts.map +1 -1
- package/dist/components/EffectsGroup.js +14 -4
- package/dist/components/FractalGrid.d.ts +23 -0
- package/dist/components/FractalGrid.d.ts.map +1 -0
- package/dist/components/FractalGrid.js +72 -0
- package/dist/components/Frame.d.ts.map +1 -1
- package/dist/components/Frame.js +2 -3
- package/dist/components/GalleryLayout.d.ts.map +1 -1
- package/dist/components/GalleryLayout.js +0 -3
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +0 -4
- package/dist/components/Glyphs.d.ts.map +1 -1
- package/dist/components/Glyphs.js +0 -1
- package/dist/components/GridsGenerator.d.ts +4 -1
- package/dist/components/GridsGenerator.d.ts.map +1 -1
- package/dist/components/GridsGenerator.js +28 -4
- package/dist/components/HdrPlaylistRenderer.d.ts.map +1 -1
- package/dist/components/HdrPlaylistRenderer.js +0 -1
- package/dist/components/HexGrid.d.ts +25 -0
- package/dist/components/HexGrid.d.ts.map +1 -0
- package/dist/components/HexGrid.js +72 -0
- package/dist/components/ImageGeometry.js +1 -1
- package/dist/components/Letter.d.ts.map +1 -1
- package/dist/components/Letter.js +1 -6
- package/dist/components/MoireGrid.d.ts +23 -0
- package/dist/components/MoireGrid.d.ts.map +1 -0
- package/dist/components/MoireGrid.js +76 -0
- package/dist/components/Moon.d.ts.map +1 -1
- package/dist/components/Moon.js +0 -1
- package/dist/components/ObjectNode.d.ts +1 -2
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +17 -20
- package/dist/components/ObjectNodeApi.d.ts +1 -2
- package/dist/components/ObjectNodeApi.d.ts.map +1 -1
- package/dist/components/ObjectNodeApi.js +7 -3
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +1 -4
- package/dist/components/ObjectsRendererApi.d.ts.map +1 -1
- package/dist/components/ObjectsRendererApi.js +4 -2
- package/dist/components/Ocean.d.ts.map +1 -1
- package/dist/components/Ocean.js +1 -4
- package/dist/components/ParticlesR3f.d.ts +0 -1
- package/dist/components/ParticlesR3f.d.ts.map +1 -1
- package/dist/components/PathRenderer.d.ts.map +1 -1
- package/dist/components/PathRenderer.js +0 -1
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +0 -28
- package/dist/components/QuasiGrid.d.ts +22 -0
- package/dist/components/QuasiGrid.d.ts.map +1 -0
- package/dist/components/QuasiGrid.js +68 -0
- package/dist/components/RadarGrid.d.ts +24 -0
- package/dist/components/RadarGrid.d.ts.map +1 -0
- package/dist/components/RadarGrid.js +71 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +0 -1
- package/dist/components/ShootingStar.js +2 -2
- package/dist/components/ShootingStars.d.ts.map +1 -1
- package/dist/components/ShootingStars.js +0 -1
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +0 -3
- package/dist/components/Skybox.d.ts +5 -0
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +0 -1
- package/dist/components/SparklesBurst.d.ts.map +1 -1
- package/dist/components/SparklesBurst.js +0 -1
- package/dist/components/VoronoiGrid.d.ts +21 -0
- package/dist/components/VoronoiGrid.d.ts.map +1 -0
- package/dist/components/VoronoiGrid.js +67 -0
- package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
- package/dist/components/effects/ShockwaveEffect.js +0 -1
- package/dist/components/effects/SmokeRibbon.d.ts.map +1 -1
- package/dist/components/effects/SmokeRibbon.js +0 -1
- package/dist/components/index.d.ts +19 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +9 -1
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/use3driseShader.d.ts.map +1 -1
- package/dist/hooks/use3driseShader.js +0 -9
- package/dist/hooks/useAnimationEvents.d.ts.map +1 -1
- package/dist/hooks/useAnimationEvents.js +0 -19
- package/dist/hooks/useCameraAnimation.d.ts.map +1 -1
- package/dist/hooks/useCameraAnimation.js +0 -5
- package/dist/hooks/useContinuousEffects.d.ts +2 -3
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +16 -61
- package/dist/hooks/useFrameAnimations.d.ts.map +1 -1
- package/dist/hooks/useFrameAnimations.js +0 -4
- package/dist/hooks/useGridSurface.d.ts +46 -0
- package/dist/hooks/useGridSurface.d.ts.map +1 -0
- package/dist/hooks/useGridSurface.js +66 -0
- package/dist/hooks/useGsapAnimation.d.ts.map +1 -1
- package/dist/hooks/useGsapAnimation.js +0 -3
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +0 -25
- package/dist/hooks/useInteractionEffects.d.ts +2 -2
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
- package/dist/hooks/useInteractionEffects.js +3 -1
- package/dist/hooks/useMaterialApplication.d.ts +2 -2
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +7 -18
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +0 -6
- package/dist/hooks/useMeshController.d.ts.map +1 -1
- package/dist/hooks/useMeshController.js +0 -16
- package/dist/hooks/useObjectAnimation.d.ts +13 -2
- package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
- package/dist/hooks/useObjectAnimation.js +26 -28
- package/dist/hooks/useObjectEdges.d.ts +2 -1
- package/dist/hooks/useObjectEdges.d.ts.map +1 -1
- package/dist/hooks/useObjectEdges.js +15 -3
- package/dist/hooks/useObjectEffects.d.ts.map +1 -1
- package/dist/hooks/useObjectEffects.js +0 -4
- package/dist/hooks/useRegisterScene.d.ts +17 -0
- package/dist/hooks/useRegisterScene.d.ts.map +1 -0
- package/dist/hooks/useRegisterScene.js +33 -0
- package/dist/hooks/useSequenceAnimation.d.ts +2 -2
- package/dist/hooks/useSequenceAnimation.d.ts.map +1 -1
- package/dist/hooks/useSequenceAnimation.js +5 -70
- package/dist/hooks/useShadowApplication.d.ts +2 -2
- package/dist/hooks/useShadowApplication.d.ts.map +1 -1
- package/dist/hooks/useShadowApplication.js +6 -2
- package/dist/hooks/useSkyAnimation.d.ts.map +1 -1
- package/dist/hooks/useSkyAnimation.js +0 -1
- package/dist/hooks/useSkySystem.d.ts.map +1 -1
- package/dist/hooks/useSkySystem.js +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/services/AnimationsManager.d.ts.map +1 -1
- package/dist/services/AnimationsManager.js +0 -1
- package/dist/shaders/CircuitGridMaterial.d.ts +76 -0
- package/dist/shaders/CircuitGridMaterial.d.ts.map +1 -0
- package/dist/shaders/CircuitGridMaterial.js +298 -0
- package/dist/shaders/ContourGridMaterial.d.ts +80 -0
- package/dist/shaders/ContourGridMaterial.d.ts.map +1 -0
- package/dist/shaders/ContourGridMaterial.js +259 -0
- package/dist/shaders/FractalGridMaterial.d.ts +76 -0
- package/dist/shaders/FractalGridMaterial.d.ts.map +1 -0
- package/dist/shaders/FractalGridMaterial.js +247 -0
- package/dist/shaders/HexGridMaterial.d.ts +73 -0
- package/dist/shaders/HexGridMaterial.d.ts.map +1 -0
- package/dist/shaders/HexGridMaterial.js +265 -0
- package/dist/shaders/MoireGridMaterial.d.ts +79 -0
- package/dist/shaders/MoireGridMaterial.d.ts.map +1 -0
- package/dist/shaders/MoireGridMaterial.js +271 -0
- package/dist/shaders/QuasiGridMaterial.d.ts +76 -0
- package/dist/shaders/QuasiGridMaterial.d.ts.map +1 -0
- package/dist/shaders/QuasiGridMaterial.js +238 -0
- package/dist/shaders/RadarGridMaterial.d.ts +77 -0
- package/dist/shaders/RadarGridMaterial.d.ts.map +1 -0
- package/dist/shaders/RadarGridMaterial.js +291 -0
- package/dist/shaders/VoronoiGridMaterial.d.ts +73 -0
- package/dist/shaders/VoronoiGridMaterial.d.ts.map +1 -0
- package/dist/shaders/VoronoiGridMaterial.js +266 -0
- package/dist/types/gridConfigs.d.ts +202 -0
- package/dist/types/gridConfigs.d.ts.map +1 -0
- package/dist/types/gridConfigs.js +11 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts +0 -1
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts.map +1 -1
- package/dist/utils/handleGenerativeEffectsAnimations.js +0 -29
- package/dist/utils/resolveObject3D.d.ts +20 -0
- package/dist/utils/resolveObject3D.d.ts.map +1 -0
- package/dist/utils/resolveObject3D.js +9 -0
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +0 -1
- package/package.json +4 -4
|
@@ -12,7 +12,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
12
12
|
// updates or edge-type resets). Without this, the dropdowns stay stale after
|
|
13
13
|
// any external materialType / materialVariant change.
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
// console.log('useMaterialOptions - syncing with new initialSettings:', initialSettings);
|
|
16
15
|
const newType = initialSettings.materialType || 'basic';
|
|
17
16
|
setSelectedType(newType);
|
|
18
17
|
const variants = MaterialRegistryAPI.getVariants(newType);
|
|
@@ -64,11 +63,9 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
64
63
|
label: variant
|
|
65
64
|
}));
|
|
66
65
|
const handleTypeChange = (type) => {
|
|
67
|
-
// console.log('Material type changed to:', type);
|
|
68
66
|
setSelectedType(type);
|
|
69
67
|
const availableVariants = MaterialRegistryAPI.getVariants(type);
|
|
70
68
|
const defaultVariant = availableVariants[0];
|
|
71
|
-
// console.log({defaultVariant})
|
|
72
69
|
setSelectedVariant(defaultVariant);
|
|
73
70
|
// Auto-select first variant when type changes
|
|
74
71
|
if (defaultVariant) {
|
|
@@ -76,7 +73,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
76
73
|
}
|
|
77
74
|
};
|
|
78
75
|
const handleVariantChange = (variant) => {
|
|
79
|
-
console.log('Material variant changed to:', variant);
|
|
80
76
|
setSelectedVariant(variant);
|
|
81
77
|
handleMaterialUpdate(selectedType, variant);
|
|
82
78
|
};
|
|
@@ -86,7 +82,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
86
82
|
try {
|
|
87
83
|
const variantDefinition = MaterialRegistryAPI.getVariantDefinition(variant);
|
|
88
84
|
if (!variantDefinition) {
|
|
89
|
-
console.warn(`Variant definition for "${variant}" not found.`);
|
|
90
85
|
return;
|
|
91
86
|
}
|
|
92
87
|
// Start fresh from the new variant's defaults — this ensures
|
|
@@ -104,7 +99,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
104
99
|
onSettingsChange(newSettings);
|
|
105
100
|
}
|
|
106
101
|
catch (error) {
|
|
107
|
-
console.error('Error updating material:', error);
|
|
108
102
|
}
|
|
109
103
|
};
|
|
110
104
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMeshController.d.ts","sourceRoot":"","sources":["../../src/hooks/useMeshController.ts"],"names":[],"mappings":"AACA,wBAAgB,iBAAiB,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"useMeshController.d.ts","sourceRoot":"","sources":["../../src/hooks/useMeshController.ts"],"names":[],"mappings":"AACA,wBAAgB,iBAAiB,IAAI,GAAG,CAqJvC;AACD,eAAe,iBAAiB,CAAC"}
|
|
@@ -6,9 +6,7 @@ export function useMeshController() {
|
|
|
6
6
|
wireframe: { value: false },
|
|
7
7
|
};
|
|
8
8
|
// const createMeshes = (meshes: BaseMeshOptions[]): CreatedObjectSettings[] => {
|
|
9
|
-
// console.log("Creating meshes with data:", meshes);
|
|
10
9
|
// const createdObjectsSettings: CreatedObjectSettings[] = [];
|
|
11
|
-
// // console.log("createMeshes...", meshes);
|
|
12
10
|
// if (!Array.isArray(meshes)) return [];
|
|
13
11
|
// meshes.forEach(mesh => {
|
|
14
12
|
// try {
|
|
@@ -19,7 +17,6 @@ export function useMeshController() {
|
|
|
19
17
|
// id,
|
|
20
18
|
// type: meshType
|
|
21
19
|
// };
|
|
22
|
-
// // console.log({ meshData });
|
|
23
20
|
// // let createdObject: CreatedRef | null = ;
|
|
24
21
|
// const createdObject: CreatedRef = {
|
|
25
22
|
// id,
|
|
@@ -50,19 +47,14 @@ export function useMeshController() {
|
|
|
50
47
|
// active: true
|
|
51
48
|
// }));
|
|
52
49
|
// }
|
|
53
|
-
// // console.log("Created object settings:", createdObjectSettings);
|
|
54
50
|
// createdObjectsSettings.push(createdObjectSettings);
|
|
55
|
-
// console.log("Created mesh:", createdObject.name);
|
|
56
51
|
// } catch (error) {
|
|
57
|
-
// console.error(`Error creating mesh of type ${(mesh as any).type}:`, error);
|
|
58
52
|
// }
|
|
59
53
|
// });
|
|
60
54
|
// return createdObjectsSettings;
|
|
61
55
|
// }
|
|
62
56
|
const createObjects = (objects) => {
|
|
63
|
-
console.log("Creating meshes with data:", objects);
|
|
64
57
|
const createdObjectsSettings = [];
|
|
65
|
-
// console.log("createMeshes...", meshes);
|
|
66
58
|
if (!Array.isArray(objects))
|
|
67
59
|
return [];
|
|
68
60
|
objects.forEach(object => {
|
|
@@ -80,7 +72,6 @@ export function useMeshController() {
|
|
|
80
72
|
type: objectType,
|
|
81
73
|
id,
|
|
82
74
|
};
|
|
83
|
-
console.log({ meshData });
|
|
84
75
|
// let createdObject: CreatedRef | null = ;
|
|
85
76
|
const meshCreationResult = createMeshByType(meshData);
|
|
86
77
|
if (!meshCreationResult)
|
|
@@ -90,7 +81,6 @@ export function useMeshController() {
|
|
|
90
81
|
name: object.name || `mesh-${id}`,
|
|
91
82
|
object: meshCreationResult.mesh
|
|
92
83
|
};
|
|
93
|
-
console.log("Created object:", createdObject);
|
|
94
84
|
createdObject && ObjectManager.addObject(createdObject);
|
|
95
85
|
if (!createdObject)
|
|
96
86
|
return;
|
|
@@ -104,12 +94,9 @@ export function useMeshController() {
|
|
|
104
94
|
};
|
|
105
95
|
if (object.animations) {
|
|
106
96
|
}
|
|
107
|
-
// console.log("Created object settings:", createdObjectSettings);
|
|
108
97
|
createdObjectsSettings.push(createdObjectSettings);
|
|
109
|
-
console.log("Created mesh:", createdObject.name);
|
|
110
98
|
}
|
|
111
99
|
catch (error) {
|
|
112
|
-
console.error(`Error creating mesh of type ${object.type}:`, error);
|
|
113
100
|
}
|
|
114
101
|
});
|
|
115
102
|
return createdObjectsSettings;
|
|
@@ -117,11 +104,9 @@ export function useMeshController() {
|
|
|
117
104
|
const createMaterialSettings = (meshData) => {
|
|
118
105
|
// let materialVariant = 'Standard';
|
|
119
106
|
// if (!meshData.material) {
|
|
120
|
-
// console.warn("Mesh data is missing material property:", meshData);
|
|
121
107
|
// // return;
|
|
122
108
|
// }
|
|
123
109
|
// if (!meshData.material.variant) {
|
|
124
|
-
// console.warn("Mesh data is missing material variant:", meshData);
|
|
125
110
|
// // return;
|
|
126
111
|
// }
|
|
127
112
|
const materialVariant = meshData.material &&
|
|
@@ -144,7 +129,6 @@ export function useMeshController() {
|
|
|
144
129
|
...materialInstance.settings
|
|
145
130
|
};
|
|
146
131
|
}
|
|
147
|
-
// console.log("Default settings for material ", materialVariant, ":", defaultSettings);
|
|
148
132
|
Object.keys(meshData.material || {}).forEach(key => {
|
|
149
133
|
if (defaultSettings[key]) {
|
|
150
134
|
defaultSettings[key] = meshData.material[key];
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { CreatedObjectSettings } from '@3driseai/3drise-core';
|
|
2
2
|
import type { UseContinuousEffectsResult } from './useContinuousEffects';
|
|
3
3
|
import type { UseInteractionEffectsResult } from './useInteractionEffects';
|
|
4
|
-
import {
|
|
4
|
+
import type { Object3DSource } from '../utils/resolveObject3D';
|
|
5
5
|
interface UseObjectAnimationOptions {
|
|
6
6
|
enabled?: boolean;
|
|
7
7
|
hovered?: boolean;
|
|
8
8
|
}
|
|
9
9
|
interface UseObjectAnimationResult extends UseContinuousEffectsResult, UseInteractionEffectsResult {
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Drive every continuous animation for one scene object.
|
|
13
|
+
*
|
|
14
|
+
* Pass the **ref** the caller put on its own group. The hooks below read
|
|
15
|
+
* `.current` inside useFrame, so the object resolves as soon as React attaches
|
|
16
|
+
* it — no re-render required, and no per-render scene traversal.
|
|
17
|
+
*
|
|
18
|
+
* With no `object` at all, the object is looked up by id once, from inside the
|
|
19
|
+
* frame loop, as a fallback for callers that only hold settings. That path
|
|
20
|
+
* needs `SceneStore.scene` to be populated (see `useRegisterScene`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const useObjectAnimation: (objectSettings: CreatedObjectSettings | null, animateMaterial: boolean, options?: UseObjectAnimationOptions, object?: Object3DSource) => UseObjectAnimationResult | null;
|
|
12
23
|
export {};
|
|
13
24
|
//# sourceMappingURL=useObjectAnimation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectAnimation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useObjectAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectAnimation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,UAAU,yBAAyB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,wBAAyB,SAAQ,0BAA0B,EAAE,2BAA2B;CACjG;AAGD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,gBAAgB,qBAAqB,GAAG,IAAI,EAAE,iBAAiB,OAAO,EAAE,UAAS,yBAA8B,EAAE,SAAS,cAAc,KAAG,wBAAwB,GAAG,IAexM,CAAC"}
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useFrame } from '@react-three/fiber';
|
|
1
3
|
import { findById } from '@3driseai/3drise-core';
|
|
2
4
|
import { useContinuousEffects } from "./useContinuousEffects.js";
|
|
3
5
|
import { useMouseMove } from "./useInteractionEffects.js";
|
|
4
6
|
import { useSequenceAnimation } from "./useSequenceAnimation.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Drive every continuous animation for one scene object.
|
|
9
|
+
*
|
|
10
|
+
* Pass the **ref** the caller put on its own group. The hooks below read
|
|
11
|
+
* `.current` inside useFrame, so the object resolves as soon as React attaches
|
|
12
|
+
* it — no re-render required, and no per-render scene traversal.
|
|
13
|
+
*
|
|
14
|
+
* With no `object` at all, the object is looked up by id once, from inside the
|
|
15
|
+
* frame loop, as a fallback for callers that only hold settings. That path
|
|
16
|
+
* needs `SceneStore.scene` to be populated (see `useRegisterScene`).
|
|
17
|
+
*/
|
|
18
|
+
export const useObjectAnimation = (objectSettings, animateMaterial, options = {}, object) => {
|
|
12
19
|
const { enabled = true, hovered = false } = options;
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
name: objectSettings?.meshSettings.name,
|
|
26
|
-
hasRefArg: !!ref,
|
|
27
|
-
});
|
|
28
|
-
// return null;
|
|
29
|
-
}
|
|
30
|
-
// console.log(hovered)
|
|
31
|
-
const continuousResult = useContinuousEffects(objectSettings, { enabled, animateMaterial, hovered }, objectRef);
|
|
32
|
-
const mouseMoveResult = useMouseMove(objectSettings, { enabled, animateMaterial }, objectRef);
|
|
33
|
-
useSequenceAnimation(objectSettings?.id, objectRef);
|
|
20
|
+
// Fallback for ref-less callers. Resolved in the frame loop rather than
|
|
21
|
+
// during render, because at render time the object is not in the scene yet.
|
|
22
|
+
const fallbackRef = useRef(null);
|
|
23
|
+
useFrame(() => {
|
|
24
|
+
if (object || fallbackRef.current || !objectSettings?.id)
|
|
25
|
+
return;
|
|
26
|
+
fallbackRef.current = findById(objectSettings.id);
|
|
27
|
+
});
|
|
28
|
+
const source = object ?? fallbackRef;
|
|
29
|
+
const continuousResult = useContinuousEffects(objectSettings, { enabled, animateMaterial, hovered }, source);
|
|
30
|
+
const mouseMoveResult = useMouseMove(objectSettings, { enabled, animateMaterial }, source);
|
|
31
|
+
useSequenceAnimation(objectSettings?.id, source);
|
|
34
32
|
return { ...continuousResult, ...mouseMoveResult };
|
|
35
33
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ObjectEdges } from '@3driseai/3drise-core';
|
|
2
|
-
|
|
2
|
+
import type { Object3DSource } from '../utils/resolveObject3D';
|
|
3
|
+
export declare function useObjectEdges(objectId: string, edgesSettings: ObjectEdges, objectSource?: Object3DSource): void;
|
|
3
4
|
//# sourceMappingURL=useObjectEdges.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectEdges.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEdges.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useObjectEdges.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEdges.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAiK/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CA6ChH"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { BoxGeometry, BufferGeometry, CylinderGeometry, EdgesGeometry, Group, LineSegments, Mesh, MeshBasicMaterial, Points, PointsMaterial, Quaternion, Vector3, Float32BufferAttribute, } from 'three';
|
|
3
3
|
import { useFrame } from '@react-three/fiber';
|
|
4
4
|
import { collectMeshes, computeThreshold, buildSubdividedEdgeGeometry, EDGES_GROUP_KEY, animateUniforms, cacheChildrenWithMaterials, findById } from '@3driseai/3drise-core';
|
|
5
5
|
import { useMaterialApplication } from './useMaterialApplication.js';
|
|
6
|
+
import { resolveObject3D } from '../utils/resolveObject3D.js';
|
|
6
7
|
;
|
|
7
8
|
// import { animateUniforms, cacheChildrenWithMaterials } from "~/utils/materialUtils";
|
|
8
9
|
const DEFAULT_TUBE_RADIUS = 0.01;
|
|
@@ -162,9 +163,20 @@ function disposeGroup(group) {
|
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
// ─── Hook ─────────────────────────────────────────────────────────────────────
|
|
165
|
-
export function useObjectEdges(objectId, edgesSettings) {
|
|
166
|
+
export function useObjectEdges(objectId, edgesSettings, objectSource) {
|
|
166
167
|
const childrenWithMaterialsRef = useRef([]);
|
|
167
|
-
const
|
|
168
|
+
const edgesEnabled = !!edgesSettings?.enabled;
|
|
169
|
+
// Resolved in an effect, never during render: a ref only attaches after the
|
|
170
|
+
// render that mounts it, and findById is a full scene traverse. Gating on
|
|
171
|
+
// `enabled` keeps the many objects with no edges from paying for it at all.
|
|
172
|
+
const [object, setObject] = useState(null);
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (!edgesEnabled) {
|
|
175
|
+
setObject(null);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setObject(resolveObject3D(objectSource) ?? findById(objectId));
|
|
179
|
+
}, [edgesEnabled, objectId, objectSource]);
|
|
168
180
|
const edgesGroup = useMemo(() => {
|
|
169
181
|
if (!object || !edgesSettings.enabled)
|
|
170
182
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectEffects.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEffects.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,sBAAsB;IACnC,YAAY,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E,qBAAqB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpF,iBAAiB,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;AAED,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useObjectEffects.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEffects.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,sBAAsB;IACnC,YAAY,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E,qBAAqB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpF,iBAAiB,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;AAED,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAgJzD;AACD,eAAe,gBAAgB,CAAC"}
|
|
@@ -18,7 +18,6 @@ export function useObjectEffects() {
|
|
|
18
18
|
// Vanish Effect
|
|
19
19
|
// ============================================================================
|
|
20
20
|
const vanishObject = useCallback((object, duration = 1.0, ease = "power2.inOut") => {
|
|
21
|
-
console.log('[useObjectEffects] vanishObject:', object.uuid);
|
|
22
21
|
object.traverse((child) => {
|
|
23
22
|
if (child.isMesh) {
|
|
24
23
|
const mesh = child;
|
|
@@ -44,7 +43,6 @@ export function useObjectEffects() {
|
|
|
44
43
|
vanishedObjects.current.add(object.uuid);
|
|
45
44
|
}, []);
|
|
46
45
|
const restoreVanishedObject = useCallback((object, duration = 1.0, ease = "power2.inOut") => {
|
|
47
|
-
console.log('[useObjectEffects] restoreVanishedObject:', object.uuid);
|
|
48
46
|
object.visible = true;
|
|
49
47
|
object.traverse((child) => {
|
|
50
48
|
if (child.isMesh) {
|
|
@@ -72,7 +70,6 @@ export function useObjectEffects() {
|
|
|
72
70
|
// Glow Effect
|
|
73
71
|
// ============================================================================
|
|
74
72
|
const animateGlowEffect = useCallback((object) => {
|
|
75
|
-
console.log('[useObjectEffects] animateGlowEffect:', object.uuid);
|
|
76
73
|
object.traverse((child) => {
|
|
77
74
|
if (child.isMesh) {
|
|
78
75
|
const mesh = child;
|
|
@@ -105,7 +102,6 @@ export function useObjectEffects() {
|
|
|
105
102
|
glowingObjects.current.add(object.uuid);
|
|
106
103
|
}, []);
|
|
107
104
|
const removeGlow = useCallback((object) => {
|
|
108
|
-
console.log('[useObjectEffects] removeGlow:', object.uuid);
|
|
109
105
|
object.traverse((child) => {
|
|
110
106
|
if (child.isMesh) {
|
|
111
107
|
const mesh = child;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish the surrounding canvas's scene and renderer to `SceneStore`.
|
|
3
|
+
*
|
|
4
|
+
* `SceneStore` backs the id-based lookups in `findById` / `findByName`, which
|
|
5
|
+
* click interactions use to target objects *other* than the one clicked. It was
|
|
6
|
+
* previously only ever populated by `SceneBuilder`, so those lookups returned
|
|
7
|
+
* null for anything rendered into a host application's own <Canvas>.
|
|
8
|
+
*
|
|
9
|
+
* Call this from any component that renders 3dRise content inside a canvas it
|
|
10
|
+
* does not own. Must be called inside a <Canvas>.
|
|
11
|
+
*
|
|
12
|
+
* Note that `SceneStore` is a module-level singleton: with several independent
|
|
13
|
+
* canvases on one page, the last one mounted wins.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useRegisterScene(): void;
|
|
16
|
+
export default useRegisterScene;
|
|
17
|
+
//# sourceMappingURL=useRegisterScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRegisterScene.d.ts","sourceRoot":"","sources":["../../src/hooks/useRegisterScene.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAcvC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useThree } from '@react-three/fiber';
|
|
3
|
+
import { SceneStore } from '@3driseai/3drise-core';
|
|
4
|
+
/**
|
|
5
|
+
* Publish the surrounding canvas's scene and renderer to `SceneStore`.
|
|
6
|
+
*
|
|
7
|
+
* `SceneStore` backs the id-based lookups in `findById` / `findByName`, which
|
|
8
|
+
* click interactions use to target objects *other* than the one clicked. It was
|
|
9
|
+
* previously only ever populated by `SceneBuilder`, so those lookups returned
|
|
10
|
+
* null for anything rendered into a host application's own <Canvas>.
|
|
11
|
+
*
|
|
12
|
+
* Call this from any component that renders 3dRise content inside a canvas it
|
|
13
|
+
* does not own. Must be called inside a <Canvas>.
|
|
14
|
+
*
|
|
15
|
+
* Note that `SceneStore` is a module-level singleton: with several independent
|
|
16
|
+
* canvases on one page, the last one mounted wins.
|
|
17
|
+
*/
|
|
18
|
+
export function useRegisterScene() {
|
|
19
|
+
const scene = useThree(state => state.scene);
|
|
20
|
+
const gl = useThree(state => state.gl);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
SceneStore.scene = scene;
|
|
23
|
+
SceneStore.gl = gl;
|
|
24
|
+
return () => {
|
|
25
|
+
// Only clear what we set — another canvas may have taken over.
|
|
26
|
+
if (SceneStore.scene === scene)
|
|
27
|
+
SceneStore.scene = null;
|
|
28
|
+
if (SceneStore.gl === gl)
|
|
29
|
+
SceneStore.gl = null;
|
|
30
|
+
};
|
|
31
|
+
}, [scene, gl]);
|
|
32
|
+
}
|
|
33
|
+
export default useRegisterScene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Object3DSource } from '../utils/resolveObject3D';
|
|
2
2
|
/**
|
|
3
3
|
* useSequenceAnimation
|
|
4
4
|
*
|
|
@@ -9,6 +9,6 @@ import type { Object3D } from "three";
|
|
|
9
9
|
* Designed to be called inside useObjectAnimation so that AnimatedObject stays
|
|
10
10
|
* a thin group wrapper.
|
|
11
11
|
*/
|
|
12
|
-
export declare const useSequenceAnimation: (objectId: string | undefined,
|
|
12
|
+
export declare const useSequenceAnimation: (objectId: string | undefined, objectSource?: Object3DSource) => void;
|
|
13
13
|
export default useSequenceAnimation;
|
|
14
14
|
//# sourceMappingURL=useSequenceAnimation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSequenceAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSequenceAnimation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSequenceAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSequenceAnimation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAqB/D;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,GAAG,SAAS,EAAE,eAAe,cAAc,KAAG,IA6JlG,CAAC;AACF,eAAe,oBAAoB,CAAC"}
|
|
@@ -4,12 +4,7 @@ import { AnimationsManager, findById } from '@3driseai/3drise-core';
|
|
|
4
4
|
import { useAnimationEvents } from './useAnimationEvents.js';
|
|
5
5
|
import { usePathAnimation } from './usePathAnimation.js';
|
|
6
6
|
import { snapshotMaterialValues, interpolateMaterialProps } from '../utils/materialUtils.js';
|
|
7
|
-
|
|
8
|
-
const debugLog = (...args) => {
|
|
9
|
-
if (DEBUG_SEQUENCE_ANIMATION) {
|
|
10
|
-
console.log('[useSequenceAnimation]', ...args);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
7
|
+
import { resolveObject3D } from '../utils/resolveObject3D.js';
|
|
13
8
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
14
9
|
// Helpers
|
|
15
10
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -39,15 +34,12 @@ function extractMaterialProps(props) {
|
|
|
39
34
|
* Designed to be called inside useObjectAnimation so that AnimatedObject stays
|
|
40
35
|
* a thin group wrapper.
|
|
41
36
|
*/
|
|
42
|
-
export const useSequenceAnimation = (objectId,
|
|
37
|
+
export const useSequenceAnimation = (objectId, objectSource) => {
|
|
43
38
|
const { startPathAnimation, updatePathAnimation, stopPathAnimation, isAnimating: isPathAnimating } = usePathAnimation();
|
|
44
39
|
const resolveObject = () => {
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
// hasRefArg: !!objectRef,
|
|
49
|
-
// resolved: resolved ? { name: resolved.name, id: resolved.userData?.id } : null,
|
|
50
|
-
// });
|
|
40
|
+
// Called from the frame loop, so a ref resolves as soon as React
|
|
41
|
+
// attaches it. findById stays as a fallback for id-only callers.
|
|
42
|
+
const resolved = resolveObject3D(objectSource) ?? (objectId ? findById(objectId) : null);
|
|
51
43
|
return resolved;
|
|
52
44
|
};
|
|
53
45
|
// Active step state. Null = no sequence step currently animating.
|
|
@@ -56,7 +48,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
56
48
|
const progressRef = useRef(1);
|
|
57
49
|
const updateProgressRef = (p) => {
|
|
58
50
|
progressRef.current = p;
|
|
59
|
-
// console.log('Progress update', { objectId, progress: p });
|
|
60
51
|
};
|
|
61
52
|
const updateStepRef = (state) => {
|
|
62
53
|
stepRef.current = state;
|
|
@@ -65,51 +56,20 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
65
56
|
useAnimationEvents({
|
|
66
57
|
onStepStart: (event) => {
|
|
67
58
|
if (!objectId || !event.step?.transitions) {
|
|
68
|
-
// debugLog('stepStart ignored: missing objectId or transitions', {
|
|
69
|
-
// objectId,
|
|
70
|
-
// hasTransitions: !!event.step?.transitions,
|
|
71
|
-
// sequenceId: event.sequenceId,
|
|
72
|
-
// stepIndex: event.stepIndex,
|
|
73
|
-
// });
|
|
74
59
|
return;
|
|
75
60
|
}
|
|
76
|
-
// debugLog('stepStart received', {
|
|
77
|
-
// objectId,
|
|
78
|
-
// sequenceId: event.sequenceId,
|
|
79
|
-
// stepIndex: event.stepIndex,
|
|
80
|
-
// transitionStates: event.step.transitions.map(t => t.state),
|
|
81
|
-
// resolvedObject: resolvedObject ? {
|
|
82
|
-
// name: resolvedObject.name,
|
|
83
|
-
// id: resolvedObject.userData?.id,
|
|
84
|
-
// } : null,
|
|
85
|
-
// });
|
|
86
61
|
// Find the transition targeting this object
|
|
87
62
|
const transitionIndex = event.step.transitions.findIndex(t => t.state === objectId);
|
|
88
63
|
if (transitionIndex === -1) {
|
|
89
|
-
// debugLog('no matching transition for objectId', {
|
|
90
|
-
// objectId,
|
|
91
|
-
// availableStates: event.step.transitions.map(t => t.state),
|
|
92
|
-
// });
|
|
93
64
|
return;
|
|
94
65
|
}
|
|
95
|
-
console.log('TRANSTITION START', objectId);
|
|
96
66
|
const resolvedObject = resolveObject();
|
|
97
|
-
console.log(objectId, resolvedObject?.name);
|
|
98
67
|
const transition = event.step.transitions[transitionIndex];
|
|
99
68
|
const stagger = event.step.stagger || 0;
|
|
100
69
|
const staggerOffsetMs = transitionIndex * stagger * 1000;
|
|
101
70
|
const d = event.step.duration || 1;
|
|
102
71
|
const ease = event.step.ease || 'linear';
|
|
103
72
|
const { properties, pathId = null } = transition;
|
|
104
|
-
console.log('Starting sequence step', resolvedObject?.name, properties);
|
|
105
|
-
// debugLog('matched transition', {
|
|
106
|
-
// objectId,
|
|
107
|
-
// pathId,
|
|
108
|
-
// duration: d,
|
|
109
|
-
// ease,
|
|
110
|
-
// fromKeys: Object.keys(properties.from || {}),
|
|
111
|
-
// toKeys: Object.keys(properties.to || {}),
|
|
112
|
-
// });
|
|
113
73
|
// Visibility shortcut
|
|
114
74
|
if (properties.to?.visible === false) {
|
|
115
75
|
if (resolvedObject)
|
|
@@ -145,13 +105,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
145
105
|
? snapshotMaterialValues(resolvedObject, missingFromKeys)
|
|
146
106
|
: {};
|
|
147
107
|
const materialFrom = { ...materialFromExplicit };
|
|
148
|
-
// debugLog('material from/to', {
|
|
149
|
-
// objectId,
|
|
150
|
-
// materialFromExplicit,
|
|
151
|
-
// snapshotted,
|
|
152
|
-
// materialFrom,
|
|
153
|
-
// materialToProps,
|
|
154
|
-
// });
|
|
155
108
|
updateStepRef({
|
|
156
109
|
startTime: performance.now() + staggerOffsetMs,
|
|
157
110
|
duration: d,
|
|
@@ -167,10 +120,8 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
167
120
|
visibilityOverride: null,
|
|
168
121
|
pathId,
|
|
169
122
|
});
|
|
170
|
-
// console.log(stepRef.current)
|
|
171
123
|
updateProgressRef(0);
|
|
172
124
|
if (pathId) {
|
|
173
|
-
debugLog('starting path animation', { objectId, pathId, duration: d, ease });
|
|
174
125
|
startPathAnimation(pathId, d, { ease });
|
|
175
126
|
}
|
|
176
127
|
else {
|
|
@@ -184,11 +135,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
184
135
|
const isForThisObject = event.step.transitions.some(t => t.state === objectId);
|
|
185
136
|
if (!isForThisObject)
|
|
186
137
|
return;
|
|
187
|
-
// debugLog('stepEnd received', {
|
|
188
|
-
// objectId,
|
|
189
|
-
// sequenceId: event.sequenceId,
|
|
190
|
-
// stepIndex: event.stepIndex,
|
|
191
|
-
// });
|
|
192
138
|
// Let useFrame finish the last frame at p=1 naturally; just clear step
|
|
193
139
|
// after a microtask so the final interpolated position is applied.
|
|
194
140
|
// Promise.resolve().then(() => {
|
|
@@ -204,7 +150,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
204
150
|
const isForThisObject = event.sequence.steps.some(s => s.transitions.some(t => t.state === objectId));
|
|
205
151
|
if (!isForThisObject)
|
|
206
152
|
return;
|
|
207
|
-
debugLog('sequenceEnd received', { objectId, sequenceId: event.sequenceId });
|
|
208
153
|
updateStepRef(null);
|
|
209
154
|
updateProgressRef(1);
|
|
210
155
|
}
|
|
@@ -213,13 +158,11 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
213
158
|
useFrame((_state, delta) => {
|
|
214
159
|
const resolvedObject = resolveObject();
|
|
215
160
|
// Only skip if truly finished (p>=1). During stagger wait, p=0 and we still need to apply fromPosition.
|
|
216
|
-
// console.log(stepRef.current)
|
|
217
161
|
if (!stepRef.current || !resolvedObject)
|
|
218
162
|
return;
|
|
219
163
|
const step = stepRef.current;
|
|
220
164
|
// Time-based progress drives property interpolation regardless of transform mode.
|
|
221
165
|
const p = AnimationsManager.getProgressFromTime(step.startTime, step.duration, step.ease);
|
|
222
|
-
// console.log(p)
|
|
223
166
|
// updateProgressRef(p);
|
|
224
167
|
// Path-based: delegate to usePathAnimation
|
|
225
168
|
if (step.pathId) {
|
|
@@ -241,14 +184,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
241
184
|
resolvedObject.rotation.set(...rot);
|
|
242
185
|
resolvedObject.scale.set(...sca);
|
|
243
186
|
}
|
|
244
|
-
if (p === 0 || p >= 0.99) {
|
|
245
|
-
// debugLog('frame progress', {
|
|
246
|
-
// objectId,
|
|
247
|
-
// progress: p,
|
|
248
|
-
// materialKeys: Object.keys(step.materialTo),
|
|
249
|
-
// pathId: step.pathId,
|
|
250
|
-
// });
|
|
251
|
-
}
|
|
252
187
|
// — Material properties —
|
|
253
188
|
interpolateMaterialProps(resolvedObject, step.materialFrom, step.materialTo, p);
|
|
254
189
|
if (p >= 1) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useShadowApplication: (
|
|
1
|
+
import type { Object3DSource } from "../utils/resolveObject3D";
|
|
2
|
+
export declare const useShadowApplication: (source: Object3DSource, castShadow: boolean | undefined, receiveShadow: boolean | undefined, triggerKey?: unknown) => void;
|
|
3
3
|
//# sourceMappingURL=useShadowApplication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShadowApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useShadowApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useShadowApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useShadowApplication.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,oBAAoB,GAAI,QAAQ,cAAc,EAAE,YAAY,OAAO,GAAG,SAAS,EAAE,eAAe,OAAO,GAAG,SAAS,EAAE,aAAa,OAAO,KAAG,IAgBxJ,CAAC"}
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
//
|
|
16
16
|
import { useEffect } from 'react';
|
|
17
17
|
import { traverseSkippingEdgesAndEffects } from '@3driseai/3drise-core';
|
|
18
|
-
|
|
18
|
+
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
19
|
+
export const useShadowApplication = (source, castShadow, receiveShadow, triggerKey) => {
|
|
19
20
|
useEffect(() => {
|
|
21
|
+
// Read the ref here, not at the call site: effects run after React has
|
|
22
|
+
// attached refs, so this is the first point the object reliably exists.
|
|
23
|
+
const obj = resolveObject3D(source);
|
|
20
24
|
if (!obj)
|
|
21
25
|
return;
|
|
22
26
|
const cast = castShadow ?? false;
|
|
@@ -27,5 +31,5 @@ export const useShadowApplication = (obj, castShadow, receiveShadow, triggerKey)
|
|
|
27
31
|
child.receiveShadow = receive;
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
|
-
}, [
|
|
34
|
+
}, [source, castShadow, receiveShadow, triggerKey]);
|
|
31
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkyAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkyAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,MAAM,WAAW,aAAa;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAgB,eAAe,IAAI;IAC3B,oBAAoB,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAClL,
|
|
1
|
+
{"version":3,"file":"useSkyAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkyAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,MAAM,WAAW,aAAa;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAgB,eAAe,IAAI;IAC3B,oBAAoB,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAClL,CA6BJ"}
|
|
@@ -29,7 +29,6 @@ export function useSkyAnimation() {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const animateSkyTransition = useCallback((from, to, onUpdate, onComplete, duration = 3) => {
|
|
32
|
-
console.log('Initiating sky animation', { from, to, duration });
|
|
33
32
|
animRef.current = { from, to, duration, elapsed: 0, onUpdate, onComplete };
|
|
34
33
|
}, []);
|
|
35
34
|
return { animateSkyTransition };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkySystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkySystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC;CACxC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"useSkySystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkySystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC;CACxC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAqD7E;AACD,eAAe,YAAY,CAAC"}
|
|
@@ -27,7 +27,6 @@ export function useSkySystem(options) {
|
|
|
27
27
|
if (!enabled || !timeSettings.enabled || !timeSettings.autoAnimate)
|
|
28
28
|
return;
|
|
29
29
|
const state = skySystemManager.getState();
|
|
30
|
-
// console.log(state.timeInHours)
|
|
31
30
|
if (previousTimeOfDayRef.current !== null &&
|
|
32
31
|
previousTimeOfDayRef.current !== state.timeOfDay) {
|
|
33
32
|
onTimeOfDayChange?.(state.timeOfDay, state.elapsedTime);
|