@nice2dev/ui-3d 1.0.6 → 1.1.0
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/cjs/core/i18n.js +3 -3
- package/dist/cjs/dance/DanceBridge.js +13 -13
- package/dist/cjs/dance/DanceScoreEngine.js +8 -8
- package/dist/cjs/dance/PoseDetector.js +20 -20
- package/dist/cjs/material/NiceMaterialEditor.js +19 -19
- package/dist/cjs/model/ModelEditorLeftPanel.js +5 -5
- package/dist/cjs/model/ModelEditorMenuBar.js +6 -6
- package/dist/cjs/model/ModelEditorRightPanel.js +19 -19
- package/dist/cjs/model/ModelEditorSubComponents.js +10 -10
- package/dist/cjs/model/ModelEditorTimeline.js +6 -6
- package/dist/cjs/model/ModelEditorToolbar.js +4 -4
- package/dist/cjs/model/ModelEditorViewport.js +2 -2
- package/dist/cjs/model/ModelViewer.js +14 -14
- package/dist/cjs/model/NiceArmatureEditor.js +18 -18
- package/dist/cjs/model/NiceMorphTargetEditor.js +18 -18
- package/dist/cjs/model/NiceOctree.js +16 -16
- package/dist/cjs/model/NicePhysicsSimulation.js +24 -24
- package/dist/cjs/model/NiceProceduralGeometry.js +8 -8
- package/dist/cjs/model/NiceTerrainEditor.js +19 -19
- package/dist/cjs/model/NiceWeightPainter.js +14 -14
- package/dist/cjs/model/NiceXRPreview.js +18 -18
- package/dist/cjs/model/useModelEditor.js +127 -127
- package/dist/cjs/model/useModelViewer.js +61 -61
- package/dist/cjs/particle/NiceParticleEditor.js +11 -11
- package/dist/cjs/rendering/NiceCascadedShadows.js +12 -12
- package/dist/cjs/rendering/NiceRenderExport.js +5 -5
- package/dist/cjs/rendering/NiceSSAO.js +18 -18
- package/dist/cjs/rendering/NiceSSR.js +14 -14
- package/dist/cjs/rendering/NiceWebGPURenderer.js +21 -21
- package/dist/cjs/ui/dist/NiceButton-D9l39Rs7.js +598 -0
- package/dist/cjs/ui/dist/NiceButton-D9l39Rs7.js.map +1 -0
- package/dist/cjs/ui/dist/NiceErrorBoundary-niMx1aSJ.js +647 -0
- package/dist/cjs/ui/dist/NiceErrorBoundary-niMx1aSJ.js.map +1 -0
- package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js +5048 -0
- package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js.map +1 -0
- package/dist/cjs/ui/dist/NicePinCodeInput-CrMfdxxc.js +13081 -0
- package/dist/cjs/ui/dist/NicePinCodeInput-CrMfdxxc.js.map +1 -0
- package/dist/cjs/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js +6054 -0
- package/dist/cjs/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js.map +1 -0
- package/dist/cjs/ui/dist/NiceToggle-CaY1u82g.js +280 -0
- package/dist/cjs/ui/dist/NiceToggle-CaY1u82g.js.map +1 -0
- package/dist/cjs/ui/dist/NiceWindow-SiCaREbq.js +806 -0
- package/dist/cjs/ui/dist/NiceWindow-SiCaREbq.js.map +1 -0
- package/dist/cjs/ui/dist/charts-Bx_kNBsE.js +3508 -0
- package/dist/cjs/ui/dist/charts-Bx_kNBsE.js.map +1 -0
- package/dist/cjs/ui/dist/core-BpghV7Ls.js +10249 -0
- package/dist/cjs/ui/dist/core-BpghV7Ls.js.map +1 -0
- package/dist/cjs/ui/dist/index-CIl98Vbm.js +40039 -0
- package/dist/cjs/ui/dist/index-CIl98Vbm.js.map +1 -0
- package/dist/cjs/uv/NiceUVEditor.js +24 -24
- package/dist/esm/model/ModelEditorLeftPanel.js +4 -4
- package/dist/esm/model/ModelEditorMenuBar.js +4 -4
- package/dist/esm/model/ModelEditorRightPanel.js +5 -5
- package/dist/esm/model/ModelEditorSubComponents.js +2 -2
- package/dist/esm/model/ModelEditorTimeline.js +5 -5
- package/dist/esm/model/ModelEditorToolbar.js +3 -3
- package/dist/esm/model/ModelEditorViewport.js +2 -2
- package/dist/esm/model/ModelViewer.js +2 -2
- package/dist/esm/ui/dist/NiceButton-D9l39Rs7.js +593 -0
- package/dist/esm/ui/dist/NiceButton-D9l39Rs7.js.map +1 -0
- package/dist/esm/ui/dist/NiceErrorBoundary-niMx1aSJ.js +637 -0
- package/dist/esm/ui/dist/NiceErrorBoundary-niMx1aSJ.js.map +1 -0
- package/dist/esm/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js +5007 -0
- package/dist/esm/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js.map +1 -0
- package/dist/esm/ui/dist/NicePinCodeInput-CrMfdxxc.js +13011 -0
- package/dist/esm/ui/dist/NicePinCodeInput-CrMfdxxc.js.map +1 -0
- package/dist/esm/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js +6037 -0
- package/dist/esm/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js.map +1 -0
- package/dist/esm/ui/dist/NiceToggle-CaY1u82g.js +276 -0
- package/dist/esm/ui/dist/NiceToggle-CaY1u82g.js.map +1 -0
- package/dist/esm/ui/dist/NiceWindow-SiCaREbq.js +795 -0
- package/dist/esm/ui/dist/NiceWindow-SiCaREbq.js.map +1 -0
- package/dist/esm/ui/dist/charts-Bx_kNBsE.js +3483 -0
- package/dist/esm/ui/dist/charts-Bx_kNBsE.js.map +1 -0
- package/dist/esm/ui/dist/core-BpghV7Ls.js +10071 -0
- package/dist/esm/ui/dist/core-BpghV7Ls.js.map +1 -0
- package/dist/esm/ui/dist/index-CIl98Vbm.js +39917 -0
- package/dist/esm/ui/dist/index-CIl98Vbm.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var ke = require('react');
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var ModelEditor_module = require('./ModelEditor.module.css.js');
|
|
7
7
|
var modelEditorTypes = require('./modelEditorTypes.js');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var NiceButtonD9l39Rs7 = require('../ui/dist/NiceButton-D9l39Rs7.js');
|
|
9
|
+
var NicePinCodeInputCrMfdxxc = require('../ui/dist/NicePinCodeInput-CrMfdxxc.js');
|
|
10
10
|
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
12
12
|
var n = Object.create(null);
|
|
@@ -32,7 +32,7 @@ var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
|
32
32
|
═══════════════════════════════════════════ */
|
|
33
33
|
/** Vec3 input row for position/scale */
|
|
34
34
|
const Vec3Row = ({ label, value, onChange }) => {
|
|
35
|
-
const [, forceUpdate] =
|
|
35
|
+
const [, forceUpdate] = ke.useState(0);
|
|
36
36
|
const set = (axis, v) => {
|
|
37
37
|
const n = parseFloat(v);
|
|
38
38
|
if (!isNaN(n)) {
|
|
@@ -41,11 +41,11 @@ const Vec3Row = ({ label, value, onChange }) => {
|
|
|
41
41
|
onChange();
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: label }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propVec3, children: [jsxRuntime.jsx(
|
|
44
|
+
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: label }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propVec3, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3X, value: value.x.toFixed(3), onChange: (val) => set("x", val) }), jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3Y, value: value.y.toFixed(3), onChange: (val) => set("y", val) }), jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3Z, value: value.z.toFixed(3), onChange: (val) => set("z", val) })] })] }));
|
|
45
45
|
};
|
|
46
46
|
/** Vec3 input row for rotation (shows degrees) */
|
|
47
47
|
const Vec3RowDeg = ({ label, value, onChange }) => {
|
|
48
|
-
const [, forceUpdate] =
|
|
48
|
+
const [, forceUpdate] = ke.useState(0);
|
|
49
49
|
const set = (axis, v) => {
|
|
50
50
|
const n = parseFloat(v);
|
|
51
51
|
if (!isNaN(n)) {
|
|
@@ -54,7 +54,7 @@ const Vec3RowDeg = ({ label, value, onChange }) => {
|
|
|
54
54
|
onChange();
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: label }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propVec3, children: [jsxRuntime.jsx(
|
|
57
|
+
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: label }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propVec3, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3X, value: (value.x * modelEditorTypes.DEG).toFixed(1), onChange: (val) => set("x", val) }), jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3Y, value: (value.y * modelEditorTypes.DEG).toFixed(1), onChange: (val) => set("y", val) }), jsxRuntime.jsx(NiceButtonD9l39Rs7.b, { className: ModelEditor_module.propVec3Z, value: (value.z * modelEditorTypes.DEG).toFixed(1), onChange: (val) => set("z", val) })] })] }));
|
|
58
58
|
};
|
|
59
59
|
/** Material card with editable properties */
|
|
60
60
|
const MaterialCard = ({ material, active, onClick, onUpdate }) => {
|
|
@@ -78,16 +78,16 @@ const MaterialCard = ({ material, active, onClick, onUpdate }) => {
|
|
|
78
78
|
mat.needsUpdate = true;
|
|
79
79
|
onUpdate();
|
|
80
80
|
};
|
|
81
|
-
return (jsxRuntime.jsxs("div", { className: `${ModelEditor_module.materialCard} ${active ? ModelEditor_module.materialCardActive : ""}`, onClick: onClick, children: [jsxRuntime.jsx("div", { className: ModelEditor_module.materialHeader, children: jsxRuntime.jsx("span", { className: ModelEditor_module.materialName, children: mat.name || mat.type }) }), hasColor && (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Color" }), jsxRuntime.jsx(
|
|
81
|
+
return (jsxRuntime.jsxs("div", { className: `${ModelEditor_module.materialCard} ${active ? ModelEditor_module.materialCardActive : ""}`, onClick: onClick, children: [jsxRuntime.jsx("div", { className: ModelEditor_module.materialHeader, children: jsxRuntime.jsx("span", { className: ModelEditor_module.materialName, children: mat.name || mat.type }) }), hasColor && (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Color" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.N, { value: `#${mat.color.getHexString()}`, onChange: (c) => setColor(c) }), jsxRuntime.jsxs("span", { style: { fontSize: 10, color: "#888" }, children: ["#", mat.color.getHexString()] })] })), hasMetalness && (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Metal" }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: 0, max: 1, step: 0.01, value: mat.metalness, onChange: (val) => setNum("metalness", val), style: { flex: 1 } }), jsxRuntime.jsx("span", { style: { fontSize: 9, color: "#888", width: 28, textAlign: "right" }, children: mat.metalness.toFixed(2) })] })), hasRoughness && (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Rough" }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: 0, max: 1, step: 0.01, value: mat.roughness, onChange: (val) => setNum("roughness", val), style: { flex: 1 } }), jsxRuntime.jsx("span", { style: { fontSize: 9, color: "#888", width: 28, textAlign: "right" }, children: mat.roughness.toFixed(2) })] })), hasEmissive && mat.emissive && (jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Emissive" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.N, { value: `#${mat.emissive.getHexString()}`, onChange: (c) => {
|
|
82
82
|
mat.emissive.set(c);
|
|
83
83
|
mat.needsUpdate = true;
|
|
84
84
|
onUpdate();
|
|
85
|
-
} })] })), jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Opacity" }), jsxRuntime.jsx(
|
|
85
|
+
} })] })), jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Opacity" }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: 0, max: 1, step: 0.01, value: mat.opacity, onChange: (val) => {
|
|
86
86
|
mat.opacity = val;
|
|
87
87
|
mat.transparent = val < 1;
|
|
88
88
|
mat.needsUpdate = true;
|
|
89
89
|
onUpdate();
|
|
90
|
-
}, style: { flex: 1 } }), jsxRuntime.jsx("span", { style: { fontSize: 9, color: "#888", width: 28, textAlign: "right" }, children: mat.opacity.toFixed(2) })] }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Side" }), jsxRuntime.jsx(
|
|
90
|
+
}, style: { flex: 1 } }), jsxRuntime.jsx("span", { style: { fontSize: 9, color: "#888", width: 28, textAlign: "right" }, children: mat.opacity.toFixed(2) })] }), jsxRuntime.jsxs("div", { className: ModelEditor_module.propRow, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.propLabel, children: "Side" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.a, { className: ModelEditor_module.propSelect, value: String(mat.side), onChange: (val) => {
|
|
91
91
|
mat.side = parseInt(val);
|
|
92
92
|
mat.needsUpdate = true;
|
|
93
93
|
onUpdate();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var ke = require('react');
|
|
5
5
|
var ModelEditor_module = require('./ModelEditor.module.css.js');
|
|
6
6
|
var modelEditorTypes = require('./modelEditorTypes.js');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var NiceButtonD9l39Rs7 = require('../ui/dist/NiceButton-D9l39Rs7.js');
|
|
8
|
+
var NicePinCodeInputCrMfdxxc = require('../ui/dist/NicePinCodeInput-CrMfdxxc.js');
|
|
9
9
|
|
|
10
|
-
const ModelEditorTimeline =
|
|
10
|
+
const ModelEditorTimeline = ke.memo(({ api }) => {
|
|
11
11
|
const { bottomCollapsed, setBottomCollapsed, animations, activeAnimIdx, isPlaying, animTime, animDuration, animSpeed, setAnimSpeed, loopAnim, setLoopAnim, seekAnim, togglePlay, stopAnim, playClip, mergeInputRef, } = api;
|
|
12
|
-
return (jsxRuntime.jsxs("div", { className: `${ModelEditor_module.bottomPanel} ${bottomCollapsed ? ModelEditor_module.bottomPanelCollapsed : ""}`, children: [jsxRuntime.jsxs("div", { className: ModelEditor_module.bottomPanelHeader, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.bottomToggle, onClick: () => setBottomCollapsed((c) => !c), children: bottomCollapsed ? "▶" : "▼" }), jsxRuntime.jsxs("span", { className: ModelEditor_module.bottomPanelTitle, onClick: () => setBottomCollapsed((c) => !c), children: ["Animation (", animations.length, " clip", animations.length !== 1 ? "s" : "", ")"] }), jsxRuntime.jsx("div", { className: ModelEditor_module.menuSep }), jsxRuntime.jsxs("div", { className: ModelEditor_module.transportBar, children: [jsxRuntime.jsx(
|
|
12
|
+
return (jsxRuntime.jsxs("div", { className: `${ModelEditor_module.bottomPanel} ${bottomCollapsed ? ModelEditor_module.bottomPanelCollapsed : ""}`, children: [jsxRuntime.jsxs("div", { className: ModelEditor_module.bottomPanelHeader, children: [jsxRuntime.jsx("span", { className: ModelEditor_module.bottomToggle, onClick: () => setBottomCollapsed((c) => !c), children: bottomCollapsed ? "▶" : "▼" }), jsxRuntime.jsxs("span", { className: ModelEditor_module.bottomPanelTitle, onClick: () => setBottomCollapsed((c) => !c), children: ["Animation (", animations.length, " clip", animations.length !== 1 ? "s" : "", ")"] }), jsxRuntime.jsx("div", { className: ModelEditor_module.menuSep }), jsxRuntime.jsxs("div", { className: ModelEditor_module.transportBar, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.transportBtn, variant: "ghost", size: "sm", onClick: () => seekAnim(0), title: "Go to start", children: "\u23EE" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.transportBtn, variant: isPlaying ? "primary" : "ghost", size: "sm", onClick: togglePlay, title: "Play/Pause (Space)", children: isPlaying ? "⏸" : "▶" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.transportBtn, variant: "ghost", size: "sm", onClick: stopAnim, title: "Stop", children: "\u23F9" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.transportBtn, variant: loopAnim ? "primary" : "ghost", size: "sm", onClick: () => setLoopAnim((v) => !v), title: "Loop", children: "\uD83D\uDD01" })] }), jsxRuntime.jsxs("span", { className: ModelEditor_module.transportTime, children: [modelEditorTypes.fmtTime(animTime), " / ", modelEditorTypes.fmtTime(animDuration)] }), jsxRuntime.jsx("div", { className: ModelEditor_module.menuSep }), jsxRuntime.jsx("label", { className: ModelEditor_module.menuLabel, children: "Speed" }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: 0.1, max: 3, step: 0.1, value: animSpeed, onChange: (val) => setAnimSpeed(val), style: { width: 60 } }), jsxRuntime.jsxs("span", { className: ModelEditor_module.menuLabel, children: [animSpeed.toFixed(1), "\u00D7"] })] }), !bottomCollapsed && (jsxRuntime.jsxs("div", { className: ModelEditor_module.animListArea, children: [jsxRuntime.jsxs("div", { className: ModelEditor_module.animList, children: [animations.length === 0 && (jsxRuntime.jsx("div", { style: { color: "#666", fontSize: 10, padding: 8 }, children: "No animations loaded" })), animations.map((anim, i) => (jsxRuntime.jsxs("div", { className: `${ModelEditor_module.animItem} ${i === activeAnimIdx ? ModelEditor_module.animItemActive : ""}`, onClick: () => playClip(i), children: [jsxRuntime.jsx("span", { children: anim.name }), jsxRuntime.jsxs("span", { className: ModelEditor_module.animDuration, children: [anim.duration.toFixed(1), "s"] })] }, `${anim.name}-${i}`))), jsxRuntime.jsx("div", { style: { padding: "4px 8px" }, children: jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.btnSecondary, variant: "ghost", size: "sm", style: { width: "100%", fontSize: 10 }, onClick: () => { var _a; return (_a = mergeInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: "+ Add Animation File" }) })] }), jsxRuntime.jsxs("div", { className: ModelEditor_module.timelineArea, children: [jsxRuntime.jsxs("div", { className: ModelEditor_module.timelineRuler, children: [animDuration > 0 &&
|
|
13
13
|
Array.from({ length: Math.ceil(animDuration) + 1 }, (_, i) => {
|
|
14
14
|
const pct = (i / animDuration) * 100;
|
|
15
|
-
return (jsxRuntime.jsxs(
|
|
15
|
+
return (jsxRuntime.jsxs(ke.Fragment, { children: [jsxRuntime.jsx("div", { className: ModelEditor_module.rulerTick, style: { left: `${pct}%` } }), jsxRuntime.jsxs("span", { className: ModelEditor_module.rulerLabel, style: { left: `${pct}%` }, children: [i, "s"] })] }, i));
|
|
16
16
|
}), animDuration > 0 && (jsxRuntime.jsx("div", { className: ModelEditor_module.playhead, style: {
|
|
17
17
|
left: `${(animTime / animDuration) * 100}%`,
|
|
18
18
|
height: "100%",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var ke = require('react');
|
|
5
5
|
var ModelEditor_module = require('./ModelEditor.module.css.js');
|
|
6
|
-
var
|
|
6
|
+
var NiceButtonD9l39Rs7 = require('../ui/dist/NiceButton-D9l39Rs7.js');
|
|
7
7
|
|
|
8
|
-
const ModelEditorToolbar =
|
|
8
|
+
const ModelEditorToolbar = ke.memo(({ api }) => {
|
|
9
9
|
const { transformMode, setTransformMode, snapEnabled, setSnapEnabled, gizmoSpace, setGizmoSpace, rootObjectRef, focusOnObject, setCameraPreset, deleteSelected, duplicateSelected, selectedNode, } = api;
|
|
10
|
-
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.toolbar, children: [jsxRuntime.jsx(
|
|
10
|
+
return (jsxRuntime.jsxs("div", { className: ModelEditor_module.toolbar, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: transformMode === "translate" ? "primary" : "ghost", size: "sm", onClick: () => setTransformMode("translate"), title: "Translate (G)", children: "\u2725" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: transformMode === "rotate" ? "primary" : "ghost", size: "sm", onClick: () => setTransformMode("rotate"), title: "Rotate (R)", children: "\u21BB" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: transformMode === "scale" ? "primary" : "ghost", size: "sm", onClick: () => setTransformMode("scale"), title: "Scale (S)", children: "\u2B21" }), jsxRuntime.jsx("div", { className: ModelEditor_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: snapEnabled ? "primary" : "ghost", size: "sm", onClick: () => setSnapEnabled((v) => !v), title: `Snap to Grid (${snapEnabled ? "ON" : "OFF"})`, children: "\uD83E\uDDF2" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: () => setGizmoSpace((s) => (s === "local" ? "world" : "local")), title: `Orientation: ${gizmoSpace}`, children: gizmoSpace === "local" ? "🔶" : "🌐" }), jsxRuntime.jsx("div", { className: ModelEditor_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: () => rootObjectRef.current && focusOnObject(rootObjectRef.current), title: "Focus (F)", children: "\u25CE" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: () => setCameraPreset("front"), title: "Front view (Numpad 1)", children: "1" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: () => setCameraPreset("right"), title: "Right view (Numpad 3)", children: "3" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: () => setCameraPreset("top"), title: "Top view (Numpad 7)", children: "7" }), jsxRuntime.jsx("div", { className: ModelEditor_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: deleteSelected, title: "Delete selected (Del)", children: "\uD83D\uDDD1" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelEditor_module.toolBtn, variant: "ghost", size: "sm", onClick: duplicateSelected, title: "Duplicate (Shift+D)", disabled: !selectedNode, children: "\uD83D\uDCCB" })] }));
|
|
11
11
|
});
|
|
12
12
|
ModelEditorToolbar.displayName = "ModelEditorToolbar";
|
|
13
13
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var ke = require('react');
|
|
5
5
|
var ModelEditor_module = require('./ModelEditor.module.css.js');
|
|
6
6
|
|
|
7
|
-
const ModelEditorViewport =
|
|
7
|
+
const ModelEditorViewport = ke.memo(({ api }) => {
|
|
8
8
|
const { mountRef, dragOver, handleDragOver, handleDragLeave, handleDrop, handleViewportClick, handleContextMenu, editorMode, polyCount, meshCount, boneCount, shadingMode, setShadingMode, gizmoSpace, setGizmoSpace, contextMenu, closeContextMenu, addPrimitive, addSceneLight, duplicateSelected, deleteSelected, selectedNode, rootObjectRef, focusOnObject, snapEnabled, setSnapEnabled, } = api;
|
|
9
9
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { ref: mountRef, className: `${ModelEditor_module.viewportContainer} ${dragOver ? ModelEditor_module.dragOver : ""}`, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleViewportClick, onContextMenu: handleContextMenu, children: [jsxRuntime.jsxs("div", { className: ModelEditor_module.viewportOverlay, children: [jsxRuntime.jsxs("span", { className: ModelEditor_module.viewportBadge, children: [editorMode.toUpperCase(), " MODE"] }), jsxRuntime.jsxs("span", { className: ModelEditor_module.viewportBadge, children: [polyCount.toLocaleString(), " tris \u00B7 ", meshCount, " meshes \u00B7 ", boneCount, " bones"] })] }), jsxRuntime.jsx("div", { className: ModelEditor_module.viewportShadingBar, children: ["wireframe", "solid", "material", "rendered"].map((m) => (jsxRuntime.jsx("button", { className: `${ModelEditor_module.shadingBtn} ${shadingMode === m ? ModelEditor_module.shadingBtnActive : ""}`, onClick: (e) => { e.stopPropagation(); setShadingMode(m); }, title: m.charAt(0).toUpperCase() + m.slice(1), children: m === "wireframe" ? "◇" : m === "solid" ? "◆" : m === "material" ? "🎨" : "☀" }, m))) }), jsxRuntime.jsx("div", { className: ModelEditor_module.viewportGizmoInfo, children: jsxRuntime.jsx("button", { className: ModelEditor_module.shadingBtn, onClick: (e) => {
|
|
10
10
|
e.stopPropagation();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var ke = require('react');
|
|
5
5
|
var ModelViewer_module = require('./ModelViewer.module.css.js');
|
|
6
6
|
var useModelViewer = require('./useModelViewer.js');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var NiceButtonD9l39Rs7 = require('../ui/dist/NiceButton-D9l39Rs7.js');
|
|
8
|
+
var NicePinCodeInputCrMfdxxc = require('../ui/dist/NicePinCodeInput-CrMfdxxc.js');
|
|
9
9
|
|
|
10
10
|
const NAV_LABELS = {
|
|
11
11
|
orbit: '🌍 Orbit',
|
|
@@ -15,19 +15,19 @@ const NAV_LABELS = {
|
|
|
15
15
|
};
|
|
16
16
|
const NiceModelViewer = ({ className, showToolbar = true, showStatusBar = true, showInfoPanel = true, toolbarExtra, onFileDrop, children, ...viewerProps }) => {
|
|
17
17
|
const api = useModelViewer.useModelViewer(viewerProps);
|
|
18
|
-
const [panelOpen, setPanelOpen] =
|
|
19
|
-
const [dragOver, setDragOver] =
|
|
20
|
-
const fileInputRef =
|
|
18
|
+
const [panelOpen, setPanelOpen] = ke.useState(false);
|
|
19
|
+
const [dragOver, setDragOver] = ke.useState(false);
|
|
20
|
+
const fileInputRef = ke.useRef(null);
|
|
21
21
|
/* ── drag & drop ── */
|
|
22
|
-
const handleDragOver =
|
|
22
|
+
const handleDragOver = ke.useCallback((e) => {
|
|
23
23
|
e.preventDefault();
|
|
24
24
|
setDragOver(true);
|
|
25
25
|
}, []);
|
|
26
|
-
const handleDragLeave =
|
|
26
|
+
const handleDragLeave = ke.useCallback((e) => {
|
|
27
27
|
e.preventDefault();
|
|
28
28
|
setDragOver(false);
|
|
29
29
|
}, []);
|
|
30
|
-
const handleDrop =
|
|
30
|
+
const handleDrop = ke.useCallback((e) => {
|
|
31
31
|
var _a;
|
|
32
32
|
e.preventDefault();
|
|
33
33
|
setDragOver(false);
|
|
@@ -39,27 +39,27 @@ const NiceModelViewer = ({ className, showToolbar = true, showStatusBar = true,
|
|
|
39
39
|
}, [api, onFileDrop]);
|
|
40
40
|
/* ── nav cycle ── */
|
|
41
41
|
const navModes = ['orbit', 'fps', 'fly', 'walkthrough'];
|
|
42
|
-
const cycleNav =
|
|
42
|
+
const cycleNav = ke.useCallback(() => {
|
|
43
43
|
const idx = navModes.indexOf(api.navigationMode);
|
|
44
44
|
api.setNavigationMode(navModes[(idx + 1) % navModes.length]);
|
|
45
45
|
}, [api]);
|
|
46
|
-
return (jsxRuntime.jsxs("div", { className: `${ModelViewer_module.root} ${className !== null && className !== void 0 ? className : ''}`, children: [showToolbar && (jsxRuntime.jsxs("div", { className: ModelViewer_module.toolbar, children: [jsxRuntime.jsx(
|
|
46
|
+
return (jsxRuntime.jsxs("div", { className: `${ModelViewer_module.root} ${className !== null && className !== void 0 ? className : ''}`, children: [showToolbar && (jsxRuntime.jsxs("div", { className: ModelViewer_module.toolbar, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", title: "Open file\u2026", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: "\uD83D\uDCC2 Open" }), jsxRuntime.jsx("input", { ref: fileInputRef, type: "file", accept: ".fbx,.glb,.gltf,.obj,.dae,.stl,.ply", style: { display: 'none' }, onChange: (e) => {
|
|
47
47
|
var _a;
|
|
48
48
|
const f = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
49
49
|
if (f)
|
|
50
50
|
api.loadFile(f);
|
|
51
51
|
e.target.value = '';
|
|
52
|
-
} }), jsxRuntime.jsx("div", { className: ModelViewer_module.toolSep }), jsxRuntime.jsx(
|
|
52
|
+
} }), jsxRuntime.jsx("div", { className: ModelViewer_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", title: "Navigation mode", onClick: cycleNav, children: NAV_LABELS[api.navigationMode] }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: api.wireframe ? 'primary' : 'ghost', size: "sm", onClick: () => api.setWireframe(!api.wireframe), title: "Wireframe", children: "\uD83D\uDD32" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: api.showGrid ? 'primary' : 'ghost', size: "sm", onClick: () => api.setShowGrid(!api.showGrid), title: "Grid", children: "\u229E" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: api.clippingEnabled ? 'primary' : 'ghost', size: "sm", onClick: () => api.setClippingEnabled(!api.clippingEnabled), title: "Clipping plane", children: "\u2702\uFE0F" }), api.clippingEnabled && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.a, { className: ModelViewer_module.animSelect, value: api.clippingAxis, onChange: (val) => api.setClippingAxis(val), options: [
|
|
53
53
|
{ value: 'x', label: 'X' },
|
|
54
54
|
{ value: 'y', label: 'Y' },
|
|
55
55
|
{ value: 'z', label: 'Z' },
|
|
56
|
-
] }), jsxRuntime.jsx(
|
|
56
|
+
] }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: -10, max: 10, step: 0.1, value: api.clippingPosition, onChange: (val) => api.setClippingPosition(val), style: { width: 60 } })] })), jsxRuntime.jsx("div", { className: ModelViewer_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", onClick: api.zoomToFit, title: "Zoom to fit", children: "\uD83D\uDD0D" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", onClick: api.resetCamera, title: "Reset camera", children: "\uD83C\uDFE0" }), jsxRuntime.jsx("div", { className: ModelViewer_module.toolSep }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", onClick: () => {
|
|
57
57
|
const url = api.screenshot();
|
|
58
58
|
const a = document.createElement('a');
|
|
59
59
|
a.href = url;
|
|
60
60
|
a.download = 'screenshot.png';
|
|
61
61
|
a.click();
|
|
62
|
-
}, title: "Screenshot", children: "\uD83D\uDCF7" }), jsxRuntime.jsx(
|
|
62
|
+
}, title: "Screenshot", children: "\uD83D\uDCF7" }), jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", onClick: api.toggleFullscreen, title: "Fullscreen", children: api.isFullscreen ? '⊡' : '⛶' }), toolbarExtra, showInfoPanel && (jsxRuntime.jsx("div", { className: ModelViewer_module.toolRight, children: jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: `${ModelViewer_module.toolBtn} ${panelOpen ? ModelViewer_module.active : ''}`, variant: panelOpen ? 'primary' : 'ghost', size: "sm", onClick: () => setPanelOpen(!panelOpen), title: "Info panel", children: "\u2139\uFE0F" }) }))] })), jsxRuntime.jsxs("div", { className: ModelViewer_module.viewport, ref: api.mountRef, tabIndex: 0, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, children: [api.loading && (jsxRuntime.jsxs("div", { className: ModelViewer_module.loadingOverlay, children: [jsxRuntime.jsx("span", { className: ModelViewer_module.loadingText, children: "Loading model\u2026" }), jsxRuntime.jsx("div", { className: ModelViewer_module.loadingBar, children: jsxRuntime.jsx("div", { className: ModelViewer_module.loadingBarFill, style: { width: `${(api.loadProgress * 100).toFixed(0)}%` } }) })] })), api.error && (jsxRuntime.jsxs("div", { className: ModelViewer_module.errorOverlay, children: [jsxRuntime.jsx("span", { style: { fontSize: 28 }, children: "\u26A0\uFE0F" }), jsxRuntime.jsx("span", { style: { marginTop: 8 }, children: api.error })] })), dragOver && (jsxRuntime.jsx("div", { className: ModelViewer_module.dropZone, children: "Drop 3D model file here" }))] }), jsxRuntime.jsxs("div", { className: `${ModelViewer_module.sidePanel} ${!panelOpen ? ModelViewer_module.hidden : ''}`, children: [jsxRuntime.jsxs("div", { className: ModelViewer_module.panelSection, children: [jsxRuntime.jsx("div", { className: ModelViewer_module.panelTitle, children: "Model Info" }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelRow, children: [jsxRuntime.jsx("label", { children: "Triangles" }), jsxRuntime.jsx("span", { children: api.polyCount.toLocaleString() })] }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelRow, children: [jsxRuntime.jsx("label", { children: "Meshes" }), jsxRuntime.jsx("span", { children: api.meshCount })] }), api.dimensions && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: ModelViewer_module.panelRow, children: [jsxRuntime.jsx("label", { children: "Width" }), jsxRuntime.jsx("span", { children: api.dimensions.width })] }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelRow, children: [jsxRuntime.jsx("label", { children: "Height" }), jsxRuntime.jsx("span", { children: api.dimensions.height })] }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelRow, children: [jsxRuntime.jsx("label", { children: "Depth" }), jsxRuntime.jsx("span", { children: api.dimensions.depth })] })] }))] }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelSection, children: [jsxRuntime.jsx("div", { className: ModelViewer_module.panelTitle, children: "Navigation" }), navModes.map((m) => (jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: api.navigationMode === m ? 'primary' : 'ghost', size: "sm", onClick: () => api.setNavigationMode(m), children: NAV_LABELS[m] }, m)))] }), jsxRuntime.jsxs("div", { className: ModelViewer_module.panelSection, children: [jsxRuntime.jsx("div", { className: ModelViewer_module.panelTitle, children: "Auto Rotate" }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { min: 0, max: 10, step: 0.5, value: api.autoRotateSpeed, onChange: (val) => api.setAutoRotateSpeed(val), style: { width: '100%' } })] }), api.animations.length > 0 && (jsxRuntime.jsxs("div", { className: ModelViewer_module.panelSection, children: [jsxRuntime.jsx("div", { className: ModelViewer_module.panelTitle, children: "Animations" }), api.animations.map((name, i) => (jsxRuntime.jsxs(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: api.activeAnimIdx === i ? 'primary' : 'ghost', size: "sm", onClick: () => api.playAnimation(i), children: ["\u25B6 ", name] }, i)))] }))] }), jsxRuntime.jsxs("div", { className: `${ModelViewer_module.animBar} ${api.animations.length === 0 ? ModelViewer_module.hidden : ''}`, children: [jsxRuntime.jsx(NiceButtonD9l39Rs7.c, { className: ModelViewer_module.toolBtn, variant: "ghost", size: "sm", onClick: api.togglePlay, children: api.isPlaying ? '⏸' : '▶' }), jsxRuntime.jsx(NiceButtonD9l39Rs7.a, { className: ModelViewer_module.animSelect, value: String(api.activeAnimIdx), onChange: (val) => api.playAnimation(parseInt(val)), options: api.animations.map((n, i) => ({ value: String(i), label: n })) }), jsxRuntime.jsx(NicePinCodeInputCrMfdxxc.U, { className: ModelViewer_module.animSlider, min: 0, max: api.animDuration || 1, step: 0.01, value: api.animTime, onChange: (val) => api.seekAnim(val) }), jsxRuntime.jsxs("span", { className: ModelViewer_module.toolLabel, children: [api.animTime.toFixed(1), "s / ", api.animDuration.toFixed(1), "s"] })] }), showStatusBar && (jsxRuntime.jsxs("div", { className: ModelViewer_module.statusBar, children: [jsxRuntime.jsx("span", { children: api.statusText }), jsxRuntime.jsxs("div", { className: ModelViewer_module.statusRight, children: [jsxRuntime.jsx("span", { children: NAV_LABELS[api.navigationMode] }), api.dimensions && (jsxRuntime.jsxs("span", { children: [api.dimensions.width, "\u00D7", api.dimensions.height, "\u00D7", api.dimensions.depth] }))] })] })), children === null || children === void 0 ? void 0 : children(api)] }));
|
|
63
63
|
};
|
|
64
64
|
/** @deprecated Use NiceModelViewer */
|
|
65
65
|
const ModelViewer = NiceModelViewer;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var THREE = require('three');
|
|
5
|
-
var
|
|
5
|
+
var ke = require('react');
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -24,12 +24,12 @@ function _interopNamespaceDefault(e) {
|
|
|
24
24
|
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
25
25
|
|
|
26
26
|
function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
27
|
-
const [bones, setBones] =
|
|
28
|
-
const [selectedBoneId, setSelectedBoneId] =
|
|
29
|
-
const [savedPoses, setSavedPoses] =
|
|
30
|
-
const helperRef =
|
|
27
|
+
const [bones, setBones] = ke.useState([]);
|
|
28
|
+
const [selectedBoneId, setSelectedBoneId] = ke.useState(null);
|
|
29
|
+
const [savedPoses, setSavedPoses] = ke.useState([]);
|
|
30
|
+
const helperRef = ke.useRef(null);
|
|
31
31
|
// Build bone info tree from skeleton
|
|
32
|
-
|
|
32
|
+
ke.useEffect(() => {
|
|
33
33
|
if (!skeleton) {
|
|
34
34
|
setBones([]);
|
|
35
35
|
return;
|
|
@@ -52,7 +52,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
52
52
|
setBones(boneInfos);
|
|
53
53
|
}, [skeleton]);
|
|
54
54
|
// Create skeleton helper for visualization
|
|
55
|
-
|
|
55
|
+
ke.useEffect(() => {
|
|
56
56
|
var _a;
|
|
57
57
|
if (!skeleton || !scene)
|
|
58
58
|
return;
|
|
@@ -69,12 +69,12 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
69
69
|
helperRef.current = null;
|
|
70
70
|
};
|
|
71
71
|
}, [skeleton, scene]);
|
|
72
|
-
const selectBone =
|
|
72
|
+
const selectBone = ke.useCallback((id) => {
|
|
73
73
|
setSelectedBoneId(id);
|
|
74
74
|
const bone = id ? (skeleton === null || skeleton === void 0 ? void 0 : skeleton.bones.find((b) => b.uuid === id)) || null : null;
|
|
75
75
|
onBoneSelect === null || onBoneSelect === void 0 ? void 0 : onBoneSelect(bone);
|
|
76
76
|
}, [skeleton, onBoneSelect]);
|
|
77
|
-
const setBonePosition =
|
|
77
|
+
const setBonePosition = ke.useCallback((id, pos) => {
|
|
78
78
|
const bone = skeleton === null || skeleton === void 0 ? void 0 : skeleton.bones.find((b) => b.uuid === id);
|
|
79
79
|
if (bone) {
|
|
80
80
|
bone.position.copy(pos);
|
|
@@ -82,7 +82,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
82
82
|
setBones((prev) => prev.map((b) => (b.id === id ? { ...b, localPosition: pos.clone() } : b)));
|
|
83
83
|
}
|
|
84
84
|
}, [skeleton]);
|
|
85
|
-
const setBoneRotation =
|
|
85
|
+
const setBoneRotation = ke.useCallback((id, rot) => {
|
|
86
86
|
const bone = skeleton === null || skeleton === void 0 ? void 0 : skeleton.bones.find((b) => b.uuid === id);
|
|
87
87
|
if (bone) {
|
|
88
88
|
bone.rotation.copy(rot);
|
|
@@ -90,7 +90,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
90
90
|
setBones((prev) => prev.map((b) => (b.id === id ? { ...b, localRotation: rot.clone() } : b)));
|
|
91
91
|
}
|
|
92
92
|
}, [skeleton]);
|
|
93
|
-
const addBone =
|
|
93
|
+
const addBone = ke.useCallback((parentId, name) => {
|
|
94
94
|
const parent = skeleton === null || skeleton === void 0 ? void 0 : skeleton.bones.find((b) => b.uuid === parentId);
|
|
95
95
|
const newBone = new THREE__namespace.Bone();
|
|
96
96
|
newBone.name = name;
|
|
@@ -119,7 +119,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
119
119
|
]);
|
|
120
120
|
return newBone;
|
|
121
121
|
}, [skeleton]);
|
|
122
|
-
const removeBone =
|
|
122
|
+
const removeBone = ke.useCallback((id) => {
|
|
123
123
|
const bone = skeleton === null || skeleton === void 0 ? void 0 : skeleton.bones.find((b) => b.uuid === id);
|
|
124
124
|
if (!bone)
|
|
125
125
|
return;
|
|
@@ -139,7 +139,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
139
139
|
if (selectedBoneId === id)
|
|
140
140
|
setSelectedBoneId(null);
|
|
141
141
|
}, [skeleton, selectedBoneId]);
|
|
142
|
-
const savePose =
|
|
142
|
+
const savePose = ke.useCallback((name) => {
|
|
143
143
|
const transforms = new Map();
|
|
144
144
|
if (skeleton) {
|
|
145
145
|
for (const bone of skeleton.bones) {
|
|
@@ -159,7 +159,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
159
159
|
setSavedPoses((prev) => [...prev, pose]);
|
|
160
160
|
return pose;
|
|
161
161
|
}, [skeleton]);
|
|
162
|
-
const loadPose =
|
|
162
|
+
const loadPose = ke.useCallback((pose) => {
|
|
163
163
|
if (!skeleton)
|
|
164
164
|
return;
|
|
165
165
|
for (const bone of skeleton.bones) {
|
|
@@ -178,7 +178,7 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
178
178
|
localScale: b.bone.scale.clone(),
|
|
179
179
|
})));
|
|
180
180
|
}, [skeleton]);
|
|
181
|
-
const resetPose =
|
|
181
|
+
const resetPose = ke.useCallback(() => {
|
|
182
182
|
if (!skeleton)
|
|
183
183
|
return;
|
|
184
184
|
for (const bone of skeleton.bones) {
|
|
@@ -216,9 +216,9 @@ function useArmatureEditor(skeleton, scene, onBoneSelect) {
|
|
|
216
216
|
/* ── Component ── */
|
|
217
217
|
const NiceArmatureEditor = ({ skeleton, skinnedMesh, scene, camera, onBoneSelect, onPoseChange, className = '', }) => {
|
|
218
218
|
const { bones, selectedBoneId, selectBone, setBonePosition, setBoneRotation, addBone, removeBone, savePose, loadPose, resetPose, savedPoses, skeletonHelper, } = useArmatureEditor(skeleton, scene, onBoneSelect);
|
|
219
|
-
const [newBoneName, setNewBoneName] =
|
|
220
|
-
const selectedBone =
|
|
221
|
-
const rootBones =
|
|
219
|
+
const [newBoneName, setNewBoneName] = ke.useState('');
|
|
220
|
+
const selectedBone = ke.useMemo(() => bones.find((b) => b.id === selectedBoneId), [bones, selectedBoneId]);
|
|
221
|
+
const rootBones = ke.useMemo(() => bones.filter((b) => !b.parentId), [bones]);
|
|
222
222
|
const renderBoneTree = (boneInfo, depth = 0) => {
|
|
223
223
|
const isSelected = boneInfo.id === selectedBoneId;
|
|
224
224
|
const childBones = bones.filter((b) => b.parentId === boneInfo.id);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var THREE = require('three');
|
|
5
|
-
var
|
|
5
|
+
var ke = require('react');
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -25,14 +25,14 @@ var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
|
25
25
|
|
|
26
26
|
/* ── Hook ── */
|
|
27
27
|
function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
28
|
-
const [targets, setTargets] =
|
|
29
|
-
const [animations, setAnimations] =
|
|
30
|
-
const [isAnimating, setIsAnimating] =
|
|
31
|
-
const animFrameRef =
|
|
32
|
-
const animStartRef =
|
|
33
|
-
const activeAnimRef =
|
|
28
|
+
const [targets, setTargets] = ke.useState([]);
|
|
29
|
+
const [animations, setAnimations] = ke.useState([]);
|
|
30
|
+
const [isAnimating, setIsAnimating] = ke.useState(false);
|
|
31
|
+
const animFrameRef = ke.useRef(0);
|
|
32
|
+
const animStartRef = ke.useRef(0);
|
|
33
|
+
const activeAnimRef = ke.useRef(null);
|
|
34
34
|
// Sync targets from mesh
|
|
35
|
-
|
|
35
|
+
ke.useEffect(() => {
|
|
36
36
|
if (!mesh || !mesh.morphTargetDictionary || !mesh.morphTargetInfluences) {
|
|
37
37
|
setTargets([]);
|
|
38
38
|
return;
|
|
@@ -50,14 +50,14 @@ function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
|
50
50
|
list.sort((a, b) => a.index - b.index);
|
|
51
51
|
setTargets(list);
|
|
52
52
|
}, [mesh]);
|
|
53
|
-
const setInfluence =
|
|
53
|
+
const setInfluence = ke.useCallback((index, value) => {
|
|
54
54
|
if (!(mesh === null || mesh === void 0 ? void 0 : mesh.morphTargetInfluences))
|
|
55
55
|
return;
|
|
56
56
|
mesh.morphTargetInfluences[index] = value;
|
|
57
57
|
setTargets((prev) => prev.map((t) => (t.index === index ? { ...t, influence: value } : t)));
|
|
58
58
|
onInfluenceChange === null || onInfluenceChange === void 0 ? void 0 : onInfluenceChange(mesh, index, value);
|
|
59
59
|
}, [mesh, onInfluenceChange]);
|
|
60
|
-
const createMorphTarget =
|
|
60
|
+
const createMorphTarget = ke.useCallback((name) => {
|
|
61
61
|
if (!mesh)
|
|
62
62
|
return;
|
|
63
63
|
const geometry = mesh.geometry;
|
|
@@ -87,7 +87,7 @@ function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
|
87
87
|
mesh.updateMorphTargets();
|
|
88
88
|
setTargets((prev) => [...prev, { name, index: newIndex, influence: 0 }]);
|
|
89
89
|
}, [mesh]);
|
|
90
|
-
const deleteMorphTarget =
|
|
90
|
+
const deleteMorphTarget = ke.useCallback((index) => {
|
|
91
91
|
if (!mesh)
|
|
92
92
|
return;
|
|
93
93
|
const geometry = mesh.geometry;
|
|
@@ -111,13 +111,13 @@ function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
|
111
111
|
influence: influences[idx],
|
|
112
112
|
})));
|
|
113
113
|
}, [mesh]);
|
|
114
|
-
const resetAllInfluences =
|
|
114
|
+
const resetAllInfluences = ke.useCallback(() => {
|
|
115
115
|
if (!(mesh === null || mesh === void 0 ? void 0 : mesh.morphTargetInfluences))
|
|
116
116
|
return;
|
|
117
117
|
mesh.morphTargetInfluences.fill(0);
|
|
118
118
|
setTargets((prev) => prev.map((t) => ({ ...t, influence: 0 })));
|
|
119
119
|
}, [mesh]);
|
|
120
|
-
const startAnimation =
|
|
120
|
+
const startAnimation = ke.useCallback((animation) => {
|
|
121
121
|
if (!(mesh === null || mesh === void 0 ? void 0 : mesh.morphTargetInfluences))
|
|
122
122
|
return;
|
|
123
123
|
activeAnimRef.current = animation;
|
|
@@ -159,18 +159,18 @@ function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
|
159
159
|
};
|
|
160
160
|
animFrameRef.current = requestAnimationFrame(animate);
|
|
161
161
|
}, [mesh]);
|
|
162
|
-
const stopAnimation =
|
|
162
|
+
const stopAnimation = ke.useCallback(() => {
|
|
163
163
|
activeAnimRef.current = null;
|
|
164
164
|
setIsAnimating(false);
|
|
165
165
|
cancelAnimationFrame(animFrameRef.current);
|
|
166
166
|
}, []);
|
|
167
|
-
|
|
167
|
+
ke.useEffect(() => {
|
|
168
168
|
return () => cancelAnimationFrame(animFrameRef.current);
|
|
169
169
|
}, []);
|
|
170
|
-
const addAnimation =
|
|
170
|
+
const addAnimation = ke.useCallback((animation) => {
|
|
171
171
|
setAnimations((prev) => [...prev, animation]);
|
|
172
172
|
}, []);
|
|
173
|
-
const removeAnimation =
|
|
173
|
+
const removeAnimation = ke.useCallback((name) => {
|
|
174
174
|
setAnimations((prev) => prev.filter((a) => a.name !== name));
|
|
175
175
|
}, []);
|
|
176
176
|
return {
|
|
@@ -190,7 +190,7 @@ function useMorphTargetEditor(mesh, onInfluenceChange) {
|
|
|
190
190
|
/* ── Component ── */
|
|
191
191
|
const NiceMorphTargetEditor = ({ mesh, onInfluenceChange, className = '', }) => {
|
|
192
192
|
const { targets, setInfluence, createMorphTarget, deleteMorphTarget, resetAllInfluences, isAnimating, startAnimation, stopAnimation, animations, addAnimation, removeAnimation, } = useMorphTargetEditor(mesh, onInfluenceChange);
|
|
193
|
-
const [newName, setNewName] =
|
|
193
|
+
const [newName, setNewName] = ke.useState('');
|
|
194
194
|
const handleCreate = () => {
|
|
195
195
|
const name = newName.trim();
|
|
196
196
|
if (!name)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var THREE = require('three');
|
|
5
|
-
var
|
|
5
|
+
var ke = require('react');
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -208,12 +208,12 @@ function buildDebugVisualization(node, group, maxDepth) {
|
|
|
208
208
|
}
|
|
209
209
|
/* ── Hook ── */
|
|
210
210
|
function useOctree(scene, configOverride) {
|
|
211
|
-
const config =
|
|
212
|
-
const [root, setRoot] =
|
|
213
|
-
const [showDebug, setShowDebug] =
|
|
214
|
-
const [stats, setStats] =
|
|
215
|
-
const debugGroup =
|
|
216
|
-
|
|
211
|
+
const config = ke.useMemo(() => ({ ...DEFAULT_CONFIG, ...configOverride }), [configOverride]);
|
|
212
|
+
const [root, setRoot] = ke.useState(null);
|
|
213
|
+
const [showDebug, setShowDebug] = ke.useState(false);
|
|
214
|
+
const [stats, setStats] = ke.useState({ nodeCount: 0, objectCount: 0 });
|
|
215
|
+
const debugGroup = ke.useRef(new THREE__namespace.Group());
|
|
216
|
+
ke.useEffect(() => {
|
|
217
217
|
if (!scene)
|
|
218
218
|
return;
|
|
219
219
|
debugGroup.current.name = '__octree_debug__';
|
|
@@ -224,7 +224,7 @@ function useOctree(scene, configOverride) {
|
|
|
224
224
|
scene.remove(debugGroup.current);
|
|
225
225
|
};
|
|
226
226
|
}, [scene, showDebug]);
|
|
227
|
-
const refreshDebug =
|
|
227
|
+
const refreshDebug = ke.useCallback((rootNode) => {
|
|
228
228
|
// Clear existing debug
|
|
229
229
|
while (debugGroup.current.children.length) {
|
|
230
230
|
const child = debugGroup.current.children[0];
|
|
@@ -234,7 +234,7 @@ function useOctree(scene, configOverride) {
|
|
|
234
234
|
buildDebugVisualization(rootNode, debugGroup.current, config.maxDepth);
|
|
235
235
|
}
|
|
236
236
|
}, [showDebug, config.maxDepth]);
|
|
237
|
-
const build =
|
|
237
|
+
const build = ke.useCallback(() => {
|
|
238
238
|
if (!scene)
|
|
239
239
|
return;
|
|
240
240
|
// Compute scene bounds
|
|
@@ -264,26 +264,26 @@ function useOctree(scene, configOverride) {
|
|
|
264
264
|
setStats({ nodeCount: countNodes(rootNode), objectCount: countObjects(rootNode) });
|
|
265
265
|
refreshDebug(rootNode);
|
|
266
266
|
}, [scene, config, refreshDebug]);
|
|
267
|
-
const insert =
|
|
267
|
+
const insert = ke.useCallback((object) => {
|
|
268
268
|
if (!root)
|
|
269
269
|
return;
|
|
270
270
|
insertObject(root, object, config);
|
|
271
271
|
setStats({ nodeCount: countNodes(root), objectCount: countObjects(root) });
|
|
272
272
|
refreshDebug(root);
|
|
273
273
|
}, [root, config, refreshDebug]);
|
|
274
|
-
const remove =
|
|
274
|
+
const remove = ke.useCallback((object) => {
|
|
275
275
|
if (!root)
|
|
276
276
|
return;
|
|
277
277
|
removeObject(root, object);
|
|
278
278
|
setStats({ nodeCount: countNodes(root), objectCount: countObjects(root) });
|
|
279
279
|
}, [root]);
|
|
280
|
-
const update =
|
|
280
|
+
const update = ke.useCallback((object) => {
|
|
281
281
|
if (!root)
|
|
282
282
|
return;
|
|
283
283
|
removeObject(root, object);
|
|
284
284
|
insertObject(root, object, config);
|
|
285
285
|
}, [root, config]);
|
|
286
|
-
const raycast =
|
|
286
|
+
const raycast = ke.useCallback((raycaster) => {
|
|
287
287
|
if (!root)
|
|
288
288
|
return [];
|
|
289
289
|
const results = [];
|
|
@@ -291,7 +291,7 @@ function useOctree(scene, configOverride) {
|
|
|
291
291
|
results.sort((a, b) => a.distance - b.distance);
|
|
292
292
|
return results;
|
|
293
293
|
}, [root]);
|
|
294
|
-
const frustumCull =
|
|
294
|
+
const frustumCull = ke.useCallback((camera) => {
|
|
295
295
|
if (!root)
|
|
296
296
|
return [];
|
|
297
297
|
const frustum = new THREE__namespace.Frustum();
|
|
@@ -302,7 +302,7 @@ function useOctree(scene, configOverride) {
|
|
|
302
302
|
frustumCullNode(root, frustum, results);
|
|
303
303
|
return results;
|
|
304
304
|
}, [root]);
|
|
305
|
-
const nearestNeighbor =
|
|
305
|
+
const nearestNeighbor = ke.useCallback((point, maxDistance = Infinity) => {
|
|
306
306
|
if (!root)
|
|
307
307
|
return null;
|
|
308
308
|
const best = { object: null, dist: maxDistance };
|
|
@@ -327,7 +327,7 @@ function useOctree(scene, configOverride) {
|
|
|
327
327
|
/* ── Component ── */
|
|
328
328
|
const NiceOctree = ({ scene, config, showDebug: initialShowDebug, className = '', }) => {
|
|
329
329
|
const octree = useOctree(scene, config);
|
|
330
|
-
|
|
330
|
+
ke.useEffect(() => {
|
|
331
331
|
if (initialShowDebug !== undefined)
|
|
332
332
|
octree.setShowDebug(initialShowDebug);
|
|
333
333
|
}, [initialShowDebug]);
|