@adatechnology/game-vehicles-three 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +786 -226
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.global.js
CHANGED
|
@@ -3745,11 +3745,11 @@ var GameVehiclesThree = (() => {
|
|
|
3745
3745
|
function installBoatsExtra(fx) {
|
|
3746
3746
|
const kit = fx.kit;
|
|
3747
3747
|
const THREE = kit.THREE;
|
|
3748
|
-
const
|
|
3748
|
+
const shared2 = fx.shared;
|
|
3749
3749
|
const trl = fx.t;
|
|
3750
3750
|
const lbl = fx.label;
|
|
3751
|
-
if (!kit || !
|
|
3752
|
-
const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, DS = THREE.DoubleSide, EA =
|
|
3751
|
+
if (!kit || !shared2.EA) return;
|
|
3752
|
+
const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, DS = THREE.DoubleSide, EA = shared2.EA, tb = EA.tab;
|
|
3753
3753
|
function sailGeo(T, Hd, C, cam, o) {
|
|
3754
3754
|
o = o || {};
|
|
3755
3755
|
const nu = o.nu || 10, nv = o.nv || 16, pos = [], idx = [], roach = o.roach || 0;
|
|
@@ -5236,7 +5236,7 @@ var GameVehiclesThree = (() => {
|
|
|
5236
5236
|
for (q = y0; q <= y1; q++) (BY[q] || (BY[q] = [])).push(k);
|
|
5237
5237
|
for (q = x0; q <= x1; q++) (BX[q] || (BX[q] = [])).push(k);
|
|
5238
5238
|
}
|
|
5239
|
-
const ray = new THREE.Ray(), tmp = new V3(), e1 = new V3(), e2 = new V3(),
|
|
5239
|
+
const ray = new THREE.Ray(), tmp = new V3(), e1 = new V3(), e2 = new V3(), cache2 = {};
|
|
5240
5240
|
const S = { bb, hw: W / 2 };
|
|
5241
5241
|
S.hit = function(o, dd) {
|
|
5242
5242
|
const d = dd.clone().normalize();
|
|
@@ -5260,9 +5260,9 @@ var GameVehiclesThree = (() => {
|
|
|
5260
5260
|
};
|
|
5261
5261
|
S.endX = function(E, y) {
|
|
5262
5262
|
const k = E + ":" + y.toFixed(3);
|
|
5263
|
-
if (
|
|
5263
|
+
if (cache2[k] != null) return cache2[k];
|
|
5264
5264
|
const h = S.hit(new V3(E * 10, y, 0), new V3(-E, 0, 0), E > 0 ? "F" : "R");
|
|
5265
|
-
return
|
|
5265
|
+
return cache2[k] = h ? h.p.x : E > 0 ? bb.max.x : bb.min.x;
|
|
5266
5266
|
};
|
|
5267
5267
|
return S;
|
|
5268
5268
|
}
|
|
@@ -9617,11 +9617,11 @@ var GameVehiclesThree = (() => {
|
|
|
9617
9617
|
function installHelicoptersExtra(fx) {
|
|
9618
9618
|
const kit = fx.kit;
|
|
9619
9619
|
const THREE = kit.THREE;
|
|
9620
|
-
const
|
|
9620
|
+
const shared2 = fx.shared;
|
|
9621
9621
|
const trl = fx.t;
|
|
9622
9622
|
const lbl = fx.label;
|
|
9623
9623
|
const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, G2 = kit.geo;
|
|
9624
|
-
const GH =
|
|
9624
|
+
const GH = shared2.GH;
|
|
9625
9625
|
function skids(c, o) {
|
|
9626
9626
|
const mat = o.mat || MT.steel, z = o.z, y = o.y || 0.07, out = [];
|
|
9627
9627
|
[1, -1].forEach(function(s) {
|
|
@@ -9768,7 +9768,7 @@ var GameVehiclesThree = (() => {
|
|
|
9768
9768
|
hood: false
|
|
9769
9769
|
},
|
|
9770
9770
|
function(c) {
|
|
9771
|
-
const EA =
|
|
9771
|
+
const EA = shared2.EA, col = "#1f4f8a", blue = c.paint(col), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
9772
9772
|
const ST = [
|
|
9773
9773
|
[1.6, 0.84, 0.92, 0.06, 2],
|
|
9774
9774
|
[1.5, 0.64, 1.22, 0.66, 2.2],
|
|
@@ -10103,7 +10103,7 @@ var GameVehiclesThree = (() => {
|
|
|
10103
10103
|
hood: false
|
|
10104
10104
|
},
|
|
10105
10105
|
function(c) {
|
|
10106
|
-
const EA =
|
|
10106
|
+
const EA = shared2.EA, wcol = "#eeece6", white = c.paint(wcol), mar = c.paint("#7a1e22"), gold = c.paint("#c49a3a"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
10107
10107
|
const ST = [
|
|
10108
10108
|
[2.62, 0.95, 1.06, 0.08, 2],
|
|
10109
10109
|
[2.48, 0.7, 1.45, 0.86, 2.2],
|
|
@@ -10488,7 +10488,7 @@ var GameVehiclesThree = (() => {
|
|
|
10488
10488
|
hood: false
|
|
10489
10489
|
},
|
|
10490
10490
|
function(c) {
|
|
10491
|
-
const EA =
|
|
10491
|
+
const EA = shared2.EA, navyC = "#1b2c52", navy = c.paint(navyC), white = c.paint("#ecebe6"), yel = c.paint("#d7b23a"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
10492
10492
|
const ST = [
|
|
10493
10493
|
[3.36, 1, 1.12, 0.08, 2],
|
|
10494
10494
|
[3.22, 0.76, 1.56, 0.96, 2.4],
|
|
@@ -10932,7 +10932,7 @@ var GameVehiclesThree = (() => {
|
|
|
10932
10932
|
hood: false
|
|
10933
10933
|
},
|
|
10934
10934
|
function(c) {
|
|
10935
|
-
const EA =
|
|
10935
|
+
const EA = shared2.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
|
|
10936
10936
|
c.meta.matte = true;
|
|
10937
10937
|
const cA = new THREE.Color("#3a4430"), cB = new THREE.Color("#66603f"), cC = new THREE.Color("#55613f"), cL = new THREE.Color("#8d958c");
|
|
10938
10938
|
function camo(x, y, z, under) {
|
|
@@ -14266,7 +14266,7 @@ var GameVehiclesThree = (() => {
|
|
|
14266
14266
|
for (q = y0; q <= y1; q++) (BY[q] || (BY[q] = [])).push(k);
|
|
14267
14267
|
for (q = x0; q <= x1; q++) (BX[q] || (BX[q] = [])).push(k);
|
|
14268
14268
|
}
|
|
14269
|
-
const ray = new THREE.Ray(), tmp = new V3(), e1 = new V3(), e2 = new V3(),
|
|
14269
|
+
const ray = new THREE.Ray(), tmp = new V3(), e1 = new V3(), e2 = new V3(), cache2 = {};
|
|
14270
14270
|
const S = { bb, hw: W / 2 };
|
|
14271
14271
|
S.hit = function(o, dd) {
|
|
14272
14272
|
const d = dd.clone().normalize();
|
|
@@ -14290,9 +14290,9 @@ var GameVehiclesThree = (() => {
|
|
|
14290
14290
|
};
|
|
14291
14291
|
S.endX = function(E, y) {
|
|
14292
14292
|
const k = E + ":" + y.toFixed(3);
|
|
14293
|
-
if (
|
|
14293
|
+
if (cache2[k] != null) return cache2[k];
|
|
14294
14294
|
const h = S.hit(new V3(E * 10, y, 0), new V3(-E, 0, 0), E > 0 ? "F" : "R");
|
|
14295
|
-
return
|
|
14295
|
+
return cache2[k] = h ? h.p.x : E > 0 ? bb.max.x : bb.min.x;
|
|
14296
14296
|
};
|
|
14297
14297
|
return S;
|
|
14298
14298
|
}
|
|
@@ -19988,7 +19988,7 @@ var GameVehiclesThree = (() => {
|
|
|
19988
19988
|
function installPlanesExtra(fx) {
|
|
19989
19989
|
const kit = fx.kit;
|
|
19990
19990
|
const THREE = kit.THREE;
|
|
19991
|
-
const
|
|
19991
|
+
const shared2 = fx.shared;
|
|
19992
19992
|
const trl = fx.t;
|
|
19993
19993
|
const lbl = fx.label;
|
|
19994
19994
|
const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, _DS = THREE.DoubleSide;
|
|
@@ -20140,7 +20140,7 @@ var GameVehiclesThree = (() => {
|
|
|
20140
20140
|
m.rotation.y += -s * Math.atan2(a - b, w);
|
|
20141
20141
|
return m;
|
|
20142
20142
|
}
|
|
20143
|
-
|
|
20143
|
+
shared2.GH = {
|
|
20144
20144
|
pose3,
|
|
20145
20145
|
starDecal,
|
|
20146
20146
|
rrect,
|
|
@@ -20174,7 +20174,7 @@ var GameVehiclesThree = (() => {
|
|
|
20174
20174
|
hood: false
|
|
20175
20175
|
},
|
|
20176
20176
|
function(c) {
|
|
20177
|
-
const EA =
|
|
20177
|
+
const EA = shared2.EA, yel = "#f0bd22";
|
|
20178
20178
|
const Q = pose3([1.62, -0.78], 0.25, [-3.24, -0.27], 0.075), P = Q.P, TH = Q.TH;
|
|
20179
20179
|
const grp = new THREE.Group();
|
|
20180
20180
|
grp.position.set(0, Q.Y0, 0);
|
|
@@ -20486,7 +20486,7 @@ var GameVehiclesThree = (() => {
|
|
|
20486
20486
|
});
|
|
20487
20487
|
const pd = pod(
|
|
20488
20488
|
c2,
|
|
20489
|
-
|
|
20489
|
+
shared2.EA,
|
|
20490
20490
|
P(1.4, -0.6).x,
|
|
20491
20491
|
P(-1.2, -0.45).x,
|
|
20492
20492
|
P(0.1, -0.66).y,
|
|
@@ -20523,7 +20523,7 @@ var GameVehiclesThree = (() => {
|
|
|
20523
20523
|
hood: false
|
|
20524
20524
|
},
|
|
20525
20525
|
function(c) {
|
|
20526
|
-
const EA =
|
|
20526
|
+
const EA = shared2.EA, wcol = "#ecebe6", white = c.paint(wcol), blue = c.paint("#1d4f8c"), grey = c.paint("#8e959a"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
20527
20527
|
const ST = [
|
|
20528
20528
|
[7.58, 1.5, 1.62, 0.08, 2],
|
|
20529
20529
|
[7.35, 1.3, 1.82, 0.56, 2.2],
|
|
@@ -20911,7 +20911,7 @@ var GameVehiclesThree = (() => {
|
|
|
20911
20911
|
hood: false
|
|
20912
20912
|
},
|
|
20913
20913
|
function(c) {
|
|
20914
|
-
const EA =
|
|
20914
|
+
const EA = shared2.EA, wcol = "#eceae3", white = c.paint(wcol), navy = c.paint("#1e2f55"), gold = c.paint("#c99a2e"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
20915
20915
|
const ST = [
|
|
20916
20916
|
[5, 2.26, 2.86, 0.62, 2.2],
|
|
20917
20917
|
[4.75, 2.08, 3, 0.98, 2.6],
|
|
@@ -21326,7 +21326,7 @@ var GameVehiclesThree = (() => {
|
|
|
21326
21326
|
hood: false
|
|
21327
21327
|
},
|
|
21328
21328
|
function(c) {
|
|
21329
|
-
const EA =
|
|
21329
|
+
const EA = shared2.EA, wcol = "#efeeea", white = c.paint(wcol), silver = c.paint("#7d868e", { metalness: 0.45, roughness: 0.35 }), navy = c.paint("#23324f"), blk = CM("#15161a", { roughness: 0.5 });
|
|
21330
21330
|
const ST = [
|
|
21331
21331
|
[6.3, 1.13, 1.2, 0.06, 2],
|
|
21332
21332
|
[6, 0.92, 1.44, 0.6, 2.1],
|
|
@@ -21707,7 +21707,7 @@ var GameVehiclesThree = (() => {
|
|
|
21707
21707
|
hood: false
|
|
21708
21708
|
},
|
|
21709
21709
|
function(c) {
|
|
21710
|
-
const EA =
|
|
21710
|
+
const EA = shared2.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
|
|
21711
21711
|
c.meta.matte = true;
|
|
21712
21712
|
const cA = new THREE.Color("#323f2b"), cB = new THREE.Color("#5f6d45"), cC = new THREE.Color("#7f8466"), cL = new THREE.Color("#a3abad");
|
|
21713
21713
|
function camo(x, z, y, under) {
|
|
@@ -24365,7 +24365,7 @@ var GameVehiclesThree = (() => {
|
|
|
24365
24365
|
function installWaterAir(fx) {
|
|
24366
24366
|
const kit = fx.kit;
|
|
24367
24367
|
const THREE = kit.THREE;
|
|
24368
|
-
const
|
|
24368
|
+
const shared2 = fx.shared;
|
|
24369
24369
|
const trl = fx.t;
|
|
24370
24370
|
const lbl = fx.label;
|
|
24371
24371
|
const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _paintCol = kit.paintColor, G2 = kit.geo, DS = THREE.DoubleSide, clamp3 = kit.clamp;
|
|
@@ -25040,7 +25040,7 @@ var GameVehiclesThree = (() => {
|
|
|
25040
25040
|
t.rotation.y += s > 0 ? -Math.atan(m) : Math.atan(m);
|
|
25041
25041
|
return t;
|
|
25042
25042
|
}
|
|
25043
|
-
|
|
25043
|
+
shared2.EA = {
|
|
25044
25044
|
colorize,
|
|
25045
25045
|
tab,
|
|
25046
25046
|
tabL,
|
|
@@ -25099,7 +25099,7 @@ var GameVehiclesThree = (() => {
|
|
|
25099
25099
|
hood: false
|
|
25100
25100
|
},
|
|
25101
25101
|
function(c) {
|
|
25102
|
-
const EA =
|
|
25102
|
+
const EA = shared2.EA, tb = EA.tab, alu = CM("#9aa1a6", { metalness: 0.65, roughness: 0.38, side: DS }), aluD = CM("#7d8489", { metalness: 0.6, roughness: 0.45, side: DS });
|
|
25103
25103
|
const L = 5, x0 = -2.5;
|
|
25104
25104
|
const H = EA.boatHull({
|
|
25105
25105
|
x0,
|
|
@@ -25251,7 +25251,7 @@ var GameVehiclesThree = (() => {
|
|
|
25251
25251
|
hood: false
|
|
25252
25252
|
},
|
|
25253
25253
|
function(c) {
|
|
25254
|
-
const EA =
|
|
25254
|
+
const EA = shared2.EA, tb = EA.tab, L = 7.26, x0 = -3.63;
|
|
25255
25255
|
const white = c.paint("#ecebe5", { roughness: 0.3, metalness: 0.1 }), navy = c.paint("#1f2f4a", { roughness: 0.3, metalness: 0.1 }), vinyl = CM("#e3ddd0", { roughness: 0.65 }), _vinylD = CM("#3c4a5c", { roughness: 0.65 }), teak = CM("#8a6a45", { roughness: 0.8 });
|
|
25256
25256
|
const H = EA.boatHull({
|
|
25257
25257
|
x0,
|
|
@@ -25498,7 +25498,7 @@ var GameVehiclesThree = (() => {
|
|
|
25498
25498
|
hood: false
|
|
25499
25499
|
},
|
|
25500
25500
|
function(c) {
|
|
25501
|
-
const EA =
|
|
25501
|
+
const EA = shared2.EA, tb = EA.tab, L = 11, x0 = -5.5;
|
|
25502
25502
|
const blue = c.paint("#2f5e86", { roughness: 0.7, metalness: 0.05 }), wht = c.paint("#e6e3da", { roughness: 0.7, metalness: 0.05 }), redP = c.paint("#7a2219", { roughness: 0.8, metalness: 0.05 }), wood = CM("#6b4a2e", { roughness: 0.85 }), deckW = CM("#8a6e4c", { roughness: 0.9, side: DS });
|
|
25503
25503
|
const H = EA.boatHull({
|
|
25504
25504
|
x0,
|
|
@@ -25802,7 +25802,7 @@ var GameVehiclesThree = (() => {
|
|
|
25802
25802
|
hood: false
|
|
25803
25803
|
},
|
|
25804
25804
|
function(c) {
|
|
25805
|
-
const EA =
|
|
25805
|
+
const EA = shared2.EA, white = "#ecebe6";
|
|
25806
25806
|
const paintW = c.paint(white);
|
|
25807
25807
|
const ST = [
|
|
25808
25808
|
[2.3, 0.98, 1.46, 0.7, 2.4],
|
|
@@ -26131,7 +26131,7 @@ var GameVehiclesThree = (() => {
|
|
|
26131
26131
|
hood: false
|
|
26132
26132
|
},
|
|
26133
26133
|
function(c) {
|
|
26134
|
-
const EA =
|
|
26134
|
+
const EA = shared2.EA, TH = 0.19, X0 = 0.3, Y0 = 1, cs = Math.cos(TH), sn = Math.sin(TH);
|
|
26135
26135
|
function P(x, y, z) {
|
|
26136
26136
|
return new V3(x * cs - y * sn + X0, x * sn + y * cs + Y0, z || 0);
|
|
26137
26137
|
}
|
|
@@ -26488,7 +26488,7 @@ var GameVehiclesThree = (() => {
|
|
|
26488
26488
|
hood: false
|
|
26489
26489
|
},
|
|
26490
26490
|
function(c) {
|
|
26491
|
-
const EA =
|
|
26491
|
+
const EA = shared2.EA, red = c.paint("#a9241e"), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
26492
26492
|
const ST = [
|
|
26493
26493
|
[1.96, 0.96, 1.06, 0.06, 2],
|
|
26494
26494
|
[1.85, 0.76, 1.4, 0.76, 2.2],
|
|
@@ -26814,7 +26814,7 @@ var GameVehiclesThree = (() => {
|
|
|
26814
26814
|
hood: false
|
|
26815
26815
|
},
|
|
26816
26816
|
function(c) {
|
|
26817
|
-
const EA =
|
|
26817
|
+
const EA = shared2.EA, org = c.paint("#d0531e"), white = c.paint("#e8e6df"), blk = CM("#1c1d1f", { roughness: 0.6 });
|
|
26818
26818
|
const ST = [
|
|
26819
26819
|
[3.34, 1, 1.12, 0.1, 2],
|
|
26820
26820
|
[3.2, 0.82, 1.48, 0.95, 2.2],
|
|
@@ -27176,11 +27176,11 @@ var GameVehiclesThree = (() => {
|
|
|
27176
27176
|
const groups = new Set(options.groups || fleetGroupIds);
|
|
27177
27177
|
const only = options.vehicles ? new Set(options.vehicles) : null;
|
|
27178
27178
|
const skip = new Set(options.exclude || []);
|
|
27179
|
-
const
|
|
27179
|
+
const shared2 = {};
|
|
27180
27180
|
const t = (key, vars) => kit.t("fleet." + key, vars);
|
|
27181
27181
|
return {
|
|
27182
27182
|
kit,
|
|
27183
|
-
shared,
|
|
27183
|
+
shared: shared2,
|
|
27184
27184
|
t,
|
|
27185
27185
|
label: (key) => ({ key, label: t("labels." + key) }),
|
|
27186
27186
|
register(spec, build) {
|
|
@@ -28520,12 +28520,12 @@ var GameVehiclesThree = (() => {
|
|
|
28520
28520
|
return triangles;
|
|
28521
28521
|
}
|
|
28522
28522
|
};
|
|
28523
|
-
function linkedList(data,
|
|
28523
|
+
function linkedList(data, start2, end, dim, clockwise) {
|
|
28524
28524
|
let i, last;
|
|
28525
|
-
if (clockwise === signedArea(data,
|
|
28526
|
-
for (i =
|
|
28525
|
+
if (clockwise === signedArea(data, start2, end, dim) > 0) {
|
|
28526
|
+
for (i = start2; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
28527
28527
|
} else {
|
|
28528
|
-
for (i = end - dim; i >=
|
|
28528
|
+
for (i = end - dim; i >= start2; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
28529
28529
|
}
|
|
28530
28530
|
if (last && equals(last, last.next)) {
|
|
28531
28531
|
removeNode(last);
|
|
@@ -28533,10 +28533,10 @@ var GameVehiclesThree = (() => {
|
|
|
28533
28533
|
}
|
|
28534
28534
|
return last;
|
|
28535
28535
|
}
|
|
28536
|
-
function filterPoints(
|
|
28537
|
-
if (!
|
|
28538
|
-
if (!end) end =
|
|
28539
|
-
let p =
|
|
28536
|
+
function filterPoints(start2, end) {
|
|
28537
|
+
if (!start2) return start2;
|
|
28538
|
+
if (!end) end = start2;
|
|
28539
|
+
let p = start2, again;
|
|
28540
28540
|
do {
|
|
28541
28541
|
again = false;
|
|
28542
28542
|
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
@@ -28615,8 +28615,8 @@ var GameVehiclesThree = (() => {
|
|
|
28615
28615
|
}
|
|
28616
28616
|
return true;
|
|
28617
28617
|
}
|
|
28618
|
-
function cureLocalIntersections(
|
|
28619
|
-
let p =
|
|
28618
|
+
function cureLocalIntersections(start2, triangles, dim) {
|
|
28619
|
+
let p = start2;
|
|
28620
28620
|
do {
|
|
28621
28621
|
const a = p.prev, b = p.next.next;
|
|
28622
28622
|
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
@@ -28625,14 +28625,14 @@ var GameVehiclesThree = (() => {
|
|
|
28625
28625
|
triangles.push(b.i / dim | 0);
|
|
28626
28626
|
removeNode(p);
|
|
28627
28627
|
removeNode(p.next);
|
|
28628
|
-
p =
|
|
28628
|
+
p = start2 = b;
|
|
28629
28629
|
}
|
|
28630
28630
|
p = p.next;
|
|
28631
|
-
} while (p !==
|
|
28631
|
+
} while (p !== start2);
|
|
28632
28632
|
return filterPoints(p);
|
|
28633
28633
|
}
|
|
28634
|
-
function splitEarcut(
|
|
28635
|
-
let a =
|
|
28634
|
+
function splitEarcut(start2, triangles, dim, minX, minY, invSize) {
|
|
28635
|
+
let a = start2;
|
|
28636
28636
|
do {
|
|
28637
28637
|
let b = a.next.next;
|
|
28638
28638
|
while (b !== a.prev) {
|
|
@@ -28647,15 +28647,15 @@ var GameVehiclesThree = (() => {
|
|
|
28647
28647
|
b = b.next;
|
|
28648
28648
|
}
|
|
28649
28649
|
a = a.next;
|
|
28650
|
-
} while (a !==
|
|
28650
|
+
} while (a !== start2);
|
|
28651
28651
|
}
|
|
28652
28652
|
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
28653
28653
|
const queue = [];
|
|
28654
|
-
let i, len,
|
|
28654
|
+
let i, len, start2, end, list2;
|
|
28655
28655
|
for (i = 0, len = holeIndices.length; i < len; i++) {
|
|
28656
|
-
|
|
28656
|
+
start2 = holeIndices[i] * dim;
|
|
28657
28657
|
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
28658
|
-
list2 = linkedList(data,
|
|
28658
|
+
list2 = linkedList(data, start2, end, dim, false);
|
|
28659
28659
|
if (list2 === list2.next) list2.steiner = true;
|
|
28660
28660
|
queue.push(getLeftmost(list2));
|
|
28661
28661
|
}
|
|
@@ -28710,14 +28710,14 @@ var GameVehiclesThree = (() => {
|
|
|
28710
28710
|
function sectorContainsSector(m, p) {
|
|
28711
28711
|
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
28712
28712
|
}
|
|
28713
|
-
function indexCurve(
|
|
28714
|
-
let p =
|
|
28713
|
+
function indexCurve(start2, minX, minY, invSize) {
|
|
28714
|
+
let p = start2;
|
|
28715
28715
|
do {
|
|
28716
28716
|
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
28717
28717
|
p.prevZ = p.prev;
|
|
28718
28718
|
p.nextZ = p.next;
|
|
28719
28719
|
p = p.next;
|
|
28720
|
-
} while (p !==
|
|
28720
|
+
} while (p !== start2);
|
|
28721
28721
|
p.prevZ.nextZ = null;
|
|
28722
28722
|
p.prevZ = null;
|
|
28723
28723
|
sortLinked(p);
|
|
@@ -28774,12 +28774,12 @@ var GameVehiclesThree = (() => {
|
|
|
28774
28774
|
y = (y | y << 1) & 1431655765;
|
|
28775
28775
|
return x | y << 1;
|
|
28776
28776
|
}
|
|
28777
|
-
function getLeftmost(
|
|
28778
|
-
let p =
|
|
28777
|
+
function getLeftmost(start2) {
|
|
28778
|
+
let p = start2, leftmost = start2;
|
|
28779
28779
|
do {
|
|
28780
28780
|
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
|
|
28781
28781
|
p = p.next;
|
|
28782
|
-
} while (p !==
|
|
28782
|
+
} while (p !== start2);
|
|
28783
28783
|
return leftmost;
|
|
28784
28784
|
}
|
|
28785
28785
|
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
@@ -28878,9 +28878,9 @@ var GameVehiclesThree = (() => {
|
|
|
28878
28878
|
this.nextZ = null;
|
|
28879
28879
|
this.steiner = false;
|
|
28880
28880
|
}
|
|
28881
|
-
function signedArea(data,
|
|
28881
|
+
function signedArea(data, start2, end, dim) {
|
|
28882
28882
|
let sum = 0;
|
|
28883
|
-
for (let i =
|
|
28883
|
+
for (let i = start2, j = end - dim; i < end; i += dim) {
|
|
28884
28884
|
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
28885
28885
|
j = i;
|
|
28886
28886
|
}
|
|
@@ -29137,7 +29137,7 @@ var GameVehiclesThree = (() => {
|
|
|
29137
29137
|
const uvs = [uv(iA), uv(iB), uv(iC), uv(iD)];
|
|
29138
29138
|
for (const k of [0, 1, 3, 1, 2, 3]) addUV(...uvs[k]);
|
|
29139
29139
|
};
|
|
29140
|
-
let
|
|
29140
|
+
let start2 = verticesArray.length / 3;
|
|
29141
29141
|
if (bevelEnabled) {
|
|
29142
29142
|
let offset = 0;
|
|
29143
29143
|
for (let i = 0; i < flen; i++) {
|
|
@@ -29160,8 +29160,8 @@ var GameVehiclesThree = (() => {
|
|
|
29160
29160
|
f3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps);
|
|
29161
29161
|
}
|
|
29162
29162
|
}
|
|
29163
|
-
groups.push({ start, count: verticesArray.length / 3 -
|
|
29164
|
-
|
|
29163
|
+
groups.push({ start: start2, count: verticesArray.length / 3 - start2, materialIndex: 0 });
|
|
29164
|
+
start2 = verticesArray.length / 3;
|
|
29165
29165
|
const sidewalls = (ring2, layeroffset2) => {
|
|
29166
29166
|
let i = ring2.length;
|
|
29167
29167
|
while (--i >= 0) {
|
|
@@ -29182,7 +29182,7 @@ var GameVehiclesThree = (() => {
|
|
|
29182
29182
|
sidewalls(ahole, layeroffset);
|
|
29183
29183
|
layeroffset += ahole.length;
|
|
29184
29184
|
}
|
|
29185
|
-
groups.push({ start, count: verticesArray.length / 3 -
|
|
29185
|
+
groups.push({ start: start2, count: verticesArray.length / 3 - start2, materialIndex: 1 });
|
|
29186
29186
|
const positions = new Float32Array(verticesArray);
|
|
29187
29187
|
return { type: "ExtrudeGeometry", parameters, positions, normals: computeVertexNormals(positions), uvs: new Float32Array(uvArray), groups };
|
|
29188
29188
|
}
|
|
@@ -29458,8 +29458,8 @@ var GameVehiclesThree = (() => {
|
|
|
29458
29458
|
var shims = /* @__PURE__ */ new WeakSet();
|
|
29459
29459
|
function shapeGeometries(THREE, options = {}) {
|
|
29460
29460
|
if (shims.has(THREE)) return THREE;
|
|
29461
|
-
const
|
|
29462
|
-
const key =
|
|
29461
|
+
const cache2 = options.cache !== false;
|
|
29462
|
+
const key = cache2 ? "cache" : "nocache";
|
|
29463
29463
|
let byKey = namespaces.get(THREE);
|
|
29464
29464
|
if (!byKey) {
|
|
29465
29465
|
byKey = /* @__PURE__ */ new Map();
|
|
@@ -29468,7 +29468,7 @@ var GameVehiclesThree = (() => {
|
|
|
29468
29468
|
const existing = byKey.get(key);
|
|
29469
29469
|
if (existing) return existing;
|
|
29470
29470
|
const made = (p) => toGeometry(THREE, p);
|
|
29471
|
-
const viaCache = (node, direct) =>
|
|
29471
|
+
const viaCache = (node, direct) => cache2 ? buildPrimitive(node) : direct();
|
|
29472
29472
|
const defined = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
29473
29473
|
const constructors = {
|
|
29474
29474
|
BoxGeometry: (width, height, depth, ws = 1, hs = 1, ds = 1) => made(viaCache({ kind: "box", size: [width ?? 1, height ?? 1, depth ?? 1], segments: [ws, hs, ds] }, () => box(width, height, depth, ws, hs, ds))),
|
|
@@ -29507,6 +29507,90 @@ var GameVehiclesThree = (() => {
|
|
|
29507
29507
|
shims.add(result);
|
|
29508
29508
|
return result;
|
|
29509
29509
|
}
|
|
29510
|
+
var isTexture = (v) => !!v && typeof v === "object" && v.isTexture === true;
|
|
29511
|
+
function texturesOf(material, out) {
|
|
29512
|
+
for (const value of Object.values(material)) if (isTexture(value)) out.add(value);
|
|
29513
|
+
const uniforms = material.uniforms;
|
|
29514
|
+
if (uniforms) {
|
|
29515
|
+
for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
|
|
29516
|
+
}
|
|
29517
|
+
}
|
|
29518
|
+
function collect(roots) {
|
|
29519
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
29520
|
+
const materials = /* @__PURE__ */ new Set();
|
|
29521
|
+
const textures = /* @__PURE__ */ new Set();
|
|
29522
|
+
const skeletons = /* @__PURE__ */ new Set();
|
|
29523
|
+
for (const root of roots) {
|
|
29524
|
+
root.traverse((object2) => {
|
|
29525
|
+
const o = object2;
|
|
29526
|
+
if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
|
|
29527
|
+
if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
|
|
29528
|
+
const list2 = Array.isArray(o.material) ? o.material : o.material ? [o.material] : [];
|
|
29529
|
+
for (const m of list2) {
|
|
29530
|
+
if (!m || typeof m.dispose !== "function") continue;
|
|
29531
|
+
materials.add(m);
|
|
29532
|
+
texturesOf(m, textures);
|
|
29533
|
+
}
|
|
29534
|
+
});
|
|
29535
|
+
}
|
|
29536
|
+
return { geometries, materials, textures, skeletons };
|
|
29537
|
+
}
|
|
29538
|
+
var marked = /* @__PURE__ */ new WeakSet();
|
|
29539
|
+
var shared = (r) => r.userData?.shared === true || marked.has(r);
|
|
29540
|
+
function releaseObject3D(roots, options = {}) {
|
|
29541
|
+
const list2 = Array.isArray(roots) ? roots : [roots];
|
|
29542
|
+
const report = { geometries: 0, materials: 0, textures: 0 };
|
|
29543
|
+
if (list2.length === 0) return report;
|
|
29544
|
+
const found = collect(list2);
|
|
29545
|
+
const keepRoots = options.keep === void 0 ? [] : Array.isArray(options.keep) ? options.keep : [options.keep];
|
|
29546
|
+
const releasing = new Set(list2);
|
|
29547
|
+
for (const keep of keepRoots) {
|
|
29548
|
+
const walk = (o) => {
|
|
29549
|
+
if (releasing.has(o)) return;
|
|
29550
|
+
const owner = o;
|
|
29551
|
+
if (owner.geometry) found.geometries.delete(owner.geometry);
|
|
29552
|
+
if (owner.skeleton) found.skeletons.delete(owner.skeleton);
|
|
29553
|
+
const mats = Array.isArray(owner.material) ? owner.material : owner.material ? [owner.material] : [];
|
|
29554
|
+
for (const m of mats) {
|
|
29555
|
+
if (!m) continue;
|
|
29556
|
+
found.materials.delete(m);
|
|
29557
|
+
const t = /* @__PURE__ */ new Set();
|
|
29558
|
+
texturesOf(m, t);
|
|
29559
|
+
for (const x of t) found.textures.delete(x);
|
|
29560
|
+
}
|
|
29561
|
+
for (const c of o.children) walk(c);
|
|
29562
|
+
};
|
|
29563
|
+
walk(keep);
|
|
29564
|
+
}
|
|
29565
|
+
for (const g of found.geometries) {
|
|
29566
|
+
if (shared(g)) continue;
|
|
29567
|
+
g.dispose();
|
|
29568
|
+
report.geometries++;
|
|
29569
|
+
}
|
|
29570
|
+
for (const m of found.materials) {
|
|
29571
|
+
if (shared(m)) continue;
|
|
29572
|
+
m.dispose();
|
|
29573
|
+
report.materials++;
|
|
29574
|
+
}
|
|
29575
|
+
for (const t of found.textures) {
|
|
29576
|
+
if (shared(t)) continue;
|
|
29577
|
+
t.dispose();
|
|
29578
|
+
report.textures++;
|
|
29579
|
+
}
|
|
29580
|
+
for (const s of found.skeletons) s.dispose();
|
|
29581
|
+
return report;
|
|
29582
|
+
}
|
|
29583
|
+
function discardObject3D(objects, options = {}) {
|
|
29584
|
+
const list2 = Array.isArray(objects) ? objects : [objects];
|
|
29585
|
+
const keep = options.keep === void 0 ? [] : Array.isArray(options.keep) ? [...options.keep] : [options.keep];
|
|
29586
|
+
for (const object2 of list2) {
|
|
29587
|
+
let top = object2;
|
|
29588
|
+
while (top.parent) top = top.parent;
|
|
29589
|
+
object2.removeFromParent();
|
|
29590
|
+
if (top !== object2 && !keep.includes(top)) keep.push(top);
|
|
29591
|
+
}
|
|
29592
|
+
return releaseObject3D(list2, { keep });
|
|
29593
|
+
}
|
|
29510
29594
|
|
|
29511
29595
|
// ../game-vehicles/dist/index.js
|
|
29512
29596
|
var __defProp2 = Object.defineProperty;
|
|
@@ -30154,7 +30238,7 @@ var GameVehiclesThree = (() => {
|
|
|
30154
30238
|
const I = kit._;
|
|
30155
30239
|
const document2 = kit.document;
|
|
30156
30240
|
const RUST = new THREE.Color("#5e3220");
|
|
30157
|
-
const
|
|
30241
|
+
const cache2 = {};
|
|
30158
30242
|
let envTex = null;
|
|
30159
30243
|
function studioEnvironment() {
|
|
30160
30244
|
if (envTex) return envTex;
|
|
@@ -30199,7 +30283,7 @@ var GameVehiclesThree = (() => {
|
|
|
30199
30283
|
const key = "s" + c.getHexString() + JSON.stringify(o, function(k, v) {
|
|
30200
30284
|
return v && v.isColor ? "#" + v.getHexString() : v && v.isTexture ? v.uuid : v;
|
|
30201
30285
|
});
|
|
30202
|
-
if (!
|
|
30286
|
+
if (!cache2[key]) {
|
|
30203
30287
|
const o2 = Object.assign({}, o);
|
|
30204
30288
|
delete o2.noEnv;
|
|
30205
30289
|
const mt = new THREE.MeshStandardMaterial(Object.assign({ color: c, roughness: 0.8, metalness: 0, flatShading: false }, o2));
|
|
@@ -30207,9 +30291,9 @@ var GameVehiclesThree = (() => {
|
|
|
30207
30291
|
mt.envMap = studioEnvironment();
|
|
30208
30292
|
if (o.envMapIntensity == null) mt.envMapIntensity = 0.55 + (mt.metalness - 0.6) * 1.6;
|
|
30209
30293
|
}
|
|
30210
|
-
|
|
30294
|
+
cache2[key] = mt;
|
|
30211
30295
|
}
|
|
30212
|
-
return
|
|
30296
|
+
return cache2[key];
|
|
30213
30297
|
}
|
|
30214
30298
|
function makeFlatMaterial(color2, o) {
|
|
30215
30299
|
return makeMaterial(color2, Object.assign({ flatShading: true, roughness: 0.92 }, o || {}));
|
|
@@ -30324,7 +30408,129 @@ var GameVehiclesThree = (() => {
|
|
|
30324
30408
|
return t;
|
|
30325
30409
|
}
|
|
30326
30410
|
kit.textTexture = textTexture;
|
|
30327
|
-
Object.assign(I, { RUST, cache, studioEnvironment, makeMaterial, makeFlatMaterial, DOUBLE_SIDE, toColor, MATERIALS, paintColor, texCache, textTexture });
|
|
30411
|
+
Object.assign(I, { RUST, cache: cache2, studioEnvironment, makeMaterial, makeFlatMaterial, DOUBLE_SIDE, toColor, MATERIALS, paintColor, texCache, textTexture });
|
|
30412
|
+
}
|
|
30413
|
+
var TRI_BLOCK = 32;
|
|
30414
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
30415
|
+
function trianglesOf(geo) {
|
|
30416
|
+
return Math.floor((geo.index ? geo.index.count : geo.attributes.position.count) / 3);
|
|
30417
|
+
}
|
|
30418
|
+
function supports(geo) {
|
|
30419
|
+
const pos = geo.attributes && geo.attributes.position;
|
|
30420
|
+
return !!pos && !pos.isInterleavedBufferAttribute && pos.itemSize === 3;
|
|
30421
|
+
}
|
|
30422
|
+
function isCurrent(geo, ti) {
|
|
30423
|
+
const pos = geo.attributes.position;
|
|
30424
|
+
return ti.position === pos && ti.positionVersion === pos.version && ti.index === (geo.index || null) && ti.indexVersion === (geo.index ? geo.index.version : 0) && ti.triangles === trianglesOf(geo);
|
|
30425
|
+
}
|
|
30426
|
+
function blockCount(triangles) {
|
|
30427
|
+
return Math.ceil(triangles / TRI_BLOCK);
|
|
30428
|
+
}
|
|
30429
|
+
function boxBlock(ti, block) {
|
|
30430
|
+
const B = ti.boxes;
|
|
30431
|
+
const t0 = block * TRI_BLOCK;
|
|
30432
|
+
const t1 = Math.min(ti.triangles, t0 + TRI_BLOCK);
|
|
30433
|
+
const o = block * 6;
|
|
30434
|
+
for (let k = 0; k < 3; k++) {
|
|
30435
|
+
ti.blocks[o + k] = Infinity;
|
|
30436
|
+
ti.blocks[o + 3 + k] = -Infinity;
|
|
30437
|
+
}
|
|
30438
|
+
for (let t = t0; t < t1; t++) {
|
|
30439
|
+
const j = t * 6;
|
|
30440
|
+
for (let k = 0; k < 3; k++) {
|
|
30441
|
+
if (B[j + k] < ti.blocks[o + k]) ti.blocks[o + k] = B[j + k];
|
|
30442
|
+
if (B[j + 3 + k] > ti.blocks[o + 3 + k]) ti.blocks[o + 3 + k] = B[j + 3 + k];
|
|
30443
|
+
}
|
|
30444
|
+
}
|
|
30445
|
+
}
|
|
30446
|
+
function boxTriangle(geo, ti, t) {
|
|
30447
|
+
const P = geo.attributes.position.array;
|
|
30448
|
+
const ix = geo.index ? geo.index.array : null;
|
|
30449
|
+
const a = (ix ? ix[t * 3] : t * 3) * 3;
|
|
30450
|
+
const b = (ix ? ix[t * 3 + 1] : t * 3 + 1) * 3;
|
|
30451
|
+
const c = (ix ? ix[t * 3 + 2] : t * 3 + 2) * 3;
|
|
30452
|
+
const j = t * 6;
|
|
30453
|
+
for (let k = 0; k < 3; k++) {
|
|
30454
|
+
ti.boxes[j + k] = Math.min(P[a + k], P[b + k], P[c + k]);
|
|
30455
|
+
ti.boxes[j + 3 + k] = Math.max(P[a + k], P[b + k], P[c + k]);
|
|
30456
|
+
}
|
|
30457
|
+
}
|
|
30458
|
+
function advance(geo, ti, deadline) {
|
|
30459
|
+
const total = blockCount(ti.triangles);
|
|
30460
|
+
while (ti.builtBlocks < total) {
|
|
30461
|
+
const block = ti.builtBlocks;
|
|
30462
|
+
const t1 = Math.min(ti.triangles, (block + 1) * TRI_BLOCK);
|
|
30463
|
+
for (let t = block * TRI_BLOCK; t < t1; t++) boxTriangle(geo, ti, t);
|
|
30464
|
+
boxBlock(ti, block);
|
|
30465
|
+
ti.builtBlocks++;
|
|
30466
|
+
if (deadline !== Infinity && performance.now() >= deadline) break;
|
|
30467
|
+
}
|
|
30468
|
+
return ti.builtBlocks === total;
|
|
30469
|
+
}
|
|
30470
|
+
function start(geo) {
|
|
30471
|
+
const pos = geo.attributes.position;
|
|
30472
|
+
const triangles = trianglesOf(geo);
|
|
30473
|
+
const ti = {
|
|
30474
|
+
position: pos,
|
|
30475
|
+
positionVersion: pos.version,
|
|
30476
|
+
index: geo.index || null,
|
|
30477
|
+
indexVersion: geo.index ? geo.index.version : 0,
|
|
30478
|
+
triangles,
|
|
30479
|
+
boxes: new Float64Array(triangles * 6),
|
|
30480
|
+
blocks: new Float64Array(blockCount(triangles) * 6),
|
|
30481
|
+
builtBlocks: 0
|
|
30482
|
+
};
|
|
30483
|
+
cache.set(geo, ti);
|
|
30484
|
+
return ti;
|
|
30485
|
+
}
|
|
30486
|
+
function triIndexOf(geo) {
|
|
30487
|
+
if (!supports(geo)) return void 0;
|
|
30488
|
+
let ti = cache.get(geo);
|
|
30489
|
+
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
30490
|
+
advance(geo, ti, Infinity);
|
|
30491
|
+
return ti;
|
|
30492
|
+
}
|
|
30493
|
+
function warmTriIndex(geo, deadline) {
|
|
30494
|
+
if (!supports(geo)) return true;
|
|
30495
|
+
let ti = cache.get(geo);
|
|
30496
|
+
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
30497
|
+
return advance(geo, ti, deadline);
|
|
30498
|
+
}
|
|
30499
|
+
function storeTriIndex(geo, boxes) {
|
|
30500
|
+
const ti = start(geo);
|
|
30501
|
+
ti.boxes = boxes;
|
|
30502
|
+
const total = blockCount(ti.triangles);
|
|
30503
|
+
for (let b = 0; b < total; b++) boxBlock(ti, b);
|
|
30504
|
+
ti.builtBlocks = total;
|
|
30505
|
+
}
|
|
30506
|
+
function liveTriIndex(geo) {
|
|
30507
|
+
if (geo.index || !supports(geo)) return void 0;
|
|
30508
|
+
const ti = cache.get(geo);
|
|
30509
|
+
return ti && isCurrent(geo, ti) && ti.builtBlocks === blockCount(ti.triangles) ? ti : void 0;
|
|
30510
|
+
}
|
|
30511
|
+
function touchTriIndex(geo, ti, vertices) {
|
|
30512
|
+
if (ti.positionVersion + 1 !== geo.attributes.position.version) return;
|
|
30513
|
+
const blocks = /* @__PURE__ */ new Set();
|
|
30514
|
+
for (const v of vertices) {
|
|
30515
|
+
const t = Math.floor(v / 3);
|
|
30516
|
+
if (t >= ti.triangles) continue;
|
|
30517
|
+
boxTriangle(geo, ti, t);
|
|
30518
|
+
blocks.add(Math.floor(t / TRI_BLOCK));
|
|
30519
|
+
}
|
|
30520
|
+
blocks.forEach((b) => boxBlock(ti, b));
|
|
30521
|
+
ti.positionVersion = geo.attributes.position.version;
|
|
30522
|
+
}
|
|
30523
|
+
function boundsFromIndex(geo) {
|
|
30524
|
+
if (geo.index || !supports(geo)) return void 0;
|
|
30525
|
+
const ti = cache.get(geo);
|
|
30526
|
+
if (!ti || !isCurrent(geo, ti) || ti.builtBlocks !== blockCount(ti.triangles) || !ti.triangles || geo.attributes.position.count !== ti.triangles * 3) return void 0;
|
|
30527
|
+
const box2 = new Float64Array([Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]);
|
|
30528
|
+
for (let b = 0, n = blockCount(ti.triangles); b < n; b++)
|
|
30529
|
+
for (let k = 0; k < 3; k++) {
|
|
30530
|
+
box2[k] = Math.min(box2[k], ti.blocks[b * 6 + k]);
|
|
30531
|
+
box2[3 + k] = Math.max(box2[3 + k], ti.blocks[b * 6 + 3 + k]);
|
|
30532
|
+
}
|
|
30533
|
+
return { box: box2, version: ti.positionVersion };
|
|
30328
30534
|
}
|
|
30329
30535
|
function installGeometry(kit) {
|
|
30330
30536
|
const THREE = kit.THREE;
|
|
@@ -30419,7 +30625,8 @@ var GameVehiclesThree = (() => {
|
|
|
30419
30625
|
g.userData.crease = true;
|
|
30420
30626
|
return g;
|
|
30421
30627
|
}
|
|
30422
|
-
|
|
30628
|
+
const latestCrease = /* @__PURE__ */ new WeakMap();
|
|
30629
|
+
function creaseTask(geo, deg) {
|
|
30423
30630
|
if (geo.index) {
|
|
30424
30631
|
const ni = geo.toNonIndexed();
|
|
30425
30632
|
Object.keys(ni.attributes).forEach(function(k) {
|
|
@@ -30427,30 +30634,22 @@ var GameVehiclesThree = (() => {
|
|
|
30427
30634
|
});
|
|
30428
30635
|
geo.setIndex(null);
|
|
30429
30636
|
}
|
|
30430
|
-
const
|
|
30431
|
-
const n =
|
|
30637
|
+
const P = geo.attributes.position.array;
|
|
30638
|
+
const n = geo.attributes.position.count;
|
|
30432
30639
|
const faces = n / 3;
|
|
30433
30640
|
const FN = new Float64Array(faces * 3);
|
|
30434
|
-
const
|
|
30435
|
-
const RANGE = 65536;
|
|
30436
|
-
function key(i) {
|
|
30437
|
-
const x = Math.round(p.getX(i) * 2e3);
|
|
30438
|
-
const y = Math.round(p.getY(i) * 2e3);
|
|
30439
|
-
const z = Math.round(p.getZ(i) * 2e3);
|
|
30440
|
-
if (Math.abs(x) < RANGE && Math.abs(y) < RANGE && Math.abs(z) < RANGE) return ((x + RANGE) * 131072 + (y + RANGE)) * 131072 + (z + RANGE);
|
|
30441
|
-
return x + "," + y + "," + z;
|
|
30442
|
-
}
|
|
30443
|
-
const keys = new Array(n);
|
|
30641
|
+
const out = new Float32Array(n * 3);
|
|
30444
30642
|
for (let f = 0; f < faces; f++) {
|
|
30445
|
-
const
|
|
30446
|
-
const
|
|
30447
|
-
const
|
|
30448
|
-
const
|
|
30449
|
-
const
|
|
30450
|
-
const
|
|
30451
|
-
const
|
|
30452
|
-
const
|
|
30453
|
-
const
|
|
30643
|
+
const o = 9 * f;
|
|
30644
|
+
const ax = P[o];
|
|
30645
|
+
const ay = P[o + 1];
|
|
30646
|
+
const az = P[o + 2];
|
|
30647
|
+
const bx = P[o + 3];
|
|
30648
|
+
const by = P[o + 4];
|
|
30649
|
+
const bz = P[o + 5];
|
|
30650
|
+
const cx = P[o + 6];
|
|
30651
|
+
const cy = P[o + 7];
|
|
30652
|
+
const cz = P[o + 8];
|
|
30454
30653
|
const e1x = cx - bx;
|
|
30455
30654
|
const e1y = cy - by;
|
|
30456
30655
|
const e1z = cz - bz;
|
|
@@ -30470,41 +30669,109 @@ var GameVehiclesThree = (() => {
|
|
|
30470
30669
|
FN[3 * f + 1] = ny;
|
|
30471
30670
|
FN[3 * f + 2] = nz;
|
|
30472
30671
|
for (let k = 0; k < 3; k++) {
|
|
30473
|
-
|
|
30474
|
-
|
|
30475
|
-
|
|
30476
|
-
|
|
30477
|
-
|
|
30672
|
+
out[9 * f + 3 * k] = nx;
|
|
30673
|
+
out[9 * f + 3 * k + 1] = ny;
|
|
30674
|
+
out[9 * f + 3 * k + 2] = nz;
|
|
30675
|
+
}
|
|
30676
|
+
}
|
|
30677
|
+
const normal = new THREE.BufferAttribute(out, 3);
|
|
30678
|
+
geo.setAttribute("normal", normal);
|
|
30679
|
+
const token = {};
|
|
30680
|
+
latestCrease.set(geo, token);
|
|
30681
|
+
let size = 16;
|
|
30682
|
+
while (size < n * 2) size *= 2;
|
|
30683
|
+
const mask = size - 1;
|
|
30684
|
+
const slot = new Int32Array(size).fill(-1);
|
|
30685
|
+
const gx = new Int32Array(n);
|
|
30686
|
+
const gy = new Int32Array(n);
|
|
30687
|
+
const gz = new Int32Array(n);
|
|
30688
|
+
const groupOf = new Int32Array(n);
|
|
30689
|
+
let groups = 0;
|
|
30690
|
+
let start2;
|
|
30691
|
+
let members;
|
|
30692
|
+
const cs = Math.cos(deg * PI / 180);
|
|
30693
|
+
let phase = 0;
|
|
30694
|
+
let at = 0;
|
|
30695
|
+
function hashSlice(deadline) {
|
|
30696
|
+
for (; at < n; at++) {
|
|
30697
|
+
if ((at & 1023) === 0 && performance.now() > deadline) return false;
|
|
30698
|
+
const x = Math.round(P[3 * at] * 2e3) | 0;
|
|
30699
|
+
const y = Math.round(P[3 * at + 1] * 2e3) | 0;
|
|
30700
|
+
const z = Math.round(P[3 * at + 2] * 2e3) | 0;
|
|
30701
|
+
let h = (Math.imul(x, 73856093) ^ Math.imul(y, 19349663) ^ Math.imul(z, 83492791)) & mask;
|
|
30702
|
+
let g = slot[h];
|
|
30703
|
+
while (g >= 0 && (gx[g] !== x || gy[g] !== y || gz[g] !== z)) {
|
|
30704
|
+
h = h + 1 & mask;
|
|
30705
|
+
g = slot[h];
|
|
30706
|
+
}
|
|
30707
|
+
if (g < 0) {
|
|
30708
|
+
g = groups++;
|
|
30709
|
+
slot[h] = g;
|
|
30710
|
+
gx[g] = x;
|
|
30711
|
+
gy[g] = y;
|
|
30712
|
+
gz[g] = z;
|
|
30713
|
+
}
|
|
30714
|
+
groupOf[at] = g;
|
|
30478
30715
|
}
|
|
30716
|
+
return true;
|
|
30479
30717
|
}
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30483
|
-
|
|
30484
|
-
const
|
|
30485
|
-
|
|
30486
|
-
let
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
if (
|
|
30491
|
-
|
|
30492
|
-
|
|
30493
|
-
|
|
30718
|
+
function gather() {
|
|
30719
|
+
start2 = new Int32Array(groups + 1);
|
|
30720
|
+
for (let i = 0; i < n; i++) start2[groupOf[i] + 1]++;
|
|
30721
|
+
for (let g = 0; g < groups; g++) start2[g + 1] += start2[g];
|
|
30722
|
+
const fill2 = start2.slice(0, groups);
|
|
30723
|
+
members = new Int32Array(n);
|
|
30724
|
+
for (let i = 0; i < n; i++) members[fill2[groupOf[i]]++] = i / 3 | 0;
|
|
30725
|
+
}
|
|
30726
|
+
function smoothSlice(deadline) {
|
|
30727
|
+
for (; at < n; at++) {
|
|
30728
|
+
if ((at & 1023) === 0 && performance.now() > deadline) return false;
|
|
30729
|
+
const fi = (at / 3 | 0) * 3;
|
|
30730
|
+
const g = groupOf[at];
|
|
30731
|
+
let sx = 0;
|
|
30732
|
+
let sy = 0;
|
|
30733
|
+
let sz = 0;
|
|
30734
|
+
for (let j = start2[g], end = start2[g + 1]; j < end; j++) {
|
|
30735
|
+
const o = members[j] * 3;
|
|
30736
|
+
if (FN[o] * FN[fi] + FN[o + 1] * FN[fi + 1] + FN[o + 2] * FN[fi + 2] >= cs) {
|
|
30737
|
+
sx += FN[o];
|
|
30738
|
+
sy += FN[o + 1];
|
|
30739
|
+
sz += FN[o + 2];
|
|
30740
|
+
}
|
|
30741
|
+
}
|
|
30742
|
+
if (sx * sx + sy * sy + sz * sz < 1e-20) {
|
|
30743
|
+
sx = FN[fi];
|
|
30744
|
+
sy = FN[fi + 1];
|
|
30745
|
+
sz = FN[fi + 2];
|
|
30494
30746
|
}
|
|
30747
|
+
const inv = 1 / (Math.sqrt(sx * sx + sy * sy + sz * sz) || 1);
|
|
30748
|
+
out[3 * at] = sx * inv;
|
|
30749
|
+
out[3 * at + 1] = sy * inv;
|
|
30750
|
+
out[3 * at + 2] = sz * inv;
|
|
30495
30751
|
}
|
|
30496
|
-
|
|
30497
|
-
|
|
30498
|
-
|
|
30499
|
-
|
|
30752
|
+
return true;
|
|
30753
|
+
}
|
|
30754
|
+
function step(deadline) {
|
|
30755
|
+
if (latestCrease.get(geo) !== token) return true;
|
|
30756
|
+
if (phase === 0) {
|
|
30757
|
+
if (!hashSlice(deadline)) return false;
|
|
30758
|
+
gather();
|
|
30759
|
+
phase = 1;
|
|
30760
|
+
at = 0;
|
|
30761
|
+
}
|
|
30762
|
+
if (phase === 1) {
|
|
30763
|
+
const done = smoothSlice(deadline);
|
|
30764
|
+
if (deadline !== Infinity) normal.needsUpdate = true;
|
|
30765
|
+
if (!done) return false;
|
|
30766
|
+
phase = 2;
|
|
30767
|
+
geo.userData.crease = true;
|
|
30500
30768
|
}
|
|
30501
|
-
|
|
30502
|
-
out[3 * i] = sx * inv;
|
|
30503
|
-
out[3 * i + 1] = sy * inv;
|
|
30504
|
-
out[3 * i + 2] = sz * inv;
|
|
30769
|
+
return true;
|
|
30505
30770
|
}
|
|
30506
|
-
geo
|
|
30507
|
-
|
|
30771
|
+
return { geo, step };
|
|
30772
|
+
}
|
|
30773
|
+
function crease(geo, deg) {
|
|
30774
|
+
creaseTask(geo, deg).step(Infinity);
|
|
30508
30775
|
return geo;
|
|
30509
30776
|
}
|
|
30510
30777
|
function pathShape(items) {
|
|
@@ -30651,28 +30918,28 @@ var GameVehiclesThree = (() => {
|
|
|
30651
30918
|
return g;
|
|
30652
30919
|
}
|
|
30653
30920
|
function cutGeometry(geo, tests) {
|
|
30654
|
-
const
|
|
30921
|
+
const idx = geo.index ? geo.index.array : null;
|
|
30655
30922
|
const names = ["position"].concat(
|
|
30656
30923
|
["color", "uv"].filter(function(n2) {
|
|
30657
|
-
return !!
|
|
30924
|
+
return !!geo.attributes[n2];
|
|
30658
30925
|
})
|
|
30659
30926
|
);
|
|
30660
30927
|
const sizes = names.map(function(n2) {
|
|
30661
|
-
return
|
|
30928
|
+
return geo.attributes[n2].itemSize;
|
|
30662
30929
|
});
|
|
30663
30930
|
const arrs = names.map(function(n2) {
|
|
30664
|
-
return
|
|
30931
|
+
return geo.attributes[n2].array;
|
|
30665
30932
|
});
|
|
30666
|
-
const nv =
|
|
30667
|
-
|
|
30668
|
-
for (let f = 0; f < nv; f += 3) {
|
|
30933
|
+
const nv = idx ? idx.length : geo.attributes.position.count;
|
|
30934
|
+
function readTri(f) {
|
|
30669
30935
|
const t = [];
|
|
30670
30936
|
for (let k = 0; k < 3; k++) {
|
|
30937
|
+
const vi = idx ? idx[f + k] : f + k;
|
|
30671
30938
|
const v = [];
|
|
30672
|
-
for (let a = 0; a < names.length; a++) for (let q = 0; q < sizes[a]; q++) v.push(arrs[a][
|
|
30939
|
+
for (let a = 0; a < names.length; a++) for (let q = 0; q < sizes[a]; q++) v.push(arrs[a][vi * sizes[a] + q]);
|
|
30673
30940
|
t.push(v);
|
|
30674
30941
|
}
|
|
30675
|
-
|
|
30942
|
+
return t;
|
|
30676
30943
|
}
|
|
30677
30944
|
const cut = {};
|
|
30678
30945
|
const n = new V3();
|
|
@@ -30698,60 +30965,177 @@ var GameVehiclesThree = (() => {
|
|
|
30698
30965
|
function fan(poly, arr) {
|
|
30699
30966
|
for (let i = 1; i < poly.length - 1; i++) arr.push([poly[0], poly[i], poly[i + 1]]);
|
|
30700
30967
|
}
|
|
30701
|
-
|
|
30702
|
-
const
|
|
30968
|
+
function testTri(T, t, next, rem) {
|
|
30969
|
+
const A = t[0];
|
|
30970
|
+
const B = t[1];
|
|
30971
|
+
const C = t[2];
|
|
30972
|
+
e1.set(B[0] - A[0], B[1] - A[1], B[2] - A[2]);
|
|
30973
|
+
e2.set(C[0] - A[0], C[1] - A[1], C[2] - A[2]);
|
|
30974
|
+
n.crossVectors(e1, e2);
|
|
30975
|
+
const len = n.length();
|
|
30976
|
+
if (len < 1e-12) {
|
|
30977
|
+
next.push(t);
|
|
30978
|
+
return;
|
|
30979
|
+
}
|
|
30980
|
+
n.multiplyScalar(1 / len);
|
|
30981
|
+
ce.set((A[0] + B[0] + C[0]) / 3, (A[1] + B[1] + C[1]) / 3, (A[2] + B[2] + C[2]) / 3);
|
|
30982
|
+
if (T.sel && !T.sel(n, ce)) {
|
|
30983
|
+
next.push(t);
|
|
30984
|
+
return;
|
|
30985
|
+
}
|
|
30986
|
+
const d = [T.sdf(A[0], A[1], A[2]), T.sdf(B[0], B[1], B[2]), T.sdf(C[0], C[1], C[2])];
|
|
30987
|
+
const ins = (d[0] < 0 ? 1 : 0) + (d[1] < 0 ? 1 : 0) + (d[2] < 0 ? 1 : 0);
|
|
30988
|
+
if (ins === 0) next.push(t);
|
|
30989
|
+
else if (ins === 3) {
|
|
30990
|
+
if (rem) rem.push(t);
|
|
30991
|
+
} else {
|
|
30992
|
+
fan(clip(t, d, 1), next);
|
|
30993
|
+
if (rem) fan(clip(t, d, -1), rem);
|
|
30994
|
+
}
|
|
30995
|
+
}
|
|
30996
|
+
const segments = [];
|
|
30997
|
+
let total = 0;
|
|
30998
|
+
const ti = tests.length === 1 && tests[0].bounds ? triIndexOf(geo) : void 0;
|
|
30999
|
+
if (ti) {
|
|
31000
|
+
const T = tests[0];
|
|
31001
|
+
const lo = T.bounds.lo;
|
|
31002
|
+
const hi = T.bounds.hi;
|
|
30703
31003
|
const rem = T.tag ? cut[T.tag] = cut[T.tag] || [] : null;
|
|
30704
|
-
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30708
|
-
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
|
|
30715
|
-
|
|
30716
|
-
|
|
30717
|
-
|
|
30718
|
-
if (T.sel && !T.sel(n, ce)) {
|
|
30719
|
-
next.push(t);
|
|
30720
|
-
return;
|
|
31004
|
+
const boxes = ti.boxes;
|
|
31005
|
+
const blocks = ti.blocks;
|
|
31006
|
+
let runFrom = -1;
|
|
31007
|
+
const closeRun = function(end) {
|
|
31008
|
+
if (runFrom < 0) return;
|
|
31009
|
+
segments.push([runFrom, end]);
|
|
31010
|
+
total += end - runFrom;
|
|
31011
|
+
runFrom = -1;
|
|
31012
|
+
};
|
|
31013
|
+
for (let blk = 0, t0 = 0; t0 < ti.triangles; blk++, t0 += TRI_BLOCK) {
|
|
31014
|
+
const j = blk * 6;
|
|
31015
|
+
if (blocks[j + 3] < lo[0] || blocks[j] > hi[0] || blocks[j + 4] < lo[1] || blocks[j + 1] > hi[1] || blocks[j + 5] < lo[2] || blocks[j + 2] > hi[2]) {
|
|
31016
|
+
if (runFrom < 0) runFrom = t0;
|
|
31017
|
+
continue;
|
|
30721
31018
|
}
|
|
30722
|
-
const
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30728
|
-
|
|
30729
|
-
|
|
31019
|
+
const t1 = Math.min(ti.triangles, t0 + TRI_BLOCK);
|
|
31020
|
+
for (let t = t0; t < t1; t++) {
|
|
31021
|
+
const q = t * 6;
|
|
31022
|
+
if (boxes[q + 3] < lo[0] || boxes[q] > hi[0] || boxes[q + 4] < lo[1] || boxes[q + 1] > hi[1] || boxes[q + 5] < lo[2] || boxes[q + 2] > hi[2]) {
|
|
31023
|
+
if (runFrom < 0) runFrom = t;
|
|
31024
|
+
continue;
|
|
31025
|
+
}
|
|
31026
|
+
closeRun(t);
|
|
31027
|
+
const next = [];
|
|
31028
|
+
testTri(T, readTri(t * 3), next, rem);
|
|
31029
|
+
if (next.length) {
|
|
31030
|
+
segments.push(next);
|
|
31031
|
+
total += next.length;
|
|
31032
|
+
}
|
|
30730
31033
|
}
|
|
31034
|
+
}
|
|
31035
|
+
closeRun(ti.triangles);
|
|
31036
|
+
} else {
|
|
31037
|
+
let tris = [];
|
|
31038
|
+
for (let f = 0; f < nv; f += 3) tris.push(readTri(f));
|
|
31039
|
+
tests.forEach(function(T) {
|
|
31040
|
+
const next = [];
|
|
31041
|
+
const rem = T.tag ? cut[T.tag] = cut[T.tag] || [] : null;
|
|
31042
|
+
tris.forEach(function(t) {
|
|
31043
|
+
testTri(T, t, next, rem);
|
|
31044
|
+
});
|
|
31045
|
+
tris = next;
|
|
30731
31046
|
});
|
|
30732
|
-
tris
|
|
30733
|
-
|
|
30734
|
-
|
|
31047
|
+
segments.push(tris);
|
|
31048
|
+
total = tris.length;
|
|
31049
|
+
}
|
|
31050
|
+
function fill2(segs, count2, boxesOut2) {
|
|
30735
31051
|
const g = new THREE.BufferGeometry();
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
|
|
30739
|
-
|
|
30740
|
-
|
|
30741
|
-
|
|
31052
|
+
const dst = names.map(function(_nm, a) {
|
|
31053
|
+
return new Float32Array(count2 * 3 * sizes[a]);
|
|
31054
|
+
});
|
|
31055
|
+
const w = names.map(function() {
|
|
31056
|
+
return 0;
|
|
31057
|
+
});
|
|
31058
|
+
let wb = 0;
|
|
31059
|
+
segs.forEach(function(seg) {
|
|
31060
|
+
if (typeof seg[0] === "number") {
|
|
31061
|
+
for (let a = 0; a < names.length; a++) {
|
|
31062
|
+
const size = sizes[a];
|
|
31063
|
+
if (!idx) {
|
|
31064
|
+
dst[a].set(arrs[a].subarray(seg[0] * 3 * size, seg[1] * 3 * size), w[a]);
|
|
31065
|
+
w[a] += (seg[1] - seg[0]) * 3 * size;
|
|
31066
|
+
continue;
|
|
31067
|
+
}
|
|
31068
|
+
for (let f = seg[0] * 3; f < seg[1] * 3; f++) for (let q = 0; q < size; q++) dst[a][w[a]++] = arrs[a][idx[f] * size + q];
|
|
31069
|
+
}
|
|
31070
|
+
if (boxesOut2 && ti) {
|
|
31071
|
+
boxesOut2.set(ti.boxes.subarray(seg[0] * 6, seg[1] * 6), wb);
|
|
31072
|
+
wb += (seg[1] - seg[0]) * 6;
|
|
31073
|
+
}
|
|
31074
|
+
return;
|
|
31075
|
+
}
|
|
31076
|
+
seg.forEach(function(t) {
|
|
31077
|
+
if (boxesOut2) {
|
|
31078
|
+
for (let k = 0; k < 3; k++) {
|
|
31079
|
+
boxesOut2[wb + k] = Math.fround(Math.min(t[0][k], t[1][k], t[2][k]));
|
|
31080
|
+
boxesOut2[wb + 3 + k] = Math.fround(Math.max(t[0][k], t[1][k], t[2][k]));
|
|
31081
|
+
}
|
|
31082
|
+
wb += 6;
|
|
31083
|
+
}
|
|
31084
|
+
let off = 0;
|
|
31085
|
+
for (let a = 0; a < names.length; a++) {
|
|
31086
|
+
for (let k = 0; k < 3; k++) for (let q = 0; q < sizes[a]; q++) dst[a][w[a]++] = t[k][off + q];
|
|
31087
|
+
off += sizes[a];
|
|
31088
|
+
}
|
|
30742
31089
|
});
|
|
30743
|
-
|
|
30744
|
-
|
|
31090
|
+
});
|
|
31091
|
+
names.forEach(function(nm, a) {
|
|
31092
|
+
g.setAttribute(nm, new THREE.BufferAttribute(dst[a], sizes[a]));
|
|
30745
31093
|
});
|
|
30746
31094
|
g.userData.crease = true;
|
|
30747
31095
|
return g;
|
|
30748
31096
|
}
|
|
30749
|
-
const
|
|
31097
|
+
const boxesOut = ti ? new Float64Array(total * 6) : void 0;
|
|
31098
|
+
const out = { geo: fill2(segments, total, boxesOut), cut: {}, tasks: {} };
|
|
31099
|
+
if (boxesOut) storeTriIndex(out.geo, boxesOut);
|
|
30750
31100
|
Object.keys(cut).forEach(function(k) {
|
|
30751
|
-
|
|
31101
|
+
const piece = fill2([cut[k]], cut[k].length);
|
|
31102
|
+
const mode = tests.find(function(T) {
|
|
31103
|
+
return T.tag === k;
|
|
31104
|
+
}).pieces;
|
|
31105
|
+
if (mode === "none") out.cut[k] = piece;
|
|
31106
|
+
else if (mode === "later") {
|
|
31107
|
+
out.cut[k] = piece;
|
|
31108
|
+
out.tasks[k] = creaseTask(piece, 42);
|
|
31109
|
+
} else out.cut[k] = crease(piece, 42);
|
|
30752
31110
|
});
|
|
30753
31111
|
return out;
|
|
30754
31112
|
}
|
|
31113
|
+
function refreshBounds(geo) {
|
|
31114
|
+
const found = boundsFromIndex(geo);
|
|
31115
|
+
if (!found) {
|
|
31116
|
+
geo.computeBoundingSphere();
|
|
31117
|
+
geo.computeBoundingBox();
|
|
31118
|
+
return;
|
|
31119
|
+
}
|
|
31120
|
+
if (geo.boundingBox && geo.boundingSphere && boundsDone.get(geo) === found.version) return;
|
|
31121
|
+
const b = found.box;
|
|
31122
|
+
if (!geo.boundingBox) geo.boundingBox = new THREE.Box3();
|
|
31123
|
+
geo.boundingBox.min.set(b[0], b[1], b[2]);
|
|
31124
|
+
geo.boundingBox.max.set(b[3], b[4], b[5]);
|
|
31125
|
+
if (!geo.boundingSphere) geo.boundingSphere = new THREE.Sphere();
|
|
31126
|
+
const center = geo.boundingBox.getCenter(geo.boundingSphere.center);
|
|
31127
|
+
const P = geo.attributes.position.array;
|
|
31128
|
+
let maxRadiusSq = 0;
|
|
31129
|
+
for (let i = 0; i < P.length; i += 3) {
|
|
31130
|
+
const dx = center.x - P[i];
|
|
31131
|
+
const dy = center.y - P[i + 1];
|
|
31132
|
+
const dz = center.z - P[i + 2];
|
|
31133
|
+
maxRadiusSq = Math.max(maxRadiusSq, dx * dx + dy * dy + dz * dz);
|
|
31134
|
+
}
|
|
31135
|
+
geo.boundingSphere.radius = Math.sqrt(maxRadiusSq);
|
|
31136
|
+
boundsDone.set(geo, found.version);
|
|
31137
|
+
}
|
|
31138
|
+
const boundsDone = /* @__PURE__ */ new WeakMap();
|
|
30755
31139
|
function mergeGeometries(list2) {
|
|
30756
31140
|
const pos = [];
|
|
30757
31141
|
const nor = [];
|
|
@@ -30882,7 +31266,7 @@ var GameVehiclesThree = (() => {
|
|
|
30882
31266
|
}
|
|
30883
31267
|
};
|
|
30884
31268
|
};
|
|
30885
|
-
Object.assign(I, { roundedBoxGeometry, taper, subdivide, crease, pathShape, tumble, loftGeometry, hullGeometry, cutGeometry, mergeGeometries, uvProject });
|
|
31269
|
+
Object.assign(I, { roundedBoxGeometry, taper, subdivide, crease, creaseTask, refreshBounds, pathShape, tumble, loftGeometry, hullGeometry, cutGeometry, mergeGeometries, uvProject });
|
|
30886
31270
|
}
|
|
30887
31271
|
function installContext(kit) {
|
|
30888
31272
|
const THREE = kit.THREE;
|
|
@@ -34209,8 +34593,15 @@ var GameVehiclesThree = (() => {
|
|
|
34209
34593
|
x.arc(cx, cy, 26 * s, 0, PI * 2);
|
|
34210
34594
|
x.fill();
|
|
34211
34595
|
}
|
|
34596
|
+
const NO_CANVAS = new Proxy(function() {
|
|
34597
|
+
}, { get: () => NO_CANVAS, apply: () => NO_CANVAS, set: () => true });
|
|
34212
34598
|
function crackGlass(c, msh, p, force, sc) {
|
|
34213
34599
|
const G2 = msh.userData.glass;
|
|
34600
|
+
if (G2.cracksFreed) {
|
|
34601
|
+
drawWeb(NO_CANVAS, 0, 0, sc != null ? sc : 0.6 + force * 0.5, Math.max(0.4, G2.aspect || 1), c.rand);
|
|
34602
|
+
G2.hits++;
|
|
34603
|
+
return;
|
|
34604
|
+
}
|
|
34214
34605
|
if (!G2.cv) {
|
|
34215
34606
|
G2.cv = document2.createElement("canvas");
|
|
34216
34607
|
G2.cv.width = G2.cv.height = 256;
|
|
@@ -34293,6 +34684,14 @@ var GameVehiclesThree = (() => {
|
|
|
34293
34684
|
const G2 = msh.userData.glass;
|
|
34294
34685
|
if (G2.broken) return;
|
|
34295
34686
|
G2.broken = true;
|
|
34687
|
+
const freeCracks = function() {
|
|
34688
|
+
if (!G2.tex) return;
|
|
34689
|
+
if (msh.material !== MATERIALS.glassEdge && msh.material?.map === G2.tex) msh.material.dispose();
|
|
34690
|
+
G2.tex.dispose();
|
|
34691
|
+
G2.tex = null;
|
|
34692
|
+
G2.cv = null;
|
|
34693
|
+
G2.cracksFreed = true;
|
|
34694
|
+
};
|
|
34296
34695
|
const cubesAt = [];
|
|
34297
34696
|
if (G2.outline && G2.T !== void 0) {
|
|
34298
34697
|
const out = G2.outline;
|
|
@@ -34326,6 +34725,7 @@ var GameVehiclesThree = (() => {
|
|
|
34326
34725
|
geo.computeVertexNormals();
|
|
34327
34726
|
msh.geometry.dispose();
|
|
34328
34727
|
msh.geometry = geo;
|
|
34728
|
+
freeCracks();
|
|
34329
34729
|
msh.material = MATERIALS.glassEdge;
|
|
34330
34730
|
let minx = 1e9;
|
|
34331
34731
|
let maxx = -1e9;
|
|
@@ -34349,8 +34749,12 @@ var GameVehiclesThree = (() => {
|
|
|
34349
34749
|
if (rim) {
|
|
34350
34750
|
msh.geometry.dispose();
|
|
34351
34751
|
msh.geometry = rim;
|
|
34752
|
+
freeCracks();
|
|
34352
34753
|
msh.material = MATERIALS.glassEdge;
|
|
34353
|
-
} else
|
|
34754
|
+
} else {
|
|
34755
|
+
freeCracks();
|
|
34756
|
+
msh.visible = false;
|
|
34757
|
+
}
|
|
34354
34758
|
for (let j = 0; j < 36; j++)
|
|
34355
34759
|
cubesAt.push(
|
|
34356
34760
|
new V3(
|
|
@@ -36171,6 +36575,8 @@ var GameVehiclesThree = (() => {
|
|
|
36171
36575
|
const pos = g && g.attributes && g.attributes.position;
|
|
36172
36576
|
return o.raycast === THREE.Mesh.prototype.raycast && !o.isSkinnedMesh && !Array.isArray(o.material) && pos && !pos.isInterleavedBufferAttribute && pos.itemSize === 3 && !g.groups.length && !(g.morphAttributes && g.morphAttributes.position) && (g.index ? g.index.count : pos.count) / 3 >= PROXY_MIN_TRIANGLES;
|
|
36173
36577
|
}
|
|
36578
|
+
let _keep = new Uint32Array(0);
|
|
36579
|
+
let _box = new Float32Array(0);
|
|
36174
36580
|
function proxyIn(o, Mw, R) {
|
|
36175
36581
|
_pm.copy(o.matrixWorld).invert().multiply(Mw);
|
|
36176
36582
|
const lo = [Infinity, Infinity, Infinity];
|
|
@@ -36183,39 +36589,48 @@ var GameVehiclesThree = (() => {
|
|
|
36183
36589
|
}
|
|
36184
36590
|
}
|
|
36185
36591
|
const g = o.geometry;
|
|
36186
|
-
const
|
|
36592
|
+
const ti = triIndexOf(g);
|
|
36593
|
+
if (!ti) return null;
|
|
36187
36594
|
const ix = g.index ? g.index.array : null;
|
|
36188
|
-
const
|
|
36189
|
-
const
|
|
36595
|
+
const boxes = ti.boxes;
|
|
36596
|
+
const blocks = ti.blocks;
|
|
36597
|
+
if (_keep.length < ti.triangles * 3) {
|
|
36598
|
+
_keep = new Uint32Array(ti.triangles * 3);
|
|
36599
|
+
_box = new Float32Array(ti.triangles * 6);
|
|
36600
|
+
}
|
|
36601
|
+
const keep = _keep;
|
|
36602
|
+
const box2 = _box;
|
|
36190
36603
|
let nk = 0;
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
const
|
|
36194
|
-
|
|
36195
|
-
|
|
36196
|
-
for (let
|
|
36197
|
-
const
|
|
36198
|
-
|
|
36199
|
-
|
|
36200
|
-
|
|
36201
|
-
|
|
36202
|
-
|
|
36203
|
-
|
|
36204
|
-
keep[nk++] = ix ? ix[t + 1] : t + 1;
|
|
36205
|
-
keep[nk++] = ix ? ix[t + 2] : t + 2;
|
|
36604
|
+
let nt = 0;
|
|
36605
|
+
for (let blk = 0, t0 = 0; t0 < ti.triangles; blk++, t0 += TRI_BLOCK) {
|
|
36606
|
+
const j = blk * 6;
|
|
36607
|
+
if (blocks[j + 3] < lo[0] || blocks[j] > hi[0] || blocks[j + 4] < lo[1] || blocks[j + 1] > hi[1] || blocks[j + 5] < lo[2] || blocks[j + 2] > hi[2]) continue;
|
|
36608
|
+
const t1 = Math.min(ti.triangles, t0 + TRI_BLOCK);
|
|
36609
|
+
for (let t = t0; t < t1; t++) {
|
|
36610
|
+
const q = t * 6;
|
|
36611
|
+
if (boxes[q + 3] < lo[0] || boxes[q] > hi[0] || boxes[q + 4] < lo[1] || boxes[q + 1] > hi[1] || boxes[q + 5] < lo[2] || boxes[q + 2] > hi[2]) continue;
|
|
36612
|
+
keep[nk++] = ix ? ix[t * 3] : t * 3;
|
|
36613
|
+
keep[nk++] = ix ? ix[t * 3 + 1] : t * 3 + 1;
|
|
36614
|
+
keep[nk++] = ix ? ix[t * 3 + 2] : t * 3 + 2;
|
|
36615
|
+
for (let k = 0; k < 6; k++) box2[nt * 6 + k] = boxes[q + k];
|
|
36616
|
+
nt++;
|
|
36206
36617
|
}
|
|
36207
36618
|
}
|
|
36208
36619
|
if (!nk) return null;
|
|
36209
36620
|
const kept = keep.slice(0, nk);
|
|
36210
|
-
const
|
|
36211
|
-
|
|
36212
|
-
|
|
36213
|
-
const b =
|
|
36214
|
-
const d = kept[t + 2] * 3;
|
|
36621
|
+
const keptBox = box2.slice(0, nt * 6);
|
|
36622
|
+
const keptBlocks = new Float32Array(Math.ceil(nt / TRI_BLOCK) * 6);
|
|
36623
|
+
for (let blk = 0; blk * TRI_BLOCK < nt; blk++) {
|
|
36624
|
+
const b = blk * 6;
|
|
36215
36625
|
for (let k = 0; k < 3; k++) {
|
|
36216
|
-
|
|
36217
|
-
|
|
36626
|
+
keptBlocks[b + k] = Infinity;
|
|
36627
|
+
keptBlocks[b + 3 + k] = -Infinity;
|
|
36218
36628
|
}
|
|
36629
|
+
for (let t = blk * TRI_BLOCK, t1 = Math.min(nt, t + TRI_BLOCK); t < t1; t++)
|
|
36630
|
+
for (let k = 0; k < 3; k++) {
|
|
36631
|
+
if (keptBox[t * 6 + k] < keptBlocks[b + k]) keptBlocks[b + k] = keptBox[t * 6 + k];
|
|
36632
|
+
if (keptBox[t * 6 + 3 + k] > keptBlocks[b + 3 + k]) keptBlocks[b + 3 + k] = keptBox[t * 6 + 3 + k];
|
|
36633
|
+
}
|
|
36219
36634
|
}
|
|
36220
36635
|
const pg = new THREE.BufferGeometry();
|
|
36221
36636
|
pg.setAttribute("position", g.attributes.position);
|
|
@@ -36226,7 +36641,8 @@ var GameVehiclesThree = (() => {
|
|
|
36226
36641
|
proxy.layers.mask = o.layers.mask;
|
|
36227
36642
|
proxy.proxyOf = o;
|
|
36228
36643
|
proxy.kept = kept;
|
|
36229
|
-
proxy.keptBox =
|
|
36644
|
+
proxy.keptBox = keptBox;
|
|
36645
|
+
proxy.keptBlocks = keptBlocks;
|
|
36230
36646
|
return proxy;
|
|
36231
36647
|
}
|
|
36232
36648
|
function narrowTo(rc, proxy) {
|
|
@@ -36246,13 +36662,21 @@ var GameVehiclesThree = (() => {
|
|
|
36246
36662
|
const hi2 = Math.max(z0, _pv.z) + 1e-4;
|
|
36247
36663
|
const K = proxy.kept;
|
|
36248
36664
|
const X = proxy.keptBox;
|
|
36665
|
+
const KB = proxy.keptBlocks;
|
|
36666
|
+
const nt = K.length / 3;
|
|
36249
36667
|
const dst = proxy.geometry.index.array;
|
|
36250
36668
|
let m = 0;
|
|
36251
|
-
for (let
|
|
36252
|
-
|
|
36253
|
-
|
|
36254
|
-
|
|
36255
|
-
|
|
36669
|
+
for (let blk = 0, t0 = 0; t0 < nt; blk++, t0 += TRI_BLOCK) {
|
|
36670
|
+
const b = blk * 6;
|
|
36671
|
+
if (KB[b + 3] < lo0 || KB[b] > hi0 || KB[b + 4] < lo1 || KB[b + 1] > hi1 || KB[b + 5] < lo2 || KB[b + 2] > hi2) continue;
|
|
36672
|
+
const t1 = Math.min(nt, t0 + TRI_BLOCK);
|
|
36673
|
+
for (let t = t0; t < t1; t++) {
|
|
36674
|
+
const j = t * 6;
|
|
36675
|
+
if (X[j + 3] < lo0 || X[j] > hi0 || X[j + 4] < lo1 || X[j + 1] > hi1 || X[j + 5] < lo2 || X[j + 2] > hi2) continue;
|
|
36676
|
+
dst[m++] = K[t * 3];
|
|
36677
|
+
dst[m++] = K[t * 3 + 1];
|
|
36678
|
+
dst[m++] = K[t * 3 + 2];
|
|
36679
|
+
}
|
|
36256
36680
|
}
|
|
36257
36681
|
proxy.geometry.setDrawRange(0, m);
|
|
36258
36682
|
}
|
|
@@ -36668,6 +37092,8 @@ var GameVehiclesThree = (() => {
|
|
|
36668
37092
|
irel.copy(rel).invert();
|
|
36669
37093
|
const pos = g.attributes.position;
|
|
36670
37094
|
let changed = false;
|
|
37095
|
+
const liveIndex = liveTriIndex(g);
|
|
37096
|
+
const movedVertices = [];
|
|
36671
37097
|
const near = boxInFrame(B, irel, v);
|
|
36672
37098
|
for (let i = 0; i < pos.count; i++) {
|
|
36673
37099
|
v.fromBufferAttribute(pos, i);
|
|
@@ -36679,6 +37105,7 @@ var GameVehiclesThree = (() => {
|
|
|
36679
37105
|
if (opt.extra) opt.extra(v, f);
|
|
36680
37106
|
v.applyMatrix4(irel);
|
|
36681
37107
|
pos.setXYZ(i, v.x, v.y, v.z);
|
|
37108
|
+
movedVertices.push(i);
|
|
36682
37109
|
changed = true;
|
|
36683
37110
|
}
|
|
36684
37111
|
if (opt.extraAll) {
|
|
@@ -36687,12 +37114,14 @@ var GameVehiclesThree = (() => {
|
|
|
36687
37114
|
if (opt.extraAll(v)) {
|
|
36688
37115
|
v.applyMatrix4(irel);
|
|
36689
37116
|
pos.setXYZ(j, v.x, v.y, v.z);
|
|
37117
|
+
movedVertices.push(j);
|
|
36690
37118
|
changed = true;
|
|
36691
37119
|
}
|
|
36692
37120
|
}
|
|
36693
37121
|
}
|
|
36694
37122
|
if (changed) {
|
|
36695
37123
|
pos.needsUpdate = true;
|
|
37124
|
+
if (liveIndex) touchTriIndex(g, liveIndex, movedVertices);
|
|
36696
37125
|
dirty.add(msh);
|
|
36697
37126
|
}
|
|
36698
37127
|
if (changed || boundsDue) {
|
|
@@ -36723,6 +37152,26 @@ var GameVehiclesThree = (() => {
|
|
|
36723
37152
|
});
|
|
36724
37153
|
return { field, moved, ax, a, cu, cv, hu, hv, outer };
|
|
36725
37154
|
}
|
|
37155
|
+
function panelBoundsIn(rel, rect, B, a, ax) {
|
|
37156
|
+
const det = rel.determinant();
|
|
37157
|
+
if (!Number.isFinite(det) || Math.abs(det) < 1e-12) return void 0;
|
|
37158
|
+
const back = rel.clone().invert();
|
|
37159
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
37160
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
37161
|
+
const q = new V3();
|
|
37162
|
+
for (let i = 0; i < 8; i++) {
|
|
37163
|
+
q.setComponent(ax[0], i & 1 ? rect[1] : rect[0]);
|
|
37164
|
+
q.setComponent(ax[1], i & 2 ? rect[3] : rect[2]);
|
|
37165
|
+
q.setComponent(a, i & 4 ? I.boxHi(B, a) : I.boxLo(B, a));
|
|
37166
|
+
q.applyMatrix4(back);
|
|
37167
|
+
for (let k = 0; k < 3; k++) {
|
|
37168
|
+
lo[k] = Math.min(lo[k], q.getComponent(k));
|
|
37169
|
+
hi[k] = Math.max(hi[k], q.getComponent(k));
|
|
37170
|
+
}
|
|
37171
|
+
}
|
|
37172
|
+
const pad = 1e-3;
|
|
37173
|
+
return { lo: lo.map((x) => x - pad), hi: hi.map((x) => x + pad) };
|
|
37174
|
+
}
|
|
36726
37175
|
function cutPanel(c, z, rect, keep, dirty, o) {
|
|
36727
37176
|
o = o || {};
|
|
36728
37177
|
const B = z.box;
|
|
@@ -36755,6 +37204,7 @@ var GameVehiclesThree = (() => {
|
|
|
36755
37204
|
}
|
|
36756
37205
|
const test = {
|
|
36757
37206
|
tag: "part",
|
|
37207
|
+
pieces: keep ? o.pieceTasks ? "later" : "crease" : "none",
|
|
36758
37208
|
sel: o.anyN || z.cutAll ? null : function(n) {
|
|
36759
37209
|
nv.copy(n).applyMatrix3(nm).normalize();
|
|
36760
37210
|
return nv.dot(outN) > 0.3;
|
|
@@ -36773,13 +37223,12 @@ var GameVehiclesThree = (() => {
|
|
|
36773
37223
|
return q;
|
|
36774
37224
|
}
|
|
36775
37225
|
};
|
|
36776
|
-
const r = cutGeometry(g, [test]);
|
|
37226
|
+
const r = cutGeometry(g, [{ ...test, bounds: panelBoundsIn(rel, rect, B, a, ax) }]);
|
|
36777
37227
|
const cg = r.cut.part;
|
|
36778
37228
|
if (!cg || !cg.attributes.position.count) return;
|
|
36779
37229
|
g.dispose();
|
|
36780
37230
|
msh.geometry = r.geo;
|
|
36781
|
-
r.geo
|
|
36782
|
-
r.geo.computeBoundingBox();
|
|
37231
|
+
I.refreshBounds(r.geo);
|
|
36783
37232
|
dirty.add(msh);
|
|
36784
37233
|
if (!keep) {
|
|
36785
37234
|
cg.dispose();
|
|
@@ -36792,6 +37241,7 @@ var GameVehiclesThree = (() => {
|
|
|
36792
37241
|
rel.decompose(pm.position, pm.quaternion, pm.scale);
|
|
36793
37242
|
c.vehicle.add(pm);
|
|
36794
37243
|
pm.updateMatrixWorld(true);
|
|
37244
|
+
if (o.pieceTasks) o.pieceTasks.set(pm, r.tasks.part);
|
|
36795
37245
|
pieces.push({ mesh: pm, cut: true });
|
|
36796
37246
|
});
|
|
36797
37247
|
return pieces;
|
|
@@ -39807,13 +40257,13 @@ var GameVehiclesThree = (() => {
|
|
|
39807
40257
|
return c;
|
|
39808
40258
|
}
|
|
39809
40259
|
kit.dispose = function(c) {
|
|
39810
|
-
const
|
|
40260
|
+
const shared2 = Object.values(I.PARTICLE_GEOMETRIES);
|
|
39811
40261
|
c.root.traverse(function(o) {
|
|
39812
40262
|
if (o.isSprite) {
|
|
39813
40263
|
if (o.material && o.material.userData.dis) o.material.dispose();
|
|
39814
40264
|
return;
|
|
39815
40265
|
}
|
|
39816
|
-
if (o.geometry && !
|
|
40266
|
+
if (o.geometry && !shared2.includes(o.geometry)) o.geometry.dispose();
|
|
39817
40267
|
});
|
|
39818
40268
|
};
|
|
39819
40269
|
kit.registerLegacySeeds = registerLegacySeeds;
|
|
@@ -40401,7 +40851,11 @@ var GameVehiclesThree = (() => {
|
|
|
40401
40851
|
__publicField(this, "plates", /* @__PURE__ */ new Map());
|
|
40402
40852
|
__publicField(this, "gone", /* @__PURE__ */ new Set());
|
|
40403
40853
|
__publicField(this, "syncPlates", /* @__PURE__ */ new Map());
|
|
40854
|
+
__publicField(this, "skins", /* @__PURE__ */ new Map());
|
|
40404
40855
|
__publicField(this, "lightsOn", true);
|
|
40856
|
+
__publicField(this, "warming");
|
|
40857
|
+
__publicField(this, "tornThisFrame", false);
|
|
40858
|
+
__publicField(this, "smoothing", /* @__PURE__ */ new Map());
|
|
40405
40859
|
__publicField(this, "hood");
|
|
40406
40860
|
this.kit = kit;
|
|
40407
40861
|
this.c = c;
|
|
@@ -40411,6 +40865,8 @@ var GameVehiclesThree = (() => {
|
|
|
40411
40865
|
for (const p of model.parts) this.byId.set(p.id, p);
|
|
40412
40866
|
c.root.updateMatrixWorld(true);
|
|
40413
40867
|
this.hood = this.nameHood();
|
|
40868
|
+
this.warming = c.deform.filter((msh) => msh.geometry && msh.geometry.attributes.position && msh.geometry.attributes.position.count >= 1500);
|
|
40869
|
+
if (!this.warming.length) this.warming = null;
|
|
40414
40870
|
for (const p of model.parts) {
|
|
40415
40871
|
if (p.role === "door" || p.role === "lid") this.makePlate(p);
|
|
40416
40872
|
else if (p.role === "mirror" && !this.mirrorObjects(p).length) this.makeMirror(p);
|
|
@@ -40546,11 +41002,21 @@ var GameVehiclesThree = (() => {
|
|
|
40546
41002
|
* keeps the shape of its model instead of flat panels over its curved sides. Follows the hinge's rotation, whoever turns it (the clips of a host, `detach`).
|
|
40547
41003
|
*/
|
|
40548
41004
|
showWhenOpen(id, piv, panel, recess) {
|
|
41005
|
+
let busy = false;
|
|
40549
41006
|
const sync = () => {
|
|
41007
|
+
if (busy) return;
|
|
40550
41008
|
const r = piv.rotation;
|
|
40551
41009
|
const open = Math.abs(r.x) + Math.abs(r.y) + Math.abs(r.z) > 1e-3 || this.gone.has(id) || piv.parent !== this.c.vehicle;
|
|
40552
|
-
|
|
40553
|
-
|
|
41010
|
+
if (open && !this.gone.has(id) && piv.parent === this.c.vehicle && !this.skins.has(id)) {
|
|
41011
|
+
busy = true;
|
|
41012
|
+
try {
|
|
41013
|
+
this.skins.set(id, this.takeSkin(id, piv));
|
|
41014
|
+
} finally {
|
|
41015
|
+
busy = false;
|
|
41016
|
+
}
|
|
41017
|
+
}
|
|
41018
|
+
panel.visible = open && !this.skins.get(id);
|
|
41019
|
+
recess.visible = open && !this.skins.get(id);
|
|
40554
41020
|
};
|
|
40555
41021
|
const euler = piv.rotation;
|
|
40556
41022
|
const quaternion = piv.quaternion;
|
|
@@ -40567,6 +41033,58 @@ var GameVehiclesThree = (() => {
|
|
|
40567
41033
|
this.syncPlates.set(id, sync);
|
|
40568
41034
|
sync();
|
|
40569
41035
|
}
|
|
41036
|
+
/**
|
|
41037
|
+
* Cuts the skin of a door or lid zone out of the body (as the damage's hanging door does) and hangs it, with the thin parts on it (trim, handle) and, for a door, the side
|
|
41038
|
+
* window over it, on the hinge. Done with the hinge closed, so every piece keeps its place; answers whether there was skin to take.
|
|
41039
|
+
*/
|
|
41040
|
+
takeSkin(id, piv) {
|
|
41041
|
+
const p = this.byId.get(id);
|
|
41042
|
+
const z = p && this.zone(p);
|
|
41043
|
+
if (!p || !z) return false;
|
|
41044
|
+
const I = this.I;
|
|
41045
|
+
const B = z.box;
|
|
41046
|
+
const q = piv.quaternion.clone();
|
|
41047
|
+
piv.quaternion.identity();
|
|
41048
|
+
this.c.root.updateMatrixWorld(true);
|
|
41049
|
+
const inv = I.worldInverseOf(this.c);
|
|
41050
|
+
let objs = [];
|
|
41051
|
+
try {
|
|
41052
|
+
if (p.role === "door") {
|
|
41053
|
+
const dirty = /* @__PURE__ */ new Set();
|
|
41054
|
+
const rect = [B.x0 + 0.03, B.x1 - 0.03, B.y0 + Math.min(0.08, (B.y1 - B.y0) * 0.1), B.y1 - 0.02];
|
|
41055
|
+
const pcs = I.cutPanel(this.c, z, rect, true, dirty).map((x) => x.mesh).filter((m) => !!m);
|
|
41056
|
+
this.mend(dirty);
|
|
41057
|
+
if (pcs.length) objs = [...pcs, ...I.followersIn(this.c, z, inv), ...I.windowsOver(this.c, z, inv)];
|
|
41058
|
+
} else {
|
|
41059
|
+
const pcs = this.cutZone(z);
|
|
41060
|
+
if (pcs.length) objs = [...pcs, ...I.followersIn(this.c, z, inv)];
|
|
41061
|
+
}
|
|
41062
|
+
} catch {
|
|
41063
|
+
objs = [];
|
|
41064
|
+
}
|
|
41065
|
+
const deform = this.c.deform ?? [];
|
|
41066
|
+
for (const o of objs) {
|
|
41067
|
+
if (!o.parent || o === piv) continue;
|
|
41068
|
+
piv.attach(o);
|
|
41069
|
+
o.traverse((x) => {
|
|
41070
|
+
x.userData.noFollow = true;
|
|
41071
|
+
});
|
|
41072
|
+
const di = deform.indexOf(o);
|
|
41073
|
+
if (di >= 0) deform.splice(di, 1);
|
|
41074
|
+
}
|
|
41075
|
+
piv.quaternion.copy(q);
|
|
41076
|
+
this.c.root.updateMatrixWorld(true);
|
|
41077
|
+
return objs.length > 0;
|
|
41078
|
+
}
|
|
41079
|
+
mend(dirty) {
|
|
41080
|
+
dirty.forEach((msh) => {
|
|
41081
|
+
const g = msh.geometry;
|
|
41082
|
+
if (g.userData.crease || !g.index) this.I.crease(g, 42);
|
|
41083
|
+
else g.computeVertexNormals();
|
|
41084
|
+
g.computeBoundingSphere();
|
|
41085
|
+
g.computeBoundingBox();
|
|
41086
|
+
});
|
|
41087
|
+
}
|
|
40570
41088
|
makeMirror(p) {
|
|
40571
41089
|
const [cx, cy, cz] = p.box.center;
|
|
40572
41090
|
const s = cz < 0 ? -1 : 1;
|
|
@@ -40704,6 +41222,31 @@ var GameVehiclesThree = (() => {
|
|
|
40704
41222
|
this.I.flattenTire(w, Math.min(0.5, 0.12 + 0.38 * melt));
|
|
40705
41223
|
}
|
|
40706
41224
|
}
|
|
41225
|
+
/** Smooths the normals of a cut mesh a slice per frame (see `pump`); until then it draws with flat face normals. */
|
|
41226
|
+
smoothLater(msh) {
|
|
41227
|
+
this.smoothing.set(msh, this.I.creaseTask(msh.geometry, 42));
|
|
41228
|
+
this.tornThisFrame = true;
|
|
41229
|
+
}
|
|
41230
|
+
/** Spends at most `budgetMs` finishing the pending normal smoothing. Call once per frame. */
|
|
41231
|
+
pump(budgetMs = 2.5) {
|
|
41232
|
+
if (this.tornThisFrame) {
|
|
41233
|
+
this.tornThisFrame = false;
|
|
41234
|
+
return;
|
|
41235
|
+
}
|
|
41236
|
+
if (!this.smoothing.size && !this.warming) return;
|
|
41237
|
+
const deadline = performance.now() + budgetMs;
|
|
41238
|
+
for (const [msh, task] of this.smoothing) {
|
|
41239
|
+
if (msh.geometry !== task.geo || task.step(deadline)) this.smoothing.delete(msh);
|
|
41240
|
+
if (performance.now() >= deadline) return;
|
|
41241
|
+
}
|
|
41242
|
+
this.warmIndexes(deadline);
|
|
41243
|
+
}
|
|
41244
|
+
/** Measures the triangles of the heavy body meshes once, a slice per frame, so the first panel torn off finds them ready (see `triIndexOf`). */
|
|
41245
|
+
warmIndexes(deadline) {
|
|
41246
|
+
if (!this.warming) return;
|
|
41247
|
+
this.warming = this.warming.filter((msh) => !warmTriIndex(msh.geometry, deadline));
|
|
41248
|
+
if (!this.warming.length) this.warming = null;
|
|
41249
|
+
}
|
|
40707
41250
|
/** Moves the panel of a lost zone out of the body (the kit's torn-off look). */
|
|
40708
41251
|
tearOff(p) {
|
|
40709
41252
|
const z = this.zone(p);
|
|
@@ -40716,10 +41259,9 @@ var GameVehiclesThree = (() => {
|
|
|
40716
41259
|
}
|
|
40717
41260
|
dirty.forEach((msh) => {
|
|
40718
41261
|
const g = msh.geometry;
|
|
40719
|
-
if (g.userData.crease || !g.index) this.
|
|
41262
|
+
if (g.userData.crease || !g.index) this.smoothLater(msh);
|
|
40720
41263
|
else g.computeVertexNormals();
|
|
40721
|
-
|
|
40722
|
-
g.computeBoundingBox();
|
|
41264
|
+
this.I.refreshBounds(g);
|
|
40723
41265
|
});
|
|
40724
41266
|
this.gone.add(p.id);
|
|
40725
41267
|
}
|
|
@@ -40862,17 +41404,19 @@ var GameVehiclesThree = (() => {
|
|
|
40862
41404
|
const mg = Math.min(0.05, (u1 - u0) * 0.08, (v1 - v0) * 0.08);
|
|
40863
41405
|
const dirty = /* @__PURE__ */ new Set();
|
|
40864
41406
|
let pcs = [];
|
|
41407
|
+
const pieceTasks = /* @__PURE__ */ new Map();
|
|
40865
41408
|
try {
|
|
40866
|
-
pcs = I.cutPanel(this.c, z, [u0 + mg, u1 - mg, v0 + mg, v1 - mg], true, dirty);
|
|
41409
|
+
pcs = I.cutPanel(this.c, z, [u0 + mg, u1 - mg, v0 + mg, v1 - mg], true, dirty, { pieceTasks });
|
|
40867
41410
|
} catch {
|
|
40868
41411
|
pcs = [];
|
|
40869
41412
|
}
|
|
41413
|
+
pieceTasks.forEach((task, mesh2) => this.smoothing.set(mesh2, task));
|
|
41414
|
+
this.tornThisFrame = true;
|
|
40870
41415
|
dirty.forEach((msh) => {
|
|
40871
41416
|
const g = msh.geometry;
|
|
40872
|
-
if (g.userData.crease || !g.index)
|
|
41417
|
+
if (g.userData.crease || !g.index) this.smoothLater(msh);
|
|
40873
41418
|
else g.computeVertexNormals();
|
|
40874
|
-
|
|
40875
|
-
g.computeBoundingBox();
|
|
41419
|
+
I.refreshBounds(g);
|
|
40876
41420
|
});
|
|
40877
41421
|
return pcs.map((q) => q.mesh).filter((m) => !!m);
|
|
40878
41422
|
}
|
|
@@ -41647,11 +42191,11 @@ var GameVehiclesThree = (() => {
|
|
|
41647
42191
|
specCache = { name: options.name ?? c.spec.name ?? c.key, parts, joints, tags: ["vehicle", kindOf(c)] };
|
|
41648
42192
|
return specCache;
|
|
41649
42193
|
};
|
|
41650
|
-
const
|
|
42194
|
+
const buildState = () => {
|
|
41651
42195
|
const parts = model.parts.map((d) => {
|
|
41652
42196
|
const p = ps.get(d.id);
|
|
41653
|
-
const
|
|
41654
|
-
const status = p.lost ? p.status : p.hp < p.def.hp ||
|
|
42197
|
+
const marked2 = p.dents.length > 0 || p.holes.length > 0 || p.cracks.length > 0;
|
|
42198
|
+
const status = p.lost ? p.status : p.hp < p.def.hp || marked2 ? "damaged" : "intact";
|
|
41655
42199
|
return {
|
|
41656
42200
|
id: d.id,
|
|
41657
42201
|
material: d.material,
|
|
@@ -41684,7 +42228,15 @@ var GameVehiclesThree = (() => {
|
|
|
41684
42228
|
}));
|
|
41685
42229
|
return { id, name: options.name ?? c.spec.name ?? c.key, position: [0, 0, 0], rotation: [0, 0, 0, 1], parts, joints, groups: groupsCache.map((g) => [...g]), destroyed: parts.every((p) => p.status === "broken" || p.status === "melted" || p.status === "ashes") };
|
|
41686
42230
|
};
|
|
42231
|
+
let stateCache;
|
|
42232
|
+
const state = () => stateCache ?? (stateCache = buildState());
|
|
42233
|
+
const isSimulating = () => {
|
|
42234
|
+
if (leaks.size > 0) return true;
|
|
42235
|
+
for (const p of ps.values()) if (!p.lost && (p.burning || p.temp > AMBIENT)) return true;
|
|
42236
|
+
return false;
|
|
42237
|
+
};
|
|
41687
42238
|
const hit = (h) => {
|
|
42239
|
+
stateCache = void 0;
|
|
41688
42240
|
const out = [];
|
|
41689
42241
|
const hh = h.space === "local" ? { ...h, space: "world", point: toWorld(h.point) } : h;
|
|
41690
42242
|
if (hh.space === "local" || !hh.point) return out;
|
|
@@ -41711,6 +42263,8 @@ var GameVehiclesThree = (() => {
|
|
|
41711
42263
|
clock += dt;
|
|
41712
42264
|
const out = queue;
|
|
41713
42265
|
queue = [];
|
|
42266
|
+
const wasSimulating = isSimulating();
|
|
42267
|
+
const handledBefore = (blastHandled ? 1 : 0) + (rollHandled ? 2 : 0);
|
|
41714
42268
|
const hood = c.hood;
|
|
41715
42269
|
if (hood) {
|
|
41716
42270
|
const sign2 = hood.sign || 1;
|
|
@@ -41731,12 +42285,15 @@ var GameVehiclesThree = (() => {
|
|
|
41731
42285
|
afterBlast(out);
|
|
41732
42286
|
afterRoll(out);
|
|
41733
42287
|
applyEffects();
|
|
42288
|
+
vis?.pump();
|
|
42289
|
+
if (wasSimulating || out.length > 0 || handledBefore !== (blastHandled ? 1 : 0) + (rollHandled ? 2 : 0)) stateCache = void 0;
|
|
41734
42290
|
return out;
|
|
41735
42291
|
};
|
|
41736
42292
|
const disassemble = (jointId, tool, dt) => {
|
|
41737
42293
|
const j = js.find((x) => x.def.id === jointId);
|
|
41738
42294
|
if (!j || !j.def.tools.includes(tool)) return -1;
|
|
41739
42295
|
if (j.open) return 1;
|
|
42296
|
+
stateCache = void 0;
|
|
41740
42297
|
j.progress = Math.min(1, j.progress + dt / j.def.seconds);
|
|
41741
42298
|
const step = Math.floor(j.progress * 4) / 4;
|
|
41742
42299
|
if (step > j.reported && j.progress < 1) {
|
|
@@ -41752,6 +42309,7 @@ var GameVehiclesThree = (() => {
|
|
|
41752
42309
|
return j.progress;
|
|
41753
42310
|
};
|
|
41754
42311
|
const extinguish = (partId) => {
|
|
42312
|
+
stateCache = void 0;
|
|
41755
42313
|
for (const p of ps.values()) {
|
|
41756
42314
|
if (partId && p.def.id !== partId) continue;
|
|
41757
42315
|
if (p.burning) {
|
|
@@ -41765,6 +42323,7 @@ var GameVehiclesThree = (() => {
|
|
|
41765
42323
|
}
|
|
41766
42324
|
};
|
|
41767
42325
|
const reset = () => {
|
|
42326
|
+
stateCache = void 0;
|
|
41768
42327
|
const old = c;
|
|
41769
42328
|
const parent = old.root.parent;
|
|
41770
42329
|
const next = kit.build(old.key, old.state, old.scenario != null ? { scenario: old.scenario } : void 0);
|
|
@@ -41782,6 +42341,7 @@ var GameVehiclesThree = (() => {
|
|
|
41782
42341
|
setup();
|
|
41783
42342
|
};
|
|
41784
42343
|
const rollover = (side2 = 1) => {
|
|
42344
|
+
stateCache = void 0;
|
|
41785
42345
|
if (kit.roll(c, side2)) rolled = true;
|
|
41786
42346
|
void rolled;
|
|
41787
42347
|
};
|
|
@@ -42626,9 +43186,9 @@ var GameVehiclesThree = (() => {
|
|
|
42626
43186
|
driver.state.u = 80 / 3.6;
|
|
42627
43187
|
for (let t = 0; t < 1; t += dt) driver.step({ ...coast, throttle: 0.3 }, dt, world(surface));
|
|
42628
43188
|
driver.state.u = 80 / 3.6;
|
|
42629
|
-
const
|
|
43189
|
+
const start2 = driver.state.x;
|
|
42630
43190
|
for (let t = 0; t < 30 && driver.state.u > 0.1; t += dt) driver.step({ ...coast, brake: 1 }, dt, world(surface));
|
|
42631
|
-
return driver.state.x -
|
|
43191
|
+
return driver.state.x - start2;
|
|
42632
43192
|
};
|
|
42633
43193
|
const dry = braking("dry_asphalt");
|
|
42634
43194
|
const wet = braking("wet_asphalt");
|
|
@@ -43035,10 +43595,10 @@ var GameVehiclesThree = (() => {
|
|
|
43035
43595
|
};
|
|
43036
43596
|
const clearHelpers = () => {
|
|
43037
43597
|
for (const entry of placed.values()) {
|
|
43038
|
-
|
|
43598
|
+
discardObject3D(entry.helpers);
|
|
43039
43599
|
entry.helpers = [];
|
|
43040
43600
|
}
|
|
43041
|
-
|
|
43601
|
+
discardObject3D(axes);
|
|
43042
43602
|
axes = [];
|
|
43043
43603
|
helpersShown = "";
|
|
43044
43604
|
};
|