@woosh/meep-engine 2.81.1 → 2.81.2
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/build/meep.module.js
CHANGED
|
@@ -2021,99 +2021,6 @@ function v3_angle_cos_between(
|
|
|
2021
2021
|
|
|
2022
2022
|
}
|
|
2023
2023
|
|
|
2024
|
-
/**
|
|
2025
|
-
*
|
|
2026
|
-
* @param {BinaryBuffer} buffer
|
|
2027
|
-
* @param {number[]} result
|
|
2028
|
-
* @param {number} result_offset
|
|
2029
|
-
*/
|
|
2030
|
-
function v3_binary_equality_decode(buffer, result, result_offset) {
|
|
2031
|
-
const header = buffer.readUint8();
|
|
2032
|
-
|
|
2033
|
-
let x = 0;
|
|
2034
|
-
let y = 0;
|
|
2035
|
-
let z = 0;
|
|
2036
|
-
|
|
2037
|
-
if ((header & 7) === 7) {
|
|
2038
|
-
//all scale components are the same
|
|
2039
|
-
x = buffer.readFloat32();
|
|
2040
|
-
y = x;
|
|
2041
|
-
z = x;
|
|
2042
|
-
} else if ((header & 1) === 1) {
|
|
2043
|
-
//X and Y are the same, Z is different
|
|
2044
|
-
x = buffer.readFloat32();
|
|
2045
|
-
y = x;
|
|
2046
|
-
z = buffer.readFloat32();
|
|
2047
|
-
} else if ((header & 2) === 2) {
|
|
2048
|
-
//Y and Z are the same, X is different
|
|
2049
|
-
x = buffer.readFloat32();
|
|
2050
|
-
y = buffer.readFloat32();
|
|
2051
|
-
z = y;
|
|
2052
|
-
} else if ((header & 4) === 4) {
|
|
2053
|
-
//X and Z are the same, Y is different
|
|
2054
|
-
x = buffer.readFloat32();
|
|
2055
|
-
y = buffer.readFloat32();
|
|
2056
|
-
z = x;
|
|
2057
|
-
} else {
|
|
2058
|
-
//scale components are different
|
|
2059
|
-
x = buffer.readFloat32();
|
|
2060
|
-
y = buffer.readFloat32();
|
|
2061
|
-
z = buffer.readFloat32();
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
result[result_offset] = x;
|
|
2065
|
-
result[result_offset + 1] = y;
|
|
2066
|
-
result[result_offset + 2] = z;
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
/**
|
|
2070
|
-
*
|
|
2071
|
-
* @param {BinaryBuffer} buffer
|
|
2072
|
-
* @param {number} x
|
|
2073
|
-
* @param {number} y
|
|
2074
|
-
* @param {number} z
|
|
2075
|
-
*/
|
|
2076
|
-
function v3_binary_equality_encode(buffer, x, y, z){
|
|
2077
|
-
|
|
2078
|
-
let header = 0;
|
|
2079
|
-
|
|
2080
|
-
if (x === y) {
|
|
2081
|
-
header |= 1;
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
if (y === z) {
|
|
2085
|
-
header |= 2;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
if (x === z) {
|
|
2089
|
-
header |= 4;
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
buffer.writeUint8(header);
|
|
2093
|
-
|
|
2094
|
-
if ((header & 7) === 7) {
|
|
2095
|
-
//all components are the same
|
|
2096
|
-
buffer.writeFloat32(x);
|
|
2097
|
-
} else if (header === 1) {
|
|
2098
|
-
//X and Y are the same, Z is different
|
|
2099
|
-
buffer.writeFloat32(x);
|
|
2100
|
-
buffer.writeFloat32(z);
|
|
2101
|
-
} else if (header === 2) {
|
|
2102
|
-
//Y and Z are the same, X is different
|
|
2103
|
-
buffer.writeFloat32(x);
|
|
2104
|
-
buffer.writeFloat32(y);
|
|
2105
|
-
} else if (header === 4) {
|
|
2106
|
-
//X and Z are the same, Y is different
|
|
2107
|
-
buffer.writeFloat32(x);
|
|
2108
|
-
buffer.writeFloat32(y);
|
|
2109
|
-
} else {
|
|
2110
|
-
//scale components are different
|
|
2111
|
-
buffer.writeFloat32(x);
|
|
2112
|
-
buffer.writeFloat32(y);
|
|
2113
|
-
buffer.writeFloat32(z);
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
2024
|
/**
|
|
2118
2025
|
*
|
|
2119
2026
|
* @param {number} x
|
|
@@ -3035,11 +2942,7 @@ let Vector3$1 = class Vector3 {
|
|
|
3035
2942
|
* @deprecated use dedicated method directly instead
|
|
3036
2943
|
*/
|
|
3037
2944
|
toBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
3038
|
-
|
|
3039
|
-
const y = this.y;
|
|
3040
|
-
const z = this.z;
|
|
3041
|
-
|
|
3042
|
-
v3_binary_equality_encode(buffer, x, y, z);
|
|
2945
|
+
throw new Error('deprecated, use v3_binary_equality_encode')
|
|
3043
2946
|
}
|
|
3044
2947
|
|
|
3045
2948
|
/**
|
|
@@ -3048,7 +2951,7 @@ let Vector3$1 = class Vector3 {
|
|
|
3048
2951
|
* @deprecated use dedicated method directly instead
|
|
3049
2952
|
*/
|
|
3050
2953
|
fromBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
3051
|
-
|
|
2954
|
+
throw new Error('deprecated, use v3_binary_equality_decode')
|
|
3052
2955
|
}
|
|
3053
2956
|
|
|
3054
2957
|
hash() {
|
package/package.json
CHANGED
package/src/core/geom/Vector3.js
CHANGED
|
@@ -11,8 +11,6 @@ import { lerp } from "../math/lerp.js";
|
|
|
11
11
|
import { sign } from "../math/sign.js";
|
|
12
12
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
13
13
|
import { v3_angle_between } from "./vec3/v3_angle_between.js";
|
|
14
|
-
import { v3_binary_equality_decode } from "./vec3/v3_binary_equality_decode.js";
|
|
15
|
-
import { v3_binary_equality_encode } from "./vec3/v3_binary_equality_encode.js";
|
|
16
14
|
import { v3_dot } from "./vec3/v3_dot.js";
|
|
17
15
|
import { v3_length } from "./vec3/v3_length.js";
|
|
18
16
|
import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
|
|
@@ -861,11 +859,7 @@ class Vector3 {
|
|
|
861
859
|
* @deprecated use dedicated method directly instead
|
|
862
860
|
*/
|
|
863
861
|
toBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
864
|
-
|
|
865
|
-
const y = this.y;
|
|
866
|
-
const z = this.z;
|
|
867
|
-
|
|
868
|
-
v3_binary_equality_encode(buffer, x, y, z);
|
|
862
|
+
throw new Error('deprecated, use v3_binary_equality_encode')
|
|
869
863
|
}
|
|
870
864
|
|
|
871
865
|
/**
|
|
@@ -874,7 +868,7 @@ class Vector3 {
|
|
|
874
868
|
* @deprecated use dedicated method directly instead
|
|
875
869
|
*/
|
|
876
870
|
fromBinaryBufferFloat32_EqualityEncoded(buffer) {
|
|
877
|
-
|
|
871
|
+
throw new Error('deprecated, use v3_binary_equality_decode')
|
|
878
872
|
}
|
|
879
873
|
|
|
880
874
|
hash() {
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
line3_computeSegmentPointDistance_sqr
|
|
12
12
|
} from "../../../../core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js";
|
|
13
13
|
import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
|
|
14
|
-
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
15
14
|
import { clamp } from "../../../../core/math/clamp.js";
|
|
15
|
+
import { lerp } from "../../../../core/math/lerp.js";
|
|
16
16
|
import { min2 } from "../../../../core/math/min2.js";
|
|
17
17
|
import {
|
|
18
18
|
computeNonuniformCatmullRomSplineSample
|
|
@@ -24,9 +24,6 @@ import { AttributeSpec } from "../../../graphics/geometry/AttributeSpec.js";
|
|
|
24
24
|
import { VertexDataSpec } from "../../../graphics/geometry/VertexDataSpec.js";
|
|
25
25
|
import { InterpolationType } from "./InterpolationType.js";
|
|
26
26
|
|
|
27
|
-
const v3_a = new Vector3();
|
|
28
|
-
const v3_b = new Vector3();
|
|
29
|
-
|
|
30
27
|
const scratch_v3_a = new Float32Array(3);
|
|
31
28
|
const scratch_v3_b = new Float32Array(3);
|
|
32
29
|
|
|
@@ -415,15 +412,14 @@ class Path {
|
|
|
415
412
|
const max_index = this.getPointCount() - 1;
|
|
416
413
|
const index_next = min2(index + 1, max_index);
|
|
417
414
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
this.getPosition(index, current);
|
|
422
|
-
this.getPosition(index_next, next);
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
result.lerpVectors(current, next, t);
|
|
415
|
+
this.readPositionToArray(index, scratch_v3_a, 0);
|
|
416
|
+
this.readPositionToArray(index_next, scratch_v3_b, 0);
|
|
426
417
|
|
|
418
|
+
result.set(
|
|
419
|
+
lerp(scratch_v3_a[0], scratch_v3_b[0], t),
|
|
420
|
+
lerp(scratch_v3_a[1], scratch_v3_b[1], t),
|
|
421
|
+
lerp(scratch_v3_a[2], scratch_v3_b[2], t),
|
|
422
|
+
)
|
|
427
423
|
return (t < 0 && index_next !== max_index);
|
|
428
424
|
|
|
429
425
|
}
|
|
@@ -605,11 +601,8 @@ class Path {
|
|
|
605
601
|
|
|
606
602
|
const n = this.getPointCount();
|
|
607
603
|
|
|
608
|
-
|
|
609
604
|
for (let i = 0; i < n; i++) {
|
|
610
|
-
this.
|
|
611
|
-
|
|
612
|
-
positions.push(v3_a.x, v3_a.y, v3_a.z);
|
|
605
|
+
this.readPositionToArray(i, positions, i * 3);
|
|
613
606
|
}
|
|
614
607
|
|
|
615
608
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Path from "./Path.js";
|
|
2
1
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
2
|
+
import Path from "./Path.js";
|
|
3
3
|
|
|
4
4
|
test("constructor does not throw", () => {
|
|
5
5
|
new Path();
|
|
@@ -130,12 +130,12 @@ test("getLowIndexOfNearestPoint", () => {
|
|
|
130
130
|
expect(Path.fromJSON({ points: [0, 0, 0] }).getLowIndexOfNearestPoint(new Vector3(-1, 0, 0))).toBe(0);
|
|
131
131
|
|
|
132
132
|
const p = Path.fromJSON({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
points: [
|
|
134
|
+
0, 0, 0,
|
|
135
|
+
1, 0, 0,
|
|
136
|
+
2, 0, 0
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
139
|
|
|
140
140
|
expect(p.getLowIndexOfNearestPoint(new Vector3(-1, 0, 0))).toBe(0);
|
|
141
141
|
expect(p.getLowIndexOfNearestPoint(new Vector3(0, 0, 0))).toBe(0);
|
|
@@ -149,8 +149,8 @@ test("getLowIndexOfNearestPoint", () => {
|
|
|
149
149
|
|
|
150
150
|
test("getPosition on a path with 1 point", () => {
|
|
151
151
|
const p = Path.fromJSON({
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
points: [1, 3, 7]
|
|
153
|
+
});
|
|
154
154
|
|
|
155
155
|
const v = new Vector3();
|
|
156
156
|
|
|
@@ -159,21 +159,35 @@ test("getPosition on a path with 1 point", () => {
|
|
|
159
159
|
expect(v.toJSON()).toEqual({ x: 1, y: 3, z: 7 });
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
+
test("sample_linear with 2 points", () => {
|
|
163
|
+
|
|
164
|
+
const path = Path.fromJSON({
|
|
165
|
+
points: [3, 1, 1, 7, 3, 5]
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const r = new Vector3();
|
|
169
|
+
|
|
170
|
+
path.sample_linear(r, 4);
|
|
171
|
+
|
|
172
|
+
expect(r.x).toBeCloseTo(5.666);
|
|
173
|
+
expect(r.y).toBeCloseTo(2.333);
|
|
174
|
+
expect(r.z).toBeCloseTo(3.666);
|
|
175
|
+
});
|
|
162
176
|
|
|
163
|
-
test("sample_catmull_rom with very small offsets",()=>{
|
|
177
|
+
test("sample_catmull_rom with very small offsets", () => {
|
|
164
178
|
const path = Path.fromJSON({
|
|
165
|
-
points:[3, 1, 1, 3, 1, 3, 7, 1, 3, 7, 1, 7, 3, 1, 7, 3, 1, 8]
|
|
179
|
+
points: [3, 1, 1, 3, 1, 3, 7, 1, 3, 7, 1, 7, 3, 1, 7, 3, 1, 8]
|
|
166
180
|
});
|
|
167
181
|
|
|
168
182
|
const v = new Vector3();
|
|
169
183
|
|
|
170
|
-
path.sample_catmull_rom(v,0);
|
|
184
|
+
path.sample_catmull_rom(v, 0);
|
|
171
185
|
|
|
172
186
|
expect(v.x).not.toBeNaN();
|
|
173
187
|
expect(v.y).not.toBeNaN();
|
|
174
188
|
expect(v.z).not.toBeNaN();
|
|
175
189
|
|
|
176
|
-
path.sample_catmull_rom(v,0.00005900000113712167);
|
|
190
|
+
path.sample_catmull_rom(v, 0.00005900000113712167);
|
|
177
191
|
|
|
178
192
|
expect(v.x).not.toBeNaN();
|
|
179
193
|
expect(v.y).not.toBeNaN();
|