@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.
@@ -6358,6 +6358,24 @@ var GameFluidsThree = (() => {
6358
6358
  for (const decal2 of this.decals) decal2.on = false;
6359
6359
  this.count = 0;
6360
6360
  }
6361
+ /**
6362
+ * Takes away the marks inside a box: world `center`, `half` extents along the axes of the world `rotation` (a quaternion, x y z w; none means the
6363
+ * world axes). The surface they were on is gone (a brick came out of a wall with its bullet holes). Returns how many went.
6364
+ */
6365
+ clearInside(center, half, rotation = [0, 0, 0, 1]) {
6366
+ const qx = -rotation[0], qy = -rotation[1], qz = -rotation[2], qw = rotation[3];
6367
+ let gone = 0;
6368
+ for (const decal2 of this.decals) {
6369
+ if (!decal2.on) continue;
6370
+ const vx2 = decal2.x - center[0], vy2 = decal2.y - center[1], vz2 = decal2.z - center[2];
6371
+ const tx = 2 * (qy * vz2 - qz * vy2), ty = 2 * (qz * vx2 - qx * vz2), tz = 2 * (qx * vy2 - qy * vx2);
6372
+ const lx = vx2 + qw * tx + (qy * tz - qz * ty), ly = vy2 + qw * ty + (qz * tx - qx * tz), lz = vz2 + qw * tz + (qx * ty - qy * tx);
6373
+ if (Math.abs(lx) > half[0] || Math.abs(ly) > half[1] || Math.abs(lz) > half[2]) continue;
6374
+ decal2.on = false;
6375
+ gone++;
6376
+ }
6377
+ return gone;
6378
+ }
6361
6379
  update(dt) {
6362
6380
  this.count = 0;
6363
6381
  for (const decal2 of this.decals) {
@@ -8691,6 +8709,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
8691
8709
 
8692
8710
  // src/liquid-body.ts
8693
8711
  var INSET = 0.985;
8712
+ var narrowMouth = (state) => {
8713
+ const shape = state.shape;
8714
+ if (!shape || state.lipRadius === void 0) return false;
8715
+ const inner = shape.kind === "cylinder" ? shape.radius : Math.min(shape.size[0], shape.size[2]) / 2;
8716
+ return state.lipRadius < inner * 0.5;
8717
+ };
8694
8718
  var LiquidBody = class {
8695
8719
  constructor(THREE, containerId, object, offset) {
8696
8720
  __publicField(this, "THREE", THREE);
@@ -8753,7 +8777,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
8753
8777
  this.vertices = 0;
8754
8778
  return;
8755
8779
  }
8756
- if (state.closed && this.isShellOpaque()) {
8780
+ if ((state.closed || narrowMouth(state)) && this.isShellOpaque()) {
8757
8781
  if (this.mesh) this.mesh.visible = false;
8758
8782
  this.vertices = 0;
8759
8783
  return;
@@ -8783,12 +8807,15 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
8783
8807
  }
8784
8808
  } else this.steamAcc = 0;
8785
8809
  }
8786
- /** Every mesh of the bound object (the liquid itself aside) is drawn with an opaque material. */
8810
+ /**
8811
+ * 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
8812
+ * `userData.destructionDebris` meshes of `game-destruction-three`) are see-through discs on the shell, not windows into it.
8813
+ */
8787
8814
  isShellOpaque() {
8788
8815
  let opaque = true;
8789
8816
  this.object.traverse((child) => {
8790
8817
  const mesh2 = child;
8791
- if (!opaque || !mesh2.isMesh || child === this.mesh) return;
8818
+ if (!opaque || !mesh2.isMesh || child === this.mesh || child.userData?.destructionDebris === true) return;
8792
8819
  const materials = Array.isArray(mesh2.material) ? mesh2.material : [mesh2.material];
8793
8820
  if (materials.some((material) => material.transparent || material.opacity < 1)) opaque = false;
8794
8821
  });