@woosh/meep-engine 2.49.7 → 2.49.8

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.
Files changed (55) hide show
  1. package/editor/enableEditor.js +1 -8
  2. package/package.json +1 -1
  3. package/samples/terrain/editor.js +2 -2
  4. package/src/core/cache/Cache.js +1 -1
  5. package/src/core/collection/HashSet.js +1 -1
  6. package/src/core/collection/table/RowFirstTableSpec.js +110 -92
  7. package/src/core/collection/table/RowFirstTableSpec.spec.js +49 -0
  8. package/src/core/color/Color.d.ts +4 -2
  9. package/src/core/color/Color.js +7 -8
  10. package/src/core/color/Color.spec.js +93 -0
  11. package/src/core/color/hex2rgb.spec.js +10 -0
  12. package/src/core/color/rgb2hex.js +1 -1
  13. package/src/core/color/rgb2hex.spec.js +13 -0
  14. package/src/core/fsm/simple/SimpleStateMachine.spec.js +75 -0
  15. package/src/core/fsm/simple/SimpleStateMachineDescription.js +1 -1
  16. package/src/core/fsm/simple/SimpleStateMachineDescription.spec.js +32 -0
  17. package/src/core/geom/2d/Rectangle.spec.js +51 -0
  18. package/src/core/geom/3d/aabb/aabb3_intersects_ray.spec.js +90 -0
  19. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.spec.js +61 -0
  20. package/src/core/geom/3d/morton/mortonEncode_magicbits.js +1 -34
  21. package/src/core/geom/3d/morton/split_by_2.js +17 -0
  22. package/src/core/geom/3d/morton/split_by_3.js +16 -0
  23. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +6 -1
  24. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +11 -0
  25. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.spec.js +8 -0
  26. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +3 -3
  27. package/src/core/geom/3d/topology/struct/binary/io/OrderedEdge.js +1 -1
  28. package/src/core/geom/random/randomPointOnBox.spec.js +57 -0
  29. package/src/engine/Engine.d.ts +4 -2
  30. package/src/engine/Engine.js +62 -41
  31. package/src/engine/Engine.spec.js +11 -0
  32. package/src/engine/InputEngine.js +12 -0
  33. package/src/engine/graphics/GraphicsEngine.js +2 -13
  34. package/src/engine/graphics/ecs/compileAllMaterials.js +1 -1
  35. package/src/engine/graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js +1 -1
  36. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
  37. package/src/engine/graphics/load_and_set_cubemap_v0.js +21 -0
  38. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  39. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -5
  40. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -4
  41. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  42. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  43. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -4
  44. package/src/engine/graphics/sh3/prototypeSH3Probe.js +4 -4
  45. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +4 -3
  46. package/src/engine/graphics/texture/virtual/VirtualTexture.js +9 -0
  47. package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +5 -4
  48. package/src/engine/graphics/texture/virtual/tile/TileLoader.js +5 -0
  49. package/src/engine/input/devices/PointerDevice.spec.js +7 -0
  50. package/src/engine/platform/InMemoryEnginePlatform.js +20 -0
  51. package/src/engine/save/Storage.d.ts +7 -7
  52. package/src/engine/save/storage/InMemoryStorage.js +34 -0
  53. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  54. /package/src/core/collection/{IteratorUtils.js → collectIteratorValueToArray.js} +0 -0
  55. /package/src/core/color/{ColorUtils.js → parseColor.js} +0 -0
@@ -1,4 +1,19 @@
1
1
  import Rectangle from "./Rectangle.js";
2
+ import Vector2 from "../Vector2.js";
3
+
4
+ test("constructor", () => {
5
+ expect(() => new Rectangle()).not.toThrow();
6
+ });
7
+
8
+ test("default constructor produces 0 size rectangle with valid position", () => {
9
+ const r = new Rectangle();
10
+
11
+ expect(r.size.x).toBe(0);
12
+ expect(r.size.y).toBe(0);
13
+
14
+ expect(r.position.x).not.toBeNaN();
15
+ expect(r.position.y).not.toBeNaN();
16
+ });
2
17
 
3
18
  test("toArray works correctly", () => {
4
19
  const v = new Rectangle(1, 2, 3, 4);
@@ -9,3 +24,39 @@ test("toArray works correctly", () => {
9
24
 
10
25
  expect(actual).toEqual([1, 2, 3, 4]);
11
26
  });
27
+
28
+ test("toJSON", () => {
29
+ const r = new Rectangle(1, 3, 7, 11);
30
+
31
+ expect(r.toJSON()).toEqual({
32
+ position: { x: 1, y: 3 },
33
+ size: { x: 7, y: 11 }
34
+ });
35
+ });
36
+
37
+ test("fromJSON", () => {
38
+
39
+ const r = new Rectangle();
40
+
41
+ r.fromJSON({
42
+ position: { x: 1, y: 3 },
43
+ size: { x: 7, y: 11 }
44
+ });
45
+
46
+ expect(r.position.x).toBe(1);
47
+ expect(r.position.y).toBe(3);
48
+
49
+ expect(r.size.x).toBe(7);
50
+ expect(r.size.y).toBe(11);
51
+ });
52
+
53
+ test("computeCenter", () => {
54
+ const r = new Rectangle(1, 3, 7, 11);
55
+
56
+ const center = new Vector2();
57
+
58
+ r.computeCenter(center);
59
+
60
+ expect(center.x).toBe(4.5);
61
+ expect(center.y).toBe(8.5);
62
+ });
@@ -1,6 +1,96 @@
1
1
  import { seededRandom } from "../../../math/random/seededRandom.js";
2
2
  import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
3
3
 
4
+ test("axis aligned ray on X", () => {
5
+ expect(aabb3_intersects_ray(
6
+ -0.5, -0.5, -0.5,
7
+ +0.5, +0.5, +0.5,
8
+ -1, 0, 0,
9
+ 1, 0, 0
10
+ )).toBe(true);
11
+
12
+ expect(aabb3_intersects_ray(
13
+ -0.5, -0.5, -0.5,
14
+ +0.5, +0.5, +0.5,
15
+ -1, 0, 0,
16
+ -1, 0, 0
17
+ )).toBe(false);
18
+
19
+ expect(aabb3_intersects_ray(
20
+ -0.5, -0.5, -0.5,
21
+ +0.5, +0.5, +0.5,
22
+ 1, 0, 0,
23
+ -1, 0, 0
24
+ )).toBe(true);
25
+
26
+ expect(aabb3_intersects_ray(
27
+ -0.5, -0.5, -0.5,
28
+ +0.5, +0.5, +0.5,
29
+ 1, 0, 0,
30
+ 1, 0, 0
31
+ )).toBe(false);
32
+ });
33
+
34
+ test("axis aligned ray on Y", () => {
35
+ expect(aabb3_intersects_ray(
36
+ -0.5, -0.5, -0.5,
37
+ +0.5, +0.5, +0.5,
38
+ 0, -1, 0,
39
+ 0, 1, 0
40
+ )).toBe(true);
41
+
42
+ expect(aabb3_intersects_ray(
43
+ -0.5, -0.5, -0.5,
44
+ +0.5, +0.5, +0.5,
45
+ 0, -1, 0,
46
+ 0, -1, 0
47
+ )).toBe(false);
48
+
49
+ expect(aabb3_intersects_ray(
50
+ -0.5, -0.5, -0.5,
51
+ +0.5, +0.5, +0.5,
52
+ 0, 1, 0,
53
+ 0, -1, 0
54
+ )).toBe(true);
55
+
56
+ expect(aabb3_intersects_ray(
57
+ -0.5, -0.5, -0.5,
58
+ +0.5, +0.5, +0.5,
59
+ 0, 1, 0,
60
+ 0, 1, 0
61
+ )).toBe(false);
62
+ });
63
+
64
+ test("axis aligned ray on Z", () => {
65
+ expect(aabb3_intersects_ray(
66
+ -0.5, -0.5, -0.5,
67
+ +0.5, +0.5, +0.5,
68
+ 0, 0, -1,
69
+ 0, 0, 1
70
+ )).toBe(true);
71
+
72
+ expect(aabb3_intersects_ray(
73
+ -0.5, -0.5, -0.5,
74
+ +0.5, +0.5, +0.5,
75
+ 0, 0, -1,
76
+ 0, 0, -1
77
+ )).toBe(false);
78
+
79
+ expect(aabb3_intersects_ray(
80
+ -0.5, -0.5, -0.5,
81
+ +0.5, +0.5, +0.5,
82
+ 0, 0, 1,
83
+ 0, 0, -1
84
+ )).toBe(true);
85
+
86
+ expect(aabb3_intersects_ray(
87
+ -0.5, -0.5, -0.5,
88
+ +0.5, +0.5, +0.5,
89
+ 0, 0, 1,
90
+ 0, 0, 1
91
+ )).toBe(false);
92
+ });
93
+
4
94
  test.skip("performance raycast", () => {
5
95
  const rng = seededRandom(42);
6
96
 
@@ -0,0 +1,61 @@
1
+ import { line3_compute_nearest_point_to_point } from "./line3_compute_nearest_point_to_point.js";
2
+
3
+ test("aligned with the start of the line", () => {
4
+ const result = [];
5
+
6
+ line3_compute_nearest_point_to_point(result, 0,
7
+ 1, 3, 7, 11, 13, 17,
8
+ 1, 3, 7
9
+ );
10
+
11
+ expect(result).toEqual([1, 3, 7])
12
+ });
13
+
14
+ test("aligned with the end of the line", () => {
15
+ const result = [];
16
+
17
+ line3_compute_nearest_point_to_point(result, 0,
18
+ 1, 3, 7, 11, 13, 17,
19
+ 11, 13, 17
20
+ );
21
+
22
+ expect(result).toEqual([11, 13, 17])
23
+ });
24
+
25
+ test("ref point is on line past line ends", () => {
26
+
27
+ const result = [];
28
+
29
+ line3_compute_nearest_point_to_point(result, 0,
30
+ -1, 0, 0, 3, 0, 0,
31
+ -2, 0, 0
32
+ );
33
+
34
+ expect(result).toEqual([-1, 0, 0])
35
+
36
+ line3_compute_nearest_point_to_point(result, 0,
37
+ -1, 0, 0, 3, 0, 0,
38
+ 7, 0, 0
39
+ );
40
+
41
+ expect(result).toEqual([3, 0, 0])
42
+ });
43
+
44
+ test("ref point is on the line", () => {
45
+
46
+ const result = [];
47
+
48
+ line3_compute_nearest_point_to_point(result, 0,
49
+ -1, 0, 0, 3, 0, 0,
50
+ 1, 0, 0
51
+ );
52
+
53
+ expect(result).toEqual([1, 0, 0])
54
+
55
+ line3_compute_nearest_point_to_point(result, 0,
56
+ -1, 0, 0, 3, 0, 0,
57
+ 2, 0, 0
58
+ );
59
+
60
+ expect(result).toEqual([2, 0, 0])
61
+ });
@@ -1,37 +1,4 @@
1
- /**
2
- * method to separate bits from a given integer 3 positions apart
3
- * we only look at the first 10 bits
4
- *
5
- * @example when input is ABC, output bits are A00B00C
6
- * @param {number} a
7
- * @returns {number}
8
- */
9
- function split_by_3(a) {
10
- let x = a;
11
- x = (x | x << 16) & 0x30000ff;
12
- x = (x | x << 8) & 0x0300f00f;
13
- x = (x | x << 4) & 0x30c30c3;
14
- x = (x | x << 2) & 0x9249249;
15
- return x;
16
- }
17
-
18
- /**
19
- * method to separate bits from a given integer 2 positions apart
20
- *
21
- * @example when input is ABC, output bits are A00B00C
22
- * @see https://github.com/Forceflow/libmorton/blob/234a443ca8e2c64f6385f1a9d6ee10a70d08a3fa/include/libmorton/morton2D.h#L99
23
- * @param {number} a
24
- * @returns {number}
25
- */
26
- export function split_by_2(a) {
27
- let x = a;
28
- x = (x | x << 16) & 0x0000FFFF;
29
- x = (x | x << 8) & 0x00FF00FF;
30
- x = (x | x << 4) & 0x0F0F0F0F;
31
- x = (x | x << 2) & 0x33333333;
32
- x = (x | x << 1) & 0x55555555;
33
- return x;
34
- }
1
+ import { split_by_3 } from "./split_by_3.js";
35
2
 
36
3
  /**
37
4
  * Based on article and C++ source code:
@@ -0,0 +1,17 @@
1
+ /**
2
+ * method to separate bits from a given integer 2 positions apart
3
+ *
4
+ * @example when input is ABC, output bits are A00B00C
5
+ * @see https://github.com/Forceflow/libmorton/blob/234a443ca8e2c64f6385f1a9d6ee10a70d08a3fa/include/libmorton/morton2D.h#L99
6
+ * @param {number} a
7
+ * @returns {number}
8
+ */
9
+ export function split_by_2(a) {
10
+ let x = a;
11
+ x = (x | x << 16) & 0x0000FFFF;
12
+ x = (x | x << 8) & 0x00FF00FF;
13
+ x = (x | x << 4) & 0x0F0F0F0F;
14
+ x = (x | x << 2) & 0x33333333;
15
+ x = (x | x << 1) & 0x55555555;
16
+ return x;
17
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * method to separate bits from a given integer 3 positions apart
3
+ * we only look at the first 10 bits
4
+ *
5
+ * @example when input is ABC, output bits are A00B00C
6
+ * @param {number} a
7
+ * @returns {number}
8
+ */
9
+ export function split_by_3(a) {
10
+ let x = a;
11
+ x = (x | x << 16) & 0x30000ff;
12
+ x = (x | x << 8) & 0x0300f00f;
13
+ x = (x | x << 4) & 0x30c30c3;
14
+ x = (x | x << 2) & 0x9249249;
15
+ return x;
16
+ }
@@ -15,7 +15,12 @@ import { v3_dot } from "../../v3_dot.js";
15
15
  * @param {number} dist Plane distance
16
16
  * @returns {boolean} true if intersection is found, false otherwise
17
17
  */
18
- export function computePlaneLineIntersection(out, originX, originY, originZ, directionX, directionY, directionZ, normalX, normalY, normalZ, dist) {
18
+ export function computePlaneLineIntersection(
19
+ out,
20
+ originX, originY, originZ,
21
+ directionX, directionY, directionZ,
22
+ normalX, normalY, normalZ, dist
23
+ ) {
19
24
  const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
20
25
 
21
26
  const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
@@ -47,3 +47,14 @@ test("ray from +Z to -Z intersects sphere", () => {
47
47
  0, 0, -1
48
48
  )).toBe(true);
49
49
  });
50
+
51
+
52
+ // negative cases
53
+
54
+ test("ray from -X to -X", () => {
55
+ expect(sphere_intersects_ray(
56
+ 0, 0, 0, 1,
57
+ -2, 0, 0,
58
+ -1, 0, 0
59
+ )).toBe(false);
60
+ });
@@ -0,0 +1,8 @@
1
+ import { sphere_radius_sqr_from_v3_array_transformed } from "./sphere_radius_sqr_from_v3_array_transformed.js";
2
+ import { MATRIX_4_IDENTITY } from "../matrix/MATRIX_4_IDENTITY.js";
3
+
4
+ test("base case", () => {
5
+ expect(sphere_radius_sqr_from_v3_array_transformed([0, 0, 0], 3, MATRIX_4_IDENTITY)).toBe(0);
6
+ expect(sphere_radius_sqr_from_v3_array_transformed([1, 0, 0], 3, MATRIX_4_IDENTITY)).toBe(1);
7
+ expect(sphere_radius_sqr_from_v3_array_transformed([-1, 0, 0], 3, MATRIX_4_IDENTITY)).toBe(1);
8
+ });
@@ -9,7 +9,7 @@ import { topo_mesh_to_three_buffer_geometry } from "../topo_mesh_to_three_buffer
9
9
  import { three_buffer_geometry_to_topo_mesh } from "../three_buffer_geometry_to_topo_mesh.js";
10
10
  import { mesh_flood_fill } from "../util/mesh_flood_fill.js";
11
11
  import { compute_aabb_from_points } from "../../aabb/compute_aabb_from_points.js";
12
- import { AABB3 } from "../../../../bvh2/aabb3/AABB3.js";
12
+ import { AABB3 } from "../../../../geom/3d/aabb/AABB3.js";
13
13
  import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
14
14
  import { makeGeometryIndexed } from "../../../../../engine/graphics/geometry/buffered/makeGeometryIndexed.js";
15
15
  import { v3_dot } from "../../../v3_dot.js";
@@ -23,10 +23,10 @@ import { SGMeshEvents } from "../../../../../engine/graphics/ecs/mesh-v2/aggrega
23
23
  import { Color } from "../../../../color/Color.js";
24
24
  import { seededRandom } from "../../../../math/random/seededRandom.js";
25
25
  import { expandConnectivityByLocality } from "../expandConnectivityByLocality.js";
26
- import { buildCubeURLs } from "../../../../../engine/graphics/texture/cubemap/buildCubeURLs.js";
27
26
  import { EntityNode } from "../../../../../engine/ecs/parent/EntityNode.js";
28
27
  import { TransformAttachmentSystem } from "../../../../../engine/ecs/transform-attachment/TransformAttachmentSystem.js";
29
28
  import { make_ray_from_viewport_position } from "../../../../../engine/graphics/make_ray_from_viewport_position.js";
29
+ import { load_and_set_cubemap_v0 } from "../../../../../engine/graphics/load_and_set_cubemap_v0.js";
30
30
 
31
31
  const harness = new EngineHarness();
32
32
 
@@ -98,7 +98,7 @@ async function main(engine) {
98
98
  enableTerrain: false
99
99
  });
100
100
 
101
- engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
101
+ load_and_set_cubemap_v0(engine.graphics,'data/textures/cubemaps/hip_miramar/32/', '.png')
102
102
 
103
103
  const path = 'data/models/sponza-pbr/gltf/sponza.glb';
104
104
 
@@ -1,4 +1,4 @@
1
- import { split_by_2 } from "../../../../morton/mortonEncode_magicbits.js";
1
+ import { split_by_2 } from "../../../../morton/split_by_2.js";
2
2
 
3
3
  export class OrderedEdge {
4
4
  /**
@@ -0,0 +1,57 @@
1
+ import { randomPointOnBox } from "./randomPointOnBox.js";
2
+
3
+ function assert_point_on_box(sample) {
4
+
5
+ const x = sample[0];
6
+ const y = sample[1];
7
+ const z = sample[2];
8
+
9
+ function assert_range(v) {
10
+ expect(v).toBeGreaterThanOrEqual(-0.5);
11
+ expect(v).toBeLessThanOrEqual(0.5);
12
+ }
13
+
14
+ if (Math.abs(x) === 0.5 && Math.abs(y) === 0.5) {
15
+ assert_range(z);
16
+ } else if (Math.abs(x) === 0.5 && Math.abs(z) === 0.5) {
17
+ assert_range(y);
18
+ } else if (Math.abs(y) === 0.5 && Math.abs(z) === 0.5) {
19
+ assert_range(x);
20
+ } else if (Math.abs(x) === 0.5) {
21
+ assert_range(y);
22
+ assert_range(z);
23
+ } else if (Math.abs(y) === 0.5) {
24
+ assert_range(x);
25
+ assert_range(z);
26
+ } else if (Math.abs(z) === 0.5) {
27
+ assert_range(y);
28
+ assert_range(x);
29
+ } else {
30
+ throw new Error(`Unexpected ${sample}`);
31
+ }
32
+
33
+ }
34
+
35
+ test("samples are on box shell", () => {
36
+ function validate(sample_value) {
37
+
38
+ const sample = [];
39
+
40
+ randomPointOnBox(() => sample_value, sample, 0);
41
+
42
+ assert_point_on_box(sample);
43
+ }
44
+
45
+ validate(0);
46
+ validate(1);
47
+
48
+ validate(0.1);
49
+ validate(0.2);
50
+ validate(0.3);
51
+ validate(0.4);
52
+ validate(0.5);
53
+ validate(0.6);
54
+ validate(0.7);
55
+ validate(0.8);
56
+ validate(0.9);
57
+ });
@@ -12,7 +12,9 @@ import {EnginePluginManager} from "./plugin/EnginePluginManager";
12
12
  import ConcurrentExecutor from "../core/process/executor/ConcurrentExecutor";
13
13
 
14
14
  export interface IEngineInitializationOptions {
15
- entityManager?: EntityManager
15
+ entityManager?: EntityManager,
16
+ enableAudio?: boolean
17
+ enableGraphics?: boolean
16
18
  }
17
19
 
18
20
  export default class Engine {
@@ -25,7 +27,7 @@ export default class Engine {
25
27
  public readonly sound: SoundEngine
26
28
  public readonly graphics: GraphicsEngine
27
29
  public readonly devices: { keyboard: KeyboardDevice, pointer: PointerDevice }
28
- public readonly assetManager: AssetManager
30
+ public readonly assetManager: AssetManager<Engine>
29
31
  public readonly ticker: Ticker
30
32
  public readonly plugins: EnginePluginManager
31
33
  public readonly executor: ConcurrentExecutor
@@ -5,7 +5,6 @@
5
5
  import ConcurrentExecutor from '../core/process/executor/ConcurrentExecutor.js';
6
6
 
7
7
  import { AssetManager } from './asset/AssetManager.js';
8
- import InputEngine from './InputEngine.js';
9
8
  import { GraphicsEngine } from './graphics/GraphicsEngine.js';
10
9
  import SoundEngine from './sound/SoundEngine.js';
11
10
  import { PerspectiveCamera as ThreePerspectiveCamera } from 'three';
@@ -49,9 +48,15 @@ class Engine {
49
48
  *
50
49
  * @param {EnginePlatform} platform
51
50
  * @param {EntityManager} [entityManager]
51
+ * @param enableGraphics
52
+ * @param enableAudio
52
53
  * @constructor
53
54
  */
54
- constructor(platform, { entityManager } = {}) {
55
+ constructor(platform, {
56
+ entityManager,
57
+ enableGraphics = true,
58
+ enableAudio = true
59
+ } = {}) {
55
60
  assert.defined(platform, 'platform');
56
61
 
57
62
  /**
@@ -105,7 +110,7 @@ class Engine {
105
110
  * @type {AssetManager<Engine>}
106
111
  */
107
112
  this.assetManager = new AssetManager({
108
- context:this,
113
+ context: this,
109
114
  executor: this.executor
110
115
  });
111
116
 
@@ -159,11 +164,6 @@ class Engine {
159
164
  });
160
165
  }
161
166
 
162
-
163
- this.initialize();
164
- }
165
-
166
- initialize() {
167
167
  // initialize performance metrics
168
168
  this.performance.create({
169
169
  name: METRIC_ID_RENDER
@@ -218,29 +218,39 @@ class Engine {
218
218
  this.camera = new ThreePerspectiveCamera(45, innerWidth / innerHeight, 1, 50);
219
219
 
220
220
 
221
- /**
222
- *
223
- * @type {GraphicsEngine}
224
- */
225
- const ge = this.graphics = new GraphicsEngine(this.camera, this.entityManager);
221
+ if (enableGraphics !== false) {
226
222
 
227
- try {
228
- ge.start();
229
- } catch (e) {
230
- logger.info("Failed to start GraphicEngine: ", e);
231
- }
223
+ const graphicsEngine = new GraphicsEngine(this.camera, this.entityManager);
232
224
 
233
- this.inputEngine = new InputEngine(ge.domElement, window);
225
+ /**
226
+ *
227
+ * @type {GraphicsEngine}
228
+ */
229
+ this.graphics = graphicsEngine;
234
230
 
235
- //sound engine
236
- const soundEngine = new SoundEngine();
237
- soundEngine.volume = 1;
231
+ try {
232
+ graphicsEngine.start();
233
+ } catch (e) {
234
+ logger.info("Failed to start GraphicEngine: ", e);
235
+ }
238
236
 
239
- /**
240
- *
241
- * @type {SoundEngine}
242
- */
243
- this.sound = soundEngine;
237
+ } else {
238
+ logger.info('enableGraphics option is not set, no graphics engine will be created');
239
+ }
240
+
241
+ if (enableAudio !== false) {
242
+ //sound engine
243
+ const soundEngine = new SoundEngine();
244
+ soundEngine.volume = 1;
245
+
246
+ /**
247
+ *
248
+ * @type {SoundEngine}
249
+ */
250
+ this.sound = soundEngine;
251
+ } else {
252
+ logger.info('enableAudio option is not set, no audio engine will be created');
253
+ }
244
254
 
245
255
  /**
246
256
  * Graphical User Interface engine
@@ -281,14 +291,20 @@ class Engine {
281
291
  this.plugins.initialize(this);
282
292
  }
283
293
 
294
+
295
+ get inputEngine() {
296
+ throw new Error('Deprecated, use .devices instead');
297
+ }
298
+
299
+ /**
300
+ * @deprecated
301
+ */
284
302
  get grid() {
285
303
  throw new Error('Deprecated, use systems/components to achieve the same functionality as before');
286
304
  }
287
305
 
288
306
  initializeViews() {
289
307
 
290
- const viewport = this.graphics.viewport;
291
-
292
308
  const gameView = new EmptyView();
293
309
 
294
310
  gameView.addClass('game-view');
@@ -299,23 +315,28 @@ class Engine {
299
315
  position: "absolute",
300
316
  pointerEvents: "none"
301
317
  });
302
-
303
- viewport.css({
304
- pointerEvents: "auto"
305
- });
306
-
307
318
  this.gameView = gameView;
308
319
 
309
- gameView.addChild(viewport);
310
320
 
311
321
  this.viewStack = new ViewStack();
312
- this.viewStack.push(gameView,'game-view');
322
+ this.viewStack.push(gameView, 'game-view');
313
323
 
314
- //bind size of renderer viewport to game view
315
- viewport.bindSignal(gameView.size.onChanged, viewport.size.set.bind(viewport.size));
316
- gameView.on.linked.add(function () {
317
- viewport.size.copy(gameView.size);
318
- });
324
+ if (this.graphics !== undefined) {
325
+
326
+ const viewport = this.graphics.viewport;
327
+
328
+ viewport.css({
329
+ pointerEvents: "auto"
330
+ });
331
+
332
+ gameView.addChild(viewport);
333
+ //bind size of renderer viewport to game view
334
+ viewport.bindSignal(gameView.size.onChanged, viewport.size.set.bind(viewport.size));
335
+ gameView.on.linked.add(function () {
336
+ viewport.size.copy(gameView.size);
337
+ });
338
+
339
+ }
319
340
  }
320
341
 
321
342
  initializeSettings() {
@@ -0,0 +1,11 @@
1
+ import Engine from "./Engine.js";
2
+ import { InMemoryEnginePlatform } from "./platform/InMemoryEnginePlatform.js";
3
+
4
+ test("constructor does not throw", () => {
5
+ const platform = new InMemoryEnginePlatform();
6
+
7
+ expect(() => new Engine(platform, {
8
+ enableAudio: false,
9
+ enableGraphics: false
10
+ })).not.toThrow();
11
+ });
@@ -4,8 +4,20 @@
4
4
  * Time: 20:15
5
5
  */
6
6
  import { KeyCodes } from './input/devices/KeyCodes.js';
7
+ import { assert } from "../core/assert.js";
7
8
 
9
+ /**
10
+ * @deprecated use PointerDevice and KeyboardDevice respectively
11
+ * @param pointerContext
12
+ * @param keyContext
13
+ * @constructor
14
+ */
8
15
  const InputEngine = function (pointerContext, keyContext) {
16
+ assert.defined(pointerContext, 'pointerContext');
17
+ assert.defined(keyContext, 'keyContext');
18
+
19
+ console.warn('deprecated, use PointerDevice and KeyboardDevice instead');
20
+
9
21
  const keyMap = [];
10
22
  const mouseMap = {};
11
23
 
@@ -36,7 +36,6 @@ import { MaterialManager } from "./material/manager/MaterialManager.js";
36
36
  import { ShadowMapRenderer } from "./shadows/ShadowMapRenderer.js";
37
37
  import { CameraViewManager } from "./render/view/CameraViewManager.js";
38
38
  import { StandardFrameBuffers } from "./StandardFrameBuffers.js";
39
- import { load_environment_map } from "./texture/cubemap/load_environment_map.js";
40
39
  import { CompositingStages } from "./composit/CompositingStages.js";
41
40
  import { DEG_TO_RAD } from "../../core/math/DEG_TO_RAD.js";
42
41
 
@@ -256,22 +255,12 @@ GraphicsEngine.prototype.getRenderer = function () {
256
255
  };
257
256
 
258
257
  /**
259
- *
258
+ * @deprecated
260
259
  * @param {string[]|string} paths URLs to faces of the cubemap
261
260
  * @returns {Promise<Texture>}
262
261
  */
263
262
  GraphicsEngine.prototype.loadEnvironmentMap = async function (paths) {
264
-
265
- const { filtered } = await load_environment_map({
266
- path: paths,
267
- renderer: this.renderer,
268
- original: false,
269
- filtered: true
270
- });
271
-
272
- this.scene.environment = filtered;
273
-
274
- return filtered;
263
+ throw new Error('Deprecated use `load_and_set_cubemap_v0` instead');
275
264
  }
276
265
 
277
266
  GraphicsEngine.prototype.updateSize = function () {