@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 +1 -1
- package/src/core/geom/3d/Ray3.js +2 -2
- package/src/core/geom/vec3/v3_array_immediate_add.js +1 -1
- package/src/core/geom/vec3/{v3_normalize_array.d.ts → v3_array_normalize.d.ts} +2 -2
- package/src/core/geom/vec3/v3_array_normalize.d.ts.map +1 -0
- package/src/core/geom/vec3/{v3_normalize_array.js → v3_array_normalize.js} +1 -1
- package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.js +2 -2
- package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals.d.ts +9 -0
- package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals.d.ts.map +1 -0
- package/src/engine/graphics/geometry/buffered/{ComputeNormals.js → geometry_compute_vertex_normals.js} +26 -16
- package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.js +2 -2
- package/src/core/geom/vec3/v3_normalize_array.d.ts.map +0 -1
- package/src/engine/graphics/geometry/buffered/ComputeNormals.d.ts +0 -9
- package/src/engine/graphics/geometry/buffered/ComputeNormals.d.ts.map +0 -1
package/package.json
CHANGED
package/src/core/geom/3d/Ray3.js
CHANGED
|
@@ -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
|
-
|
|
114
|
+
v3_array_normalize(this, 3, this, 3);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {number[]|Float32Array} input
|
|
6
6
|
* @param {number} input_offset
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
9
|
-
//# sourceMappingURL=
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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}
|
|
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
|
|
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
|
-
|
|
34
|
-
|
|
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 =
|
|
42
|
-
vAy =
|
|
43
|
-
vAz =
|
|
47
|
+
vAx = positions[vA];
|
|
48
|
+
vAy = positions[vA + 1];
|
|
49
|
+
vAz = positions[vA + 2];
|
|
44
50
|
|
|
45
|
-
vBx =
|
|
46
|
-
vBy =
|
|
47
|
-
vBz =
|
|
51
|
+
vBx = positions[vB];
|
|
52
|
+
vBy = positions[vB + 1];
|
|
53
|
+
vBz = positions[vB + 2];
|
|
48
54
|
|
|
49
|
-
vCx =
|
|
50
|
-
vCy =
|
|
51
|
-
vCz =
|
|
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
|
-
|
|
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"}
|