@adatechnology/game-fluids-three 0.4.3 → 0.4.5
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 +30 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -144,6 +144,12 @@ var clipSolid = (solid, u, d, pos, nor) => {
|
|
|
144
144
|
|
|
145
145
|
// src/liquid-body.ts
|
|
146
146
|
var INSET = 0.985;
|
|
147
|
+
var narrowMouth = (state) => {
|
|
148
|
+
const shape = state.shape;
|
|
149
|
+
if (!shape || state.lipRadius === void 0) return false;
|
|
150
|
+
const inner = shape.kind === "cylinder" ? shape.radius : Math.min(shape.size[0], shape.size[2]) / 2;
|
|
151
|
+
return state.lipRadius < inner * 0.5;
|
|
152
|
+
};
|
|
147
153
|
var LiquidBody = class {
|
|
148
154
|
constructor(THREE, containerId, object, offset) {
|
|
149
155
|
__publicField(this, "THREE", THREE);
|
|
@@ -206,7 +212,7 @@ var LiquidBody = class {
|
|
|
206
212
|
this.vertices = 0;
|
|
207
213
|
return;
|
|
208
214
|
}
|
|
209
|
-
if (state.closed && this.isShellOpaque()) {
|
|
215
|
+
if ((state.closed || narrowMouth(state)) && this.isShellOpaque()) {
|
|
210
216
|
if (this.mesh) this.mesh.visible = false;
|
|
211
217
|
this.vertices = 0;
|
|
212
218
|
return;
|
|
@@ -236,12 +242,15 @@ var LiquidBody = class {
|
|
|
236
242
|
}
|
|
237
243
|
} else this.steamAcc = 0;
|
|
238
244
|
}
|
|
239
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Every mesh of the bound object (the liquid itself aside) is drawn with an opaque material. The marks drawn on its surface (bullet holes, scorches: the
|
|
247
|
+
* `userData.destructionDebris` meshes of `game-destruction-three`) are see-through discs on the shell, not windows into it.
|
|
248
|
+
*/
|
|
240
249
|
isShellOpaque() {
|
|
241
250
|
let opaque = true;
|
|
242
251
|
this.object.traverse((child) => {
|
|
243
252
|
const mesh = child;
|
|
244
|
-
if (!opaque || !mesh.isMesh || child === this.mesh) return;
|
|
253
|
+
if (!opaque || !mesh.isMesh || child === this.mesh || child.userData?.destructionDebris === true) return;
|
|
245
254
|
const materials = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
246
255
|
if (materials.some((material) => material.transparent || material.opacity < 1)) opaque = false;
|
|
247
256
|
});
|