@woosh/meep-engine 2.126.41 → 2.126.43

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.126.41",
8
+ "version": "2.126.43",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wDALW,KAAK,SACL,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,gBAC1B,MAAM,UACN,SAAS,CAAC,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QA8BjD"}
1
+ {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wDALW,KAAK,SACL,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,gBAC1B,MAAM,UACN,SAAS,CAAC,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAiCjD"}
@@ -22,10 +22,13 @@ export function aabb3_from_v3_array_transformed(result, input, input_length, mat
22
22
  const y = input[i + 1];
23
23
  const z = input[i + 2];
24
24
 
25
- const _x = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
26
- const _y = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
27
- const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
25
+ // perform matrix multiplication
26
+ const _w = 1 / (matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15]);
28
27
 
28
+ const _x = (matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12]) * _w;
29
+ const _y = (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) * _w;
30
+ const _z = (matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14]) * _w;
31
+
29
32
  x0 = min2(_x, x0);
30
33
  y0 = min2(_y, y0);
31
34
  z0 = min2(_z, z0);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Identity 4x4 matrix, also called "eye" matrix sometimes.
3
+ * @type {number[]|mat4}
4
+ */
5
+ export const M4_IDENTITY: number[] | mat4;
6
+ //# sourceMappingURL=M4_IDENTITY.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M4_IDENTITY.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/M4_IDENTITY.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0BAFU,MAAM,EAAE,GAAC,IAAI,CAOpB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Identity 4x4 matrix, also called "eye" matrix sometimes.
3
+ * @type {number[]|mat4}
4
+ */
5
+ export const M4_IDENTITY = Object.freeze([
6
+ 1, 0, 0, 0,
7
+ 0, 1, 0, 0,
8
+ 0, 0, 1, 0,
9
+ 0, 0, 0, 1
10
+ ]);
11
+
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Identity 4x4 matrix, also called "eye" matrix sometimes.
3
- * @type {number[]|mat4}
2
+ * Alias
3
+ * @deprecated use {@link M4_IDENTITY} directly instead
4
4
  */
5
- export const MATRIX_4_IDENTITY: number[] | mat4;
5
+ export const MATRIX_4_IDENTITY: any;
6
6
  //# sourceMappingURL=MATRIX_4_IDENTITY.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MATRIX_4_IDENTITY.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/MATRIX_4_IDENTITY.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,gCAFU,MAAM,EAAE,GAAC,IAAI,CAOpB"}
1
+ {"version":3,"file":"MATRIX_4_IDENTITY.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/MATRIX_4_IDENTITY.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oCAA6C"}
@@ -1,10 +1,7 @@
1
+ import { M4_IDENTITY } from "./M4_IDENTITY.js";
2
+
1
3
  /**
2
- * Identity 4x4 matrix, also called "eye" matrix sometimes.
3
- * @type {number[]|mat4}
4
+ * Alias
5
+ * @deprecated use {@link M4_IDENTITY} directly instead
4
6
  */
5
- export const MATRIX_4_IDENTITY = Object.freeze([
6
- 1, 0, 0, 0,
7
- 0, 1, 0, 0,
8
- 0, 0, 1, 0,
9
- 0, 0, 0, 1
10
- ]);
7
+ export const MATRIX_4_IDENTITY = M4_IDENTITY;
@@ -1,5 +1,5 @@
1
1
  import { array_copy } from "../../../collection/array/array_copy.js";
2
- import { MATRIX_4_IDENTITY } from "./MATRIX_4_IDENTITY.js";
2
+ import { M4_IDENTITY } from "./M4_IDENTITY.js";
3
3
 
4
4
  /**
5
5
  * Create a 4x4 matrix that corresponds to translation transform
@@ -7,7 +7,7 @@ import { MATRIX_4_IDENTITY } from "./MATRIX_4_IDENTITY.js";
7
7
  * @param {ArrayLike<number>} translation 3d vector
8
8
  */
9
9
  export function m4_make_translation(output, translation) {
10
- array_copy(MATRIX_4_IDENTITY, 0, output, 0, 16);
10
+ array_copy(M4_IDENTITY, 0, output, 0, 16);
11
11
 
12
12
  output[12] = translation[0];
13
13
  output[13] = translation[1];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the first-order partial derivative of a hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
3
+ *
4
+ * @param {number} t
5
+ * @param {number} p0
6
+ * @param {number} p1
7
+ * @param {number} m0
8
+ * @param {number} m1
9
+ * @returns {number}
10
+ */
11
+ export function spline3_hermite_derivative(t: number, p0: number, p1: number, m0: number, m1: number): number;
12
+ //# sourceMappingURL=spline3_hermite_derivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spline3_hermite_derivative.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_derivative.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,8CAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAclB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Returns the first-order partial derivative of a hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
3
+ *
4
+ * @param {number} t
5
+ * @param {number} p0
6
+ * @param {number} p1
7
+ * @param {number} m0
8
+ * @param {number} m1
9
+ * @returns {number}
10
+ */
11
+ export function spline3_hermite_derivative(t, p0, p1, m0, m1) {
12
+
13
+ // see https://github.com/krishauser/Klampt/blob/0ed16608a3eceee59d04383a17c207ebc33a399f/Python/klampt/math/spline.py#L22
14
+
15
+ const t2 = t * t
16
+ const dcx1 = (6.0 * t2 - 6.0 * t)
17
+ const dcx2 = (-6.0 * t2 + 6.0 * t)
18
+ const dcv1 = 3.0 * t2 - 4.0 * t + 1.0
19
+ const dcv2 = 3.0 * t2 - 2.0 * t
20
+
21
+ return dcx1 * p0 + dcx2 * p1 + dcv1 * m0 + dcv2 * m1
22
+
23
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Subdivides a hermite curve into two hermite curves.
3
+ * The result is written in form [a_p0, a_p1, a_m0, a_m1, b_p0, b_p1, b_m0, b_m1], note the stride and offset.
4
+ * @param {number[]} output where to write the result
5
+ * @param {number} output_offset where to start writing
6
+ * @param {number} output_stride what should be the step between result values, useful when working in higher dimensions. Typically, this will be 1.
7
+ * @param {number} p0
8
+ * @param {number} p1
9
+ * @param {number} m0 tangent at p0
10
+ * @param {number} m1 tangent at p1
11
+ * @param {number} [t=0.5] where to split, normalized position, must be value between 0 and 1
12
+ */
13
+ export function spline3_hermite_subdivide(output: number[], output_offset: number, output_stride: number, p0: number, p1: number, m0: number, m1: number, t?: number): void;
14
+ //# sourceMappingURL=spline3_hermite_subdivide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spline3_hermite_subdivide.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_subdivide.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,kDATW,MAAM,EAAE,iBACR,MAAM,iBACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QA+BhB"}
@@ -0,0 +1,46 @@
1
+ import { assert } from "../../assert.js";
2
+ import { spline3_hermite } from "./spline3_hermite.js";
3
+ import { spline3_hermite_derivative } from "./spline3_hermite_derivative.js";
4
+
5
+ /**
6
+ * Subdivides a hermite curve into two hermite curves.
7
+ * The result is written in form [a_p0, a_p1, a_m0, a_m1, b_p0, b_p1, b_m0, b_m1], note the stride and offset.
8
+ * @param {number[]} output where to write the result
9
+ * @param {number} output_offset where to start writing
10
+ * @param {number} output_stride what should be the step between result values, useful when working in higher dimensions. Typically, this will be 1.
11
+ * @param {number} p0
12
+ * @param {number} p1
13
+ * @param {number} m0 tangent at p0
14
+ * @param {number} m1 tangent at p1
15
+ * @param {number} [t=0.5] where to split, normalized position, must be value between 0 and 1
16
+ */
17
+ export function spline3_hermite_subdivide(
18
+ output,
19
+ output_offset,
20
+ output_stride,
21
+ p0, p1, m0, m1,
22
+ t = 0.5
23
+ ) {
24
+ assert.isNonNegativeInteger(output_offset, 'output_offset');
25
+ assert.isNonNegativeInteger(output_stride, 'output_stride');
26
+ assert.greaterThanOrEqual(output_stride, 1, 'output_stride must be at least 1');
27
+
28
+ // see https://github.com/krishauser/Klampt/blob/0ed16608a3eceee59d04383a17c207ebc33a399f/Python/klampt/math/spline.py#L63
29
+
30
+ const xm = spline3_hermite(t, p0, p1, m0, m1);
31
+ const vm = spline3_hermite_derivative(t, p0, p1, m0, m1);
32
+
33
+
34
+ // first segment
35
+ output[output_offset] = p0;
36
+ output[output_offset + output_stride] = xm;
37
+ output[output_offset + output_stride * 2] = m0 * t;
38
+ output[output_offset + output_stride * 3] = vm * t;
39
+
40
+ // second segment
41
+ output[output_offset + output_stride * 4] = xm;
42
+ output[output_offset + output_stride * 5] = p1;
43
+ output[output_offset + output_stride * 6] = vm * (1 - t);
44
+ output[output_offset + output_stride * 7] = m1 * (1 - t);
45
+
46
+ }
@@ -1,6 +1,6 @@
1
1
  import { BvhClient } from "../../../core/bvh2/bvh3/BvhClient.js";
2
2
  import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
3
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
3
+ import { M4_IDENTITY } from "../../../core/geom/3d/mat4/M4_IDENTITY.js";
4
4
  import {
5
5
  expand_aabb_by_transformed_three_object
6
6
  } from "../../graphics/three/expand_aabb_by_transformed_three_object.js";
@@ -146,7 +146,7 @@ class Renderable {
146
146
  -Infinity, -Infinity, -Infinity
147
147
  ]);
148
148
 
149
- expand_aabb_by_transformed_three_object(aabb, object, MATRIX_4_IDENTITY);
149
+ expand_aabb_by_transformed_three_object(aabb, object, M4_IDENTITY);
150
150
 
151
151
  // sanity checks to ensure valid bounds
152
152
  if (!Number.isFinite(aabb[0])) {
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  import { noop } from "../../../../core/function/noop.js";
8
8
  import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
9
- import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
9
+ import { M4_IDENTITY } from "../../../../core/geom/3d/mat4/M4_IDENTITY.js";
10
10
  import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
11
11
  import { TextureAssetLoader } from "../../../asset/loaders/texture/TextureAssetLoader.js";
12
12
  import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
@@ -220,7 +220,7 @@ class TerrainSystem extends System {
220
220
  // terrain has a transform
221
221
  terrain.transform = transform.matrix;
222
222
  } else {
223
- terrain.transform = MATRIX_4_IDENTITY;
223
+ terrain.transform = M4_IDENTITY;
224
224
  }
225
225
 
226
226
  terrain.update(this.__time_delta);
@@ -2,8 +2,8 @@ import { assert } from "../../../core/assert.js";
2
2
  import { allocate_m4 } from "../../../core/geom/3d/mat4/allocate_m4.js";
3
3
  import { compose_matrix4_array } from "../../../core/geom/3d/mat4/compose_matrix4_array.js";
4
4
  import { decompose_matrix_4_array } from "../../../core/geom/3d/mat4/decompose_matrix_4_array.js";
5
+ import { M4_IDENTITY } from "../../../core/geom/3d/mat4/M4_IDENTITY.js";
5
6
  import { m4_multiply } from "../../../core/geom/3d/mat4/m4_multiply.js";
6
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
7
7
  import Quaternion from "../../../core/geom/Quaternion.js";
8
8
  import Vector3 from "../../../core/geom/Vector3.js";
9
9
  import { TransformFlags } from "./TransformFlags.js";
@@ -400,7 +400,7 @@ export class Transform {
400
400
  * - scale: [1,1,1]
401
401
  */
402
402
  makeIdentity() {
403
- this.fromMatrix(MATRIX_4_IDENTITY);
403
+ this.fromMatrix(M4_IDENTITY);
404
404
  }
405
405
 
406
406
  /**
@@ -2,15 +2,15 @@ import { Group, Matrix4, Mesh } from "three";
2
2
  import { mergeBufferGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
3
3
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
4
4
  import { HashMap } from "../../../../../core/collection/map/HashMap.js";
5
+ import { M4_IDENTITY } from "../../../../../core/geom/3d/mat4/M4_IDENTITY.js";
5
6
  import { m4_multiply } from "../../../../../core/geom/3d/mat4/m4_multiply.js";
6
- import { MATRIX_4_IDENTITY } from "../../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
7
7
  import { StaticMaterialCache } from "../../../../asset/loaders/material/StaticMaterialCache.js";
8
8
  import { computeGeometryEquality } from "../../buffered/computeGeometryEquality.js";
9
9
  import { computeGeometryHash } from "../../buffered/computeGeometryHash.js";
10
10
 
11
11
  class GeometryContext {
12
12
  constructor() {
13
- this.matrix = new Float32Array(MATRIX_4_IDENTITY);
13
+ this.matrix = new Float32Array(M4_IDENTITY);
14
14
  this.material = null;
15
15
  this.geometry = null;
16
16
  }
@@ -52,7 +52,7 @@ function compute_transform_matrix(object, ancestor_root, result) {
52
52
  //
53
53
  path.reverse();
54
54
 
55
- result.set(MATRIX_4_IDENTITY);
55
+ result.set(M4_IDENTITY);
56
56
 
57
57
  for (let i = 0; i < path.length; i++) {
58
58
  const el = path[i];