@3driseai/3drise-viewer 0.1.13 → 0.1.14
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/dist/components/Frame.d.ts.map +1 -1
- package/dist/components/Frame.js +5 -3
- package/dist/components/FrameImage.d.ts.map +1 -1
- package/dist/components/FrameImage.js +2 -1
- package/dist/components/GalleryLayout.d.ts +0 -1
- package/dist/components/GalleryLayout.d.ts.map +1 -1
- package/dist/components/GalleryLayout.js +7 -3
- package/dist/components/ImageGeometry.d.ts.map +1 -1
- package/dist/components/ImageGeometry.js +36 -4
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/effects/LightningEffect.d.ts.map +1 -1
- package/dist/components/effects/LightningEffect.js +4 -1
- package/dist/hooks/useObjectEdges.d.ts.map +1 -1
- package/dist/hooks/useObjectEdges.js +19 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../src/components/Frame.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzJ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,EAAE,qBAAqB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAoB,EAAE,aAAa,EAAE,gBAAqB,EAAE,YAAiB,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,GAAG,EAAE,UAAU,+
|
|
1
|
+
{"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../src/components/Frame.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzJ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,EAAE,qBAAqB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAoB,EAAE,aAAa,EAAE,gBAAqB,EAAE,YAAiB,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,GAAG,EAAE,UAAU,+BAqDlR"}
|
package/dist/components/Frame.js
CHANGED
|
@@ -33,7 +33,8 @@ export default function Frame({ url, isActive, createdObject, position, rotation
|
|
|
33
33
|
useCursor(hovered);
|
|
34
34
|
const enabledEffects = transformEffects.filter(e => e.enabled !== false);
|
|
35
35
|
const animateMaterial = enabledEffects.length > 0 || colorEffects.some(e => e.enabled !== false);
|
|
36
|
-
|
|
36
|
+
// console.log(isActive)
|
|
37
|
+
useObjectAnimation(createdObject, animateMaterial, { enabled: !isActive, hovered }, frameRef);
|
|
37
38
|
const scale = [
|
|
38
39
|
0.9 * (layoutSettings.width || 1),
|
|
39
40
|
0.9 * (layoutSettings.height || 1),
|
|
@@ -50,7 +51,8 @@ export default function Frame({ url, isActive, createdObject, position, rotation
|
|
|
50
51
|
};
|
|
51
52
|
if (!texture)
|
|
52
53
|
return null;
|
|
53
|
-
return (_jsx("mesh", { name: url, ref: frameRef, position: position, rotation: rotation, scale: scale,
|
|
54
|
+
return (_jsx("mesh", { name: url, ref: frameRef, position: position, rotation: rotation, scale: scale, onPointerEnter: handlePointerEnter, onPointerLeave: handlePointerLeave, onClick: onClick, userData: {
|
|
54
55
|
url,
|
|
55
|
-
}, children: children ? children :
|
|
56
|
+
}, children: children ? children :
|
|
57
|
+
(_jsxs(_Fragment, { children: [_jsx(FrameGeometry, { shapeType: 'rectangle', layoutSettings: layoutSettings, scale: layoutSettings.outerFrameScale }), _jsx(MaterialLibrary, { materialSettings: materialSettings }), showFront && (_jsx(FrameImage, { ref: imageRef, texture: texture, shapeType: 'rectangle', position: [0, 0, 0.02] })), showBack && (_jsx(FrameImage, { texture: texture, shapeType: 'rectangle', position: [0, 0, -0.02], rotation: [0, Math.PI, 0], isBack: true }))] })) }));
|
|
56
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameImage.d.ts","sourceRoot":"","sources":["../../src/components/FrameImage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FrameImage.d.ts","sourceRoot":"","sources":["../../src/components/FrameImage.tsx"],"names":[],"mappings":"AAgBA,eAAO,MAAM,UAAU,EAYjB,GAAI,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { IMAGE_KEY } from "@3driseai/3drise-core";
|
|
3
4
|
import { FrameGeometry } from "./FrameGeometry.js";
|
|
4
5
|
export const FrameImage = forwardRef(({ texture, shapeType, position, rotation, isBack = false, layoutSettings, }, ref) => {
|
|
5
6
|
const width = layoutSettings?.width || 1;
|
|
@@ -10,6 +11,6 @@ export const FrameImage = forwardRef(({ texture, shapeType, position, rotation,
|
|
|
10
11
|
width: width * imageScale,
|
|
11
12
|
height: height * imageScale,
|
|
12
13
|
};
|
|
13
|
-
return (_jsxs("mesh", { ref: ref, raycast: () => null, position: position, rotation: rotation, children: [_jsx(FrameGeometry, { shapeType: shapeType, layoutSettings: scaledSettings }), _jsx("meshBasicMaterial", { map: texture, toneMapped: false, transparent: true })] }));
|
|
14
|
+
return (_jsxs("mesh", { ref: ref, raycast: () => null, userData: { [IMAGE_KEY]: true }, position: position, rotation: rotation, children: [_jsx(FrameGeometry, { shapeType: shapeType, layoutSettings: scaledSettings }), _jsx("meshBasicMaterial", { map: texture, toneMapped: false, transparent: true })] }));
|
|
14
15
|
});
|
|
15
16
|
FrameImage.displayName = 'FrameImage';
|
|
@@ -5,7 +5,6 @@ import { Object3D } from "three";
|
|
|
5
5
|
import { type ThreeEvent } from "@react-three/fiber";
|
|
6
6
|
export interface GalleryLayoutProps extends ObjectReadyProps {
|
|
7
7
|
createdObject: CreatedObjectSettings;
|
|
8
|
-
selectedFrameUrl?: string;
|
|
9
8
|
handleObjectClick?: (createdObject: CreatedObjectSettings, ref: Object3D, event: ThreeEvent<MouseEvent>) => void;
|
|
10
9
|
}
|
|
11
10
|
declare const GalleryLayout: React.FC<GalleryLayoutProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryLayout.d.ts","sourceRoot":"","sources":["../../src/components/GalleryLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IACxD,aAAa,EAAE,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"GalleryLayout.d.ts","sourceRoot":"","sources":["../../src/components/GalleryLayout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IACxD,aAAa,EAAE,qBAAqB,CAAC;IAErC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiC/C,CAAC;AACF,eAAe,aAAa,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useObjectReady } from '../hooks/useObjectReady.js';
|
|
3
|
-
import { useMemo, useRef } from 'react';
|
|
3
|
+
import { useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { updateCurrentLayoutSettings } from '@3driseai/3drise-core';
|
|
5
5
|
import Frame from './Frame.js';
|
|
6
6
|
import { ImageGeometry } from './ImageGeometry.js';
|
|
7
|
-
const GalleryLayout = ({ createdObject,
|
|
7
|
+
const GalleryLayout = ({ createdObject, handleObjectClick, onObjectReady, onObjectDispose, }) => {
|
|
8
|
+
const [selectedFrameUrl, setSelectedFrameUrl] = useState(undefined);
|
|
8
9
|
const groupRef = useRef(null);
|
|
9
10
|
useObjectReady(groupRef, createdObject, onObjectReady, onObjectDispose);
|
|
10
11
|
const { config, materialSettings, animations } = createdObject;
|
|
@@ -14,6 +15,9 @@ const GalleryLayout = ({ createdObject, selectedFrameUrl, handleObjectClick, onO
|
|
|
14
15
|
outerFrameScale: 1,
|
|
15
16
|
};
|
|
16
17
|
const { frames, layoutSettings } = useMemo(() => updateCurrentLayoutSettings(galleryLayout), [galleryLayout]);
|
|
17
|
-
return (_jsx("group", { ref: groupRef, scale: [1, 1, 1], position: [0, 0, 0], rotation: [0, 0, 0], children: frames.map((frame, index) => (_jsx(Frame, { url: frame.url, isActive: selectedFrameUrl === frame.url, createdObject: createdObject, position: frame.position, rotation: frame.rotation, hoverSettings: { sensitivity: 0.5, applyToChildren: false }, transformEffects: animations?.transform?.effects || [], layoutSettings: layoutSettings, side: galleryLayout?.side
|
|
18
|
+
return (_jsx("group", { ref: groupRef, scale: [1, 1, 1], position: [0, 0, 0], rotation: [0, 0, 0], children: frames.map((frame, index) => (_jsx(Frame, { url: frame.url, isActive: selectedFrameUrl === frame.url, createdObject: createdObject, position: frame.position, rotation: frame.rotation, hoverSettings: { sensitivity: 0.5, applyToChildren: false }, transformEffects: animations?.transform?.effects || [], layoutSettings: layoutSettings, side: galleryLayout?.side ?? 2, materialSettings: materialSettings, handleObjectClick: (createdObject, ref, event) => {
|
|
19
|
+
setSelectedFrameUrl(frame.url);
|
|
20
|
+
handleObjectClick?.(createdObject, ref, event);
|
|
21
|
+
}, children: layoutSettings.geometryType !== 'none' && (_jsx(ImageGeometry, { url: frame.url, geometryType: layoutSettings.geometryType, outerFrameScale: layoutSettings.outerFrameScale, side: galleryLayout?.side ?? 2 })) }, index))) }));
|
|
18
22
|
};
|
|
19
23
|
export default GalleryLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageGeometry.d.ts","sourceRoot":"","sources":["../../src/components/ImageGeometry.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzF,MAAM,WAAW,kBAAkB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,WAAW,CAAC;CAC/B;
|
|
1
|
+
{"version":3,"file":"ImageGeometry.d.ts","sourceRoot":"","sources":["../../src/components/ImageGeometry.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzF,MAAM,WAAW,kBAAkB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,WAAW,CAAC;CAC/B;AASD,eAAO,MAAM,aAAa,EAiFpB,GAAI,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Mesh, MeshBasicMaterial } from 'three';
|
|
4
4
|
import { createMeshByType } from '@3driseai/3drise-core';
|
|
5
|
-
import { texturesManager } from '@3driseai/3drise-core';
|
|
6
|
-
|
|
5
|
+
import { texturesManager, IMAGE_KEY } from '@3driseai/3drise-core';
|
|
6
|
+
// Stable references so unrelated re-renders (e.g. hover state toggles on the
|
|
7
|
+
// parent Frame) don't invalidate the meshConfig/createdMesh memos below and
|
|
8
|
+
// leak a fresh Mesh/BufferGeometry/Material every render.
|
|
9
|
+
const DEFAULT_POSITION = [0, 0, 0];
|
|
10
|
+
const DEFAULT_ROTATION = [0, 0, 0];
|
|
11
|
+
const DEFAULT_SCALE = [1, 1, 1];
|
|
12
|
+
export const ImageGeometry = forwardRef(({ geometryType, url, position = DEFAULT_POSITION, rotation = DEFAULT_ROTATION, scale = DEFAULT_SCALE, side = 2, outerFrameScale = 1, }, ref) => {
|
|
7
13
|
const [texture, setTexture] = useState(null);
|
|
8
14
|
useEffect(() => {
|
|
9
15
|
const textureName = url.split('/').pop()?.split('.')[0] || `texture-${Date.now()}`;
|
|
@@ -40,12 +46,13 @@ export const ImageGeometry = forwardRef(({ geometryType, url, position = [0, 0,
|
|
|
40
46
|
}, [geometryType, position, rotation, scale]);
|
|
41
47
|
const createdMesh = useMemo(() => {
|
|
42
48
|
const mesh = createMeshByType(meshConfig)?.mesh;
|
|
49
|
+
mesh.userData = { [IMAGE_KEY]: true };
|
|
43
50
|
if (!(mesh instanceof Mesh))
|
|
44
51
|
return null;
|
|
45
52
|
if (texture) {
|
|
46
53
|
mesh.material = new MeshBasicMaterial({
|
|
47
54
|
map: texture,
|
|
48
|
-
side:
|
|
55
|
+
side: side,
|
|
49
56
|
toneMapped: false,
|
|
50
57
|
transparent: true,
|
|
51
58
|
polygonOffset: true,
|
|
@@ -55,6 +62,31 @@ export const ImageGeometry = forwardRef(({ geometryType, url, position = [0, 0,
|
|
|
55
62
|
}
|
|
56
63
|
return mesh;
|
|
57
64
|
}, [meshConfig, texture]);
|
|
65
|
+
// Every recompute above allocates a new geometry + material; dispose the
|
|
66
|
+
// previous instance so they don't leak GPU resources.
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
return () => {
|
|
69
|
+
createdMesh?.geometry?.dispose();
|
|
70
|
+
const material = createdMesh?.material;
|
|
71
|
+
if (Array.isArray(material))
|
|
72
|
+
material.forEach((m) => m.dispose());
|
|
73
|
+
else
|
|
74
|
+
material?.dispose();
|
|
75
|
+
};
|
|
76
|
+
}, [createdMesh]);
|
|
77
|
+
// `side` isn't a createdMesh dependency (changing it shouldn't rebuild the
|
|
78
|
+
// geometry), so apply it to the existing material reactively instead.
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const material = createdMesh?.material;
|
|
81
|
+
if (!material)
|
|
82
|
+
return;
|
|
83
|
+
if (Array.isArray(material))
|
|
84
|
+
material.forEach((m) => { m.side = side; m.needsUpdate = true; });
|
|
85
|
+
else {
|
|
86
|
+
material.side = side;
|
|
87
|
+
material.needsUpdate = true;
|
|
88
|
+
}
|
|
89
|
+
}, [createdMesh, side]);
|
|
58
90
|
if (!createdMesh)
|
|
59
91
|
return null;
|
|
60
92
|
return (_jsx("group", { position: position, rotation: rotation, children: _jsx("primitive", { name: url, ref: ref, object: createdMesh }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectNode.d.ts","sourceRoot":"","sources":["../../src/components/ObjectNode.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAe,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,KAAK,eAAe,GAAG,gBAAgB,GAAG;IACtC,IAAI,EAAE,cAAc,CAAC;IACrB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC7G,CAAC;AAgBF,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"ObjectNode.d.ts","sourceRoot":"","sources":["../../src/components/ObjectNode.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAe,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,KAAK,eAAe,GAAG,gBAAgB,GAAG;IACtC,IAAI,EAAE,cAAc,CAAC;IACrB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC7G,CAAC;AAgBF,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqHzC,CAAC;AACF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightningEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/LightningEffect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,UAAU,oBAAqB,SAAQ,gBAAgB;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAsDD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"LightningEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/LightningEffect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,UAAU,oBAAqB,SAAQ,gBAAgB;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAsDD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2LnD,CAAC;AACF,eAAe,eAAe,CAAC"}
|
|
@@ -60,7 +60,10 @@ const LightningEffect = ({ boundingRadius, config, animations, onObjectReady, on
|
|
|
60
60
|
const startValuesCacheRef = useRef({});
|
|
61
61
|
const rootRef = useRef(null);
|
|
62
62
|
useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
|
|
63
|
-
const
|
|
63
|
+
const requestedDepth = Number(branchDepth);
|
|
64
|
+
const depth = Number.isFinite(requestedDepth)
|
|
65
|
+
? Math.min(Math.max(Math.floor(requestedDepth), 2), 6)
|
|
66
|
+
: 2;
|
|
64
67
|
const N = Math.pow(2, depth) + 1; // vertex count: 5, 9, 17, 33, 65
|
|
65
68
|
const coreCol = useMemo(() => new THREE.Color(color), [color]);
|
|
66
69
|
const glowCol = useMemo(() => new THREE.Color(glowColor), [glowColor]);
|
|
@@ -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;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAmH/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,
|
|
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;AAmH/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CA8DhH"}
|
|
@@ -131,13 +131,30 @@ export function useObjectEdges(objectId, edgesSettings, objectSource) {
|
|
|
131
131
|
}
|
|
132
132
|
setObject(resolveObject3D(objectSource) ?? findById(objectId));
|
|
133
133
|
}, [edgesEnabled, objectId, objectSource]);
|
|
134
|
+
// Descendant meshes (e.g. gallery images) can still be loading their
|
|
135
|
+
// texture asynchronously when `object` first resolves, so the initial
|
|
136
|
+
// build below can run before there's anything to outline. Poll the real
|
|
137
|
+
// mesh count each frame and bump a tick when it changes so edges get
|
|
138
|
+
// rebuilt once the subtree actually has geometry.
|
|
139
|
+
const meshCountRef = useRef(-1);
|
|
140
|
+
const [structureTick, setStructureTick] = useState(0);
|
|
141
|
+
useFrame(() => {
|
|
142
|
+
if (!object)
|
|
143
|
+
return;
|
|
144
|
+
const count = collectMeshes(object).length;
|
|
145
|
+
if (count !== meshCountRef.current) {
|
|
146
|
+
meshCountRef.current = count;
|
|
147
|
+
setStructureTick((t) => t + 1);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
134
150
|
const edgesGroup = useMemo(() => {
|
|
135
151
|
if (!object || !edgesSettings.enabled)
|
|
136
152
|
return null;
|
|
137
153
|
return buildEdgesGroup(object, edgesSettings);
|
|
138
|
-
// Rebuild when geometry-affecting settings change
|
|
154
|
+
// Rebuild when geometry-affecting settings change, or the subtree's
|
|
155
|
+
// mesh count changes (structureTick — see the polling effect above).
|
|
139
156
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
-
}, [object, edgesSettings.type, edgesSettings.enabled, edgesSettings.tubeRadius, edgesSettings.cubeSize]);
|
|
157
|
+
}, [object, edgesSettings.type, edgesSettings.enabled, edgesSettings.tubeRadius, edgesSettings.cubeSize, structureTick]);
|
|
141
158
|
// Attach edges to the live object so they move with it
|
|
142
159
|
useEffect(() => {
|
|
143
160
|
if (!object || !edgesGroup)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3driseai/3drise-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@3driseai/3drise-common": "^1.0.1",
|
|
42
|
-
"@3driseai/3drise-core": "^1.0.
|
|
42
|
+
"@3driseai/3drise-core": "^1.0.9"
|
|
43
43
|
}
|
|
44
44
|
}
|