@nice2dev/ui-3d 1.3.15 → 1.3.16
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/CHANGELOG.md +9 -0
- package/dist/cjs/collaborative/collaborativeScene.js +160 -206
- package/dist/cjs/core/editorAsk.js +51 -41
- package/dist/cjs/core/i18n.js +13 -14
- package/dist/cjs/core/threeCompat.js +29 -42
- package/dist/cjs/dance/DanceBridge.js +148 -177
- package/dist/cjs/dance/DanceScoreEngine.js +209 -221
- package/dist/cjs/dance/PoseDetector.js +302 -275
- package/dist/cjs/index.js +110 -113
- package/dist/cjs/material/MaterialEditor.module.css.js +242 -5
- package/dist/cjs/material/NiceMaterialEditor.js +1213 -757
- package/dist/cjs/material/materialEditorTypes.js +35 -49
- package/dist/cjs/material/materialEditorUtils.js +684 -747
- package/dist/cjs/material/materialNodeDefinitions.js +1411 -1459
- package/dist/cjs/model/ModelEditor.js +90 -40
- package/dist/cjs/model/ModelEditor.module.css.js +257 -5
- package/dist/cjs/model/ModelEditorLeftPanel.js +126 -47
- package/dist/cjs/model/ModelEditorMenuBar.js +359 -32
- package/dist/cjs/model/ModelEditorRightPanel.js +647 -131
- package/dist/cjs/model/ModelEditorSubComponents.js +277 -112
- package/dist/cjs/model/ModelEditorTimeline.js +232 -34
- package/dist/cjs/model/ModelEditorToolbar.js +170 -14
- package/dist/cjs/model/ModelEditorViewport.js +231 -39
- package/dist/cjs/model/ModelViewer.js +388 -63
- package/dist/cjs/model/ModelViewer.module.css.js +77 -5
- package/dist/cjs/model/NiceArmatureEditor.js +473 -274
- package/dist/cjs/model/NiceMorphTargetEditor.js +333 -227
- package/dist/cjs/model/NiceOctree.js +372 -320
- package/dist/cjs/model/NicePhysicsSimulation.js +528 -298
- package/dist/cjs/model/NiceProceduralGeometry.js +673 -300
- package/dist/cjs/model/NiceTerrainEditor.js +595 -385
- package/dist/cjs/model/NiceWeightPainter.js +384 -261
- package/dist/cjs/model/NiceXRPreview.js +385 -308
- package/dist/cjs/model/cadModeUtils.js +103 -106
- package/dist/cjs/model/editorShortcuts.js +171 -194
- package/dist/cjs/model/modelEditorTypes.js +100 -118
- package/dist/cjs/model/modelEditorUtils.js +1061 -1146
- package/dist/cjs/model/simsModeUtils.js +1023 -1053
- package/dist/cjs/model/useModelEditor.js +1977 -1933
- package/dist/cjs/model/useModelViewer.js +633 -665
- package/dist/cjs/nice2dev-ui-3d.css +1 -1
- package/dist/cjs/particle/NiceParticleEditor.js +1186 -571
- package/dist/cjs/particle/ParticleEditor.module.css.js +122 -5
- package/dist/cjs/particle/particleEditorTypes.js +62 -70
- package/dist/cjs/particle/particleEditorUtils.js +998 -1013
- package/dist/cjs/rendering/NiceCascadedShadows.js +381 -259
- package/dist/cjs/rendering/NiceRenderExport.js +424 -337
- package/dist/cjs/rendering/NiceSSAO.js +454 -337
- package/dist/cjs/rendering/NiceSSR.js +387 -261
- package/dist/cjs/rendering/NiceWebGPURenderer.js +359 -230
- package/dist/cjs/uv/NiceUVEditor.js +787 -550
- package/dist/cjs/uv/UVEditor.module.css.js +53 -5
- package/dist/cjs/uv/uvEditorTypes.js +59 -76
- package/dist/cjs/uv/uvEditorUtils.js +501 -575
- package/dist/esm/collaborative/collaborativeScene.js +163 -205
- package/dist/esm/core/editorAsk.js +53 -40
- package/dist/esm/core/i18n.js +15 -13
- package/dist/esm/core/threeCompat.js +18 -26
- package/dist/esm/dance/DanceBridge.js +151 -176
- package/dist/esm/dance/DanceScoreEngine.js +211 -220
- package/dist/esm/dance/PoseDetector.js +304 -274
- package/dist/esm/index.js +258 -36
- package/dist/esm/material/MaterialEditor.module.css.js +242 -3
- package/dist/esm/material/NiceMaterialEditor.js +1215 -756
- package/dist/esm/material/materialEditorTypes.js +45 -48
- package/dist/esm/material/materialEditorUtils.js +713 -746
- package/dist/esm/material/materialNodeDefinitions.js +1415 -1458
- package/dist/esm/model/ModelEditor.js +91 -39
- package/dist/esm/model/ModelEditor.module.css.js +257 -3
- package/dist/esm/model/ModelEditorLeftPanel.js +126 -45
- package/dist/esm/model/ModelEditorMenuBar.js +359 -30
- package/dist/esm/model/ModelEditorRightPanel.js +634 -114
- package/dist/esm/model/ModelEditorSubComponents.js +265 -94
- package/dist/esm/model/ModelEditorTimeline.js +232 -32
- package/dist/esm/model/ModelEditorToolbar.js +170 -12
- package/dist/esm/model/ModelEditorViewport.js +231 -37
- package/dist/esm/model/ModelViewer.js +389 -62
- package/dist/esm/model/ModelViewer.module.css.js +77 -3
- package/dist/esm/model/NiceArmatureEditor.js +462 -258
- package/dist/esm/model/NiceMorphTargetEditor.js +322 -211
- package/dist/esm/model/NiceOctree.js +361 -304
- package/dist/esm/model/NicePhysicsSimulation.js +517 -282
- package/dist/esm/model/NiceProceduralGeometry.js +667 -284
- package/dist/esm/model/NiceTerrainEditor.js +584 -369
- package/dist/esm/model/NiceWeightPainter.js +373 -245
- package/dist/esm/model/NiceXRPreview.js +374 -292
- package/dist/esm/model/cadModeUtils.js +95 -88
- package/dist/esm/model/editorShortcuts.js +172 -193
- package/dist/esm/model/modelEditorTypes.js +90 -100
- package/dist/esm/model/modelEditorUtils.js +1056 -1128
- package/dist/esm/model/simsModeUtils.js +1021 -1035
- package/dist/esm/model/useModelEditor.js +1946 -1920
- package/dist/esm/model/useModelViewer.js +619 -647
- package/dist/esm/nice2dev-ui-3d.css +1 -1
- package/dist/esm/particle/NiceParticleEditor.js +1188 -570
- package/dist/esm/particle/ParticleEditor.module.css.js +122 -3
- package/dist/esm/particle/particleEditorTypes.js +69 -69
- package/dist/esm/particle/particleEditorUtils.js +1027 -1012
- package/dist/esm/rendering/NiceCascadedShadows.js +370 -243
- package/dist/esm/rendering/NiceRenderExport.js +413 -321
- package/dist/esm/rendering/NiceSSAO.js +450 -328
- package/dist/esm/rendering/NiceSSR.js +383 -252
- package/dist/esm/rendering/NiceWebGPURenderer.js +326 -214
- package/dist/esm/uv/NiceUVEditor.js +788 -549
- package/dist/esm/uv/UVEditor.module.css.js +53 -3
- package/dist/esm/uv/uvEditorTypes.js +68 -75
- package/dist/esm/uv/uvEditorUtils.js +515 -557
- package/package.json +7 -12
|
@@ -1,337 +1,710 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const ui = require("@nice2dev/ui");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const THREE = require("three");
|
|
7
|
+
const i18n = require("../core/i18n.js");
|
|
9
8
|
function _interopNamespaceDefault(e) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
}
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
20
17
|
});
|
|
18
|
+
}
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
27
|
-
|
|
28
|
-
/* ── Generators ── */
|
|
24
|
+
const THREE__namespace = /* @__PURE__ */ _interopNamespaceDefault(THREE);
|
|
29
25
|
function seededRng(seed) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
let s = seed;
|
|
27
|
+
return () => {
|
|
28
|
+
s = s * 16807 % 2147483647;
|
|
29
|
+
return (s - 1) / 2147483646;
|
|
30
|
+
};
|
|
35
31
|
}
|
|
36
32
|
function generateTree(params) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
parent.add(leaf);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const tip = position.clone().addScaledVector(direction.clone().normalize(), length);
|
|
62
|
-
const angleRad = (params.branchAngle * Math.PI) / 180;
|
|
63
|
-
for (let i = 0; i < params.branches; i++) {
|
|
64
|
-
const phi = (i / params.branches) * Math.PI * 2 + rng() * 0.5;
|
|
65
|
-
const theta = angleRad + (rng() - 0.5) * 0.3;
|
|
66
|
-
const newDir = new THREE__namespace.Vector3(Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi));
|
|
67
|
-
// Blend with parent direction
|
|
68
|
-
newDir.add(direction.clone().normalize().multiplyScalar(0.5)).normalize();
|
|
69
|
-
addBranch(parent, tip, newDir, length * (0.6 + rng() * 0.2), radius * params.branchTaper, depth - 1);
|
|
70
|
-
}
|
|
33
|
+
const group = new THREE__namespace.Group();
|
|
34
|
+
group.name = "ProceduralTree";
|
|
35
|
+
const rng = seededRng(params.seed);
|
|
36
|
+
const trunkMat = new THREE__namespace.MeshStandardMaterial({ color: 9127187 });
|
|
37
|
+
const leafMat = new THREE__namespace.MeshStandardMaterial({ color: 2263842 });
|
|
38
|
+
function addBranch(parent, position, direction, length, radius, depth) {
|
|
39
|
+
const geo = new THREE__namespace.CylinderGeometry(radius * params.branchTaper, radius, length, 8);
|
|
40
|
+
geo.translate(0, length / 2, 0);
|
|
41
|
+
const mesh = new THREE__namespace.Mesh(geo, trunkMat);
|
|
42
|
+
mesh.position.copy(position);
|
|
43
|
+
const up = new THREE__namespace.Vector3(0, 1, 0);
|
|
44
|
+
const quat = new THREE__namespace.Quaternion().setFromUnitVectors(up, direction.clone().normalize());
|
|
45
|
+
mesh.quaternion.copy(quat);
|
|
46
|
+
parent.add(mesh);
|
|
47
|
+
if (depth <= 0) {
|
|
48
|
+
const leafGeo = new THREE__namespace.IcosahedronGeometry(length * 0.6, 1);
|
|
49
|
+
const leaf = new THREE__namespace.Mesh(leafGeo, leafMat);
|
|
50
|
+
const tip2 = position.clone().addScaledVector(direction.clone().normalize(), length);
|
|
51
|
+
leaf.position.copy(tip2);
|
|
52
|
+
parent.add(leaf);
|
|
53
|
+
return;
|
|
71
54
|
}
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
const tip = position.clone().addScaledVector(direction.clone().normalize(), length);
|
|
56
|
+
const angleRad = params.branchAngle * Math.PI / 180;
|
|
57
|
+
for (let i = 0; i < params.branches; i++) {
|
|
58
|
+
const phi = i / params.branches * Math.PI * 2 + rng() * 0.5;
|
|
59
|
+
const theta = angleRad + (rng() - 0.5) * 0.3;
|
|
60
|
+
const newDir = new THREE__namespace.Vector3(
|
|
61
|
+
Math.sin(theta) * Math.cos(phi),
|
|
62
|
+
Math.cos(theta),
|
|
63
|
+
Math.sin(theta) * Math.sin(phi)
|
|
64
|
+
);
|
|
65
|
+
newDir.add(direction.clone().normalize().multiplyScalar(0.5)).normalize();
|
|
66
|
+
addBranch(
|
|
67
|
+
parent,
|
|
68
|
+
tip,
|
|
69
|
+
newDir,
|
|
70
|
+
length * (0.6 + rng() * 0.2),
|
|
71
|
+
radius * params.branchTaper,
|
|
72
|
+
depth - 1
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
addBranch(
|
|
77
|
+
group,
|
|
78
|
+
new THREE__namespace.Vector3(),
|
|
79
|
+
new THREE__namespace.Vector3(0, 1, 0),
|
|
80
|
+
params.trunkHeight,
|
|
81
|
+
params.trunkRadius,
|
|
82
|
+
params.depth
|
|
83
|
+
);
|
|
84
|
+
return group;
|
|
74
85
|
}
|
|
75
86
|
function generateRock(params) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
const geo = new THREE__namespace.IcosahedronGeometry(params.radius, params.detail);
|
|
88
|
+
const posAttr = geo.attributes.position;
|
|
89
|
+
const rng = seededRng(params.seed);
|
|
90
|
+
for (let i = 0; i < posAttr.count; i++) {
|
|
91
|
+
const vertex = new THREE__namespace.Vector3().fromBufferAttribute(posAttr, i);
|
|
92
|
+
const normal = vertex.clone().normalize();
|
|
93
|
+
const noise = (rng() - 0.5) * 2 * params.noiseAmount;
|
|
94
|
+
const freq = params.noiseScale;
|
|
95
|
+
const displacement = Math.sin(vertex.x * freq) * Math.cos(vertex.y * freq) * Math.sin(vertex.z * freq);
|
|
96
|
+
const totalDisp = (noise + displacement * params.noiseAmount) * params.radius;
|
|
97
|
+
vertex.addScaledVector(normal, totalDisp);
|
|
98
|
+
posAttr.setXYZ(i, vertex.x, vertex.y, vertex.z);
|
|
99
|
+
}
|
|
100
|
+
geo.computeVertexNormals();
|
|
101
|
+
const mesh = new THREE__namespace.Mesh(
|
|
102
|
+
geo,
|
|
103
|
+
new THREE__namespace.MeshStandardMaterial({ color: 8421504, roughness: 0.9 })
|
|
104
|
+
);
|
|
105
|
+
mesh.name = "ProceduralRock";
|
|
106
|
+
mesh.castShadow = true;
|
|
107
|
+
return mesh;
|
|
95
108
|
}
|
|
96
109
|
function generateBuilding(params) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
for (let
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
110
|
+
const group = new THREE__namespace.Group();
|
|
111
|
+
group.name = "ProceduralBuilding";
|
|
112
|
+
const wallMat = new THREE__namespace.MeshStandardMaterial({ color: 13944233 });
|
|
113
|
+
const windowMat = new THREE__namespace.MeshStandardMaterial({
|
|
114
|
+
color: 8900331,
|
|
115
|
+
metalness: 0.3,
|
|
116
|
+
roughness: 0.1
|
|
117
|
+
});
|
|
118
|
+
const roofMat = new THREE__namespace.MeshStandardMaterial({ color: 9109504 });
|
|
119
|
+
const totalHeight = params.floors * params.floorHeight;
|
|
120
|
+
const bodyGeo = new THREE__namespace.BoxGeometry(params.width, totalHeight, params.depth);
|
|
121
|
+
bodyGeo.translate(0, totalHeight / 2, 0);
|
|
122
|
+
group.add(new THREE__namespace.Mesh(bodyGeo, wallMat));
|
|
123
|
+
for (let floor = 0; floor < params.floors; floor++) {
|
|
124
|
+
const y = floor * params.floorHeight + params.floorHeight * 0.5;
|
|
125
|
+
for (let w = 0; w < params.windowsPerFloor; w++) {
|
|
126
|
+
const x = (w - (params.windowsPerFloor - 1) / 2) * (params.width / (params.windowsPerFloor + 1));
|
|
127
|
+
const winGeo = new THREE__namespace.PlaneGeometry(params.windowWidth, params.windowHeight);
|
|
128
|
+
const winMesh = new THREE__namespace.Mesh(winGeo, windowMat);
|
|
129
|
+
winMesh.position.set(x, y, params.depth / 2 + 0.01);
|
|
130
|
+
group.add(winMesh);
|
|
131
|
+
const winBack = winMesh.clone();
|
|
132
|
+
winBack.position.z = -params.depth / 2 - 0.01;
|
|
133
|
+
winBack.rotation.y = Math.PI;
|
|
134
|
+
group.add(winBack);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
switch (params.roofStyle) {
|
|
138
|
+
case "gable": {
|
|
139
|
+
const shape = new THREE__namespace.Shape();
|
|
140
|
+
shape.moveTo(-params.width / 2, 0);
|
|
141
|
+
shape.lineTo(0, params.roofHeight);
|
|
142
|
+
shape.lineTo(params.width / 2, 0);
|
|
143
|
+
shape.lineTo(-params.width / 2, 0);
|
|
144
|
+
const extrudeGeo = new THREE__namespace.ExtrudeGeometry(shape, {
|
|
145
|
+
depth: params.depth,
|
|
146
|
+
bevelEnabled: false
|
|
147
|
+
});
|
|
148
|
+
const roof = new THREE__namespace.Mesh(extrudeGeo, roofMat);
|
|
149
|
+
roof.position.set(0, totalHeight, -params.depth / 2);
|
|
150
|
+
group.add(roof);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "hip": {
|
|
154
|
+
const roofGeo = new THREE__namespace.ConeGeometry(
|
|
155
|
+
Math.max(params.width, params.depth) * 0.7,
|
|
156
|
+
params.roofHeight,
|
|
157
|
+
4
|
|
158
|
+
);
|
|
159
|
+
roofGeo.rotateY(Math.PI / 4);
|
|
160
|
+
const roof = new THREE__namespace.Mesh(roofGeo, roofMat);
|
|
161
|
+
roof.position.y = totalHeight + params.roofHeight / 2;
|
|
162
|
+
group.add(roof);
|
|
163
|
+
break;
|
|
127
164
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
shape.lineTo(0, params.roofHeight);
|
|
134
|
-
shape.lineTo(params.width / 2, 0);
|
|
135
|
-
shape.lineTo(-params.width / 2, 0);
|
|
136
|
-
const extrudeGeo = new THREE__namespace.ExtrudeGeometry(shape, {
|
|
137
|
-
depth: params.depth,
|
|
138
|
-
bevelEnabled: false,
|
|
139
|
-
});
|
|
140
|
-
const roof = new THREE__namespace.Mesh(extrudeGeo, roofMat);
|
|
141
|
-
roof.position.set(0, totalHeight, -params.depth / 2);
|
|
142
|
-
group.add(roof);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
case 'hip': {
|
|
146
|
-
const roofGeo = new THREE__namespace.ConeGeometry(Math.max(params.width, params.depth) * 0.7, params.roofHeight, 4);
|
|
147
|
-
roofGeo.rotateY(Math.PI / 4);
|
|
148
|
-
const roof = new THREE__namespace.Mesh(roofGeo, roofMat);
|
|
149
|
-
roof.position.y = totalHeight + params.roofHeight / 2;
|
|
150
|
-
group.add(roof);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
default: {
|
|
154
|
-
// flat roof
|
|
155
|
-
const flatGeo = new THREE__namespace.BoxGeometry(params.width + 0.4, 0.2, params.depth + 0.4);
|
|
156
|
-
const roof = new THREE__namespace.Mesh(flatGeo, roofMat);
|
|
157
|
-
roof.position.y = totalHeight + 0.1;
|
|
158
|
-
group.add(roof);
|
|
159
|
-
}
|
|
165
|
+
default: {
|
|
166
|
+
const flatGeo = new THREE__namespace.BoxGeometry(params.width + 0.4, 0.2, params.depth + 0.4);
|
|
167
|
+
const roof = new THREE__namespace.Mesh(flatGeo, roofMat);
|
|
168
|
+
roof.position.y = totalHeight + 0.1;
|
|
169
|
+
group.add(roof);
|
|
160
170
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
171
|
+
}
|
|
172
|
+
group.traverse((child) => {
|
|
173
|
+
if (child instanceof THREE__namespace.Mesh) {
|
|
174
|
+
child.castShadow = true;
|
|
175
|
+
child.receiveShadow = true;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return group;
|
|
168
179
|
}
|
|
169
180
|
function generatePipe(params) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
const curve = new THREE__namespace.CatmullRomCurve3(params.points, params.closed);
|
|
182
|
+
const geo = new THREE__namespace.TubeGeometry(
|
|
183
|
+
curve,
|
|
184
|
+
params.segments,
|
|
185
|
+
params.radius,
|
|
186
|
+
params.radialSegments,
|
|
187
|
+
params.closed
|
|
188
|
+
);
|
|
189
|
+
const mesh = new THREE__namespace.Mesh(
|
|
190
|
+
geo,
|
|
191
|
+
new THREE__namespace.MeshStandardMaterial({ color: 11184810, metalness: 0.8, roughness: 0.2 })
|
|
192
|
+
);
|
|
193
|
+
mesh.name = "ProceduralPipe";
|
|
194
|
+
mesh.castShadow = true;
|
|
195
|
+
return mesh;
|
|
176
196
|
}
|
|
177
197
|
function generateGear(params) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
shape.lineTo(x, y);
|
|
190
|
-
}
|
|
198
|
+
const shape = new THREE__namespace.Shape();
|
|
199
|
+
const angleStep = Math.PI * 2 / (params.teeth * 2);
|
|
200
|
+
for (let i = 0; i < params.teeth * 2; i++) {
|
|
201
|
+
const angle = i * angleStep;
|
|
202
|
+
const r = i % 2 === 0 ? params.outerRadius : params.outerRadius - params.toothDepth;
|
|
203
|
+
const x = Math.cos(angle) * r;
|
|
204
|
+
const y = Math.sin(angle) * r;
|
|
205
|
+
if (i === 0) {
|
|
206
|
+
shape.moveTo(x, y);
|
|
207
|
+
} else {
|
|
208
|
+
shape.lineTo(x, y);
|
|
191
209
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
hole.lineTo(x, y);
|
|
205
|
-
}
|
|
210
|
+
}
|
|
211
|
+
shape.closePath();
|
|
212
|
+
const hole = new THREE__namespace.Path();
|
|
213
|
+
const holeSegments = 32;
|
|
214
|
+
for (let i = 0; i <= holeSegments; i++) {
|
|
215
|
+
const angle = i / holeSegments * Math.PI * 2;
|
|
216
|
+
const x = Math.cos(angle) * params.innerRadius;
|
|
217
|
+
const y = Math.sin(angle) * params.innerRadius;
|
|
218
|
+
if (i === 0) {
|
|
219
|
+
hole.moveTo(x, y);
|
|
220
|
+
} else {
|
|
221
|
+
hole.lineTo(x, y);
|
|
206
222
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
}
|
|
224
|
+
shape.holes.push(hole);
|
|
225
|
+
const geo = new THREE__namespace.ExtrudeGeometry(shape, {
|
|
226
|
+
depth: params.thickness,
|
|
227
|
+
bevelEnabled: false
|
|
228
|
+
});
|
|
229
|
+
geo.rotateX(-Math.PI / 2);
|
|
230
|
+
geo.translate(0, params.thickness / 2, 0);
|
|
231
|
+
const mesh = new THREE__namespace.Mesh(
|
|
232
|
+
geo,
|
|
233
|
+
new THREE__namespace.MeshStandardMaterial({ color: 8947848, metalness: 0.7, roughness: 0.3 })
|
|
234
|
+
);
|
|
235
|
+
mesh.name = "ProceduralGear";
|
|
236
|
+
mesh.castShadow = true;
|
|
237
|
+
return mesh;
|
|
218
238
|
}
|
|
219
|
-
/* ── Hook ── */
|
|
220
239
|
const DEFAULT_TREE = {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
240
|
+
trunkRadius: 0.3,
|
|
241
|
+
trunkHeight: 4,
|
|
242
|
+
branches: 3,
|
|
243
|
+
depth: 3,
|
|
244
|
+
branchAngle: 30,
|
|
245
|
+
branchLength: 3,
|
|
246
|
+
branchTaper: 0.7,
|
|
247
|
+
seed: 42
|
|
229
248
|
};
|
|
230
249
|
const DEFAULT_ROCK = {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
250
|
+
radius: 1,
|
|
251
|
+
detail: 3,
|
|
252
|
+
noiseScale: 3,
|
|
253
|
+
noiseAmount: 0.2,
|
|
254
|
+
seed: 42
|
|
236
255
|
};
|
|
237
256
|
const DEFAULT_BUILDING = {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
width: 8,
|
|
258
|
+
depth: 6,
|
|
259
|
+
floors: 4,
|
|
260
|
+
floorHeight: 3,
|
|
261
|
+
windowsPerFloor: 3,
|
|
262
|
+
windowWidth: 1.2,
|
|
263
|
+
windowHeight: 1.5,
|
|
264
|
+
roofStyle: "gable",
|
|
265
|
+
roofHeight: 3
|
|
247
266
|
};
|
|
248
267
|
const DEFAULT_PIPE = {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
radius: 0.2,
|
|
269
|
+
segments: 64,
|
|
270
|
+
radialSegments: 8,
|
|
271
|
+
closed: false,
|
|
272
|
+
points: [
|
|
273
|
+
new THREE__namespace.Vector3(0, 0, 0),
|
|
274
|
+
new THREE__namespace.Vector3(2, 2, 0),
|
|
275
|
+
new THREE__namespace.Vector3(4, 0, 2),
|
|
276
|
+
new THREE__namespace.Vector3(6, 2, 2)
|
|
277
|
+
]
|
|
259
278
|
};
|
|
260
279
|
const DEFAULT_GEAR = {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
280
|
+
innerRadius: 0.5,
|
|
281
|
+
outerRadius: 2,
|
|
282
|
+
teeth: 12,
|
|
283
|
+
toothDepth: 0.3,
|
|
284
|
+
thickness: 0.4
|
|
266
285
|
};
|
|
267
286
|
function useProceduralGeometry(scene, onGenerated) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
287
|
+
const [type, setType] = React.useState("tree");
|
|
288
|
+
const [treeParams, setTreeParams] = React.useState(DEFAULT_TREE);
|
|
289
|
+
const [rockParams, setRockParams] = React.useState(DEFAULT_ROCK);
|
|
290
|
+
const [buildingParams, setBuildingParams] = React.useState(DEFAULT_BUILDING);
|
|
291
|
+
const [pipeParams, setPipeParams] = React.useState(DEFAULT_PIPE);
|
|
292
|
+
const [gearParams, setGearParams] = React.useState(DEFAULT_GEAR);
|
|
293
|
+
const generate = React.useCallback(() => {
|
|
294
|
+
if (!scene) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
let result;
|
|
298
|
+
switch (type) {
|
|
299
|
+
case "tree":
|
|
300
|
+
result = generateTree(treeParams);
|
|
301
|
+
break;
|
|
302
|
+
case "rock":
|
|
303
|
+
result = generateRock(rockParams);
|
|
304
|
+
break;
|
|
305
|
+
case "building":
|
|
306
|
+
result = generateBuilding(buildingParams);
|
|
307
|
+
break;
|
|
308
|
+
case "pipe":
|
|
309
|
+
result = generatePipe(pipeParams);
|
|
310
|
+
break;
|
|
311
|
+
case "gear":
|
|
312
|
+
result = generateGear(gearParams);
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
scene.add(result);
|
|
316
|
+
onGenerated?.(result);
|
|
317
|
+
}, [scene, type, treeParams, rockParams, buildingParams, pipeParams, gearParams, onGenerated]);
|
|
318
|
+
return {
|
|
319
|
+
type,
|
|
320
|
+
setType,
|
|
321
|
+
treeParams,
|
|
322
|
+
setTreeParams,
|
|
323
|
+
rockParams,
|
|
324
|
+
setRockParams,
|
|
325
|
+
buildingParams,
|
|
326
|
+
setBuildingParams,
|
|
327
|
+
pipeParams,
|
|
328
|
+
setPipeParams,
|
|
329
|
+
gearParams,
|
|
330
|
+
setGearParams,
|
|
331
|
+
generate
|
|
332
|
+
};
|
|
314
333
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
334
|
+
const NiceProceduralGeometry = ({
|
|
335
|
+
scene,
|
|
336
|
+
onGenerated,
|
|
337
|
+
className = ""
|
|
338
|
+
}) => {
|
|
339
|
+
const { t } = i18n.useNiceTranslation();
|
|
340
|
+
const {
|
|
341
|
+
type,
|
|
342
|
+
setType,
|
|
343
|
+
treeParams,
|
|
344
|
+
setTreeParams,
|
|
345
|
+
rockParams,
|
|
346
|
+
setRockParams,
|
|
347
|
+
buildingParams,
|
|
348
|
+
setBuildingParams,
|
|
349
|
+
gearParams,
|
|
350
|
+
setGearParams,
|
|
351
|
+
generate
|
|
352
|
+
} = useProceduralGeometry(scene, onGenerated);
|
|
353
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
354
|
+
"div",
|
|
355
|
+
{
|
|
356
|
+
className: `nice-procedural-geometry ${className}`,
|
|
357
|
+
style: { display: "grid", gap: 8, fontSize: 13 },
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: t("proceduralGeometry.proceduralGeometry", "Procedural Geometry") }),
|
|
360
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
361
|
+
"select",
|
|
362
|
+
{
|
|
363
|
+
value: type,
|
|
364
|
+
onChange: (e) => setType(e.target.value),
|
|
365
|
+
style: { width: "100%", padding: "4px 8px" },
|
|
366
|
+
children: [
|
|
367
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "tree", children: t("proceduralGeometry.tree", "Tree") }),
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "rock", children: t("proceduralGeometry.rock", "Rock") }),
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "building", children: t("proceduralGeometry.building", "Building") }),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "pipe", children: t("proceduralGeometry.pipe", "Pipe") }),
|
|
371
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "gear", children: t("proceduralGeometry.gear", "Gear") })
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
type === "tree" && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: 4 }, children: [
|
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
377
|
+
t("proceduralGeometry.height", "Height: {trunkHeight}").replace(
|
|
378
|
+
"{trunkHeight}",
|
|
379
|
+
String(treeParams.trunkHeight.toFixed(1))
|
|
380
|
+
),
|
|
381
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
382
|
+
"input",
|
|
383
|
+
{
|
|
384
|
+
type: "range",
|
|
385
|
+
min: 1,
|
|
386
|
+
max: 15,
|
|
387
|
+
step: 0.5,
|
|
388
|
+
value: treeParams.trunkHeight,
|
|
389
|
+
onChange: (e) => setTreeParams({ ...treeParams, trunkHeight: parseFloat(e.target.value) }),
|
|
390
|
+
style: { width: "100%" }
|
|
391
|
+
}
|
|
392
|
+
)
|
|
393
|
+
] }),
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
395
|
+
t("proceduralGeometry.branches", "Branches: {branches}").replace(
|
|
396
|
+
"{branches}",
|
|
397
|
+
String(treeParams.branches)
|
|
398
|
+
),
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
400
|
+
"input",
|
|
401
|
+
{
|
|
402
|
+
type: "range",
|
|
403
|
+
min: 1,
|
|
404
|
+
max: 6,
|
|
405
|
+
value: treeParams.branches,
|
|
406
|
+
onChange: (e) => setTreeParams({ ...treeParams, branches: parseInt(e.target.value, 10) }),
|
|
407
|
+
style: { width: "100%" }
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
] }),
|
|
411
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
412
|
+
t("proceduralGeometry.depth", "Depth: {depth}").replace(
|
|
413
|
+
"{depth}",
|
|
414
|
+
String(treeParams.depth)
|
|
415
|
+
),
|
|
416
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
417
|
+
"input",
|
|
418
|
+
{
|
|
419
|
+
type: "range",
|
|
420
|
+
min: 1,
|
|
421
|
+
max: 5,
|
|
422
|
+
value: treeParams.depth,
|
|
423
|
+
onChange: (e) => setTreeParams({ ...treeParams, depth: parseInt(e.target.value, 10) }),
|
|
424
|
+
style: { width: "100%" }
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
] }),
|
|
428
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
429
|
+
t("proceduralGeometry.angle", "Angle: {branchAngle}°").replace(
|
|
430
|
+
"{branchAngle}",
|
|
431
|
+
String(treeParams.branchAngle)
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
434
|
+
"input",
|
|
435
|
+
{
|
|
436
|
+
type: "range",
|
|
437
|
+
min: 10,
|
|
438
|
+
max: 80,
|
|
439
|
+
value: treeParams.branchAngle,
|
|
440
|
+
onChange: (e) => setTreeParams({ ...treeParams, branchAngle: parseInt(e.target.value, 10) }),
|
|
441
|
+
style: { width: "100%" }
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
] }),
|
|
445
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
446
|
+
t("proceduralGeometry.seed", "Seed: {seed}").replace(
|
|
447
|
+
"{seed}",
|
|
448
|
+
String(treeParams.seed)
|
|
449
|
+
),
|
|
450
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
451
|
+
"input",
|
|
452
|
+
{
|
|
453
|
+
type: "range",
|
|
454
|
+
min: 1,
|
|
455
|
+
max: 999,
|
|
456
|
+
value: treeParams.seed,
|
|
457
|
+
onChange: (e) => setTreeParams({ ...treeParams, seed: parseInt(e.target.value, 10) }),
|
|
458
|
+
style: { width: "100%" }
|
|
459
|
+
}
|
|
460
|
+
)
|
|
461
|
+
] })
|
|
462
|
+
] }),
|
|
463
|
+
type === "rock" && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: 4 }, children: [
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
465
|
+
t("proceduralGeometry.radius", "Radius: {radius}").replace(
|
|
466
|
+
"{radius}",
|
|
467
|
+
String(rockParams.radius.toFixed(1))
|
|
468
|
+
),
|
|
469
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
470
|
+
"input",
|
|
471
|
+
{
|
|
472
|
+
type: "range",
|
|
473
|
+
min: 0.2,
|
|
474
|
+
max: 5,
|
|
475
|
+
step: 0.1,
|
|
476
|
+
value: rockParams.radius,
|
|
477
|
+
onChange: (e) => setRockParams({ ...rockParams, radius: parseFloat(e.target.value) }),
|
|
478
|
+
style: { width: "100%" }
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
483
|
+
t("proceduralGeometry.detail", "Detail: {detail}").replace(
|
|
484
|
+
"{detail}",
|
|
485
|
+
String(rockParams.detail)
|
|
486
|
+
),
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
488
|
+
"input",
|
|
489
|
+
{
|
|
490
|
+
type: "range",
|
|
491
|
+
min: 1,
|
|
492
|
+
max: 5,
|
|
493
|
+
value: rockParams.detail,
|
|
494
|
+
onChange: (e) => setRockParams({ ...rockParams, detail: parseInt(e.target.value, 10) }),
|
|
495
|
+
style: { width: "100%" }
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
] }),
|
|
499
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
500
|
+
t("proceduralGeometry.noise", "Noise: {noiseAmount}").replace(
|
|
501
|
+
"{noiseAmount}",
|
|
502
|
+
String(rockParams.noiseAmount.toFixed(2))
|
|
503
|
+
),
|
|
504
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
505
|
+
"input",
|
|
506
|
+
{
|
|
507
|
+
type: "range",
|
|
508
|
+
min: 0,
|
|
509
|
+
max: 0.5,
|
|
510
|
+
step: 0.01,
|
|
511
|
+
value: rockParams.noiseAmount,
|
|
512
|
+
onChange: (e) => setRockParams({ ...rockParams, noiseAmount: parseFloat(e.target.value) }),
|
|
513
|
+
style: { width: "100%" }
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
] }),
|
|
517
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
518
|
+
t("proceduralGeometry.seed", "Seed: {seed}").replace(
|
|
519
|
+
"{seed}",
|
|
520
|
+
String(rockParams.seed)
|
|
521
|
+
),
|
|
522
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
523
|
+
"input",
|
|
524
|
+
{
|
|
525
|
+
type: "range",
|
|
526
|
+
min: 1,
|
|
527
|
+
max: 999,
|
|
528
|
+
value: rockParams.seed,
|
|
529
|
+
onChange: (e) => setRockParams({ ...rockParams, seed: parseInt(e.target.value, 10) }),
|
|
530
|
+
style: { width: "100%" }
|
|
531
|
+
}
|
|
532
|
+
)
|
|
533
|
+
] })
|
|
534
|
+
] }),
|
|
535
|
+
type === "building" && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: 4 }, children: [
|
|
536
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
537
|
+
t("proceduralGeometry.width", "Width: {width}").replace(
|
|
538
|
+
"{width}",
|
|
539
|
+
String(buildingParams.width)
|
|
540
|
+
),
|
|
541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
542
|
+
"input",
|
|
543
|
+
{
|
|
544
|
+
type: "range",
|
|
545
|
+
min: 4,
|
|
546
|
+
max: 20,
|
|
547
|
+
step: 1,
|
|
548
|
+
value: buildingParams.width,
|
|
549
|
+
onChange: (e) => setBuildingParams({ ...buildingParams, width: parseInt(e.target.value, 10) }),
|
|
550
|
+
style: { width: "100%" }
|
|
551
|
+
}
|
|
552
|
+
)
|
|
553
|
+
] }),
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
555
|
+
t("proceduralGeometry.floors", "Floors: {floors}").replace(
|
|
556
|
+
"{floors}",
|
|
557
|
+
String(buildingParams.floors)
|
|
558
|
+
),
|
|
559
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
560
|
+
"input",
|
|
561
|
+
{
|
|
562
|
+
type: "range",
|
|
563
|
+
min: 1,
|
|
564
|
+
max: 20,
|
|
565
|
+
value: buildingParams.floors,
|
|
566
|
+
onChange: (e) => setBuildingParams({ ...buildingParams, floors: parseInt(e.target.value, 10) }),
|
|
567
|
+
style: { width: "100%" }
|
|
568
|
+
}
|
|
569
|
+
)
|
|
570
|
+
] }),
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
572
|
+
t("proceduralGeometry.windowsFloor", "Windows/Floor: {windowsPerFloor}").replace(
|
|
573
|
+
"{windowsPerFloor}",
|
|
574
|
+
String(buildingParams.windowsPerFloor)
|
|
575
|
+
),
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
577
|
+
"input",
|
|
578
|
+
{
|
|
579
|
+
type: "range",
|
|
580
|
+
min: 1,
|
|
581
|
+
max: 10,
|
|
582
|
+
value: buildingParams.windowsPerFloor,
|
|
583
|
+
onChange: (e) => setBuildingParams({
|
|
584
|
+
...buildingParams,
|
|
585
|
+
windowsPerFloor: parseInt(e.target.value, 10)
|
|
586
|
+
}),
|
|
587
|
+
style: { width: "100%" }
|
|
588
|
+
}
|
|
589
|
+
)
|
|
590
|
+
] }),
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
592
|
+
t("proceduralGeometry.roof", "Roof:"),
|
|
593
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
594
|
+
"select",
|
|
595
|
+
{
|
|
596
|
+
value: buildingParams.roofStyle,
|
|
597
|
+
onChange: (e) => setBuildingParams({
|
|
598
|
+
...buildingParams,
|
|
599
|
+
roofStyle: e.target.value
|
|
600
|
+
}),
|
|
601
|
+
style: { marginLeft: 8 },
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "flat", children: t("proceduralGeometry.flat", "Flat") }),
|
|
604
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "gable", children: t("proceduralGeometry.gable", "Gable") }),
|
|
605
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "hip", children: t("proceduralGeometry.hip", "Hip") })
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
] })
|
|
610
|
+
] }),
|
|
611
|
+
type === "gear" && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: 4 }, children: [
|
|
612
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
613
|
+
t("proceduralGeometry.outerRadius", "Outer Radius: {outerRadius}").replace(
|
|
614
|
+
"{outerRadius}",
|
|
615
|
+
String(gearParams.outerRadius.toFixed(1))
|
|
616
|
+
),
|
|
617
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
618
|
+
"input",
|
|
619
|
+
{
|
|
620
|
+
type: "range",
|
|
621
|
+
min: 0.5,
|
|
622
|
+
max: 5,
|
|
623
|
+
step: 0.1,
|
|
624
|
+
value: gearParams.outerRadius,
|
|
625
|
+
onChange: (e) => setGearParams({ ...gearParams, outerRadius: parseFloat(e.target.value) }),
|
|
626
|
+
style: { width: "100%" }
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
] }),
|
|
630
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
631
|
+
t("proceduralGeometry.teeth", "Teeth: {teeth}").replace(
|
|
632
|
+
"{teeth}",
|
|
633
|
+
String(gearParams.teeth)
|
|
634
|
+
),
|
|
635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
636
|
+
"input",
|
|
637
|
+
{
|
|
638
|
+
type: "range",
|
|
639
|
+
min: 4,
|
|
640
|
+
max: 30,
|
|
641
|
+
value: gearParams.teeth,
|
|
642
|
+
onChange: (e) => setGearParams({ ...gearParams, teeth: parseInt(e.target.value, 10) }),
|
|
643
|
+
style: { width: "100%" }
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
] }),
|
|
647
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
648
|
+
t("proceduralGeometry.toothDepth", "Tooth Depth: {toothDepth}").replace(
|
|
649
|
+
"{toothDepth}",
|
|
650
|
+
String(gearParams.toothDepth.toFixed(2))
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
653
|
+
"input",
|
|
654
|
+
{
|
|
655
|
+
type: "range",
|
|
656
|
+
min: 0.05,
|
|
657
|
+
max: 1,
|
|
658
|
+
step: 0.05,
|
|
659
|
+
value: gearParams.toothDepth,
|
|
660
|
+
onChange: (e) => setGearParams({ ...gearParams, toothDepth: parseFloat(e.target.value) }),
|
|
661
|
+
style: { width: "100%" }
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
] }),
|
|
665
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
666
|
+
t("proceduralGeometry.thickness", "Thickness: {thickness}").replace(
|
|
667
|
+
"{thickness}",
|
|
668
|
+
String(gearParams.thickness.toFixed(2))
|
|
669
|
+
),
|
|
670
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
671
|
+
"input",
|
|
672
|
+
{
|
|
673
|
+
type: "range",
|
|
674
|
+
min: 0.1,
|
|
675
|
+
max: 2,
|
|
676
|
+
step: 0.1,
|
|
677
|
+
value: gearParams.thickness,
|
|
678
|
+
onChange: (e) => setGearParams({ ...gearParams, thickness: parseFloat(e.target.value) }),
|
|
679
|
+
style: { width: "100%" }
|
|
680
|
+
}
|
|
681
|
+
)
|
|
682
|
+
] })
|
|
683
|
+
] }),
|
|
684
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
685
|
+
"button",
|
|
686
|
+
{
|
|
687
|
+
type: "button",
|
|
688
|
+
onClick: generate,
|
|
689
|
+
style: {
|
|
690
|
+
background: "var(--nice-color-accent, #6366f1)",
|
|
691
|
+
color: "var(--nice-text-on-primary, #fff)",
|
|
692
|
+
border: "none",
|
|
693
|
+
borderRadius: 4,
|
|
694
|
+
padding: "6px 12px",
|
|
695
|
+
cursor: "pointer"
|
|
696
|
+
},
|
|
697
|
+
children: [
|
|
698
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.NiceIcon, { name: "wand", size: 14 }),
|
|
699
|
+
" ",
|
|
700
|
+
t("proceduralGeometry.generate", "Generate")
|
|
701
|
+
]
|
|
702
|
+
}
|
|
703
|
+
)
|
|
704
|
+
]
|
|
705
|
+
}
|
|
706
|
+
);
|
|
333
707
|
};
|
|
334
|
-
|
|
335
708
|
exports.NiceProceduralGeometry = NiceProceduralGeometry;
|
|
336
709
|
exports.generateBuilding = generateBuilding;
|
|
337
710
|
exports.generateGear = generateGear;
|