@woosh/meep-engine 2.111.2 → 2.111.3

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": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.111.2",
8
+ "version": "2.111.3",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -2,9 +2,9 @@ import { assert } from "../../assert.js";
2
2
  import { array_copy } from "../../collection/array/array_copy.js";
3
3
  import { array_range_equal_strict } from "../../collection/array/array_range_equal_strict.js";
4
4
  import { computeHashFloatArray } from "../../math/hash/computeHashFloatArray.js";
5
+ import { v3_array_normalize } from "../vec3/v3_array_normalize.js";
5
6
  import { v3_matrix4_multiply } from "../vec3/v3_matrix4_multiply.js";
6
7
  import { v3_matrix4_rotate } from "../vec3/v3_matrix4_rotate.js";
7
- import { v3_normalize_array } from "../vec3/v3_normalize_array.js";
8
8
  import { ray3_interval_array_apply_matrix4 } from "./ray/ray3_interval_array_apply_matrix4.js";
9
9
 
10
10
  /**
@@ -111,7 +111,7 @@ export class Ray3 extends Float32Array {
111
111
  }
112
112
 
113
113
  normalizeDirection() {
114
- v3_normalize_array(this, 3, this, 3);
114
+ v3_array_normalize(this, 3, this, 3);
115
115
  }
116
116
 
117
117
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Adds input to output
3
3
  * `out += input`
4
- * @param {number[]} out
4
+ * @param {number[]|Float32Array} out
5
5
  * @param {number} out_offset
6
6
  * @param {number[]} input
7
7
  * @param {number} input_offset
@@ -5,5 +5,5 @@
5
5
  * @param {number[]|Float32Array} input
6
6
  * @param {number} input_offset
7
7
  */
8
- export function v3_normalize_array(output: number[] | Float32Array, output_offset: number, input: number[] | Float32Array, input_offset: number): void;
9
- //# sourceMappingURL=v3_normalize_array.d.ts.map
8
+ export function v3_array_normalize(output: number[] | Float32Array, output_offset: number, input: number[] | Float32Array, input_offset: number): void;
9
+ //# sourceMappingURL=v3_array_normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_array_normalize.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_array_normalize.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,2CALW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,QAqBhB"}
@@ -7,7 +7,7 @@ import { v3_length } from "./v3_length.js";
7
7
  * @param {number[]|Float32Array} input
8
8
  * @param {number} input_offset
9
9
  */
10
- export function v3_normalize_array(
10
+ export function v3_array_normalize(
11
11
  output, output_offset,
12
12
  input, input_offset,
13
13
  ) {
@@ -1,4 +1,4 @@
1
- import { computeVertexNormals } from '../../graphics/geometry/buffered/ComputeNormals.js';
1
+ import { geometry_compute_vertex_normals } from '../../graphics/geometry/buffered/geometry_compute_vertex_normals.js';
2
2
 
3
3
  /**
4
4
  *
@@ -103,7 +103,7 @@ function buildBufferGeometry(samplerHeight, position, size, scale, totalSize, re
103
103
  }
104
104
  }
105
105
 
106
- computeVertexNormals(vertices, normals, indices);
106
+ geometry_compute_vertex_normals(vertices, normals, indices);
107
107
 
108
108
  //CleanupGeometry(geometry);
109
109
  return {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * based on code from THREE.js
3
+ * Prior to calling this function, normals need to be set to 0
4
+ * @param {Array.<number>|Float32Array} positions
5
+ * @param {Array.<number>|Float32Array} normals
6
+ * @param {Array.<number>|Uint32Array} indices
7
+ */
8
+ export function geometry_compute_vertex_normals(positions: Array<number> | Float32Array, normals: Array<number> | Float32Array, indices: Array<number> | Uint32Array): void;
9
+ //# sourceMappingURL=geometry_compute_vertex_normals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry_compute_vertex_normals.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals.js"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,2DAJW,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,WAAW,QAsEpC"}
@@ -1,4 +1,4 @@
1
- import { v3_normalize_array } from "../../../../core/geom/vec3/v3_normalize_array.js";
1
+ import { v3_array_normalize } from "../../../../core/geom/vec3/v3_array_normalize.js";
2
2
 
3
3
  /**
4
4
  *
@@ -8,19 +8,23 @@ function normalizeVectors(normals) {
8
8
  const count = normals.length;
9
9
  for (let i = 0; i < count; i += 3) {
10
10
 
11
- v3_normalize_array(normals, i, normals, i);
11
+ v3_array_normalize(normals, i, normals, i);
12
12
 
13
13
  }
14
14
  }
15
15
 
16
16
  /**
17
17
  * based on code from THREE.js
18
- * normals need to be set to 0
19
- * @param {Array.<number>|Float32Array} vertices
18
+ * Prior to calling this function, normals need to be set to 0
19
+ * @param {Array.<number>|Float32Array} positions
20
20
  * @param {Array.<number>|Float32Array} normals
21
21
  * @param {Array.<number>|Uint32Array} indices
22
22
  */
23
- export function computeVertexNormals(vertices, normals, indices) {
23
+ export function geometry_compute_vertex_normals(
24
+ positions,
25
+ normals,
26
+ indices
27
+ ) {
24
28
  let vA, vB, vC;
25
29
 
26
30
  let vAx, vAy, vAz, vBx, vBy, vBz, vCx, vCy, vCz;
@@ -29,26 +33,28 @@ export function computeVertexNormals(vertices, normals, indices) {
29
33
 
30
34
  let crossX, crossY, crossZ;
31
35
  // indexed elements
36
+
32
37
  let i = 0;
33
- const il = indices.length;
34
- for (; i < il; i += 3) {
38
+
39
+ const index_length = indices.length;
40
+ for (; i < index_length; i += 3) {
35
41
 
36
42
  vA = indices[i] * 3;
37
43
  vB = indices[i + 1] * 3;
38
44
  vC = indices[i + 2] * 3;
39
45
 
40
46
  //obtain vertex coordinates
41
- vAx = vertices[vA];
42
- vAy = vertices[vA + 1];
43
- vAz = vertices[vA + 2];
47
+ vAx = positions[vA];
48
+ vAy = positions[vA + 1];
49
+ vAz = positions[vA + 2];
44
50
 
45
- vBx = vertices[vB];
46
- vBy = vertices[vB + 1];
47
- vBz = vertices[vB + 2];
51
+ vBx = positions[vB];
52
+ vBy = positions[vB + 1];
53
+ vBz = positions[vB + 2];
48
54
 
49
- vCx = vertices[vC];
50
- vCy = vertices[vC + 1];
51
- vCz = vertices[vC + 2];
55
+ vCx = positions[vC];
56
+ vCy = positions[vC + 1];
57
+ vCz = positions[vC + 2];
52
58
 
53
59
  //compute CB and AB vectors
54
60
  vCBx = vCx - vBx;
@@ -64,6 +70,8 @@ export function computeVertexNormals(vertices, normals, indices) {
64
70
  crossY = vCBz * vABx - vCBx * vABz;
65
71
  crossZ = vCBx * vABy - vCBy * vABx;
66
72
 
73
+ // accumulate normal values
74
+
67
75
  normals[vA] += crossX;
68
76
  normals[vA + 1] += crossY;
69
77
  normals[vA + 2] += crossZ;
@@ -77,5 +85,7 @@ export function computeVertexNormals(vertices, normals, indices) {
77
85
  normals[vC + 2] += crossZ;
78
86
  }
79
87
 
88
+ // restore unit magnitude
89
+
80
90
  normalizeVectors(normals);
81
91
  }
@@ -1,8 +1,8 @@
1
+ import { v3_array_normalize } from "../../../../core/geom/vec3/v3_array_normalize.js";
1
2
  import { v3_displace_in_direction_array } from "../../../../core/geom/vec3/v3_displace_in_direction_array.js";
2
3
  import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
3
4
  import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
4
5
  import { v3_length_sqr } from "../../../../core/geom/vec3/v3_length_sqr.js";
5
- import { v3_normalize_array } from "../../../../core/geom/vec3/v3_normalize_array.js";
6
6
 
7
7
  const scratch_direction = new Float32Array(3);
8
8
 
@@ -103,7 +103,7 @@ function reach_out(
103
103
  scratch_direction[1] = target_y - origin_y;
104
104
  scratch_direction[2] = target_z - origin_z;
105
105
 
106
- v3_normalize_array(scratch_direction, 0, scratch_direction, 0);
106
+ v3_array_normalize(scratch_direction, 0, scratch_direction, 0);
107
107
 
108
108
  for (let i = 1; i < size; i++) {
109
109
  const current_offset = i * 3;
@@ -1 +0,0 @@
1
- {"version":3,"file":"v3_normalize_array.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_normalize_array.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,2CALW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,QAqBhB"}
@@ -1,9 +0,0 @@
1
- /**
2
- * based on code from THREE.js
3
- * normals need to be set to 0
4
- * @param {Array.<number>|Float32Array} vertices
5
- * @param {Array.<number>|Float32Array} normals
6
- * @param {Array.<number>|Uint32Array} indices
7
- */
8
- export function computeVertexNormals(vertices: Array<number> | Float32Array, normals: Array<number> | Float32Array, indices: Array<number> | Uint32Array): void;
9
- //# sourceMappingURL=ComputeNormals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComputeNormals.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/ComputeNormals.js"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,+CAJW,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,WAAW,QA4DpC"}