@3driseai/3drise-viewer 0.1.4 → 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/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -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
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
//
|
|
8
8
|
import { useEffect, useRef } from 'react';
|
|
9
9
|
import { createAndApplyMaterial, MATERIAL_INSTANCE_KEY, MaterialRegistryAPI, ObjectManager, resolveTextures, traverseSkippingEdgesAndEffects } from '@3driseai/3drise-core';
|
|
10
|
+
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
10
11
|
// TEST: 0=raw defaults, 1=+DoubleSide, 2=+transparent, 3=+metalness/roughness
|
|
11
12
|
const TEST_MATERIAL_MODE = 1;
|
|
12
|
-
export const useMaterialApplication = (
|
|
13
|
+
export const useMaterialApplication = (source, materialSettings, shouldApply3driseMaterial, onApplied) => {
|
|
13
14
|
// Track all material instances we've created so we can release them on change/unmount
|
|
14
15
|
// const { getTypeByName } = useObjectTypes();
|
|
15
16
|
const activeInstancesRef = useRef([]);
|
|
@@ -24,6 +25,9 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
24
25
|
return found;
|
|
25
26
|
};
|
|
26
27
|
useEffect(() => {
|
|
28
|
+
// Read the ref here, not at the call site: effects run after React has
|
|
29
|
+
// attached refs, so this is the first point the object reliably exists.
|
|
30
|
+
const obj = resolveObject3D(source);
|
|
27
31
|
if (!obj || !materialSettings || materialSettings.materialType === 'advanced' ||
|
|
28
32
|
materialSettings.materialVariant === '3dRiseShader' || (shouldApply3driseMaterial === false))
|
|
29
33
|
return;
|
|
@@ -31,7 +35,7 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
31
35
|
return () => {
|
|
32
36
|
releaseActiveInstances();
|
|
33
37
|
};
|
|
34
|
-
}, [materialSettings,
|
|
38
|
+
}, [materialSettings, source]);
|
|
35
39
|
// Unmount-only cleanup: dispose everything once the mesh leaves the scene.
|
|
36
40
|
useEffect(() => {
|
|
37
41
|
return () => {
|
|
@@ -53,29 +57,22 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
53
57
|
activeInstancesRef.current = [];
|
|
54
58
|
};
|
|
55
59
|
const handleSettingsChange = async (obj, materialSettings) => {
|
|
56
|
-
// console.log('Applying material with settings:', { obj, materialSettings });
|
|
57
60
|
if (!obj || !materialSettings || materialSettings.materialType === 'advanced')
|
|
58
61
|
return;
|
|
59
|
-
// console.log('Applying material with settings:',obj.name, obj);
|
|
60
62
|
// const originObject: Object3D | null = getOriginObject(obj);
|
|
61
63
|
const applyMaterial = materialSettings.apply !== undefined ? materialSettings.apply : true;
|
|
62
|
-
// console.log({applyMaterial});
|
|
63
64
|
// If apply is false, restore original materials
|
|
64
65
|
if (!applyMaterial) {
|
|
65
66
|
const objectId = obj.userData?.id;
|
|
66
|
-
// console.log({objectId})
|
|
67
67
|
if (objectId) {
|
|
68
68
|
releaseActiveInstances();
|
|
69
69
|
ObjectManager.restoreOriginalMaterials(objectId);
|
|
70
|
-
// console.log(`Restored original materials for object ID ${objectId}`);
|
|
71
70
|
}
|
|
72
71
|
onApplied?.();
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
74
|
const materialType = MaterialRegistryAPI.getTypeDefinition(materialSettings.materialType);
|
|
76
|
-
// console.log('Material type definition:', materialType);
|
|
77
75
|
if (!materialType) {
|
|
78
|
-
console.error(`Material type "${materialSettings.materialType}" not found in registry.`);
|
|
79
76
|
return;
|
|
80
77
|
}
|
|
81
78
|
const firstVariant = Object.keys(materialType.variants)[0];
|
|
@@ -84,12 +81,9 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
84
81
|
const resolvedSettings = await resolveTextures(variant, materialSettings);
|
|
85
82
|
// 2. Traverse the object tree and apply material to any child with .material.
|
|
86
83
|
const objectids = materialSettings.objectIds || [];
|
|
87
|
-
// console.log(originObject)
|
|
88
|
-
// console.log({ objectids });
|
|
89
84
|
if (obj) {
|
|
90
85
|
if (objectids.length > 0) {
|
|
91
86
|
let meshes = [];
|
|
92
|
-
// console.log('Applying material to specific object IDs:', objectids);
|
|
93
87
|
obj.traverse((child) => {
|
|
94
88
|
if (child && child.name && objectids.includes(child.name)) {
|
|
95
89
|
meshes.push(child);
|
|
@@ -97,16 +91,13 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
97
91
|
});
|
|
98
92
|
meshes.forEach(mesh => mesh.traverse((child) => {
|
|
99
93
|
if (child && child.material) {
|
|
100
|
-
// console.log('Applying material to child:', child.name);
|
|
101
94
|
applyMaterialToChild(child, variant, resolvedSettings);
|
|
102
95
|
}
|
|
103
96
|
}));
|
|
104
97
|
return;
|
|
105
98
|
}
|
|
106
99
|
traverseSkippingEdgesAndEffects(obj, true, (child) => {
|
|
107
|
-
// console.log('Traversing child:', child.name, child);
|
|
108
100
|
if (child && child.material) {
|
|
109
|
-
// console.log('Applying material to child:');
|
|
110
101
|
applyMaterialToChild(child, variant, resolvedSettings);
|
|
111
102
|
}
|
|
112
103
|
});
|
|
@@ -139,8 +130,7 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
139
130
|
// else if (TEST_MATERIAL_MODE === 3) {
|
|
140
131
|
// object.material = new MeshStandardMaterial({ side: DoubleSide, transparent: true, metalness: 0.5, roughness: 0.5 });
|
|
141
132
|
// return;
|
|
142
|
-
// }
|
|
143
|
-
// console.log(`Applying material to object ${object.name} with variant "${variant}" and settings:`, resolvedSettings);
|
|
133
|
+
// }
|
|
144
134
|
const materialInstance = createAndApplyMaterial(variant, resolvedSettings);
|
|
145
135
|
// materialInstance.material.side = FrontSide; // Default to FrontSide; specific variants can override to DoubleSide in their defaultSettings
|
|
146
136
|
// Assign to the object
|
|
@@ -151,7 +141,6 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
151
141
|
object.userData[MATERIAL_INSTANCE_KEY] = materialInstance;
|
|
152
142
|
}
|
|
153
143
|
catch (error) {
|
|
154
|
-
console.error(`Failed to apply material "${variant}" to object:`, error);
|
|
155
144
|
}
|
|
156
145
|
};
|
|
157
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7G,KAAK,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAEtG,MAAM,WAAW,wBAAwB;IACrC,YAAY,EAAE,oBAAoB,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,aAAa,CAAC;IACnC,cAAc,EAAE,aAAa,CAAC;IAC9B,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,gBAAgB,EAAE,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI,EAAE,aAAY,iBAA0B,EAAE,cAAa,WAAqB,KAAG,
|
|
1
|
+
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7G,KAAK,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAEtG,MAAM,WAAW,wBAAwB;IACrC,YAAY,EAAE,oBAAoB,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,aAAa,CAAC;IACnC,cAAc,EAAE,aAAa,CAAC;IAC9B,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,gBAAgB,EAAE,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI,EAAE,aAAY,iBAA0B,EAAE,cAAa,WAAqB,KAAG,wBA4G9M,CAAC"}
|
|
@@ -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"}
|