@adatechnology/game-destruction-three 0.8.1 → 0.9.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.global.js +29 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -52,6 +52,13 @@ var GameDestructionThree = (() => {
|
|
|
52
52
|
const length = Math.hypot(direction[0], direction[1], direction[2]);
|
|
53
53
|
return { speed, direction: [direction[0] / length, direction[1] / length, direction[2] / length], distance, falloff };
|
|
54
54
|
}
|
|
55
|
+
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
56
|
+
function markKitOrigin(object, origin) {
|
|
57
|
+
const node = object;
|
|
58
|
+
node.userData = node.userData ?? {};
|
|
59
|
+
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
60
|
+
return object;
|
|
61
|
+
}
|
|
55
62
|
|
|
56
63
|
// ../game-vfx/dist/index.js
|
|
57
64
|
var __defProp2 = Object.defineProperty;
|
|
@@ -8418,7 +8425,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8418
8425
|
for (const mesh2 of anchors.meshes) mesh2.material.dispose();
|
|
8419
8426
|
anchors = void 0;
|
|
8420
8427
|
};
|
|
8421
|
-
const root = new THREE.Group();
|
|
8428
|
+
const root = markKitOrigin(new THREE.Group(), { owner: "game-vfx-three", kind: "effect" });
|
|
8422
8429
|
options.scene.add(root);
|
|
8423
8430
|
const direction = new THREE.Vector3(...options.lightDirection ?? LAB_LIGHT_DIRECTION).normalize();
|
|
8424
8431
|
const sky = hexToLinearRgb(SKY_COLOR);
|
|
@@ -8613,6 +8620,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8613
8620
|
}
|
|
8614
8621
|
|
|
8615
8622
|
// src/fragments.ts
|
|
8623
|
+
var SHEET_MAX = 4e-3;
|
|
8624
|
+
var SHEET_AIR = 2.5;
|
|
8625
|
+
var SHEET_SWAY = 3;
|
|
8616
8626
|
var FragmentSystem = class {
|
|
8617
8627
|
constructor(THREE, o) {
|
|
8618
8628
|
__publicField(this, "THREE", THREE);
|
|
@@ -8718,7 +8728,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8718
8728
|
asleep: false,
|
|
8719
8729
|
rest: 0,
|
|
8720
8730
|
fade: 1,
|
|
8721
|
-
dying: false
|
|
8731
|
+
dying: false,
|
|
8732
|
+
air: f.shape === "scrap" && sz[2] <= SHEET_MAX ? SHEET_AIR : 0
|
|
8722
8733
|
};
|
|
8723
8734
|
this.list.push(live);
|
|
8724
8735
|
let alive = this.list.reduce((n, l) => n + (l.dying ? 0 : 1), 0);
|
|
@@ -8802,6 +8813,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8802
8813
|
}
|
|
8803
8814
|
} else {
|
|
8804
8815
|
f.ang.multiplyScalar(Math.exp(-0.15 * dt));
|
|
8816
|
+
if (f.air > 0) this.flutter(f, dt);
|
|
8805
8817
|
}
|
|
8806
8818
|
if (contact && f.vel.lengthSq() < 4) this.settle(f, dt);
|
|
8807
8819
|
const slow = f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2;
|
|
@@ -8816,6 +8828,14 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8816
8828
|
f.still = 0;
|
|
8817
8829
|
}
|
|
8818
8830
|
}
|
|
8831
|
+
/** A sheet in the air: drag slows it to a slow fall, and it sways and turns over as it goes. */
|
|
8832
|
+
flutter(f, dt) {
|
|
8833
|
+
f.vel.multiplyScalar(Math.exp(-f.air * dt));
|
|
8834
|
+
f.vel.x += (this.rng() - 0.5) * SHEET_SWAY * dt;
|
|
8835
|
+
f.vel.z += (this.rng() - 0.5) * SHEET_SWAY * dt;
|
|
8836
|
+
f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
8837
|
+
f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
8838
|
+
}
|
|
8819
8839
|
/** Tip the fragment towards lying on its flattest face. */
|
|
8820
8840
|
settle(f, dt) {
|
|
8821
8841
|
const mesh2 = f.mesh;
|
|
@@ -10140,6 +10160,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10140
10160
|
0.03,
|
|
10141
10161
|
0.15
|
|
10142
10162
|
],
|
|
10163
|
+
sheet: 1e-3,
|
|
10143
10164
|
damageScale: {
|
|
10144
10165
|
slash: 3
|
|
10145
10166
|
},
|
|
@@ -10155,7 +10176,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10155
10176
|
smoke: "grey"
|
|
10156
10177
|
},
|
|
10157
10178
|
visual: {
|
|
10158
|
-
charColor: 1709072
|
|
10179
|
+
charColor: 1709072,
|
|
10180
|
+
innerColor: 15524048
|
|
10159
10181
|
},
|
|
10160
10182
|
tags: [
|
|
10161
10183
|
"fabric",
|
|
@@ -12266,6 +12288,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12266
12288
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
12267
12289
|
if (kind === "smoke") return { color: SMOKE_TONES[def?.thermal.smoke ?? "grey"] };
|
|
12268
12290
|
if (kind === "fibers" || kind === "leaves") {
|
|
12291
|
+
if (def?.visual?.innerColor !== void 0) return { color: def.visual.innerColor };
|
|
12269
12292
|
const c = pv ? this.visuals.baseColorHex(pv.meshes[0] ?? {}) : -1;
|
|
12270
12293
|
return c >= 0 ? { color: c } : void 0;
|
|
12271
12294
|
}
|
|
@@ -12414,7 +12437,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12414
12437
|
for (let i = 0; i < ev.fragments.length; i += step) {
|
|
12415
12438
|
const fr = ev.fragments[i];
|
|
12416
12439
|
const fdef = this.world.materials.get(fr.material);
|
|
12417
|
-
const
|
|
12440
|
+
const tone = fr.inner && fdef?.visual?.innerColor !== void 0 ? fdef.visual.innerColor : fdef === def || !fdef ? color : fallbackColor(fr.material, fdef);
|
|
12441
|
+
const mat = this.fragments.materialFor(fr.material, tone, transparent || fdef?.visual?.transparent === true, opacity);
|
|
12418
12442
|
this.fragments.spawn(fr, mat, ev.object, maxAlive);
|
|
12419
12443
|
}
|
|
12420
12444
|
const up = [0, 1, 0];
|
|
@@ -12432,7 +12456,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12432
12456
|
this.vfx.burst("dust", ev.point, up, 5, 0.8, { color: 11901556 });
|
|
12433
12457
|
break;
|
|
12434
12458
|
case "tear":
|
|
12435
|
-
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color });
|
|
12459
|
+
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color: def?.visual?.innerColor ?? color });
|
|
12436
12460
|
break;
|
|
12437
12461
|
case "snap":
|
|
12438
12462
|
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3);
|