@woosh/meep-engine 2.48.16 → 2.48.18
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/editor/tools/TransformTool.js +4 -2
- package/package.json +1 -1
- package/src/core/binary/dec2hex.spec.js +13 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +18 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +18 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +56 -0
- package/src/core/cache/Cache.d.ts +5 -0
- package/src/core/cache/Cache.js +8 -1
- package/src/core/cache/Cache.spec.js +47 -3
- package/src/core/codegen/LineBuilder.js +117 -106
- package/src/core/collection/HashMap.spec.js +32 -0
- package/src/core/collection/list/List.js +6 -4
- package/src/core/geom/Quaternion.d.ts +3 -1
- package/src/core/geom/Quaternion.js +8 -4
- package/src/core/geom/Vector3.js +9 -31
- package/src/core/math/fract.spec.js +11 -0
- package/src/core/math/isPowerOfTwo.spec.js +9 -0
- package/src/core/math/isPowerOrTwo.js +5 -0
- package/src/core/math/newton_solver_1d.js +1 -1
- package/src/core/math/newton_solver_1d.spec.js +9 -0
- package/src/core/math/pingpong.spec.js +11 -0
- package/src/core/math/random/randomBytes.js +16 -0
- package/src/core/math/random/randomFloatBetween.spec.js +8 -0
- package/src/core/math/random/randomFromArray.js +3 -3
- package/src/core/math/random/randomIntegerBetween.js +5 -0
- package/src/core/math/random/randomIntegerBetween.spec.js +7 -0
- package/src/core/math/statistics/halton_sequence.spec.js +17 -0
- package/src/engine/asset/AssetManager.d.ts +11 -1
- package/src/engine/asset/AssetManager.spec.js +2 -2
- package/src/engine/control/ControlContext.js +2 -1
- package/src/engine/ecs/EntityBuilder.d.ts +6 -0
- package/src/engine/ecs/EntityBuilder.js +2 -22
- package/src/engine/ecs/EntityBuilder.spec.js +71 -1
- package/src/engine/ecs/EntityBuilderFlags.js +20 -0
- package/src/engine/ecs/EntityComponentDataset.js +3 -6
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/src/engine/ecs/gui/menu/radial/RadialContextMenu.js +2 -1
- package/src/engine/ecs/guid/GUID.js +48 -26
- package/src/engine/ecs/guid/GUID.spec.js +56 -10
- package/src/engine/ecs/speaker/VoiceSystem.js +2 -1
- package/src/engine/ecs/transform/Transform.d.ts +11 -1
- package/src/engine/ecs/transform/Transform.js +6 -3
- package/src/engine/ecs/transform/Transform.spec.js +67 -1
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +2 -1
- package/src/engine/physics/fluid/Fluid.js +3 -0
- package/src/engine/graphics/ecs/mesh/setThreeObjectRotation.js +0 -11
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { GUID } from "./GUID.js";
|
|
2
2
|
|
|
3
3
|
test("uniqueness out of 2", () => {
|
|
4
|
-
const a =
|
|
5
|
-
const b =
|
|
4
|
+
const a = GUID.v1();
|
|
5
|
+
const b = GUID.v1();
|
|
6
6
|
|
|
7
7
|
expect(a.equals(b)).toBe(false);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
test("equality", () => {
|
|
12
|
-
const a =
|
|
13
|
-
const b =
|
|
14
|
-
|
|
15
|
-
a.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
16
|
-
b.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
11
|
+
const a = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
12
|
+
const b = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
17
13
|
|
|
18
14
|
expect(a.equals(b)).toBe(true);
|
|
19
15
|
|
|
@@ -28,10 +24,24 @@ test("hash stability", () => {
|
|
|
28
24
|
expect(guid.hash()).toBe(guid.hash());
|
|
29
25
|
});
|
|
30
26
|
|
|
27
|
+
test("copy", () => {
|
|
28
|
+
const a = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
29
|
+
const a_string = a.toString();
|
|
30
|
+
|
|
31
|
+
const b = GUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
|
|
32
|
+
|
|
33
|
+
expect(a.equals(b)).toBe(false);
|
|
34
|
+
|
|
35
|
+
b.copy(a);
|
|
36
|
+
|
|
37
|
+
expect(a.equals(b)).toBe(true);
|
|
38
|
+
|
|
39
|
+
// make sure that "a" is not changed
|
|
40
|
+
expect(a.toString()).toEqual(a_string);
|
|
41
|
+
});
|
|
31
42
|
|
|
32
43
|
test("to/from JSON consistency", () => {
|
|
33
|
-
const a =
|
|
34
|
-
a.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
|
|
44
|
+
const a = GUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
|
|
35
45
|
|
|
36
46
|
const b = new GUID();
|
|
37
47
|
|
|
@@ -39,3 +49,39 @@ test("to/from JSON consistency", () => {
|
|
|
39
49
|
|
|
40
50
|
expect(b.equals(a)).toBe(true)
|
|
41
51
|
});
|
|
52
|
+
|
|
53
|
+
test(".data setter performs a copy instead of assignment", () => {
|
|
54
|
+
const id = new GUID();
|
|
55
|
+
|
|
56
|
+
const data = new Uint8Array(16);
|
|
57
|
+
|
|
58
|
+
id.data = data;
|
|
59
|
+
|
|
60
|
+
expect(id.data).not.toBe(data);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test(".data set/get", () => {
|
|
64
|
+
const a = new GUID();
|
|
65
|
+
|
|
66
|
+
const sample_0 = [
|
|
67
|
+
0xFF, 0xFF, 0xFF, 0xFF,
|
|
68
|
+
0xFF, 0xFF, 0xFF, 0xFF,
|
|
69
|
+
0xFF, 0xFF, 0xFF, 0xFF,
|
|
70
|
+
0xFF, 0xFF, 0xFF, 0xFF,
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
a.data = sample_0;
|
|
74
|
+
|
|
75
|
+
expect(Array.from(a.data)).toEqual(sample_0);
|
|
76
|
+
|
|
77
|
+
const sample_1 = [
|
|
78
|
+
0x00, 0x01, 0x02, 0x03,
|
|
79
|
+
0x04, 0x05, 0x06, 0x07,
|
|
80
|
+
0x08, 0x09, 0x0A, 0x0B,
|
|
81
|
+
0x0C, 0x0D, 0x0E, 0x0F,
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
a.data = sample_1;
|
|
85
|
+
|
|
86
|
+
expect(Array.from(a.data)).toEqual(sample_1);
|
|
87
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { max2 } from "../../../core/math/max2.js";
|
|
2
2
|
import { Voice } from "./Voice.js";
|
|
3
|
-
import EntityBuilder
|
|
3
|
+
import EntityBuilder from "../EntityBuilder.js";
|
|
4
4
|
import GUIElement from "../gui/GUIElement.js";
|
|
5
5
|
import { SerializationMetadata } from "../components/SerializationMetadata.js";
|
|
6
6
|
import HeadsUpDisplay from "../gui/hud/HeadsUpDisplay.js";
|
|
@@ -32,6 +32,7 @@ import { globalMetrics } from "../../metrics/GlobalMetrics.js";
|
|
|
32
32
|
import { MetricsCategory } from "../../metrics/MetricsCategory.js";
|
|
33
33
|
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
34
34
|
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
35
|
+
import { EntityBuilderFlags } from "../EntityBuilderFlags.js";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Delay before the user notices the text and begins to read
|
|
@@ -6,7 +6,7 @@ export class Transform {
|
|
|
6
6
|
public readonly rotation: Quaternion
|
|
7
7
|
public readonly scale: Vector3
|
|
8
8
|
|
|
9
|
-
public readonly matrix:ArrayLike<number>
|
|
9
|
+
public readonly matrix: ArrayLike<number>
|
|
10
10
|
|
|
11
11
|
public lookAt(target: Vector3): void
|
|
12
12
|
|
|
@@ -22,6 +22,8 @@ export class Transform {
|
|
|
22
22
|
rotation?: { x: number, y: number, z: number, w: number },
|
|
23
23
|
}): void
|
|
24
24
|
|
|
25
|
+
toJSON(): any
|
|
26
|
+
|
|
25
27
|
copy(other: Transform): void
|
|
26
28
|
|
|
27
29
|
clone(): Transform
|
|
@@ -37,4 +39,12 @@ export class Transform {
|
|
|
37
39
|
multiplyTransforms(a: Transform, b: Transform): void
|
|
38
40
|
|
|
39
41
|
makeIdentity(): void
|
|
42
|
+
|
|
43
|
+
setFlag(flag: number): void
|
|
44
|
+
|
|
45
|
+
getFlag(flag: number): boolean
|
|
46
|
+
|
|
47
|
+
clearFlag(flag: number): void
|
|
48
|
+
|
|
49
|
+
writeFlag(flag: number, value: boolean): void
|
|
40
50
|
}
|
|
@@ -10,6 +10,7 @@ import { TransformFlags } from "./TransformFlags.js";
|
|
|
10
10
|
import { allocate_transform_m4 } from "../../graphics/ecs/mesh-v2/allocate_transform_m4.js";
|
|
11
11
|
import { assert } from "../../../core/assert.js";
|
|
12
12
|
import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
|
|
13
|
+
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
*
|
|
@@ -315,9 +316,11 @@ export class Transform {
|
|
|
315
316
|
* - scale: [1,1,1]
|
|
316
317
|
*/
|
|
317
318
|
makeIdentity() {
|
|
318
|
-
this.
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
this.fromMatrix4(MATRIX_4_IDENTITY);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
toString() {
|
|
323
|
+
return `{ position: ${this.position}, rotation: ${this.rotation}, scale: ${this.scale} }`;
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
326
|
|
|
@@ -2,6 +2,7 @@ import { Transform } from "./Transform.js";
|
|
|
2
2
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
3
3
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
4
4
|
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
5
|
+
import { TransformFlags } from "./TransformFlags.js";
|
|
5
6
|
|
|
6
7
|
test("constructor does not throw", () => {
|
|
7
8
|
|
|
@@ -18,5 +19,70 @@ test("new transform has identity transform", () => {
|
|
|
18
19
|
expect(t.rotation.equals(Quaternion.identity)).toBe(true);
|
|
19
20
|
expect(t.scale.equals(Vector3.one)).toBe(true);
|
|
20
21
|
|
|
21
|
-
expect(t.matrix).toEqual(MATRIX_4_IDENTITY);
|
|
22
|
+
expect(Array.from(t.matrix)).toEqual(MATRIX_4_IDENTITY);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("makeIdentity", () => {
|
|
26
|
+
|
|
27
|
+
const t = new Transform();
|
|
28
|
+
|
|
29
|
+
t.position.set(1, 2, 3);
|
|
30
|
+
|
|
31
|
+
t.makeIdentity();
|
|
32
|
+
|
|
33
|
+
expect(t.position.toJSON()).toEqual({ x: 0, y: 0, z: 0 })
|
|
34
|
+
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("position changes propagate to matrix", () => {
|
|
38
|
+
const t = new Transform();
|
|
39
|
+
|
|
40
|
+
t.setFlag(TransformFlags.AutomaticChangeDetection);
|
|
41
|
+
|
|
42
|
+
t.position.set(-1, 3, -7);
|
|
43
|
+
|
|
44
|
+
expect(t.matrix[12]).toBe(-1);
|
|
45
|
+
expect(t.matrix[13]).toBe(3);
|
|
46
|
+
expect(t.matrix[14]).toBe(-7);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @return {Transform}
|
|
52
|
+
*/
|
|
53
|
+
function sample_a() {
|
|
54
|
+
const a = new Transform();
|
|
55
|
+
|
|
56
|
+
a.position.set(1, 2, 3);
|
|
57
|
+
a.rotation.set(5, -7, 11, -13);
|
|
58
|
+
a.scale.set(17, -23, 29);
|
|
59
|
+
|
|
60
|
+
return a;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
test("to/fromJSON consistency", () => {
|
|
64
|
+
const a = sample_a();
|
|
65
|
+
|
|
66
|
+
const b = new Transform();
|
|
67
|
+
|
|
68
|
+
b.fromJSON(a.toJSON());
|
|
69
|
+
|
|
70
|
+
expect(a.equals(b)).toBe(true);
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test("equality", () => {
|
|
74
|
+
const a = sample_a();
|
|
75
|
+
const b = sample_a();
|
|
76
|
+
|
|
77
|
+
expect(a.equals(b)).toBe(true);
|
|
78
|
+
|
|
79
|
+
b.position._add(1, 0, 0);
|
|
80
|
+
|
|
81
|
+
expect(a.equals(b)).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("toString produces a valid string", () => {
|
|
85
|
+
const t = new Transform();
|
|
86
|
+
|
|
87
|
+
expect(typeof t.toString()).toBe("string");
|
|
22
88
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EngineHarness } from "../../../../EngineHarness.js";
|
|
2
2
|
import { FPDecalSystem } from "./FPDecalSystem.js";
|
|
3
|
-
import EntityBuilder
|
|
3
|
+
import EntityBuilder from "../../../../ecs/EntityBuilder.js";
|
|
4
4
|
import { Decal } from "./Decal.js";
|
|
5
5
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
6
6
|
import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
|
|
@@ -31,6 +31,7 @@ import { GizmoRenderingPlugin } from "../../../render/gizmo/GizmoRenderingPlugin
|
|
|
31
31
|
import { Gizmo } from "../../../render/gizmo/Gizmo.js";
|
|
32
32
|
import { ForwardPlusRenderingPlugin } from "../../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
33
33
|
import { TaskLoadingScreen } from "../../../../../view/task/TaskLoadingScreen.js";
|
|
34
|
+
import { EntityBuilderFlags } from "../../../../ecs/EntityBuilderFlags.js";
|
|
34
35
|
|
|
35
36
|
const decal_urls = `data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_13_t.png
|
|
36
37
|
data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_01_t.png
|