@adatechnology/game-destruction-three 0.8.0 → 0.8.1
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 +86 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +86 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -10770,7 +10770,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10770
10770
|
depthWrite: false,
|
|
10771
10771
|
polygonOffset: true,
|
|
10772
10772
|
polygonOffsetFactor: -4,
|
|
10773
|
-
polygonOffsetUnits: -4
|
|
10773
|
+
polygonOffsetUnits: -4,
|
|
10774
|
+
side: this.THREE.DoubleSide
|
|
10774
10775
|
}));
|
|
10775
10776
|
}
|
|
10776
10777
|
/** Opaque patch in the colour of what shows under a spalled coat. */
|
|
@@ -11163,6 +11164,27 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
11163
11164
|
}
|
|
11164
11165
|
addHole(mv, worldPoint, worldNormal, diameter) {
|
|
11165
11166
|
const { s, pos, quat: quat2 } = this.decalPose(mv.mesh, worldPoint, worldNormal, 25e-4);
|
|
11167
|
+
const work = mv.host ? mv.host.work : mv.work;
|
|
11168
|
+
if (work && mv.touched) {
|
|
11169
|
+
const ln = worldNormal.clone().transformDirection(this.m4.copy(mv.mesh.matrixWorld).invert()).normalize();
|
|
11170
|
+
let minDistSq = Infinity;
|
|
11171
|
+
let nearestDisp = 0;
|
|
11172
|
+
const from = mv.range ? mv.range[0] * 3 : 0;
|
|
11173
|
+
const to = mv.range ? mv.range[1] * 3 : work.length;
|
|
11174
|
+
for (let i = from; i < to; i += 3) {
|
|
11175
|
+
const dx = work[i] - pos.x;
|
|
11176
|
+
const dy = work[i + 1] - pos.y;
|
|
11177
|
+
const dz = work[i + 2] - pos.z;
|
|
11178
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
11179
|
+
if (d2 < minDistSq) {
|
|
11180
|
+
minDistSq = d2;
|
|
11181
|
+
nearestDisp = dx * ln.x + dy * ln.y + dz * ln.z;
|
|
11182
|
+
}
|
|
11183
|
+
}
|
|
11184
|
+
if (minDistSq < (0.06 / s) ** 2 && nearestDisp < 0) {
|
|
11185
|
+
pos.addScaledVector(ln, nearestDisp);
|
|
11186
|
+
}
|
|
11187
|
+
}
|
|
11166
11188
|
const disc = new this.THREE.Mesh(this.kit.discGeometry(), this.kit.discMaterial());
|
|
11167
11189
|
disc.position.copy(pos);
|
|
11168
11190
|
disc.quaternion.copy(quat2);
|
|
@@ -11634,7 +11656,13 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
11634
11656
|
gas: 15921906,
|
|
11635
11657
|
sap: 12098362,
|
|
11636
11658
|
acid: 10211900,
|
|
11637
|
-
blood: 9046538
|
|
11659
|
+
blood: 9046538,
|
|
11660
|
+
soda: 3808786,
|
|
11661
|
+
coffee: 3875860,
|
|
11662
|
+
beer: 14259516,
|
|
11663
|
+
milk: 16052714,
|
|
11664
|
+
wine: 7016479,
|
|
11665
|
+
juice: 15238923
|
|
11638
11666
|
};
|
|
11639
11667
|
var SMOKE_TONES = { white: 15132390, grey: 9079434, black: 2763306 };
|
|
11640
11668
|
var DEFAULT_SPEED = {
|
|
@@ -12163,13 +12191,39 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12163
12191
|
}
|
|
12164
12192
|
case "leak": {
|
|
12165
12193
|
const key = `${ev.object}|${ev.part}`;
|
|
12194
|
+
const b = this.bounds.get(ev.object);
|
|
12195
|
+
let localPoint;
|
|
12196
|
+
let localDirection;
|
|
12197
|
+
if (b) {
|
|
12198
|
+
b.root.updateWorldMatrix(true, false);
|
|
12199
|
+
const inv = new this.THREE.Matrix4().copy(b.root.matrixWorld).invert();
|
|
12200
|
+
const lp = this.v1.set(ev.point[0], ev.point[1], ev.point[2]).applyMatrix4(inv);
|
|
12201
|
+
const ld = this.v2.set(ev.direction[0], ev.direction[1], ev.direction[2]).transformDirection(inv).normalize();
|
|
12202
|
+
localPoint = [lp.x, lp.y, lp.z];
|
|
12203
|
+
localDirection = [ld.x, ld.y, ld.z];
|
|
12204
|
+
}
|
|
12166
12205
|
const same = this.leaks.find((l) => l.object === ev.object && l.part === ev.part && Math.hypot(l.point[0] - ev.point[0], l.point[1] - ev.point[1], l.point[2] - ev.point[2]) < 0.03);
|
|
12167
12206
|
if (same) {
|
|
12168
12207
|
same.rate = ev.rate;
|
|
12169
12208
|
same.direction = ev.direction;
|
|
12209
|
+
if (localPoint) same.localPoint = localPoint;
|
|
12210
|
+
if (localDirection) same.localDirection = localDirection;
|
|
12170
12211
|
} else {
|
|
12171
12212
|
if (this.leaks.length >= 24) this.leaks.shift();
|
|
12172
|
-
this.leaks.push({
|
|
12213
|
+
this.leaks.push({
|
|
12214
|
+
object: ev.object,
|
|
12215
|
+
part: ev.part,
|
|
12216
|
+
fluid: ev.fluid,
|
|
12217
|
+
point: ev.point,
|
|
12218
|
+
direction: ev.direction,
|
|
12219
|
+
rate: ev.rate,
|
|
12220
|
+
pressurized: ev.pressurized,
|
|
12221
|
+
acc: 0,
|
|
12222
|
+
opened: this.world.part(ev.object, ev.part)?.holes.some((h) => h.through) ?? false,
|
|
12223
|
+
localPoint,
|
|
12224
|
+
localDirection,
|
|
12225
|
+
life: 0
|
|
12226
|
+
});
|
|
12173
12227
|
}
|
|
12174
12228
|
void key;
|
|
12175
12229
|
break;
|
|
@@ -12605,21 +12659,44 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12605
12659
|
updateLeaks(dt) {
|
|
12606
12660
|
for (let i = this.leaks.length - 1; i >= 0; i--) {
|
|
12607
12661
|
const l = this.leaks[i];
|
|
12662
|
+
const b = this.bounds.get(l.object);
|
|
12608
12663
|
const ps = this.world.part(l.object, l.part);
|
|
12609
|
-
if (!ps || ps.liters === void 0 || ps.liters <=
|
|
12664
|
+
if (!b || !ps || ps.liters === void 0 || ps.liters <= 1e-4 || l.opened && !ps.holes.some((h) => h.through)) {
|
|
12610
12665
|
this.leaks.splice(i, 1);
|
|
12611
12666
|
continue;
|
|
12612
12667
|
}
|
|
12668
|
+
l.life = (l.life ?? 0) + dt;
|
|
12669
|
+
if (l.pressurized && l.life > 0.8) l.pressurized = false;
|
|
12670
|
+
if (l.lastLiters !== void 0 && Math.abs(ps.liters - l.lastLiters) < 1e-5) {
|
|
12671
|
+
l.idleSeconds = (l.idleSeconds ?? 0) + dt;
|
|
12672
|
+
if (l.idleSeconds > 0.4) {
|
|
12673
|
+
this.leaks.splice(i, 1);
|
|
12674
|
+
continue;
|
|
12675
|
+
}
|
|
12676
|
+
} else {
|
|
12677
|
+
l.idleSeconds = 0;
|
|
12678
|
+
l.lastLiters = ps.liters;
|
|
12679
|
+
}
|
|
12680
|
+
let pt = l.point;
|
|
12681
|
+
let dir = l.direction;
|
|
12682
|
+
if (l.localPoint && l.localDirection) {
|
|
12683
|
+
b.root.updateWorldMatrix(true, false);
|
|
12684
|
+
const wp = this.v1.set(l.localPoint[0], l.localPoint[1], l.localPoint[2]).applyMatrix4(b.root.matrixWorld);
|
|
12685
|
+
const wd = this.v2.set(l.localDirection[0], l.localDirection[1], l.localDirection[2]).transformDirection(b.root.matrixWorld).normalize();
|
|
12686
|
+
pt = [wp.x, wp.y, wp.z];
|
|
12687
|
+
dir = [wd.x, wd.y, wd.z];
|
|
12688
|
+
l.point = pt;
|
|
12689
|
+
l.direction = dir;
|
|
12690
|
+
}
|
|
12613
12691
|
l.acc += clamp6(20 + l.rate * 400, 15, 120) * dt;
|
|
12614
12692
|
const color = FLUID_COLORS[l.fluid] ?? 11184810;
|
|
12615
|
-
const
|
|
12616
|
-
const dl = Math.hypot(d[0], d[1], d[2]) || 1;
|
|
12693
|
+
const dl = Math.hypot(dir[0], dir[1], dir[2]) || 1;
|
|
12617
12694
|
const sp = l.pressurized ? 2.5 + this.rng() * 1.5 : 0.3 + this.rng() * 0.3;
|
|
12618
12695
|
while (l.acc >= 1) {
|
|
12619
12696
|
l.acc -= 1;
|
|
12620
|
-
const vel = [
|
|
12621
|
-
if (l.fluid === "gas") this.vfx.spawn("steam",
|
|
12622
|
-
else this.vfx.spawn("drips",
|
|
12697
|
+
const vel = [dir[0] / dl * sp + (this.rng() - 0.5) * 0.25, dir[1] / dl * sp + (this.rng() - 0.5) * 0.25, dir[2] / dl * sp + (this.rng() - 0.5) * 0.25];
|
|
12698
|
+
if (l.fluid === "gas") this.vfx.spawn("steam", pt, vel, { color, size: 0.5, alpha: 0.5 });
|
|
12699
|
+
else this.vfx.spawn("drips", pt, vel, { color, tag: this.rng() < 0.03 ? this.tagOf(l.object) : 0, owner: this.owner });
|
|
12623
12700
|
}
|
|
12624
12701
|
}
|
|
12625
12702
|
}
|