@pinkaphant/kolmo 0.2.2 → 0.3.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/bin/kolmo.mjs +1 -1
- package/dist/engine/kolmoActor.js +125 -83
- package/dist/engine/kolmoLongDrive.js +136 -91
- package/dist/engine/kolmoStore.d.ts +6 -5
- package/dist/engine/kolmoStore.js +115 -79
- package/dist/engine/kolmoVehicle.d.ts +1 -1
- package/dist/engine/kolmoVehicle.js +160 -147
- package/dist/engine/kolmoVehicleDriver.d.ts +12 -4
- package/dist/engine/kolmoVehicleDriver.js +40 -20
- package/dist/engine/kolmoWorld.js +55 -35
- package/dist/importer/CabinPreviewRig.d.ts +13 -0
- package/dist/importer/CabinPreviewRig.js +138 -0
- package/dist/importer/CabinStepSection.d.ts +17 -0
- package/dist/importer/CabinStepSection.js +222 -0
- package/dist/importer/ChopShopPanel.d.ts +31 -1
- package/dist/importer/ChopShopPanel.js +474 -380
- package/dist/importer/GateHudBar.d.ts +3 -0
- package/dist/importer/GateHudBar.js +8 -2
- package/dist/importer/GlbImportGate.js +183 -147
- package/dist/importer/ImporterPlinthUikitTags.d.ts +2 -1
- package/dist/importer/ImporterPlinthUikitTags.js +23 -16
- package/dist/importer/Step1CalibrationPlinth.d.ts +10 -0
- package/dist/importer/Step1CalibrationPlinth.js +203 -141
- package/dist/importer/Step2UniversalPad.d.ts +8 -1
- package/dist/importer/Step2UniversalPad.js +112 -90
- package/dist/importer/cabinMeshBuilders.d.ts +13 -0
- package/dist/importer/cabinMeshBuilders.js +104 -0
- package/dist/importer/cabinMixamoRig.d.ts +53 -0
- package/dist/importer/cabinMixamoRig.js +150 -0
- package/dist/importer/chopShopActions.d.ts +6 -0
- package/dist/importer/chopShopActions.js +86 -61
- package/dist/importer/chopShopUiComponents.d.ts +22 -0
- package/dist/importer/chopShopUiComponents.js +91 -0
- package/dist/importer/gateStore.d.ts +5 -2
- package/dist/importer/gateStore.js +13 -10
- package/dist/importer/glbNormalizer.d.ts +10 -1
- package/dist/importer/glbNormalizer.js +114 -49
- package/dist/importer/importerWebMcp.js +4 -1
- package/dist/importer/index.d.ts +4 -2
- package/dist/importer/index.js +24 -21
- package/dist/importer/khrCompiler.d.ts +20 -1
- package/dist/importer/khrCompiler.js +539 -290
- package/dist/importer/launcherBake.js +12 -8
- package/dist/importer/meshIslands.d.ts +4 -0
- package/dist/importer/meshIslands.js +104 -99
- package/dist/importer/surfaceCutter.d.ts +12 -3
- package/dist/importer/surfaceCutter.js +220 -127
- package/dist/importer/surfaceTopology.d.ts +13 -2
- package/dist/importer/surfaceTopology.js +57 -29
- package/dist/importer/universalGateBake.d.ts +7 -1
- package/dist/importer/universalGateBake.js +63 -60
- package/dist/importer/usdToGlb.js +19 -7
- package/dist/importer/useChopShopController.d.ts +27 -1
- package/dist/importer/useChopShopController.js +369 -255
- package/dist/importer/wheelAxlePairing.d.ts +3 -1
- package/dist/importer/wheelAxlePairing.js +82 -33
- package/dist/index.js +31 -28
- package/dist/junk/ShardPieces.js +3 -3
- package/dist/physics/index.d.ts +7 -0
- package/dist/physics/index.js +66 -40
- package/package.json +1 -1
|
@@ -1,38 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { createFleet12GonWheelGroup as e } from "./wheelAxlePairing.js";
|
|
2
|
+
import { sliceMeshTriangles as t } from "./meshIslands.js";
|
|
3
|
+
import { CHOP_ROLES as n, MIRROR_OFF_CENTER_M as r, buildSurfaceTopology as i, countSelectionFaces as a, edgeKey as o, edgeLength as s, edgeWeight as c, floodFillByCrease as l, floodTriangles as u, getIslandTopology as d, mirrorTriangles as f, selectionEntries as p, shortestEdgePath as m, snapToVertex as h, weldKey as g } from "./surfaceTopology.js";
|
|
4
|
+
import * as _ from "three";
|
|
4
5
|
// src/importer/surfaceCutter.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
r +=
|
|
6
|
+
var v = new _.Triangle(), y = new _.Vector3(), b = new _.Vector3();
|
|
7
|
+
function x(e, t) {
|
|
8
|
+
let n = 0, r = 0, i = 0;
|
|
9
|
+
for (let a = 0; a < 3; a++) {
|
|
10
|
+
let o = e.corners[t * 3 + a] * 3;
|
|
11
|
+
n += e.points[o], r += e.points[o + 1], i += e.points[o + 2];
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return [
|
|
14
|
+
n / 3,
|
|
15
|
+
r / 3,
|
|
16
|
+
i / 3
|
|
17
|
+
];
|
|
13
18
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
19
|
+
function S(e, t, n, r, i, a, o, s) {
|
|
20
|
+
y.set(t, n, r);
|
|
21
|
+
let c = -1, l = s;
|
|
22
|
+
for (let t = 0; t < e.triangleCount; t++) {
|
|
23
|
+
let n = t * 3;
|
|
24
|
+
if (i * e.normals[n] + a * e.normals[n + 1] + o * e.normals[n + 2] < .5) continue;
|
|
25
|
+
let r = e.corners[n] * 3, s = e.corners[n + 1] * 3, u = e.corners[n + 2] * 3;
|
|
26
|
+
v.a.set(e.points[r], e.points[r + 1], e.points[r + 2]), v.b.set(e.points[s], e.points[s + 1], e.points[s + 2]), v.c.set(e.points[u], e.points[u + 1], e.points[u + 2]);
|
|
27
|
+
let d = v.closestPointToPoint(y, b).distanceTo(y);
|
|
28
|
+
d <= l && (l = d, c = t);
|
|
29
|
+
}
|
|
16
30
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
mirrored: a
|
|
31
|
+
t: c,
|
|
32
|
+
d: l
|
|
20
33
|
};
|
|
21
34
|
}
|
|
22
|
-
function
|
|
23
|
-
let
|
|
35
|
+
function C(e, t, n, i, a) {
|
|
36
|
+
let o = new Map(i.map((e) => [e.id, e])), s = /* @__PURE__ */ new Map(), c = (t, n) => {
|
|
37
|
+
if (e.get(t)?.includes(n)) return;
|
|
38
|
+
let r = s.get(t);
|
|
39
|
+
r || (r = /* @__PURE__ */ new Set(), s.set(t, r)), r.add(n);
|
|
40
|
+
};
|
|
41
|
+
if (n) {
|
|
42
|
+
let t = .035;
|
|
43
|
+
for (let [n, s] of e) {
|
|
44
|
+
let e = o.get(n);
|
|
45
|
+
if (!e || s.length === 0) continue;
|
|
46
|
+
let l = d(e), u = s.filter((e) => Math.abs(x(l, e)[0]) > r);
|
|
47
|
+
if (u.length === 0) continue;
|
|
48
|
+
let p = e.min[0] < -.08 && e.max[0] > .08 ? f(l, u, t) : [];
|
|
49
|
+
for (let e of p) c(n, e);
|
|
50
|
+
if (p.length < u.length) {
|
|
51
|
+
let e = i.filter((e) => !a?.has(e.id));
|
|
52
|
+
for (let r of u) {
|
|
53
|
+
let [i, a, o] = x(l, r), s = -i, u = -l.normals[r * 3], f = l.normals[r * 3 + 1], p = l.normals[r * 3 + 2], m = -1, h = -1, g = t;
|
|
54
|
+
for (let i of e) {
|
|
55
|
+
if (s < i.min[0] - t || s > i.max[0] + t || a < i.min[1] - t || a > i.max[1] + t || o < i.min[2] - t || o > i.max[2] + t) continue;
|
|
56
|
+
let e = S(d(i), s, a, o, u, f, p, g);
|
|
57
|
+
e.t >= 0 && e.d <= g && (i.id !== n || e.t !== r) && (g = e.d, m = i.id, h = e.t);
|
|
58
|
+
}
|
|
59
|
+
m >= 0 && h >= 0 && c(m, h);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let l = [];
|
|
65
|
+
for (let t of [.../* @__PURE__ */ new Set([...e.keys(), ...s.keys()])].sort((e, t) => e - t)) {
|
|
66
|
+
let n = [...new Set(e.get(t) ?? [])].sort((e, t) => e - t), r = [...s.get(t) ?? []].filter((e) => !n.includes(e)).sort((e, t) => e - t);
|
|
67
|
+
(n.length > 0 || r.length > 0) && l.push({
|
|
68
|
+
islandId: t,
|
|
69
|
+
triangles: n,
|
|
70
|
+
mirrored: r
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
let u = l.find((e) => e.islandId === t) ?? l[0];
|
|
74
|
+
return {
|
|
75
|
+
islandId: u?.islandId ?? t,
|
|
76
|
+
triangles: u?.triangles ?? [],
|
|
77
|
+
mirrored: u?.mirrored ?? [],
|
|
78
|
+
entries: l
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function w(e, t, n, r) {
|
|
82
|
+
let i = d(e), a = n === "crease" ? l(i, t, r.creaseDeg) : [t], o = /* @__PURE__ */ new Map();
|
|
83
|
+
for (let e of p(r.current)) e.triangles.length > 0 && o.set(e.islandId, [...e.triangles]);
|
|
84
|
+
let s = new Set(o.get(e.id) ?? []);
|
|
24
85
|
for (let e of a) r.remove ? s.delete(e) : s.add(e);
|
|
25
|
-
return
|
|
86
|
+
return s.size > 0 ? o.set(e.id, [...s].sort((e, t) => e - t)) : o.delete(e.id), C(o, e.id, r.mirrorX, r.allIslands?.length ? r.allIslands : [e], r.excludeMirrorIds);
|
|
26
87
|
}
|
|
27
|
-
function
|
|
88
|
+
function T(e, t) {
|
|
28
89
|
if (t.length < 2) return t.map((e) => [
|
|
29
90
|
e[0],
|
|
30
91
|
e[1],
|
|
31
92
|
e[2]
|
|
32
93
|
]);
|
|
33
|
-
let n =
|
|
94
|
+
let n = d(e), r = t.map((e) => h(n, e)), i = [], a = t.length >= 3 ? r.length : r.length - 1;
|
|
34
95
|
for (let e = 0; e < a; e++) {
|
|
35
|
-
let o =
|
|
96
|
+
let o = m(n, r[e], r[(e + 1) % r.length]) ?? [r[e], r[(e + 1) % r.length]];
|
|
36
97
|
for (let r of o.slice(0, e === a - 1 && t.length < 3 ? void 0 : -1)) i.push([
|
|
37
98
|
n.points[r * 3],
|
|
38
99
|
n.points[r * 3 + 1],
|
|
@@ -41,31 +102,31 @@ function _(e, t) {
|
|
|
41
102
|
}
|
|
42
103
|
return t.length >= 3 && i.length > 0 && i.push([...i[0]]), i;
|
|
43
104
|
}
|
|
44
|
-
function
|
|
105
|
+
function E(e, t, n) {
|
|
45
106
|
if (t.length < 3) throw Error("Place at least 3 seam dots around the panel first.");
|
|
46
|
-
let
|
|
47
|
-
if (new Set(
|
|
48
|
-
let
|
|
49
|
-
for (let e = 0; e <
|
|
50
|
-
let t =
|
|
51
|
-
if (!t) throw Error(`No mesh edge path connects dot ${e + 1} to dot ${(e + 1) %
|
|
52
|
-
for (let e of t.slice(0, -1))
|
|
53
|
-
}
|
|
54
|
-
let
|
|
55
|
-
for (let e = 0; e <
|
|
56
|
-
let
|
|
57
|
-
if (!
|
|
58
|
-
let
|
|
59
|
-
if (new Set(
|
|
60
|
-
let
|
|
61
|
-
return
|
|
107
|
+
let r = d(e), i = t.map((e) => h(r, e));
|
|
108
|
+
if (new Set(i).size !== i.length) throw Error("Two dots snapped to the same vertex — spread dots apart or enable Split Coarse Edges.");
|
|
109
|
+
let a = [], l = /* @__PURE__ */ new Set();
|
|
110
|
+
for (let e = 0; e < i.length; e++) {
|
|
111
|
+
let t = m(r, i[e], i[(e + 1) % i.length], l, n.exact ? s : c);
|
|
112
|
+
if (!t) throw Error(`No mesh edge path connects dot ${e + 1} to dot ${(e + 1) % i.length + 1}.`);
|
|
113
|
+
for (let e of t.slice(0, -1)) a.push(e), l.add(e);
|
|
114
|
+
}
|
|
115
|
+
let f = /* @__PURE__ */ new Set();
|
|
116
|
+
for (let e = 0; e < a.length; e++) f.add(o(a[e], a[(e + 1) % a.length]));
|
|
117
|
+
let p = [...f].map((e) => r.edgeTriangles.get(e) ?? []).find((e) => e.length === 2);
|
|
118
|
+
if (!p) throw Error("Loop runs only along open mesh border — nothing enclosed to peel.");
|
|
119
|
+
let g = u(r, p[0], (e) => !f.has(e));
|
|
120
|
+
if (new Set(g).has(p[1])) throw Error("Loop didn't enclose an isolated patch — add another dot along the shutline.");
|
|
121
|
+
let _ = u(r, p[1], (e) => !f.has(e)), v = (e) => e.reduce((e, t) => e + r.areas[t], 0), y = v(g) <= v(_) ? g : _;
|
|
122
|
+
return C(/* @__PURE__ */ new Map([[e.id, y]]), e.id, n.mirrorX, n.allIslands?.length ? n.allIslands : [e], n.excludeMirrorIds);
|
|
62
123
|
}
|
|
63
|
-
function
|
|
64
|
-
let
|
|
124
|
+
function D(e, t, n = .28) {
|
|
125
|
+
let r = e.index ? e.toNonIndexed() : e.clone(), a = Object.keys(r.attributes), s = a.map((e) => r.getAttribute(e).itemSize), c = a.slice(0, a.indexOf("position")).reduce((e, t, n) => e + s[n], 0), l = r.getAttribute("position").count, u = (e) => {
|
|
65
126
|
let t = [];
|
|
66
|
-
return
|
|
67
|
-
let
|
|
68
|
-
for (let n = 0; n < s[
|
|
127
|
+
return a.forEach((n, i) => {
|
|
128
|
+
let a = r.getAttribute(n);
|
|
129
|
+
for (let n = 0; n < s[i]; n++) t.push(a.getComponent(e, n));
|
|
69
130
|
}), t;
|
|
70
131
|
}, d = [];
|
|
71
132
|
for (let e = 0; e * 3 + 2 < l; e++) d.push([
|
|
@@ -73,54 +134,54 @@ function y(e, t, i = .28) {
|
|
|
73
134
|
u(e * 3 + 1),
|
|
74
135
|
u(e * 3 + 2)
|
|
75
136
|
]);
|
|
76
|
-
let
|
|
137
|
+
let f = d.length, p = (e) => new _.Vector3(e[c], e[c + 1], e[c + 2]), m = (e, t, n) => e.map((e, r) => e + (t[r] - e) * n), h = i(r);
|
|
77
138
|
for (let e = 0; e < t.length; e++) {
|
|
78
|
-
let
|
|
139
|
+
let r = new _.Vector3(...t[e]), i = new _.Vector3(...t[(e + 1) % t.length]), a = i.clone().sub(r), s = a.length();
|
|
79
140
|
if (s < 1e-7) continue;
|
|
80
|
-
|
|
81
|
-
let c =
|
|
82
|
-
for (let e = 0; e <
|
|
141
|
+
a.divideScalar(s);
|
|
142
|
+
let c = r.clone().add(i).multiplyScalar(.5), l = new _.Vector3(), u = new _.Vector3();
|
|
143
|
+
for (let e = 0; e < h.triangleCount; e++) {
|
|
83
144
|
u.set(0, 0, 0);
|
|
84
|
-
for (let t = 0; t < 3; t++) u.add(new
|
|
85
|
-
u.multiplyScalar(1 / 3).distanceTo(c) <= Math.max(s, .25) && l.addScaledVector(new
|
|
145
|
+
for (let t = 0; t < 3; t++) u.add(new _.Vector3().fromArray(h.points, h.corners[e * 3 + t] * 3));
|
|
146
|
+
u.multiplyScalar(1 / 3).distanceTo(c) <= Math.max(s, .25) && l.addScaledVector(new _.Vector3().fromArray(h.normals, e * 3), h.areas[e]);
|
|
86
147
|
}
|
|
87
|
-
let
|
|
148
|
+
let f = l.lengthSq() > 0 ? l.normalize() : new _.Vector3(0, 1, 0), v = new _.Vector3().crossVectors(a, f);
|
|
88
149
|
if (v.lengthSq() < 1e-12) continue;
|
|
89
150
|
v.normalize();
|
|
90
|
-
let y = (e) => v.dot(e) - v.dot(
|
|
91
|
-
let t =
|
|
151
|
+
let y = (e) => v.dot(e) - v.dot(r), b = 1e-6, x = /* @__PURE__ */ new Map(), S = (e) => {
|
|
152
|
+
let t = p(e), n = g(t.x, t.y, t.z), r = x.get(n);
|
|
92
153
|
return r === void 0 && (r = x.size, x.set(n, r)), r;
|
|
93
154
|
}, C = d.map((e) => {
|
|
94
|
-
let t = e.map((e) => y(
|
|
95
|
-
if (n === 0 ||
|
|
96
|
-
let
|
|
155
|
+
let t = e.map((e) => y(p(e))), n = t.filter((e) => e > b).length, r = t.filter((e) => e < -1e-6).length;
|
|
156
|
+
if (n === 0 || r === 0) return null;
|
|
157
|
+
let i = n === 1 ? t.findIndex((e) => e > b) : t.findIndex((e) => e < -1e-6), [a, s, c] = [
|
|
97
158
|
0,
|
|
98
159
|
1,
|
|
99
160
|
2
|
|
100
|
-
].map((t) => e[(
|
|
161
|
+
].map((t) => e[(i + t) % 3]), [l, u, d] = [
|
|
101
162
|
0,
|
|
102
163
|
1,
|
|
103
164
|
2
|
|
104
|
-
].map((e) => t[(
|
|
165
|
+
].map((e) => t[(i + e) % 3]), f = Math.abs(u) <= b ? null : m(a, s, l / (l - u)), h = Math.abs(d) <= b ? null : m(a, c, l / (l - d));
|
|
105
166
|
return {
|
|
106
|
-
c0:
|
|
167
|
+
c0: a,
|
|
107
168
|
c1: s,
|
|
108
169
|
c2: c,
|
|
109
170
|
p01: f,
|
|
110
|
-
p02:
|
|
111
|
-
k01: f ?
|
|
112
|
-
k02:
|
|
113
|
-
chord: [f ?? s,
|
|
171
|
+
p02: h,
|
|
172
|
+
k01: f ? o(S(a), S(s)) : -1,
|
|
173
|
+
k02: h ? o(S(a), S(c)) : -1,
|
|
174
|
+
chord: [f ?? s, h ?? c]
|
|
114
175
|
};
|
|
115
176
|
}), w = /* @__PURE__ */ new Set();
|
|
116
177
|
for (let e of C) {
|
|
117
178
|
if (!e) continue;
|
|
118
|
-
let t = Infinity,
|
|
119
|
-
for (let
|
|
120
|
-
let e =
|
|
121
|
-
t = Math.min(t, s),
|
|
179
|
+
let t = Infinity, i = -Infinity, o = Infinity;
|
|
180
|
+
for (let n of e.chord) {
|
|
181
|
+
let e = p(n).sub(r), s = e.dot(a);
|
|
182
|
+
t = Math.min(t, s), i = Math.max(i, s), o = Math.min(o, Math.abs(e.dot(f)));
|
|
122
183
|
}
|
|
123
|
-
|
|
184
|
+
i >= -1e-6 && t <= s + b && o <= n && (e.p01 && w.add(e.k01), e.p02 && w.add(e.k02));
|
|
124
185
|
}
|
|
125
186
|
let T = [];
|
|
126
187
|
d.forEach((e, t) => {
|
|
@@ -161,47 +222,100 @@ function y(e, t, i = .28) {
|
|
|
161
222
|
]);
|
|
162
223
|
}), d = T;
|
|
163
224
|
}
|
|
164
|
-
let v = new
|
|
165
|
-
return
|
|
166
|
-
let n = s[t],
|
|
225
|
+
let v = new _.BufferGeometry(), y = 0;
|
|
226
|
+
return a.forEach((e, t) => {
|
|
227
|
+
let n = s[t], i = new Float32Array(d.length * 3 * n);
|
|
167
228
|
d.forEach((e, t) => {
|
|
168
|
-
for (let
|
|
169
|
-
}), v.setAttribute(e, new
|
|
229
|
+
for (let r = 0; r < 3; r++) for (let a = 0; a < n; a++) i[(t * 3 + r) * n + a] = e[r][y + a];
|
|
230
|
+
}), v.setAttribute(e, new _.BufferAttribute(i, n, r.getAttribute(e).normalized)), y += n;
|
|
170
231
|
}), v.getAttribute("normal") || v.computeVertexNormals(), v.computeBoundingBox(), v.computeBoundingSphere(), {
|
|
171
232
|
geometry: v,
|
|
172
|
-
added: d.length -
|
|
233
|
+
added: d.length - f
|
|
173
234
|
};
|
|
174
235
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
let
|
|
179
|
-
|
|
180
|
-
let
|
|
181
|
-
|
|
236
|
+
function O(e) {
|
|
237
|
+
if (e.length === 0) return new _.BufferGeometry();
|
|
238
|
+
if (e.length === 1) return e[0];
|
|
239
|
+
let t = Object.keys(e[0].attributes).filter((t) => e.every((e) => !!e.getAttribute(t))), n = e.reduce((e, t) => e + (t.getAttribute("position")?.count ?? 0), 0), r = new _.BufferGeometry();
|
|
240
|
+
for (let i of t) {
|
|
241
|
+
let t = e[0].getAttribute(i).itemSize, a = new Float32Array(n * t), o = 0;
|
|
242
|
+
for (let n of e) {
|
|
243
|
+
let e = n.getAttribute(i);
|
|
244
|
+
for (let n = 0; n < e.count; n++) for (let r = 0; r < t; r++) a[(o + n) * t + r] = e.getComponent(n, r);
|
|
245
|
+
o += e.count;
|
|
246
|
+
}
|
|
247
|
+
r.setAttribute(i, new _.BufferAttribute(a, t));
|
|
248
|
+
}
|
|
249
|
+
for (let t of e) t.dispose();
|
|
250
|
+
return r.getAttribute("normal") || r.computeVertexNormals(), r.computeBoundingBox(), r.computeBoundingSphere(), r;
|
|
251
|
+
}
|
|
252
|
+
function k(e, n, r, i) {
|
|
253
|
+
let a = new Map(e.map((e) => [e.id, e])), o = p(n).filter((e) => a.has(e.islandId) && (e.triangles.length > 0 || e.mirrored.length > 0));
|
|
254
|
+
if (o.length === 0) throw Error("Selected surface island no longer exists.");
|
|
255
|
+
let s = a.get(o[0].islandId).mesh.parent, c = i ?? s;
|
|
256
|
+
if (!i && c) for (; c.parent;) c = c.parent;
|
|
257
|
+
if (!c) throw Error("Selected island mesh has no parent scene.");
|
|
258
|
+
let l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = (e, t, n) => {
|
|
259
|
+
let r = e.get(t);
|
|
260
|
+
r ? r.push(n) : e.set(t, [n]);
|
|
261
|
+
};
|
|
262
|
+
for (let e of o) {
|
|
263
|
+
let n = a.get(e.islandId), r = l.get(n.mesh);
|
|
264
|
+
r || (r = /* @__PURE__ */ new Set(), l.set(n.mesh, r));
|
|
265
|
+
for (let t of e.triangles) r.add(n.triangleIndices[t]);
|
|
266
|
+
for (let t of e.mirrored) r.add(n.triangleIndices[t]);
|
|
267
|
+
e.triangles.length > 0 && f(u, n.material, t(n.geometry, e.triangles)), e.mirrored.length > 0 && f(d, n.material, t(n.geometry, e.mirrored));
|
|
268
|
+
}
|
|
269
|
+
let m = [], h = (e, t) => {
|
|
270
|
+
let n = 0;
|
|
271
|
+
for (let [r, i] of e) {
|
|
272
|
+
let e = new _.Mesh(O(i), r);
|
|
273
|
+
e.name = n === 0 ? t : `${t}_${n}`, c.add(e), m.push(e), n++;
|
|
274
|
+
}
|
|
182
275
|
};
|
|
183
|
-
|
|
184
|
-
let
|
|
185
|
-
for (let e
|
|
186
|
-
|
|
187
|
-
|
|
276
|
+
h(u, r), h(d, `${r}_mirror`);
|
|
277
|
+
let g = /* @__PURE__ */ new Map();
|
|
278
|
+
for (let [e, n] of l) {
|
|
279
|
+
let r = e.geometry, i = r.getAttribute("position"), a = r.getIndex(), o = i ? Math.floor((a ? a.count : i.count) / 3) : 0;
|
|
280
|
+
g.set(e, r);
|
|
281
|
+
let s = [];
|
|
282
|
+
for (let e = 0; e < o; e++) n.has(e) || s.push(e);
|
|
283
|
+
e.geometry = s.length > 0 ? t(r, s) : new _.BufferGeometry();
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
mintedMeshes: m,
|
|
188
287
|
undo: () => {
|
|
189
|
-
|
|
190
|
-
for (let e of
|
|
288
|
+
for (let [e, t] of g) e.geometry.dispose(), e.geometry = t;
|
|
289
|
+
for (let e of m) e.removeFromParent(), e.geometry.dispose();
|
|
191
290
|
}
|
|
192
291
|
};
|
|
193
292
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
293
|
+
function A(e, t, n) {
|
|
294
|
+
return k([e], t, n);
|
|
295
|
+
}
|
|
296
|
+
function j(e, t) {
|
|
297
|
+
let n = (e) => `${e.mesh.uuid}|${e.triangleIndices.length}|${e.center.map((e) => e.toFixed(4)).join(",")}`, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
|
|
196
298
|
for (let e of t) {
|
|
197
299
|
let t = n(e), i = r.get(t);
|
|
198
300
|
i ? i.push(e.id) : r.set(t, [e.id]);
|
|
199
301
|
}
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
|
|
302
|
+
for (let t of e) {
|
|
303
|
+
let e = r.get(n(t))?.shift() ?? null;
|
|
304
|
+
e !== null && i.add(e), a.set(t.id, e);
|
|
305
|
+
}
|
|
306
|
+
for (let n of e) {
|
|
307
|
+
if (a.get(n.id) !== null) continue;
|
|
308
|
+
let e = null, r = .03;
|
|
309
|
+
for (let a of t) {
|
|
310
|
+
if (i.has(a.id) || a.mesh.uuid !== n.mesh.uuid) continue;
|
|
311
|
+
let t = Math.hypot(a.center[0] - n.center[0], a.center[1] - n.center[1], a.center[2] - n.center[2]) + Math.hypot(a.size[0] - n.size[0], a.size[1] - n.size[1], a.size[2] - n.size[2]);
|
|
312
|
+
t <= r && (r = t, e = a.id);
|
|
313
|
+
}
|
|
314
|
+
e !== null && (i.add(e), a.set(n.id, e));
|
|
315
|
+
}
|
|
316
|
+
return a;
|
|
203
317
|
}
|
|
204
|
-
function
|
|
318
|
+
function M(e, t, n) {
|
|
205
319
|
let r = e.find((e) => e.id === t);
|
|
206
320
|
if (!r || Math.abs(r.center[0]) <= .08) return null;
|
|
207
321
|
let i = Math.max(...r.size, .15), a = null, o = .55;
|
|
@@ -212,43 +326,22 @@ function S(e, t, n) {
|
|
|
212
326
|
}
|
|
213
327
|
return a;
|
|
214
328
|
}
|
|
215
|
-
function
|
|
216
|
-
let i = e
|
|
329
|
+
function N(e, n, r = .004) {
|
|
330
|
+
let i = t(e, n), a = i.getAttribute("position"), o = i.getAttribute("normal");
|
|
217
331
|
if (a && o) {
|
|
218
332
|
for (let e = 0; e < a.count; e++) a.setXYZ(e, a.getX(e) + o.getX(e) * r, a.getY(e) + o.getY(e) * r, a.getZ(e) + o.getZ(e) * r);
|
|
219
333
|
a.needsUpdate = !0;
|
|
220
334
|
}
|
|
221
335
|
return i;
|
|
222
336
|
}
|
|
223
|
-
function
|
|
224
|
-
let
|
|
225
|
-
|
|
226
|
-
let
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
o.
|
|
232
|
-
let s = new p.Mesh(i, new p.MeshStandardMaterial({
|
|
233
|
-
color: "#1b2028",
|
|
234
|
-
roughness: .92,
|
|
235
|
-
metalness: .05,
|
|
236
|
-
flatShading: !0
|
|
237
|
-
}));
|
|
238
|
-
s.name = `${n}_tire`;
|
|
239
|
-
let c = new p.Mesh(a, new p.MeshStandardMaterial({
|
|
240
|
-
color: "#cbd5e1",
|
|
241
|
-
roughness: .36,
|
|
242
|
-
metalness: .72,
|
|
243
|
-
flatShading: !0
|
|
244
|
-
}));
|
|
245
|
-
c.name = `${n}_rim`;
|
|
246
|
-
let l = new p.Mesh(o, new p.MeshStandardMaterial({
|
|
247
|
-
color: "#f59e0b",
|
|
248
|
-
roughness: .45,
|
|
249
|
-
metalness: .6,
|
|
250
|
-
flatShading: !0
|
|
251
|
-
}));
|
|
252
|
-
return l.name = `${n}_hub`, r.add(s, c, l), r;
|
|
337
|
+
function P(e, t, n, r = .0045) {
|
|
338
|
+
let i = p(t);
|
|
339
|
+
if (i.length === 0) return null;
|
|
340
|
+
let a = new Map(e.map((e) => [e.id, e])), o = [];
|
|
341
|
+
for (let e of i) {
|
|
342
|
+
let t = e[n], i = a.get(e.islandId);
|
|
343
|
+
i && t.length > 0 && o.push(N(i.geometry, t, r));
|
|
344
|
+
}
|
|
345
|
+
return o.length > 0 ? O(o) : null;
|
|
253
346
|
}
|
|
254
|
-
export {
|
|
347
|
+
export { n as CHOP_ROLES, P as buildMultiSelectionOverlay, N as buildSelectionOverlayGeometry, i as buildSurfaceTopology, a as countSelectionFaces, e as createFleet12GonWheelGroup, M as findMirrorIslandId, l as floodFillByCrease, d as getIslandTopology, f as mirrorTriangles, k as peelFaceSelection, A as peelIslandSelection, T as previewLoopPolyline, D as refineMeshAlongLoop, j as remapIslandIds, w as selectFacesByClick, E as selectFacesByLoop, p as selectionEntries };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { MeshIsland } from "./meshIslands.js";
|
|
3
3
|
export type SurfaceSelectMode = "island" | "crease" | "loop" | "triangle";
|
|
4
|
-
export type ChopPartRole = "door" | "hood" | "trunk" | "fender" | "bumper";
|
|
5
|
-
export type ActiveChopRole = "wheel" | ChopPartRole;
|
|
4
|
+
export type ChopPartRole = "door" | "hood" | "trunk" | "glass" | "fender" | "bumper";
|
|
5
|
+
export type ActiveChopRole = "wheel" | "propeller" | ChopPartRole;
|
|
6
6
|
export type CutVec3 = readonly [number, number, number];
|
|
7
7
|
export declare const CHOP_ROLES: ReadonlyArray<{
|
|
8
8
|
role: ActiveChopRole;
|
|
@@ -10,11 +10,22 @@ export declare const CHOP_ROLES: ReadonlyArray<{
|
|
|
10
10
|
color: string;
|
|
11
11
|
massKg: number;
|
|
12
12
|
}>;
|
|
13
|
+
export interface IslandFaceSlice {
|
|
14
|
+
readonly islandId: number;
|
|
15
|
+
readonly triangles: number[];
|
|
16
|
+
readonly mirrored: number[];
|
|
17
|
+
}
|
|
13
18
|
export interface FaceSelection {
|
|
14
19
|
readonly islandId: number;
|
|
15
20
|
readonly triangles: number[];
|
|
16
21
|
readonly mirrored: number[];
|
|
22
|
+
readonly entries?: readonly IslandFaceSlice[];
|
|
17
23
|
}
|
|
24
|
+
export declare function selectionEntries(sel: FaceSelection | null | undefined): readonly IslandFaceSlice[];
|
|
25
|
+
export declare function countSelectionFaces(sel: FaceSelection | null | undefined): {
|
|
26
|
+
primary: number;
|
|
27
|
+
mirrored: number;
|
|
28
|
+
};
|
|
18
29
|
export interface SurfaceTopology {
|
|
19
30
|
readonly geometry: THREE.BufferGeometry;
|
|
20
31
|
readonly triangleCount: number;
|
|
@@ -7,6 +7,12 @@ var t = [
|
|
|
7
7
|
color: "#00E5FF",
|
|
8
8
|
massKg: 22
|
|
9
9
|
},
|
|
10
|
+
{
|
|
11
|
+
role: "propeller",
|
|
12
|
+
label: "Propeller / Rotor",
|
|
13
|
+
color: "#EC4899",
|
|
14
|
+
massKg: 14
|
|
15
|
+
},
|
|
10
16
|
{
|
|
11
17
|
role: "door",
|
|
12
18
|
label: "Door (Hinge)",
|
|
@@ -25,6 +31,12 @@ var t = [
|
|
|
25
31
|
color: "#A855F7",
|
|
26
32
|
massKg: 16
|
|
27
33
|
},
|
|
34
|
+
{
|
|
35
|
+
role: "glass",
|
|
36
|
+
label: "Glass / Window",
|
|
37
|
+
color: "#7DD3FC",
|
|
38
|
+
massKg: 6
|
|
39
|
+
},
|
|
28
40
|
{
|
|
29
41
|
role: "fender",
|
|
30
42
|
label: "Fender Panel",
|
|
@@ -37,22 +49,38 @@ var t = [
|
|
|
37
49
|
color: "#38BDF8",
|
|
38
50
|
massKg: 12
|
|
39
51
|
}
|
|
40
|
-
]
|
|
41
|
-
function
|
|
42
|
-
|
|
52
|
+
];
|
|
53
|
+
function n(e) {
|
|
54
|
+
return e ? e.entries && e.entries.length > 0 ? e.entries : e.triangles.length > 0 || e.mirrored.length > 0 ? [{
|
|
55
|
+
islandId: e.islandId,
|
|
56
|
+
triangles: e.triangles,
|
|
57
|
+
mirrored: e.mirrored
|
|
58
|
+
}] : [] : [];
|
|
59
|
+
}
|
|
60
|
+
function r(e) {
|
|
61
|
+
let t = 0, r = 0;
|
|
62
|
+
for (let i of n(e)) t += i.triangles.length, r += i.mirrored.length;
|
|
63
|
+
return {
|
|
64
|
+
primary: t,
|
|
65
|
+
mirrored: r
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
var i = 2 ** 26, a = .08, o = .65, s = /* @__PURE__ */ new WeakMap(), c = (e, t) => e < t ? e * i + t : t * i + e, l = (e, t, n) => `${Math.round(e * 1e4)},${Math.round(t * 1e4)},${Math.round(n * 1e4)}`;
|
|
69
|
+
function u(e) {
|
|
70
|
+
let t = s.get(e.geometry);
|
|
43
71
|
if (t) return t;
|
|
44
|
-
let n =
|
|
45
|
-
return
|
|
72
|
+
let n = d(e.geometry);
|
|
73
|
+
return s.set(e.geometry, n), n;
|
|
46
74
|
}
|
|
47
|
-
function
|
|
48
|
-
let n = t.getAttribute("position"), r = t.getIndex(), i = n ? r ? r.count : n.count : 0, a = Math.floor(i / 3),
|
|
75
|
+
function d(t) {
|
|
76
|
+
let n = t.getAttribute("position"), r = t.getIndex(), i = n ? r ? r.count : n.count : 0, a = Math.floor(i / 3), o = new Uint32Array(a * 3), s = /* @__PURE__ */ new Map(), u = [];
|
|
49
77
|
for (let e = 0; e < a * 3; e++) {
|
|
50
|
-
let t = r ? r.getX(e) : e, i = n.getX(t), a = n.getY(t),
|
|
51
|
-
f === void 0 && (f =
|
|
78
|
+
let t = r ? r.getX(e) : e, i = n.getX(t), a = n.getY(t), c = n.getZ(t), d = l(i, a, c), f = s.get(d);
|
|
79
|
+
f === void 0 && (f = s.size, s.set(d, f), u.push(i, a, c)), o[e] = f;
|
|
52
80
|
}
|
|
53
|
-
let d = Float32Array.from(u), f =
|
|
81
|
+
let d = Float32Array.from(u), f = s.size, p = new Float32Array(a * 3), m = new Float32Array(a), h = /* @__PURE__ */ new Map(), g = Array.from({ length: f }, () => /* @__PURE__ */ new Set()), _ = new e.Vector3(), v = new e.Vector3(), y = new e.Vector3(), b = new e.Vector3();
|
|
54
82
|
for (let e = 0; e < a; e++) {
|
|
55
|
-
let t =
|
|
83
|
+
let t = o[e * 3], n = o[e * 3 + 1], r = o[e * 3 + 2];
|
|
56
84
|
_.fromArray(d, t * 3), v.fromArray(d, n * 3), y.fromArray(d, r * 3), b.crossVectors(v.sub(_), y.sub(_));
|
|
57
85
|
let i = b.length();
|
|
58
86
|
m[e] = i * .5, i > 0 && b.divideScalar(i).toArray(p, e * 3);
|
|
@@ -62,7 +90,7 @@ function l(t) {
|
|
|
62
90
|
[r, t]
|
|
63
91
|
]) {
|
|
64
92
|
if (i === a) continue;
|
|
65
|
-
let t =
|
|
93
|
+
let t = c(i, a), n = h.get(t);
|
|
66
94
|
n ? n.push(e) : h.set(t, [e]), g[i].add(a), g[a].add(i);
|
|
67
95
|
}
|
|
68
96
|
}
|
|
@@ -70,7 +98,7 @@ function l(t) {
|
|
|
70
98
|
geometry: t,
|
|
71
99
|
triangleCount: a,
|
|
72
100
|
vertexCount: f,
|
|
73
|
-
corners:
|
|
101
|
+
corners: o,
|
|
74
102
|
points: d,
|
|
75
103
|
normals: p,
|
|
76
104
|
areas: m,
|
|
@@ -78,26 +106,26 @@ function l(t) {
|
|
|
78
106
|
neighbors: g.map((e) => [...e])
|
|
79
107
|
};
|
|
80
108
|
}
|
|
81
|
-
function
|
|
109
|
+
function f(e, t, n) {
|
|
82
110
|
if (t < 0 || t >= e.triangleCount) return [];
|
|
83
111
|
let r = new Uint8Array(e.triangleCount), i = [t];
|
|
84
112
|
r[t] = 1;
|
|
85
113
|
for (let t = 0; t < i.length; t++) {
|
|
86
114
|
let a = i[t];
|
|
87
115
|
for (let t = 0; t < 3; t++) {
|
|
88
|
-
let
|
|
89
|
-
if (
|
|
90
|
-
let l = o
|
|
116
|
+
let o = e.corners[a * 3 + t], s = e.corners[a * 3 + (t + 1) % 3];
|
|
117
|
+
if (o === s) continue;
|
|
118
|
+
let l = c(o, s);
|
|
91
119
|
for (let t of e.edgeTriangles.get(l) ?? []) !r[t] && n(l, a, t) && (r[t] = 1, i.push(t));
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
return i.sort((e, t) => e - t);
|
|
95
123
|
}
|
|
96
|
-
function
|
|
124
|
+
function p(e, t, n = 32) {
|
|
97
125
|
let r = Math.cos(n * Math.PI / 180), i = e.normals;
|
|
98
|
-
return
|
|
126
|
+
return f(e, t, (e, t, n) => i[t * 3] * i[n * 3] + i[t * 3 + 1] * i[n * 3 + 1] + i[t * 3 + 2] * i[n * 3 + 2] >= r);
|
|
99
127
|
}
|
|
100
|
-
function
|
|
128
|
+
function m(e, t, n = .03) {
|
|
101
129
|
let r = Math.max(n, 1e-4), i = (e, t, n) => `${Math.floor(e / r)},${Math.floor(t / r)},${Math.floor(n / r)}`, a = /* @__PURE__ */ new Map(), o = new Float32Array(e.triangleCount * 3);
|
|
102
130
|
for (let t = 0; t < e.triangleCount; t++) {
|
|
103
131
|
let n = 0, r = 0, s = 0;
|
|
@@ -121,19 +149,19 @@ function f(e, t, n = .03) {
|
|
|
121
149
|
}
|
|
122
150
|
return [...c].sort((e, t) => e - t);
|
|
123
151
|
}
|
|
124
|
-
function
|
|
152
|
+
function h(e, t, n) {
|
|
125
153
|
let r = e.points;
|
|
126
154
|
return Math.hypot(r[t * 3] - r[n * 3], r[t * 3 + 1] - r[n * 3 + 1], r[t * 3 + 2] - r[n * 3 + 2]);
|
|
127
155
|
}
|
|
128
|
-
function
|
|
129
|
-
let r = e.edgeTriangles.get(
|
|
156
|
+
function g(e, t, n) {
|
|
157
|
+
let r = e.edgeTriangles.get(c(t, n)), i = 1;
|
|
130
158
|
if (r && r.length === 2) {
|
|
131
|
-
let t = e.normals, n = r[0],
|
|
132
|
-
|
|
159
|
+
let t = e.normals, n = r[0], a = r[1], o = t[n * 3] * t[a * 3] + t[n * 3 + 1] * t[a * 3 + 1] + t[n * 3 + 2] * t[a * 3 + 2];
|
|
160
|
+
i = Math.min(1, Math.acos(Math.max(-1, Math.min(1, o))) / (Math.PI / 2));
|
|
133
161
|
}
|
|
134
|
-
return
|
|
162
|
+
return h(e, t, n) * (1 - o * i);
|
|
135
163
|
}
|
|
136
|
-
function
|
|
164
|
+
function _(e, t) {
|
|
137
165
|
let n = 0, r = Infinity;
|
|
138
166
|
for (let i = 0; i < e.vertexCount; i++) {
|
|
139
167
|
let a = (e.points[i * 3] - t[0]) ** 2 + (e.points[i * 3 + 1] - t[1]) ** 2 + (e.points[i * 3 + 2] - t[2]) ** 2;
|
|
@@ -141,7 +169,7 @@ function h(e, t) {
|
|
|
141
169
|
}
|
|
142
170
|
return n;
|
|
143
171
|
}
|
|
144
|
-
function
|
|
172
|
+
function v(e, t, n, r, i = g) {
|
|
145
173
|
if (t === n) return [t];
|
|
146
174
|
let a = new Float64Array(e.vertexCount).fill(Infinity), o = new Int32Array(e.vertexCount).fill(-1), s = [[0, t]];
|
|
147
175
|
a[t] = 0;
|
|
@@ -180,4 +208,4 @@ function g(e, t, n, r, i = m) {
|
|
|
180
208
|
for (let e = n; e !== t;) e = o[e], u.push(e);
|
|
181
209
|
return u.reverse();
|
|
182
210
|
}
|
|
183
|
-
export { t as CHOP_ROLES,
|
|
211
|
+
export { t as CHOP_ROLES, a as MIRROR_OFF_CENTER_M, d as buildSurfaceTopology, r as countSelectionFaces, c as edgeKey, h as edgeLength, g as edgeWeight, p as floodFillByCrease, f as floodTriangles, u as getIslandTopology, m as mirrorTriangles, n as selectionEntries, v as shortestEdgePath, _ as snapToVertex, l as weldKey };
|