@3driseai/3drise-viewer 0.1.5 → 0.1.7
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 +1 -6
- 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 +19 -7
- 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 +18 -29
- 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/ParticlesR3f.js +63 -12
- package/dist/components/PathRenderer.d.ts.map +1 -1
- package/dist/components/PathRenderer.js +0 -1
- package/dist/components/PointCloud.d.ts.map +1 -1
- package/dist/components/PointCloud.js +50 -10
- 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 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- 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 +9 -21
- package/dist/hooks/useMaterialOptions.d.ts +2 -2
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +13 -37
- 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 +18 -52
- 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/pointsMaterialOwnership.d.ts +9 -0
- package/dist/utils/pointsMaterialOwnership.d.ts.map +1 -0
- package/dist/utils/pointsMaterialOwnership.js +14 -0
- 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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { useFrame } from '@react-three/fiber';
|
|
4
|
+
/**
|
|
5
|
+
* Per-frame plumbing shared by every shader-plane grid in this package.
|
|
6
|
+
*
|
|
7
|
+
* Advances `u_time` with the raw clock (each shader applies its own
|
|
8
|
+
* `u_animSpeed`, matching MyGridMaterial), mirrors the pointer into `u_mouse`
|
|
9
|
+
* as NDC — the 3drise convention — projects the pointer onto the grid's own
|
|
10
|
+
* plane for `u_focus` when `followMouse` is on, and drives `u_reveal` toward
|
|
11
|
+
* its target.
|
|
12
|
+
*
|
|
13
|
+
* The pick plane is derived from the mesh's world matrix rather than hard-coded
|
|
14
|
+
* to XZ, so the projection stays correct whether the grid lies flat or stands
|
|
15
|
+
* upright, and whether or not the host applied a transform above it.
|
|
16
|
+
*
|
|
17
|
+
* Reveal is driven at a constant *rate* rather than by replaying a fixed
|
|
18
|
+
* timeline, so retargeting mid-flight — the dissolve that starts while the
|
|
19
|
+
* build is still running — continues smoothly from wherever it had got to
|
|
20
|
+
* instead of snapping back to the start.
|
|
21
|
+
*/
|
|
22
|
+
export function useGridSurface(materialRef, meshRef, options = {}) {
|
|
23
|
+
const { followMouse = false, reveal = 1, revealDuration = 0 } = options;
|
|
24
|
+
const scratch = useMemo(() => ({
|
|
25
|
+
ray: new THREE.Raycaster(),
|
|
26
|
+
plane: new THREE.Plane(),
|
|
27
|
+
hit: new THREE.Vector3(),
|
|
28
|
+
origin: new THREE.Vector3(),
|
|
29
|
+
normal: new THREE.Vector3(),
|
|
30
|
+
}), []);
|
|
31
|
+
// Starts at 0 when it has a duration to travel, so the first frame is the
|
|
32
|
+
// beginning of the build rather than a flash of the finished grid.
|
|
33
|
+
const revealNow = useRef(revealDuration > 0 ? 0 : reveal);
|
|
34
|
+
useFrame((state, delta) => {
|
|
35
|
+
const material = materialRef.current;
|
|
36
|
+
if (!material)
|
|
37
|
+
return;
|
|
38
|
+
material.u_time = state.clock.elapsedTime;
|
|
39
|
+
material.u_mouse.copy(state.pointer);
|
|
40
|
+
const target = THREE.MathUtils.clamp(reveal, 0, 1);
|
|
41
|
+
if (revealDuration > 0) {
|
|
42
|
+
const step = delta / revealDuration;
|
|
43
|
+
const remaining = target - revealNow.current;
|
|
44
|
+
revealNow.current += Math.sign(remaining) * Math.min(Math.abs(remaining), step);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
revealNow.current = target;
|
|
48
|
+
}
|
|
49
|
+
material.u_reveal = revealNow.current;
|
|
50
|
+
const mesh = meshRef.current;
|
|
51
|
+
if (!followMouse || !mesh)
|
|
52
|
+
return;
|
|
53
|
+
const { ray, plane, hit, origin, normal } = scratch;
|
|
54
|
+
mesh.updateWorldMatrix(true, false);
|
|
55
|
+
// A PlaneGeometry lives in local XY, so local +Z is its normal.
|
|
56
|
+
normal.set(0, 0, 1).transformDirection(mesh.matrixWorld).normalize();
|
|
57
|
+
origin.setFromMatrixPosition(mesh.matrixWorld);
|
|
58
|
+
plane.setFromNormalAndCoplanarPoint(normal, origin);
|
|
59
|
+
ray.setFromCamera(state.pointer, state.camera);
|
|
60
|
+
if (ray.ray.intersectPlane(plane, hit)) {
|
|
61
|
+
mesh.worldToLocal(hit);
|
|
62
|
+
material.u_focus.set(hit.x, hit.y);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export default useGridSurface;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGsapAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useGsapAnimation.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C7B,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,eAAc,GAAG,EAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useGsapAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useGsapAnimation.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C7B,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,eAAc,GAAG,EAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqPxD,CAAC;AACF,eAAe,gBAAgB,CAAC"}
|
|
@@ -75,7 +75,6 @@ export const useGsapAnimation = (dependencies = []) => {
|
|
|
75
75
|
* Animates multiple 3D objects with the given settings
|
|
76
76
|
*/
|
|
77
77
|
const animateObjects = (objects, settings = DEFAULT_SETTINGS) => {
|
|
78
|
-
console.log("Animating objects with settings:", settings, objects);
|
|
79
78
|
const finalSettings = { ...DEFAULT_SETTINGS, ...settings };
|
|
80
79
|
objects.forEach((object, index) => {
|
|
81
80
|
const targetPosition = new THREE.Vector3(...(finalSettings.position || [0, 0, 0]));
|
|
@@ -217,10 +216,8 @@ export const useGsapAnimation = (dependencies = []) => {
|
|
|
217
216
|
* Pulses objects (scale up and down)
|
|
218
217
|
*/
|
|
219
218
|
const animatePulse = useCallback((objects, settings = {}) => {
|
|
220
|
-
console.log("Animating pulse for objects", objects, "with settings", settings);
|
|
221
219
|
objects.forEach((object, index) => {
|
|
222
220
|
const delay = (settings.delay || 0) + (index * 0.1);
|
|
223
|
-
console.log("Animating pulse for object", object, "with delay", delay);
|
|
224
221
|
gsap.to(object.scale, {
|
|
225
222
|
x: 2.2,
|
|
226
223
|
y: 2.2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteraction.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteraction.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAA4B,MAAM,uBAAuB,CAAC;AAatG,wBAAgB,cAAc,CAAC,EAE/B,cAAc,EAAE,SAAS,GAAG,EAAE;IAClB,cAAc,EAAE,WAAW,CAAC;IAC5B,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAClC;;;;;
|
|
1
|
+
{"version":3,"file":"useInteraction.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteraction.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAA4B,MAAM,uBAAuB,CAAC;AAatG,wBAAgB,cAAc,CAAC,EAE/B,cAAc,EAAE,SAAS,GAAG,EAAE;IAClB,cAAc,EAAE,WAAW,CAAC;IAC5B,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAClC;;;;;EA+NR;AACD,eAAe,cAAc,CAAC"}
|
|
@@ -42,7 +42,6 @@ cameraSettings, sequences, }) {
|
|
|
42
42
|
if (!targetIds || targetIds.length === 0) {
|
|
43
43
|
return [currentRef];
|
|
44
44
|
}
|
|
45
|
-
console.log('[useInteraction] resolveTargets:', { targetIds, targetMode });
|
|
46
45
|
const targetRefs = [];
|
|
47
46
|
// Add current object if mode is 'add'
|
|
48
47
|
if (targetMode === 'add') {
|
|
@@ -54,9 +53,6 @@ cameraSettings, sequences, }) {
|
|
|
54
53
|
if (obj) {
|
|
55
54
|
targetRefs.push(obj);
|
|
56
55
|
}
|
|
57
|
-
else {
|
|
58
|
-
console.warn(`[useInteraction] Target not found: ${id}`);
|
|
59
|
-
}
|
|
60
56
|
});
|
|
61
57
|
return targetRefs.length > 0 ? targetRefs : [currentRef];
|
|
62
58
|
}, []);
|
|
@@ -66,16 +62,11 @@ cameraSettings, sequences, }) {
|
|
|
66
62
|
const triggerAnimations = useCallback((animationIds) => {
|
|
67
63
|
if (!animationIds || animationIds.length === 0)
|
|
68
64
|
return;
|
|
69
|
-
console.log('[useInteraction] triggerAnimations:', animationIds);
|
|
70
|
-
console.log('Available sequences:', sequences.map(s => s.id));
|
|
71
65
|
animationIds.forEach(animationId => {
|
|
72
66
|
const sequence = sequences.find(s => s.id === animationId);
|
|
73
67
|
if (sequence) {
|
|
74
68
|
AnimationsManager.playSequence(sequence);
|
|
75
69
|
}
|
|
76
|
-
else {
|
|
77
|
-
console.warn(`[useInteraction] Sequence not found: ${animationId}`);
|
|
78
|
-
}
|
|
79
70
|
});
|
|
80
71
|
}, [sequences]);
|
|
81
72
|
// ===========================================================================
|
|
@@ -89,7 +80,6 @@ cameraSettings, sequences, }) {
|
|
|
89
80
|
const defaultDistance = 2.0;
|
|
90
81
|
const isCurrentlySelected = currentAnimatedRef.current !== null;
|
|
91
82
|
const isSameObject = currentAnimatedRef.current?.uuid === ref.uuid;
|
|
92
|
-
console.log('[useInteraction] executeOperation:', operation);
|
|
93
83
|
switch (operation) {
|
|
94
84
|
case 'vanish': {
|
|
95
85
|
if (isVanished(ref.uuid)) {
|
|
@@ -188,7 +178,6 @@ cameraSettings, sequences, }) {
|
|
|
188
178
|
mat.needsUpdate = true;
|
|
189
179
|
}
|
|
190
180
|
catch (err) {
|
|
191
|
-
console.error('[useInteraction] Failed to load texture:', err);
|
|
192
181
|
}
|
|
193
182
|
}
|
|
194
183
|
break;
|
|
@@ -198,10 +187,7 @@ cameraSettings, sequences, }) {
|
|
|
198
187
|
case 'delete':
|
|
199
188
|
case 'toggle':
|
|
200
189
|
case 'loadProject':
|
|
201
|
-
console.log(`[useInteraction] ${operation} - not implemented for scene interactions`);
|
|
202
190
|
break;
|
|
203
|
-
default:
|
|
204
|
-
console.warn(`[useInteraction] Unknown operation: ${operation}`);
|
|
205
191
|
}
|
|
206
192
|
}, [
|
|
207
193
|
isVanished,
|
|
@@ -222,7 +208,6 @@ cameraSettings, sequences, }) {
|
|
|
222
208
|
const executeOperations = useCallback((operations, ref, createdObject, textureUrl) => {
|
|
223
209
|
if (!operations || operations.length === 0)
|
|
224
210
|
return;
|
|
225
|
-
console.log('[useInteraction] executeOperations:', operations);
|
|
226
211
|
operations.forEach(operation => {
|
|
227
212
|
executeOperation(operation, ref, createdObject, textureUrl);
|
|
228
213
|
});
|
|
@@ -234,19 +219,9 @@ cameraSettings, sequences, }) {
|
|
|
234
219
|
const { interaction, ref, createdObject } = params;
|
|
235
220
|
if (!interaction.enabled)
|
|
236
221
|
return;
|
|
237
|
-
console.log('[useInteraction] executeInteraction:', {
|
|
238
|
-
mouseEvent: interaction.mouseEvent,
|
|
239
|
-
operations: interaction.operations,
|
|
240
|
-
targetIds: interaction.targetIds,
|
|
241
|
-
animationIds: interaction.animationIds
|
|
242
|
-
});
|
|
243
222
|
let textureUrl = undefined;
|
|
244
223
|
if (interaction.operations?.includes('displayImage')) {
|
|
245
|
-
console.log('Display Image interaction triggered:', {
|
|
246
|
-
ref,
|
|
247
|
-
});
|
|
248
224
|
textureUrl = ref.userData?.url;
|
|
249
|
-
console.log('Texture URL:', textureUrl);
|
|
250
225
|
}
|
|
251
226
|
// 1. Resolve target objects
|
|
252
227
|
const targets = resolveTargets(interaction, ref);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CreatedObjectSettings } from '@3driseai/3drise-core';
|
|
2
|
-
import {
|
|
2
|
+
import type { Object3DSource } from "../utils/resolveObject3D";
|
|
3
3
|
export interface UseInteractionEffectsOptions {
|
|
4
4
|
enabled?: boolean;
|
|
5
5
|
animateMaterial?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface UseInteractionEffectsResult {
|
|
8
8
|
}
|
|
9
|
-
export declare const useMouseMove: (objectSettings: CreatedObjectSettings | null, options
|
|
9
|
+
export declare const useMouseMove: (objectSettings: CreatedObjectSettings | null, options?: UseInteractionEffectsOptions, objectSource?: Object3DSource) => UseInteractionEffectsResult;
|
|
10
10
|
export default useMouseMove;
|
|
11
11
|
//# sourceMappingURL=useInteractionEffects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractionEffects.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteractionEffects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useInteractionEffects.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteractionEffects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,MAAM,WAAW,4BAA4B;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,2BAA2B;CAC3C;AAqDD,eAAO,MAAM,YAAY,GAAI,gBAAgB,qBAAqB,GAAG,IAAI,EAAE,UAAS,4BAAiC,EAAE,eAAe,cAAc,KAAG,2BAqBtJ,CAAC;AACF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFrame } from "@react-three/fiber";
|
|
2
2
|
import { detectAnimatableDomain, handleEdgesMouseMove, handleMaterialMouseMove, handleTransformMouseMove, } from '@3driseai/3drise-core';
|
|
3
|
+
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
3
4
|
// =============================================================================
|
|
4
5
|
// FLAT-SHAPE BACK COMPAT
|
|
5
6
|
// =============================================================================
|
|
@@ -50,9 +51,10 @@ function resolveDomains(settings) {
|
|
|
50
51
|
// =============================================================================
|
|
51
52
|
// useMouseMove
|
|
52
53
|
// =============================================================================
|
|
53
|
-
export const useMouseMove = (objectSettings, options = {},
|
|
54
|
+
export const useMouseMove = (objectSettings, options = {}, objectSource) => {
|
|
54
55
|
const { enabled = true, animateMaterial = true } = options;
|
|
55
56
|
useFrame((state) => {
|
|
57
|
+
const object = resolveObject3D(objectSource);
|
|
56
58
|
if (!enabled || !object || !objectSettings)
|
|
57
59
|
return;
|
|
58
60
|
const domains = resolveDomains(objectSettings);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MaterialSettings } from '@3driseai/3drise-core';
|
|
2
|
-
import {
|
|
3
|
-
export declare const useMaterialApplication: (
|
|
2
|
+
import type { Object3DSource } from "../utils/resolveObject3D";
|
|
3
|
+
export declare const useMaterialApplication: (source: Object3DSource, materialSettings: MaterialSettings, shouldApply3driseMaterial?: boolean, onApplied?: () => void) => void;
|
|
4
4
|
//# sourceMappingURL=useMaterialApplication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,eAAO,MAAM,sBAAsB,GAAI,QAAQ,cAAc,EAAE,kBAAkB,gBAAgB,EAAE,4BAA4B,OAAO,EAAE,YAAY,MAAM,IAAI,KAAG,IAuIhK,CAAC"}
|
|
@@ -7,9 +7,8 @@
|
|
|
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
|
-
|
|
11
|
-
const
|
|
12
|
-
export const useMaterialApplication = (obj, materialSettings, shouldApply3driseMaterial, onApplied) => {
|
|
10
|
+
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
11
|
+
export const useMaterialApplication = (source, materialSettings, shouldApply3driseMaterial, onApplied) => {
|
|
13
12
|
// Track all material instances we've created so we can release them on change/unmount
|
|
14
13
|
// const { getTypeByName } = useObjectTypes();
|
|
15
14
|
const activeInstancesRef = useRef([]);
|
|
@@ -24,14 +23,18 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
24
23
|
return found;
|
|
25
24
|
};
|
|
26
25
|
useEffect(() => {
|
|
26
|
+
// Read the ref here, not at the call site: effects run after React has
|
|
27
|
+
// attached refs, so this is the first point the object reliably exists.
|
|
28
|
+
const obj = resolveObject3D(source);
|
|
27
29
|
if (!obj || !materialSettings || materialSettings.materialType === 'advanced' ||
|
|
28
|
-
materialSettings.materialVariant === '3dRiseShader'
|
|
30
|
+
materialSettings.materialVariant === '3dRiseShader'
|
|
31
|
+
|| (shouldApply3driseMaterial === false))
|
|
29
32
|
return;
|
|
30
33
|
handleSettingsChange(obj, materialSettings);
|
|
31
34
|
return () => {
|
|
32
35
|
releaseActiveInstances();
|
|
33
36
|
};
|
|
34
|
-
}, [materialSettings,
|
|
37
|
+
}, [materialSettings, source]);
|
|
35
38
|
// Unmount-only cleanup: dispose everything once the mesh leaves the scene.
|
|
36
39
|
useEffect(() => {
|
|
37
40
|
return () => {
|
|
@@ -53,29 +56,22 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
53
56
|
activeInstancesRef.current = [];
|
|
54
57
|
};
|
|
55
58
|
const handleSettingsChange = async (obj, materialSettings) => {
|
|
56
|
-
// console.log('Applying material with settings:', { obj, materialSettings });
|
|
57
59
|
if (!obj || !materialSettings || materialSettings.materialType === 'advanced')
|
|
58
60
|
return;
|
|
59
|
-
// console.log('Applying material with settings:',obj.name, obj);
|
|
60
61
|
// const originObject: Object3D | null = getOriginObject(obj);
|
|
61
62
|
const applyMaterial = materialSettings.apply !== undefined ? materialSettings.apply : true;
|
|
62
|
-
// console.log({applyMaterial});
|
|
63
63
|
// If apply is false, restore original materials
|
|
64
64
|
if (!applyMaterial) {
|
|
65
65
|
const objectId = obj.userData?.id;
|
|
66
|
-
// console.log({objectId})
|
|
67
66
|
if (objectId) {
|
|
68
67
|
releaseActiveInstances();
|
|
69
68
|
ObjectManager.restoreOriginalMaterials(objectId);
|
|
70
|
-
// console.log(`Restored original materials for object ID ${objectId}`);
|
|
71
69
|
}
|
|
72
70
|
onApplied?.();
|
|
73
71
|
return;
|
|
74
72
|
}
|
|
75
73
|
const materialType = MaterialRegistryAPI.getTypeDefinition(materialSettings.materialType);
|
|
76
|
-
// console.log('Material type definition:', materialType);
|
|
77
74
|
if (!materialType) {
|
|
78
|
-
console.error(`Material type "${materialSettings.materialType}" not found in registry.`);
|
|
79
75
|
return;
|
|
80
76
|
}
|
|
81
77
|
const firstVariant = Object.keys(materialType.variants)[0];
|
|
@@ -84,12 +80,9 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
84
80
|
const resolvedSettings = await resolveTextures(variant, materialSettings);
|
|
85
81
|
// 2. Traverse the object tree and apply material to any child with .material.
|
|
86
82
|
const objectids = materialSettings.objectIds || [];
|
|
87
|
-
// console.log(originObject)
|
|
88
|
-
// console.log({ objectids });
|
|
89
83
|
if (obj) {
|
|
90
84
|
if (objectids.length > 0) {
|
|
91
85
|
let meshes = [];
|
|
92
|
-
// console.log('Applying material to specific object IDs:', objectids);
|
|
93
86
|
obj.traverse((child) => {
|
|
94
87
|
if (child && child.name && objectids.includes(child.name)) {
|
|
95
88
|
meshes.push(child);
|
|
@@ -97,16 +90,13 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
97
90
|
});
|
|
98
91
|
meshes.forEach(mesh => mesh.traverse((child) => {
|
|
99
92
|
if (child && child.material) {
|
|
100
|
-
// console.log('Applying material to child:', child.name);
|
|
101
93
|
applyMaterialToChild(child, variant, resolvedSettings);
|
|
102
94
|
}
|
|
103
95
|
}));
|
|
104
96
|
return;
|
|
105
97
|
}
|
|
106
98
|
traverseSkippingEdgesAndEffects(obj, true, (child) => {
|
|
107
|
-
// console.log('Traversing child:', child.name, child);
|
|
108
99
|
if (child && child.material) {
|
|
109
|
-
// console.log('Applying material to child:');
|
|
110
100
|
applyMaterialToChild(child, variant, resolvedSettings);
|
|
111
101
|
}
|
|
112
102
|
});
|
|
@@ -139,8 +129,7 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
139
129
|
// else if (TEST_MATERIAL_MODE === 3) {
|
|
140
130
|
// object.material = new MeshStandardMaterial({ side: DoubleSide, transparent: true, metalness: 0.5, roughness: 0.5 });
|
|
141
131
|
// return;
|
|
142
|
-
// }
|
|
143
|
-
// console.log(`Applying material to object ${object.name} with variant "${variant}" and settings:`, resolvedSettings);
|
|
132
|
+
// }
|
|
144
133
|
const materialInstance = createAndApplyMaterial(variant, resolvedSettings);
|
|
145
134
|
// materialInstance.material.side = FrontSide; // Default to FrontSide; specific variants can override to DoubleSide in their defaultSettings
|
|
146
135
|
// Assign to the object
|
|
@@ -151,7 +140,6 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
|
|
|
151
140
|
object.userData[MATERIAL_INSTANCE_KEY] = materialInstance;
|
|
152
141
|
}
|
|
153
142
|
catch (error) {
|
|
154
|
-
console.error(`Failed to apply material "${variant}" to object:`, error);
|
|
155
143
|
}
|
|
156
144
|
};
|
|
157
145
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaterialRegistryAPI } from '@3driseai/3drise-core';
|
|
2
|
-
import type { CreatedObjectType,
|
|
2
|
+
import type { CreatedObjectType, MaterialSettings, ModeGroup, SelectOptions } from '@3driseai/3drise-core';
|
|
3
3
|
type RegistryMaterialType = Exclude<Parameters<typeof MaterialRegistryAPI.getVariants>[0], undefined>;
|
|
4
4
|
export interface UseMaterialOptionsReturn {
|
|
5
5
|
selectedType: RegistryMaterialType;
|
|
@@ -9,6 +9,6 @@ export interface UseMaterialOptionsReturn {
|
|
|
9
9
|
handleTypeChange: (type: RegistryMaterialType) => void;
|
|
10
10
|
handleVariantChange: (variant: string) => void;
|
|
11
11
|
}
|
|
12
|
-
export declare const useMaterialOptions: (initialSettings: MaterialSettings, onSettingsChange?: (newSettings: MaterialSettings) => void, objectType?: CreatedObjectType,
|
|
12
|
+
export declare const useMaterialOptions: (initialSettings: MaterialSettings, onSettingsChange?: (newSettings: MaterialSettings) => void, objectType?: CreatedObjectType, surface?: ModeGroup) => UseMaterialOptionsReturn;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=useMaterialOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3G,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,UAAS,SAAkB,KAAG,wBA0FvM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { MaterialRegistryAPI } from '@3driseai/3drise-core';
|
|
2
|
+
import { MaterialRegistryAPI, materialTypeFitsSurface } from '@3driseai/3drise-core';
|
|
3
3
|
import { FrontSide } from 'three';
|
|
4
|
-
export const useMaterialOptions = (initialSettings, onSettingsChange, objectType = 'mesh',
|
|
4
|
+
export const useMaterialOptions = (initialSettings, onSettingsChange, objectType = 'mesh', surface = 'mesh') => {
|
|
5
5
|
// Ensure we always have a valid material type
|
|
6
6
|
const validType = (initialSettings.materialType || 'basic');
|
|
7
7
|
const [selectedType, setSelectedType] = useState(validType);
|
|
@@ -12,42 +12,23 @@ 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);
|
|
19
18
|
setSelectedVariant(initialSettings.materialVariant || variants[0] || '');
|
|
20
19
|
}, [initialSettings.materialType, initialSettings.materialVariant]);
|
|
21
20
|
const allmaterialTypes = MaterialRegistryAPI.getTypes();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const materialTypeOptions = () =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (is3dRiseShaderMaterial) {
|
|
35
|
-
return dRiseShaderMaterialTypes.map((type) => ({
|
|
36
|
-
value: type,
|
|
37
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
if (isLineMaterial) {
|
|
41
|
-
return lineMaterialTypes.map((type) => ({
|
|
42
|
-
value: type,
|
|
43
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
return meshMaterialTypes.map((type) => ({
|
|
47
|
-
value: type,
|
|
48
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
49
|
-
}));
|
|
50
|
-
};
|
|
21
|
+
// Offer only the families that can actually draw on this object's surface.
|
|
22
|
+
// A <points> takes the `particles` family and nothing else; every other
|
|
23
|
+
// surface takes everything except it. Note this keys off the surface, never
|
|
24
|
+
// off the currently selected material — the previous version did the latter,
|
|
25
|
+
// which meant an object could never get back to a family once it left it.
|
|
26
|
+
const materialTypeOptions = () => allmaterialTypes
|
|
27
|
+
.filter((type) => materialTypeFitsSurface(type, surface))
|
|
28
|
+
.map((type) => ({
|
|
29
|
+
value: type,
|
|
30
|
+
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
31
|
+
}));
|
|
51
32
|
// is3dRiseShaderMaterial ?
|
|
52
33
|
// dRiseShaderMaterialTypes.map((type: string) => ({
|
|
53
34
|
// value: type,
|
|
@@ -64,11 +45,9 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
64
45
|
label: variant
|
|
65
46
|
}));
|
|
66
47
|
const handleTypeChange = (type) => {
|
|
67
|
-
// console.log('Material type changed to:', type);
|
|
68
48
|
setSelectedType(type);
|
|
69
49
|
const availableVariants = MaterialRegistryAPI.getVariants(type);
|
|
70
50
|
const defaultVariant = availableVariants[0];
|
|
71
|
-
// console.log({defaultVariant})
|
|
72
51
|
setSelectedVariant(defaultVariant);
|
|
73
52
|
// Auto-select first variant when type changes
|
|
74
53
|
if (defaultVariant) {
|
|
@@ -76,7 +55,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
76
55
|
}
|
|
77
56
|
};
|
|
78
57
|
const handleVariantChange = (variant) => {
|
|
79
|
-
console.log('Material variant changed to:', variant);
|
|
80
58
|
setSelectedVariant(variant);
|
|
81
59
|
handleMaterialUpdate(selectedType, variant);
|
|
82
60
|
};
|
|
@@ -86,7 +64,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
86
64
|
try {
|
|
87
65
|
const variantDefinition = MaterialRegistryAPI.getVariantDefinition(variant);
|
|
88
66
|
if (!variantDefinition) {
|
|
89
|
-
console.warn(`Variant definition for "${variant}" not found.`);
|
|
90
67
|
return;
|
|
91
68
|
}
|
|
92
69
|
// Start fresh from the new variant's defaults — this ensures
|
|
@@ -104,7 +81,6 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
104
81
|
onSettingsChange(newSettings);
|
|
105
82
|
}
|
|
106
83
|
catch (error) {
|
|
107
|
-
console.error('Error updating material:', error);
|
|
108
84
|
}
|
|
109
85
|
};
|
|
110
86
|
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"}
|