@adatechnology/game-vehicles-three 0.2.0 → 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/dist/index.d.ts +10 -1
- package/dist/index.global.js +326 -80
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.global.js
CHANGED
|
@@ -22,6 +22,7 @@ var GameVehiclesThree = (() => {
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
DEFAULT_TEST_VEHICLES: () => DEFAULT_TEST_VEHICLES,
|
|
25
|
+
DEFAULT_TEST_WRECKS: () => DEFAULT_TEST_WRECKS,
|
|
25
26
|
LITE_CLASSES: () => LITE_CLASSES,
|
|
26
27
|
PAGE_ITEM_ALIASES: () => PAGE_ITEM_ALIASES,
|
|
27
28
|
PAGE_SCENARIO_ALIASES: () => PAGE_SCENARIO_ALIASES,
|
|
@@ -30404,46 +30405,79 @@ var GameVehiclesThree = (() => {
|
|
|
30404
30405
|
}
|
|
30405
30406
|
const p = geo.attributes.position;
|
|
30406
30407
|
const n = p.count;
|
|
30407
|
-
const
|
|
30408
|
-
const
|
|
30409
|
-
const
|
|
30410
|
-
const
|
|
30411
|
-
const C = new V3();
|
|
30412
|
-
const e1 = new V3();
|
|
30413
|
-
const e2 = new V3();
|
|
30408
|
+
const faces = n / 3;
|
|
30409
|
+
const FN = new Float64Array(faces * 3);
|
|
30410
|
+
const map = /* @__PURE__ */ new Map();
|
|
30411
|
+
const RANGE = 65536;
|
|
30414
30412
|
function key(i) {
|
|
30415
|
-
|
|
30413
|
+
const x = Math.round(p.getX(i) * 2e3);
|
|
30414
|
+
const y = Math.round(p.getY(i) * 2e3);
|
|
30415
|
+
const z = Math.round(p.getZ(i) * 2e3);
|
|
30416
|
+
if (Math.abs(x) < RANGE && Math.abs(y) < RANGE && Math.abs(z) < RANGE) return ((x + RANGE) * 131072 + (y + RANGE)) * 131072 + (z + RANGE);
|
|
30417
|
+
return x + "," + y + "," + z;
|
|
30416
30418
|
}
|
|
30417
30419
|
const keys = new Array(n);
|
|
30418
|
-
for (let f = 0; f <
|
|
30419
|
-
|
|
30420
|
-
|
|
30421
|
-
|
|
30422
|
-
const
|
|
30423
|
-
|
|
30424
|
-
|
|
30420
|
+
for (let f = 0; f < faces; f++) {
|
|
30421
|
+
const ax = p.getX(3 * f);
|
|
30422
|
+
const ay = p.getY(3 * f);
|
|
30423
|
+
const az = p.getZ(3 * f);
|
|
30424
|
+
const bx = p.getX(3 * f + 1);
|
|
30425
|
+
const by = p.getY(3 * f + 1);
|
|
30426
|
+
const bz = p.getZ(3 * f + 1);
|
|
30427
|
+
const cx = p.getX(3 * f + 2);
|
|
30428
|
+
const cy = p.getY(3 * f + 2);
|
|
30429
|
+
const cz = p.getZ(3 * f + 2);
|
|
30430
|
+
const e1x = cx - bx;
|
|
30431
|
+
const e1y = cy - by;
|
|
30432
|
+
const e1z = cz - bz;
|
|
30433
|
+
const e2x = ax - bx;
|
|
30434
|
+
const e2y = ay - by;
|
|
30435
|
+
const e2z = az - bz;
|
|
30436
|
+
let nx = e1y * e2z - e1z * e2y;
|
|
30437
|
+
let ny = e1z * e2x - e1x * e2z;
|
|
30438
|
+
let nz = e1x * e2y - e1y * e2x;
|
|
30439
|
+
if (nx * nx + ny * ny + nz * nz > 1e-20) {
|
|
30440
|
+
const inv = 1 / (Math.sqrt(nx * nx + ny * ny + nz * nz) || 1);
|
|
30441
|
+
nx *= inv;
|
|
30442
|
+
ny *= inv;
|
|
30443
|
+
nz *= inv;
|
|
30444
|
+
}
|
|
30445
|
+
FN[3 * f] = nx;
|
|
30446
|
+
FN[3 * f + 1] = ny;
|
|
30447
|
+
FN[3 * f + 2] = nz;
|
|
30425
30448
|
for (let k = 0; k < 3; k++) {
|
|
30426
30449
|
const kk = key(3 * f + k);
|
|
30427
30450
|
keys[3 * f + k] = kk;
|
|
30428
|
-
|
|
30451
|
+
const list2 = map.get(kk);
|
|
30452
|
+
if (list2) list2.push(f);
|
|
30453
|
+
else map.set(kk, [f]);
|
|
30429
30454
|
}
|
|
30430
30455
|
}
|
|
30431
30456
|
const cs = Math.cos(deg * PI / 180);
|
|
30432
30457
|
const out = new Float32Array(n * 3);
|
|
30433
|
-
const s = new V3();
|
|
30434
30458
|
for (let i = 0; i < n; i++) {
|
|
30435
|
-
const fi = i / 3 | 0;
|
|
30436
|
-
const list2 = map
|
|
30437
|
-
|
|
30459
|
+
const fi = (i / 3 | 0) * 3;
|
|
30460
|
+
const list2 = map.get(keys[i]);
|
|
30461
|
+
let sx = 0;
|
|
30462
|
+
let sy = 0;
|
|
30463
|
+
let sz = 0;
|
|
30438
30464
|
for (let j = 0; j < list2.length; j++) {
|
|
30439
|
-
const g =
|
|
30440
|
-
if (g
|
|
30465
|
+
const g = list2[j] * 3;
|
|
30466
|
+
if (FN[g] * FN[fi] + FN[g + 1] * FN[fi + 1] + FN[g + 2] * FN[fi + 2] >= cs) {
|
|
30467
|
+
sx += FN[g];
|
|
30468
|
+
sy += FN[g + 1];
|
|
30469
|
+
sz += FN[g + 2];
|
|
30470
|
+
}
|
|
30441
30471
|
}
|
|
30442
|
-
if (
|
|
30443
|
-
|
|
30444
|
-
|
|
30445
|
-
|
|
30446
|
-
|
|
30472
|
+
if (sx * sx + sy * sy + sz * sz < 1e-20) {
|
|
30473
|
+
sx = FN[fi];
|
|
30474
|
+
sy = FN[fi + 1];
|
|
30475
|
+
sz = FN[fi + 2];
|
|
30476
|
+
}
|
|
30477
|
+
const inv = 1 / (Math.sqrt(sx * sx + sy * sy + sz * sz) || 1);
|
|
30478
|
+
out[3 * i] = sx * inv;
|
|
30479
|
+
out[3 * i + 1] = sy * inv;
|
|
30480
|
+
out[3 * i + 2] = sz * inv;
|
|
30447
30481
|
}
|
|
30448
30482
|
geo.setAttribute("normal", new THREE.BufferAttribute(out, 3));
|
|
30449
30483
|
geo.userData.crease = true;
|
|
@@ -36061,6 +36095,153 @@ var GameVehiclesThree = (() => {
|
|
|
36061
36095
|
return hole;
|
|
36062
36096
|
}
|
|
36063
36097
|
const _zr = new THREE.Raycaster();
|
|
36098
|
+
const PROXY_MIN_TRIANGLES = 500;
|
|
36099
|
+
const STROKE_REACH = 0.6;
|
|
36100
|
+
const _pv = new V3();
|
|
36101
|
+
const _pm = new THREE.Matrix4();
|
|
36102
|
+
function decalRegion(c, z) {
|
|
36103
|
+
const B = z.box;
|
|
36104
|
+
const lo = [0, 1, 2].map(function(k) {
|
|
36105
|
+
return I.boxLo(B, k) - STROKE_REACH;
|
|
36106
|
+
});
|
|
36107
|
+
const hi = [0, 1, 2].map(function(k) {
|
|
36108
|
+
return I.boxHi(B, k) + STROKE_REACH;
|
|
36109
|
+
});
|
|
36110
|
+
const a = axisOf(z.dir);
|
|
36111
|
+
const dn = z.dir.clone().normalize();
|
|
36112
|
+
const sg = z.dir.getComponent(a) > 0 ? 1 : -1;
|
|
36113
|
+
const outer = sg > 0 ? I.boxLo(B, a) - 0.6 : I.boxHi(B, a) + 0.6;
|
|
36114
|
+
const far = 0.6 + (I.boxHi(B, a) - I.boxLo(B, a)) + 0.05;
|
|
36115
|
+
for (let i = 0; i < 8; i++) {
|
|
36116
|
+
const p = new V3();
|
|
36117
|
+
p.setComponent(a, outer);
|
|
36118
|
+
[0, 1, 2].filter(function(k) {
|
|
36119
|
+
return k !== a;
|
|
36120
|
+
}).forEach(function(k, j) {
|
|
36121
|
+
p.setComponent(k, i >> j & 1 ? I.boxHi(B, k) : I.boxLo(B, k));
|
|
36122
|
+
});
|
|
36123
|
+
for (let e = 0; e < 2; e++) {
|
|
36124
|
+
const q = e ? p.clone().addScaledVector(dn, far) : p;
|
|
36125
|
+
for (let k = 0; k < 3; k++) {
|
|
36126
|
+
lo[k] = Math.min(lo[k], q.getComponent(k) - 0.05);
|
|
36127
|
+
hi[k] = Math.max(hi[k], q.getComponent(k) + 0.05);
|
|
36128
|
+
}
|
|
36129
|
+
}
|
|
36130
|
+
}
|
|
36131
|
+
return { lo, hi };
|
|
36132
|
+
}
|
|
36133
|
+
function regionCands(c, z, cands) {
|
|
36134
|
+
if (!cands.some(heavy)) return cands;
|
|
36135
|
+
const R = decalRegion(c, z);
|
|
36136
|
+
const Mw = c.vehicle.matrixWorld;
|
|
36137
|
+
return cands.map(function(o) {
|
|
36138
|
+
if (!heavy(o)) return o;
|
|
36139
|
+
if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
|
|
36140
|
+
if (!o.geometry.boundingBox) o.geometry.computeBoundingBox();
|
|
36141
|
+
return proxyIn(o, Mw, R);
|
|
36142
|
+
});
|
|
36143
|
+
}
|
|
36144
|
+
function heavy(o) {
|
|
36145
|
+
const g = o.geometry;
|
|
36146
|
+
const pos = g && g.attributes && g.attributes.position;
|
|
36147
|
+
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;
|
|
36148
|
+
}
|
|
36149
|
+
function proxyIn(o, Mw, R) {
|
|
36150
|
+
_pm.copy(o.matrixWorld).invert().multiply(Mw);
|
|
36151
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
36152
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
36153
|
+
for (let i = 0; i < 8; i++) {
|
|
36154
|
+
_pv.set(i & 1 ? R.hi[0] : R.lo[0], i & 2 ? R.hi[1] : R.lo[1], i & 4 ? R.hi[2] : R.lo[2]).applyMatrix4(_pm);
|
|
36155
|
+
for (let k = 0; k < 3; k++) {
|
|
36156
|
+
lo[k] = Math.min(lo[k], _pv.getComponent(k));
|
|
36157
|
+
hi[k] = Math.max(hi[k], _pv.getComponent(k));
|
|
36158
|
+
}
|
|
36159
|
+
}
|
|
36160
|
+
const g = o.geometry;
|
|
36161
|
+
const P = g.attributes.position.array;
|
|
36162
|
+
const ix = g.index ? g.index.array : null;
|
|
36163
|
+
const n = ix ? ix.length : P.length / 3;
|
|
36164
|
+
const keep = new Uint32Array(n - n % 3);
|
|
36165
|
+
let nk = 0;
|
|
36166
|
+
for (let t = 0; t + 2 < n; t += 3) {
|
|
36167
|
+
const a = (ix ? ix[t] : t) * 3;
|
|
36168
|
+
const b = (ix ? ix[t + 1] : t + 1) * 3;
|
|
36169
|
+
const d = (ix ? ix[t + 2] : t + 2) * 3;
|
|
36170
|
+
let out = false;
|
|
36171
|
+
for (let k = 0; k < 3 && !out; k++) {
|
|
36172
|
+
const u = P[a + k];
|
|
36173
|
+
const v = P[b + k];
|
|
36174
|
+
const w = P[d + k];
|
|
36175
|
+
out = Math.max(u, v, w) < lo[k] || Math.min(u, v, w) > hi[k];
|
|
36176
|
+
}
|
|
36177
|
+
if (!out) {
|
|
36178
|
+
keep[nk++] = ix ? ix[t] : t;
|
|
36179
|
+
keep[nk++] = ix ? ix[t + 1] : t + 1;
|
|
36180
|
+
keep[nk++] = ix ? ix[t + 2] : t + 2;
|
|
36181
|
+
}
|
|
36182
|
+
}
|
|
36183
|
+
if (!nk) return null;
|
|
36184
|
+
const kept = keep.slice(0, nk);
|
|
36185
|
+
const box2 = new Float32Array(kept.length / 3 * 6);
|
|
36186
|
+
for (let t = 0, j = 0; t < kept.length; t += 3, j += 6) {
|
|
36187
|
+
const a = kept[t] * 3;
|
|
36188
|
+
const b = kept[t + 1] * 3;
|
|
36189
|
+
const d = kept[t + 2] * 3;
|
|
36190
|
+
for (let k = 0; k < 3; k++) {
|
|
36191
|
+
box2[j + k] = Math.min(P[a + k], P[b + k], P[d + k]);
|
|
36192
|
+
box2[j + 3 + k] = Math.max(P[a + k], P[b + k], P[d + k]);
|
|
36193
|
+
}
|
|
36194
|
+
}
|
|
36195
|
+
const pg = new THREE.BufferGeometry();
|
|
36196
|
+
pg.setAttribute("position", g.attributes.position);
|
|
36197
|
+
pg.setIndex(new THREE.BufferAttribute(new Uint32Array(kept.length), 1));
|
|
36198
|
+
pg.boundingSphere = g.boundingSphere;
|
|
36199
|
+
pg.boundingBox = g.boundingBox;
|
|
36200
|
+
const proxy = new THREE.Mesh(pg, o.material);
|
|
36201
|
+
proxy.layers.mask = o.layers.mask;
|
|
36202
|
+
proxy.proxyOf = o;
|
|
36203
|
+
proxy.kept = kept;
|
|
36204
|
+
proxy.keptBox = box2;
|
|
36205
|
+
return proxy;
|
|
36206
|
+
}
|
|
36207
|
+
function narrowTo(rc, proxy) {
|
|
36208
|
+
const o = proxy.proxyOf;
|
|
36209
|
+
const ray = rc.ray;
|
|
36210
|
+
_pm.copy(o.matrixWorld).invert();
|
|
36211
|
+
_pv.copy(ray.origin).applyMatrix4(_pm);
|
|
36212
|
+
const x0 = _pv.x;
|
|
36213
|
+
const y0 = _pv.y;
|
|
36214
|
+
const z0 = _pv.z;
|
|
36215
|
+
_pv.copy(ray.direction).multiplyScalar(rc.far).add(ray.origin).applyMatrix4(_pm);
|
|
36216
|
+
const lo0 = Math.min(x0, _pv.x) - 1e-4;
|
|
36217
|
+
const lo1 = Math.min(y0, _pv.y) - 1e-4;
|
|
36218
|
+
const lo2 = Math.min(z0, _pv.z) - 1e-4;
|
|
36219
|
+
const hi0 = Math.max(x0, _pv.x) + 1e-4;
|
|
36220
|
+
const hi1 = Math.max(y0, _pv.y) + 1e-4;
|
|
36221
|
+
const hi2 = Math.max(z0, _pv.z) + 1e-4;
|
|
36222
|
+
const K = proxy.kept;
|
|
36223
|
+
const X = proxy.keptBox;
|
|
36224
|
+
const dst = proxy.geometry.index.array;
|
|
36225
|
+
let m = 0;
|
|
36226
|
+
for (let t = 0, j = 0; t < K.length; t += 3, j += 6) {
|
|
36227
|
+
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;
|
|
36228
|
+
dst[m++] = K[t];
|
|
36229
|
+
dst[m++] = K[t + 1];
|
|
36230
|
+
dst[m++] = K[t + 2];
|
|
36231
|
+
}
|
|
36232
|
+
proxy.geometry.setDrawRange(0, m);
|
|
36233
|
+
}
|
|
36234
|
+
function castAt(rc, cands) {
|
|
36235
|
+
for (let i = 0; i < cands.length; i++) {
|
|
36236
|
+
const q = cands[i];
|
|
36237
|
+
if (!q.proxyOf) continue;
|
|
36238
|
+
q.matrixWorld.copy(q.proxyOf.matrixWorld);
|
|
36239
|
+
narrowTo(rc, q);
|
|
36240
|
+
}
|
|
36241
|
+
const hits = rc.intersectObjects(cands, false);
|
|
36242
|
+
for (let i = 0; i < hits.length; i++) if (hits[i].object.proxyOf) hits[i].object = hits[i].object.proxyOf;
|
|
36243
|
+
return hits;
|
|
36244
|
+
}
|
|
36064
36245
|
function zoneCands(c, z, inv, glassToo) {
|
|
36065
36246
|
const out = [];
|
|
36066
36247
|
c.vehicle.traverse(function(o) {
|
|
@@ -36113,7 +36294,7 @@ var GameVehiclesThree = (() => {
|
|
|
36113
36294
|
});
|
|
36114
36295
|
_zr.set(org.clone().applyMatrix4(Mw), d.clone().transformDirection(Mw));
|
|
36115
36296
|
_zr.far = 0.6 + (I.boxHi(B, a) - I.boxLo(B, a)) + 0.05;
|
|
36116
|
-
const hits = _zr
|
|
36297
|
+
const hits = castAt(_zr, cands);
|
|
36117
36298
|
for (let i = 0; i < hits.length; i++) {
|
|
36118
36299
|
const h = hits[i];
|
|
36119
36300
|
if (!h.face) continue;
|
|
@@ -36141,7 +36322,7 @@ var GameVehiclesThree = (() => {
|
|
|
36141
36322
|
const q = s.p.clone().addScaledVector(t, len * 0.5 * k / M);
|
|
36142
36323
|
_rt.set(q.clone().addScaledVector(n, 0.08).applyMatrix4(Mw), n.clone().negate().transformDirection(Mw));
|
|
36143
36324
|
_rt.far = 0.2;
|
|
36144
|
-
const h = _rt
|
|
36325
|
+
const h = castAt(_rt, cands).find(function(x) {
|
|
36145
36326
|
return x.face;
|
|
36146
36327
|
});
|
|
36147
36328
|
if (!h) return null;
|
|
@@ -36212,6 +36393,7 @@ var GameVehiclesThree = (() => {
|
|
|
36212
36393
|
const R = c.rand;
|
|
36213
36394
|
const need = (spec.fine || 0) + (spec.deep || 0) + (spec.chip || 0) + (spec.rust || 0) + (spec.tear || 0) + (spec.ding || 0) + (spec.soot || 0) + (spec.crater || 0);
|
|
36214
36395
|
if (!need) return [];
|
|
36396
|
+
cands = regionCands(c, z, cands).filter(Boolean);
|
|
36215
36397
|
const S = zoneSurf(c, z, need + 2, R, cands);
|
|
36216
36398
|
let k = 0;
|
|
36217
36399
|
const ang0 = R() * PI;
|
|
@@ -36290,8 +36472,25 @@ var GameVehiclesThree = (() => {
|
|
|
36290
36472
|
}
|
|
36291
36473
|
function subdivIn(geo, rel, B, maxLen) {
|
|
36292
36474
|
const a = geo.attributes.position.array;
|
|
36293
|
-
|
|
36294
|
-
|
|
36475
|
+
let out = new Float32Array(a.length + 4096);
|
|
36476
|
+
let used = 0;
|
|
36477
|
+
const push = function(a0, a1, a2, b0, b1, b2, c0, c1, c2) {
|
|
36478
|
+
if (used + 9 > out.length) {
|
|
36479
|
+
const bigger = new Float32Array(out.length * 2);
|
|
36480
|
+
bigger.set(out);
|
|
36481
|
+
out = bigger;
|
|
36482
|
+
}
|
|
36483
|
+
out[used] = a0;
|
|
36484
|
+
out[used + 1] = a1;
|
|
36485
|
+
out[used + 2] = a2;
|
|
36486
|
+
out[used + 3] = b0;
|
|
36487
|
+
out[used + 4] = b1;
|
|
36488
|
+
out[used + 5] = b2;
|
|
36489
|
+
out[used + 6] = c0;
|
|
36490
|
+
out[used + 7] = c1;
|
|
36491
|
+
out[used + 8] = c2;
|
|
36492
|
+
used += 9;
|
|
36493
|
+
};
|
|
36295
36494
|
const e = 0.15;
|
|
36296
36495
|
function d(p, q) {
|
|
36297
36496
|
return Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
|
|
@@ -36305,7 +36504,7 @@ var GameVehiclesThree = (() => {
|
|
|
36305
36504
|
const ca = d(C, A);
|
|
36306
36505
|
const mx = Math.max(ab, bc, ca);
|
|
36307
36506
|
if (mx <= maxLen || depth > 9) {
|
|
36308
|
-
|
|
36507
|
+
push(A[0], A[1], A[2], Bv[0], Bv[1], Bv[2], C[0], C[1], C[2]);
|
|
36309
36508
|
return;
|
|
36310
36509
|
}
|
|
36311
36510
|
if (mx === ab) {
|
|
@@ -36322,31 +36521,26 @@ var GameVehiclesThree = (() => {
|
|
|
36322
36521
|
tri(F2, Bv, C, depth + 1);
|
|
36323
36522
|
}
|
|
36324
36523
|
}
|
|
36524
|
+
const M = rel.elements;
|
|
36525
|
+
const at = function(x, y, z, k) {
|
|
36526
|
+
const w = 1 / (M[3] * x + M[7] * y + M[11] * z + M[15]);
|
|
36527
|
+
return k === 0 ? (M[0] * x + M[4] * y + M[8] * z + M[12]) * w : k === 1 ? (M[1] * x + M[5] * y + M[9] * z + M[13]) * w : (M[2] * x + M[6] * y + M[10] * z + M[14]) * w;
|
|
36528
|
+
};
|
|
36529
|
+
const lo = [B.x0 - e, B.y0 - e, B.z0 - e];
|
|
36530
|
+
const hi = [B.x1 + e, B.y1 + e, B.z1 + e];
|
|
36325
36531
|
for (let i = 0; i < a.length; i += 9) {
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36335
|
-
[A, Bv, C].forEach(function(p) {
|
|
36336
|
-
v.set(p[0], p[1], p[2]).applyMatrix4(rel);
|
|
36337
|
-
x0 = Math.min(x0, v.x);
|
|
36338
|
-
x1 = Math.max(x1, v.x);
|
|
36339
|
-
y0 = Math.min(y0, v.y);
|
|
36340
|
-
y1 = Math.max(y1, v.y);
|
|
36341
|
-
z0 = Math.min(z0, v.z);
|
|
36342
|
-
z1 = Math.max(z1, v.z);
|
|
36343
|
-
});
|
|
36344
|
-
if (x1 < B.x0 - e || x0 > B.x1 + e || y1 < B.y0 - e || y0 > B.y1 + e || z1 < B.z0 - e || z0 > B.z1 + e)
|
|
36345
|
-
out.push(A[0], A[1], A[2], Bv[0], Bv[1], Bv[2], C[0], C[1], C[2]);
|
|
36346
|
-
else tri(A, Bv, C, 0);
|
|
36532
|
+
let outside = false;
|
|
36533
|
+
for (let k = 0; k < 3 && !outside; k++) {
|
|
36534
|
+
const p = at(a[i], a[i + 1], a[i + 2], k);
|
|
36535
|
+
const q = at(a[i + 3], a[i + 4], a[i + 5], k);
|
|
36536
|
+
const r = at(a[i + 6], a[i + 7], a[i + 8], k);
|
|
36537
|
+
outside = Math.max(p, q, r) < lo[k] || Math.min(p, q, r) > hi[k];
|
|
36538
|
+
}
|
|
36539
|
+
if (outside) push(a[i], a[i + 1], a[i + 2], a[i + 3], a[i + 4], a[i + 5], a[i + 6], a[i + 7], a[i + 8]);
|
|
36540
|
+
else tri([a[i], a[i + 1], a[i + 2]], [a[i + 3], a[i + 4], a[i + 5]], [a[i + 6], a[i + 7], a[i + 8]], 0);
|
|
36347
36541
|
}
|
|
36348
36542
|
const g = new THREE.BufferGeometry();
|
|
36349
|
-
g.setAttribute("position", new THREE.
|
|
36543
|
+
g.setAttribute("position", new THREE.BufferAttribute(out.slice(0, used), 3));
|
|
36350
36544
|
g.userData.crease = true;
|
|
36351
36545
|
g.userData.p0 = null;
|
|
36352
36546
|
return g;
|
|
@@ -36369,6 +36563,17 @@ var GameVehiclesThree = (() => {
|
|
|
36369
36563
|
});
|
|
36370
36564
|
return out;
|
|
36371
36565
|
}
|
|
36566
|
+
function boxInFrame(B, m, tmp) {
|
|
36567
|
+
const r = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
36568
|
+
for (let i = 0; i < 8; i++) {
|
|
36569
|
+
tmp.set(i & 1 ? B.x1 : B.x0, i & 2 ? B.y1 : B.y0, i & 4 ? B.z1 : B.z0).applyMatrix4(m);
|
|
36570
|
+
for (let k = 0; k < 3; k++) {
|
|
36571
|
+
r[k] = Math.min(r[k], tmp.getComponent(k) - 1e-4);
|
|
36572
|
+
r[k + 3] = Math.max(r[k + 3], tmp.getComponent(k) + 1e-4);
|
|
36573
|
+
}
|
|
36574
|
+
}
|
|
36575
|
+
return r;
|
|
36576
|
+
}
|
|
36372
36577
|
function zoneDent(c, z, dents, dirty, opt) {
|
|
36373
36578
|
opt = opt || {};
|
|
36374
36579
|
const B = z.box;
|
|
@@ -36423,6 +36628,7 @@ var GameVehiclesThree = (() => {
|
|
|
36423
36628
|
g = msh.geometry = g.clone();
|
|
36424
36629
|
msh.userData.zCloned = true;
|
|
36425
36630
|
}
|
|
36631
|
+
let boundsDue = false;
|
|
36426
36632
|
const nonIdx = !g.index;
|
|
36427
36633
|
const onlyPos = Object.keys(g.attributes).every(function(k) {
|
|
36428
36634
|
return k === "position" || k === "normal";
|
|
@@ -36431,15 +36637,17 @@ var GameVehiclesThree = (() => {
|
|
|
36431
36637
|
const ng = subdivIn(g, rel, B, opt.sub || 0.075);
|
|
36432
36638
|
g.dispose();
|
|
36433
36639
|
g = msh.geometry = ng;
|
|
36434
|
-
|
|
36435
|
-
ng.computeBoundingBox();
|
|
36640
|
+
boundsDue = true;
|
|
36436
36641
|
dirty.add(msh);
|
|
36437
36642
|
}
|
|
36438
36643
|
irel.copy(rel).invert();
|
|
36439
36644
|
const pos = g.attributes.position;
|
|
36440
36645
|
let changed = false;
|
|
36646
|
+
const near = boxInFrame(B, irel, v);
|
|
36441
36647
|
for (let i = 0; i < pos.count; i++) {
|
|
36442
|
-
v.fromBufferAttribute(pos, i)
|
|
36648
|
+
v.fromBufferAttribute(pos, i);
|
|
36649
|
+
if (v.x < near[0] || v.x > near[3] || v.y < near[1] || v.y > near[4] || v.z < near[2] || v.z > near[5]) continue;
|
|
36650
|
+
v.applyMatrix4(rel);
|
|
36443
36651
|
const f = field(v);
|
|
36444
36652
|
if (f <= 1e-5) continue;
|
|
36445
36653
|
v.addScaledVector(d, f);
|
|
@@ -36460,9 +36668,11 @@ var GameVehiclesThree = (() => {
|
|
|
36460
36668
|
}
|
|
36461
36669
|
if (changed) {
|
|
36462
36670
|
pos.needsUpdate = true;
|
|
36671
|
+
dirty.add(msh);
|
|
36672
|
+
}
|
|
36673
|
+
if (changed || boundsDue) {
|
|
36463
36674
|
g.computeBoundingSphere();
|
|
36464
36675
|
g.computeBoundingBox();
|
|
36465
|
-
dirty.add(msh);
|
|
36466
36676
|
}
|
|
36467
36677
|
});
|
|
36468
36678
|
const dset = new Set(c.deform);
|
|
@@ -39545,6 +39755,20 @@ var GameVehiclesThree = (() => {
|
|
|
39545
39755
|
else kit.applyArmor(c);
|
|
39546
39756
|
}
|
|
39547
39757
|
if (zoneState == null && st === "damaged" && kit.config.damagedScenario) zoneState = kit.zoneScenario(c, kit.config.damagedScenario);
|
|
39758
|
+
else if (zoneState && zoneState.scenario != null) {
|
|
39759
|
+
c.scenario = zoneState.scenario;
|
|
39760
|
+
let fromScenario = { health: {}, flags: {} };
|
|
39761
|
+
try {
|
|
39762
|
+
fromScenario = kit.zoneScenario(c, zoneState.scenario);
|
|
39763
|
+
} catch (e) {
|
|
39764
|
+
;
|
|
39765
|
+
(c.zoneErrors = c.zoneErrors || []).push("scenario: " + (e && e.message));
|
|
39766
|
+
}
|
|
39767
|
+
zoneState = {
|
|
39768
|
+
health: Object.assign({}, fromScenario.health, zoneState.health),
|
|
39769
|
+
flags: Object.assign({}, fromScenario.flags, zoneState.flags)
|
|
39770
|
+
};
|
|
39771
|
+
}
|
|
39548
39772
|
if (zoneState) kit.applyZones(c, zoneState);
|
|
39549
39773
|
else {
|
|
39550
39774
|
c.zoneState = { health: {}, flags: {} };
|
|
@@ -41488,7 +41712,7 @@ var GameVehiclesThree = (() => {
|
|
|
41488
41712
|
const reset = () => {
|
|
41489
41713
|
const old = c;
|
|
41490
41714
|
const parent = old.root.parent;
|
|
41491
|
-
const next = kit.build(old.key, old.state);
|
|
41715
|
+
const next = kit.build(old.key, old.state, old.scenario != null ? { scenario: old.scenario } : void 0);
|
|
41492
41716
|
if (parent) {
|
|
41493
41717
|
next.root.position.copy(old.root.position);
|
|
41494
41718
|
next.root.quaternion.copy(old.root.quaternion);
|
|
@@ -41543,7 +41767,8 @@ var GameVehiclesThree = (() => {
|
|
|
41543
41767
|
}
|
|
41544
41768
|
function buildVehicleItem(kit, key, options = {}) {
|
|
41545
41769
|
const THREE = kit.THREE;
|
|
41546
|
-
const
|
|
41770
|
+
const zoneState = options.scenario != null ? { scenario: options.scenario } : void 0;
|
|
41771
|
+
const vehicle = options.lod ? kit.build(key, options.state ?? "intact", zoneState, { lod: true }) : kit.build(key, options.state ?? "intact", zoneState);
|
|
41547
41772
|
const m = vehicle.meta;
|
|
41548
41773
|
const root = new THREE.Group();
|
|
41549
41774
|
root.name = key;
|
|
@@ -41984,6 +42209,7 @@ var GameVehiclesThree = (() => {
|
|
|
41984
42209
|
"vehicles_kill_battery",
|
|
41985
42210
|
"vehicles_rollover",
|
|
41986
42211
|
"vehicles_melt",
|
|
42212
|
+
"vehicles_burnt_wreck",
|
|
41987
42213
|
"vehicles_drive_arcade",
|
|
41988
42214
|
"vehicles_drive_semi"
|
|
41989
42215
|
];
|
|
@@ -42015,7 +42241,7 @@ var GameVehiclesThree = (() => {
|
|
|
42015
42241
|
en: {
|
|
42016
42242
|
group: "Vehicles",
|
|
42017
42243
|
name: "Vehicles area",
|
|
42018
|
-
items: { hatch: "Compact hatch", sedan: "Midsize sedan", pickup: "Midsize pickup", sport_bike: "Sport bike", box_truck: "Box truck", city_bus: "City bus", battle_tank: "Battle tank", attack_helicopter: "Attack helicopter" },
|
|
42244
|
+
items: { hatch: "Compact hatch", sedan: "Midsize sedan", pickup: "Midsize pickup", sport_bike: "Sport bike", box_truck: "Box truck", city_bus: "City bus", battle_tank: "Battle tank", attack_helicopter: "Attack helicopter", sedan_burnt: "Burnt sedan", hatch_burnt: "Burnt hatch" },
|
|
42019
42245
|
controls: { quality: "Quality", paint_by_seed: "Paint by seed", color_seed: "Colour seed", palette: "Palette", driving: "Driving", surface: "Surface" },
|
|
42020
42246
|
hints: {
|
|
42021
42247
|
quality: "High: the kit at full detail. Light: fewer segments and no interior (the light mode of the fleet); applies to the vehicles placed from now on",
|
|
@@ -42048,7 +42274,8 @@ var GameVehiclesThree = (() => {
|
|
|
42048
42274
|
vehicles_rollover: "Vehicles: roll over",
|
|
42049
42275
|
vehicles_melt: "Vehicles: melt (long fire burns the tyres)",
|
|
42050
42276
|
vehicles_drive_arcade: "Vehicles: arcade driving down a lane that ends in a wall",
|
|
42051
|
-
vehicles_drive_semi: "Vehicles: semi-simulation braking on dry, wet and mud"
|
|
42277
|
+
vehicles_drive_semi: "Vehicles: semi-simulation braking on dry, wet and mud",
|
|
42278
|
+
vehicles_burnt_wreck: "Vehicles: the burnt sedan comes out of the kit burnt, with the glass gone"
|
|
42052
42279
|
},
|
|
42053
42280
|
checks: {
|
|
42054
42281
|
windshield_holes: "Windshield: {0} hole(s), went through {1:b} (expected: 1, true)",
|
|
@@ -42073,13 +42300,15 @@ var GameVehiclesThree = (() => {
|
|
|
42073
42300
|
arcade_bounce: "Arcade: the car bounces back at {0} m/s (expected: below 0)",
|
|
42074
42301
|
arcade_noise: "Arcade: {0} engine noise(s) and {1} crash noise(s) (expected: 1 or more each)",
|
|
42075
42302
|
semi_order: "Semi: braking from 80 km/h takes dry {0} m, wet {1} m, mud {2} m (expected: dry shorter than wet shorter than mud)",
|
|
42076
|
-
semi_mud: "Semi: a 2WD car on mud {0:on} (expected: bogged on, a bog event)"
|
|
42303
|
+
semi_mud: "Semi: a 2WD car on mud {0:on} (expected: bogged on, a bog event)",
|
|
42304
|
+
wreck_burnt: "Burnt sedan: burnt flag {0:b} (expected: yes)",
|
|
42305
|
+
wreck_glass: "Burnt sedan: {0} glass zone(s), {1} still above 0 (expected: 1 or more, none above 0)"
|
|
42077
42306
|
}
|
|
42078
42307
|
},
|
|
42079
42308
|
"pt-BR": {
|
|
42080
42309
|
group: "Ve\xEDculos",
|
|
42081
42310
|
name: "\xC1rea de ve\xEDculos",
|
|
42082
|
-
items: { hatch: "Hatch compacto", sedan: "Sed\xE3 m\xE9dio", pickup: "Picape m\xE9dia", sport_bike: "Moto esportiva", box_truck: "Caminh\xE3o ba\xFA", city_bus: "\xD4nibus urbano", battle_tank: "Tanque de guerra", attack_helicopter: "Helic\xF3ptero de ataque" },
|
|
42311
|
+
items: { hatch: "Hatch compacto", sedan: "Sed\xE3 m\xE9dio", pickup: "Picape m\xE9dia", sport_bike: "Moto esportiva", box_truck: "Caminh\xE3o ba\xFA", city_bus: "\xD4nibus urbano", battle_tank: "Tanque de guerra", attack_helicopter: "Helic\xF3ptero de ataque", sedan_burnt: "Sed\xE3 queimado", hatch_burnt: "Hatch queimado" },
|
|
42083
42312
|
controls: { quality: "Qualidade", paint_by_seed: "Pintar pela semente", color_seed: "Semente da cor", palette: "Paleta", driving: "Dire\xE7\xE3o", surface: "Piso" },
|
|
42084
42313
|
hints: {
|
|
42085
42314
|
quality: "Alta: o kit com todo o detalhe. Leve: menos segmentos e sem interior (o modo leve da frota); vale para os ve\xEDculos postos daqui em diante",
|
|
@@ -42112,7 +42341,8 @@ var GameVehiclesThree = (() => {
|
|
|
42112
42341
|
vehicles_rollover: "Ve\xEDculos: capotar",
|
|
42113
42342
|
vehicles_melt: "Ve\xEDculos: derreter (fogo longo queima os pneus)",
|
|
42114
42343
|
vehicles_drive_arcade: "Ve\xEDculos: dire\xE7\xE3o arcade numa pista que acaba num muro",
|
|
42115
|
-
vehicles_drive_semi: "Ve\xEDculos: frenagem da semissimula\xE7\xE3o no seco, no molhado e na lama"
|
|
42344
|
+
vehicles_drive_semi: "Ve\xEDculos: frenagem da semissimula\xE7\xE3o no seco, no molhado e na lama",
|
|
42345
|
+
vehicles_burnt_wreck: "Ve\xEDculos: o sed\xE3 queimado sai do kit queimado, sem os vidros"
|
|
42116
42346
|
},
|
|
42117
42347
|
checks: {
|
|
42118
42348
|
windshield_holes: "Para-brisa: {0} furo(s), atravessou {1:b} (esperado: 1, sim)",
|
|
@@ -42137,7 +42367,9 @@ var GameVehiclesThree = (() => {
|
|
|
42137
42367
|
arcade_bounce: "Arcade: o carro volta a {0} m/s (esperado: abaixo de 0)",
|
|
42138
42368
|
arcade_noise: "Arcade: {0} ru\xEDdo(s) de motor e {1} de batida (esperado: 1 ou mais de cada)",
|
|
42139
42369
|
semi_order: "Semi: frear de 80 km/h leva no seco {0} m, no molhado {1} m, na lama {2} m (esperado: seco menor que molhado menor que lama)",
|
|
42140
|
-
semi_mud: "Semi: um carro 2WD na lama {0:on} (esperado: atolado, com evento de atolamento)"
|
|
42370
|
+
semi_mud: "Semi: um carro 2WD na lama {0:on} (esperado: atolado, com evento de atolamento)",
|
|
42371
|
+
wreck_burnt: "Sed\xE3 queimado: marca de queimado {0:b} (esperado: sim)",
|
|
42372
|
+
wreck_glass: "Sed\xE3 queimado: {0} zona(s) de vidro, {1} ainda acima de 0 (esperado: 1 ou mais, nenhuma acima de 0)"
|
|
42141
42373
|
}
|
|
42142
42374
|
}
|
|
42143
42375
|
};
|
|
@@ -42296,6 +42528,14 @@ var GameVehiclesThree = (() => {
|
|
|
42296
42528
|
const t = part(room, v, "tyre_front_left");
|
|
42297
42529
|
expect(events(room, "melt", v) >= 1 && (t.status === "melted" || t.melt > 0.5), say("tyre_melt", t.status, Math.round(t.melt * 100), events(room, "melt", v)));
|
|
42298
42530
|
}),
|
|
42531
|
+
// new in the kit: the burnt wreck comes ready from the kit (the fleet's `burnt` scenario built into the vehicle), no damage applied by the area
|
|
42532
|
+
scenario("vehicles_burnt_wreck", ({ room, expect }) => {
|
|
42533
|
+
const c = room.spawn("sedan_burnt", [0, 0, -7], 0).root.userData.vehicle;
|
|
42534
|
+
expect(c.zoneState.flags.burnt === true, say("wreck_burnt", c.zoneState.flags.burnt === true));
|
|
42535
|
+
const glass = c.zones.filter((z) => z.type === "glass");
|
|
42536
|
+
const up = glass.filter((z) => (c.zoneState.health[z.id] ?? 100) > 0);
|
|
42537
|
+
expect(glass.length >= 1 && up.length === 0, say("wreck_glass", glass.length, up.length));
|
|
42538
|
+
}),
|
|
42299
42539
|
// new in the kit: the drivers, headless (no vehicle is spawned)
|
|
42300
42540
|
scenario("vehicles_drive_arcade", ({ expect }) => {
|
|
42301
42541
|
const driver = createArcadeDriver();
|
|
@@ -42576,6 +42816,10 @@ var GameVehiclesThree = (() => {
|
|
|
42576
42816
|
exhaust: "vehicle_exhaust"
|
|
42577
42817
|
};
|
|
42578
42818
|
var defaultSoundIds = { engine: "engine_saw", horn: "horn", crash: "sfx_impact" };
|
|
42819
|
+
var DEFAULT_TEST_WRECKS = [
|
|
42820
|
+
{ key: "sedan_burnt", vehicle: "midsize_sedan", scenario: "burnt" },
|
|
42821
|
+
{ key: "hatch_burnt", vehicle: "compact_hatch", scenario: "burnt" }
|
|
42822
|
+
];
|
|
42579
42823
|
|
|
42580
42824
|
// src/test-area/module.ts
|
|
42581
42825
|
var VEHICLES_AREA_ID = "vehicles_area";
|
|
@@ -42589,6 +42833,8 @@ var GameVehiclesThree = (() => {
|
|
|
42589
42833
|
const locale = options.locale ?? "pt-BR";
|
|
42590
42834
|
const text = TEXT[locale] ?? TEXT["pt-BR"];
|
|
42591
42835
|
const keys = options.vehicles ?? DEFAULT_TEST_VEHICLES;
|
|
42836
|
+
const wrecks = options.wrecks ?? DEFAULT_TEST_WRECKS;
|
|
42837
|
+
const entries = [...keys.map((key) => ({ key, id: itemId(key) })), ...wrecks.map((w) => ({ key: w.vehicle, id: w.key, scenario: w.scenario }))];
|
|
42592
42838
|
const effectIds = { ...defaultEffectIds, ...options.effects };
|
|
42593
42839
|
const soundIds = { ...defaultSoundIds, ...options.sounds };
|
|
42594
42840
|
const settings = { quality: "high", paint: false, seed: 1, palette: "auto", driving: "arcade", surface: "dry_asphalt" };
|
|
@@ -42637,17 +42883,17 @@ var GameVehiclesThree = (() => {
|
|
|
42637
42883
|
}
|
|
42638
42884
|
entry.paint.color.set(color2);
|
|
42639
42885
|
};
|
|
42640
|
-
const item = (key) => ({
|
|
42641
|
-
id:
|
|
42642
|
-
name: text.items[
|
|
42886
|
+
const item = ({ key, id: itemKey, scenario }) => ({
|
|
42887
|
+
id: itemKey,
|
|
42888
|
+
name: text.items[itemKey] ?? key,
|
|
42643
42889
|
movable: false,
|
|
42644
42890
|
// the first build of a vehicle takes most of a second
|
|
42645
42891
|
slow: true,
|
|
42646
42892
|
build: (THREE) => {
|
|
42647
42893
|
const kit = kitFor(THREE);
|
|
42648
|
-
const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite" });
|
|
42894
|
+
const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite", ...scenario ? { scenario } : {} });
|
|
42649
42895
|
built.root.userData.kit = kit;
|
|
42650
|
-
const entry = { root: built.root, key, item: built, index: counter++, helpers: [] };
|
|
42896
|
+
const entry = { root: built.root, key, ...scenario ? { scenario } : {}, item: built, index: counter++, helpers: [] };
|
|
42651
42897
|
placed.set(built.root.uuid, entry);
|
|
42652
42898
|
measure(entry);
|
|
42653
42899
|
paintOf(entry);
|
|
@@ -42656,7 +42902,7 @@ var GameVehiclesThree = (() => {
|
|
|
42656
42902
|
impl: (root, id) => {
|
|
42657
42903
|
const r = root;
|
|
42658
42904
|
const kit = r.userData.kit;
|
|
42659
|
-
const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[
|
|
42905
|
+
const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[itemKey] ?? key });
|
|
42660
42906
|
tapEffects(d);
|
|
42661
42907
|
r.userData.destructible = d;
|
|
42662
42908
|
return d;
|
|
@@ -42930,7 +43176,7 @@ var GameVehiclesThree = (() => {
|
|
|
42930
43176
|
for (const entry of placed.values()) {
|
|
42931
43177
|
const want = fleetDims(entry.key);
|
|
42932
43178
|
const got = entry.size;
|
|
42933
|
-
if (!want || !got) continue;
|
|
43179
|
+
if (!want || !got || entry.scenario) continue;
|
|
42934
43180
|
worst = Math.max(worst, Math.abs(got.length - want.length), Math.abs(got.width - want.width), Math.abs(got.height - want.height));
|
|
42935
43181
|
}
|
|
42936
43182
|
return Math.round(worst * 1e3);
|
|
@@ -42942,23 +43188,23 @@ var GameVehiclesThree = (() => {
|
|
|
42942
43188
|
get placed() {
|
|
42943
43189
|
return placed;
|
|
42944
43190
|
},
|
|
42945
|
-
items: () =>
|
|
43191
|
+
items: () => entries.map(item),
|
|
42946
43192
|
area: () => {
|
|
42947
43193
|
const gap = 1.6;
|
|
42948
43194
|
const WIDE = 6;
|
|
42949
43195
|
const rowOf = (list2, z) => {
|
|
42950
43196
|
let cursor = 0;
|
|
42951
|
-
const spots = list2.map((
|
|
42952
|
-
const width = fleetDims(key)?.width ?? 2;
|
|
43197
|
+
const spots = list2.map((entry) => {
|
|
43198
|
+
const width = fleetDims(entry.key)?.width ?? 2;
|
|
42953
43199
|
const x = cursor + width / 2;
|
|
42954
43200
|
cursor += width + gap;
|
|
42955
|
-
return {
|
|
43201
|
+
return { id: entry.id, x };
|
|
42956
43202
|
});
|
|
42957
43203
|
return { spots, z, width: Math.max(0, cursor - gap) };
|
|
42958
43204
|
};
|
|
42959
|
-
const front = rowOf(
|
|
42960
|
-
const back = rowOf(
|
|
42961
|
-
const placements = [front, back].flatMap((row) => row.spots.map(({
|
|
43205
|
+
const front = rowOf(entries.filter((e) => (fleetDims(e.key)?.width ?? 2) <= WIDE), 0);
|
|
43206
|
+
const back = rowOf(entries.filter((e) => (fleetDims(e.key)?.width ?? 2) > WIDE), -16);
|
|
43207
|
+
const placements = [front, back].flatMap((row) => row.spots.map(({ id, x }) => ({ item: id, position: [x - row.width / 2, 0, row.z], rotationY: 0 })));
|
|
42962
43208
|
return { placements, view: { eye: [0, 5, Math.max(14, front.width * 0.6)], target: [0, 1, -2] } };
|
|
42963
43209
|
},
|
|
42964
43210
|
controls: () => {
|