@woosh/meep-engine 2.51.0 → 2.52.0

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 (98) hide show
  1. package/package.json +1 -1
  2. package/src/core/NumberFormat.js +0 -71
  3. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -0
  4. package/src/core/bvh2/bvh3/query/BVHQueryAny.js +16 -0
  5. package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
  6. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
  7. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
  8. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
  9. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
  10. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
  11. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
  12. package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
  13. package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
  14. package/src/core/geom/Vector2.d.ts +9 -0
  15. package/src/core/geom/Vector2.js +8 -22
  16. package/src/core/geom/Vector2.spec.js +153 -0
  17. package/src/core/model/ModuleRegistry.js +2 -4
  18. package/src/core/model/ModuleRegistry.spec.js +31 -0
  19. package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
  20. package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
  21. package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
  22. package/src/core/model/stat/LinearModifier.js +2 -2
  23. package/src/core/model/stat/LinearModifier.spec.js +62 -0
  24. package/src/core/model/stat/Stat.js +12 -0
  25. package/src/core/model/stat/Stat.spec.js +36 -0
  26. package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
  27. package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
  28. package/src/core/primitives/numbers/number_pretty_print.js +49 -0
  29. package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
  30. package/src/core/process/BaseProcess.js +8 -8
  31. package/src/engine/Clock.js +30 -29
  32. package/src/engine/Clock.spec.js +26 -0
  33. package/src/engine/ecs/EntityBuilder.js +3 -1
  34. package/src/engine/ecs/EntityBuilder.spec.js +21 -0
  35. package/src/engine/ecs/gui/GUIElement.js +1 -1
  36. package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
  37. package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +1 -1
  38. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +1 -1
  39. package/src/engine/ecs/transform/Transform.js +1 -0
  40. package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
  41. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraph.spec.js +5 -0
  42. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
  43. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
  44. package/src/engine/graphics/ecs/decal/DecalSystem.js +2 -20
  45. package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
  46. package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
  47. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
  48. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +4 -33
  49. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
  50. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
  51. package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
  52. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  53. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -4
  54. package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +0 -2
  55. package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
  56. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +0 -2
  57. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -4
  58. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -4
  59. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
  60. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -6
  61. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
  62. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
  63. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
  64. package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  65. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  66. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +3 -23
  67. package/src/engine/grid/components/GridObstacle.js +45 -25
  68. package/src/engine/grid/components/GridObstacle.spec.js +130 -1
  69. package/src/engine/grid/components/GridPosition.js +5 -17
  70. package/src/engine/grid/components/GridPosition2Transform.js +1 -70
  71. package/src/engine/grid/components/GridPosition2TransformSerializationAdapter.js +70 -0
  72. package/src/engine/plugin/EnginePlugin.js +12 -14
  73. package/src/engine/plugin/EnginePlugin.spec.js +5 -0
  74. package/src/engine/plugin/EnginePluginManager.js +18 -22
  75. package/src/engine/scene/transitionToScene.js +12 -1
  76. package/src/engine/simulation/Ticker.js +1 -1
  77. package/src/generation/theme/TerrainLayerDescription.js +1 -1
  78. package/src/view/common/LabelView.js +3 -3
  79. package/src/engine/ecs/components/AimController.js +0 -18
  80. package/src/engine/ecs/components/Attacker.js +0 -13
  81. package/src/engine/ecs/components/MeshCollider.js +0 -15
  82. package/src/engine/ecs/components/RangedAttack.js +0 -12
  83. package/src/engine/ecs/components/TargetAI.js +0 -11
  84. package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
  85. package/src/engine/ecs/systems/AimControllerSystem.js +0 -63
  86. package/src/engine/ecs/systems/AttackerSystem.js +0 -67
  87. package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
  88. package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
  89. package/src/engine/ecs/systems/MortalitySystem.js +0 -46
  90. package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
  91. package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
  92. package/src/engine/ecs/systems/TargetAISystem.js +0 -107
  93. package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
  94. package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
  95. package/src/engine/grid/components/ViewportGridProjection.js +0 -20
  96. package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
  97. package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
  98. /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
@@ -15,7 +15,7 @@ import {
15
15
  compute_typed_array_constructor_from_data_type
16
16
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
17
17
  import { Base64 } from "../../../../core/binary/Base64.js";
18
- import { computeStridedIntegerArrayHash } from "../../../computeStridedIntegerArrayHash.js";
18
+ import { computeStridedIntegerArrayHash } from "../../../../core/primitives/array/computeStridedIntegerArrayHash.js";
19
19
  import { is_typed_array_equals } from "../../../../core/collection/array/typed/is_typed_array_equals.js";
20
20
 
21
21
  /**
@@ -2,6 +2,7 @@ import { ensureGeometryBoundingBox } from "../util/ensureGeometryBoundingBox.js"
2
2
  import { aabb3_matrix4_project } from "../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
3
3
  import { aabb3_array_combine } from "../../../core/geom/3d/aabb/aabb3_array_combine.js";
4
4
  import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
5
+ import { aabb3_from_threejs_geometry } from "../../../core/geom/3d/aabb/aabb3_from_threejs_geometry.js";
5
6
 
6
7
  const scratch_aabb3_array_0 = new Float32Array(6);
7
8
  const scratch_aabb3_array_1 = new Float32Array(6);
@@ -10,7 +11,7 @@ const scratch_aabb3_array_1 = new Float32Array(6);
10
11
  *
11
12
  * @param {number[]|Float32Array} result
12
13
  * @param {Object3D} object
13
- * @param {number[]|Float32Array} transform
14
+ * @param {number[]|Float32Array} transform 4x4 transform matrix to be used as a root transform instead of whatever is set on the object, this lets us compute local-space bounds without having to modify the source object
14
15
  */
15
16
  export function expand_aabb_by_transformed_three_object(result, object, transform) {
16
17
 
@@ -22,28 +23,7 @@ export function expand_aabb_by_transformed_three_object(result, object, transfor
22
23
  if (geometry !== undefined) {
23
24
 
24
25
  ensureGeometryBoundingBox(geometry);
25
-
26
- const gbb = geometry.boundingBox;
27
-
28
- const min = gbb.min;
29
-
30
- const x0 = min.x;
31
- const y0 = min.y;
32
- const z0 = min.z;
33
-
34
- const max = gbb.max;
35
-
36
- const x1 = max.x;
37
- const y1 = max.y;
38
- const z1 = max.z;
39
-
40
- scratch_aabb3_array_0[0] = x0;
41
- scratch_aabb3_array_0[1] = y0;
42
- scratch_aabb3_array_0[2] = z0;
43
-
44
- scratch_aabb3_array_0[3] = x1;
45
- scratch_aabb3_array_0[4] = y1;
46
- scratch_aabb3_array_0[5] = z1;
26
+ aabb3_from_threejs_geometry(scratch_aabb3_array_0,geometry);
47
27
 
48
28
  aabb3_matrix4_project(scratch_aabb3_array_1, scratch_aabb3_array_0, transform);
49
29
 
@@ -10,10 +10,13 @@ import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualS
10
10
  import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
11
11
 
12
12
  class GridObstacle {
13
- constructor() {
14
- this.data = [1];
15
- this.size = new Vector2(1, 1);
16
- }
13
+ data = [1];
14
+
15
+ /**
16
+ * @readonly
17
+ * @type {Vector2}
18
+ */
19
+ size = new Vector2(1, 1);
17
20
 
18
21
  /**
19
22
  *
@@ -21,8 +24,8 @@ class GridObstacle {
21
24
  * @param {number} h
22
25
  */
23
26
  resize(w, h) {
24
- assert.ok(Number.isInteger(w) && w >= 0, `expected non-negative integer, got ${w}`);
25
- assert.ok(Number.isInteger(h) && h >= 0, `expected non-negative integer, got ${h}`);
27
+ assert.isNonNegativeInteger(w, 'w');
28
+ assert.isNonNegativeInteger(h, 'h');
26
29
 
27
30
  const x1 = this.size.x;
28
31
  const y1 = this.size.y;
@@ -61,9 +64,9 @@ class GridObstacle {
61
64
  * @param {*} [thisArg]
62
65
  */
63
66
  traverseMask(offsetX, offsetY, visitor, thisArg) {
64
- assert.typeOf(offsetX, 'number', 'offsetX');
65
- assert.typeOf(offsetY, 'number', 'offsetY');
66
- assert.typeOf(visitor, 'function', 'visitor');
67
+ assert.isNumber(offsetX, 'offsetX');
68
+ assert.isNumber(offsetY, 'offsetY');
69
+ assert.isFunction(visitor, 'visitor');
67
70
 
68
71
  const size = this.size;
69
72
  const sX = size.x;
@@ -100,11 +103,11 @@ class GridObstacle {
100
103
  * @returns {number}
101
104
  */
102
105
  readPoint(x, y) {
103
- assert.typeOf(x, 'number', 'x');
104
- assert.typeOf(y, 'number', 'y');
106
+ assert.isNumber(x, 'x');
107
+ assert.isNumber(y, 'y');
105
108
 
106
- assert.ok(Number.isInteger(x), `expected x to be an integer, got ${x} instead`);
107
- assert.ok(Number.isInteger(y), `expected y to be an integer, got ${y} instead`);
109
+ assert.isInteger(x, 'x');
110
+ assert.isInteger(y, 'y');
108
111
 
109
112
  const index = y * this.size.x + x;
110
113
  return this.data[index];
@@ -117,6 +120,9 @@ class GridObstacle {
117
120
  * @param {number} value
118
121
  */
119
122
  writePoint(x, y, value) {
123
+ assert.isNonNegativeInteger(value, 'value');
124
+ assert.lessThanOrEqual(value, 255);
125
+
120
126
  const index = y * this.size.x + x;
121
127
 
122
128
  this.data[index] = value;
@@ -129,8 +135,8 @@ class GridObstacle {
129
135
  * @returns {boolean}
130
136
  */
131
137
  isPointWithin(x, y) {
132
- assert.typeOf(x, 'number', 'x');
133
- assert.typeOf(y, 'number', 'y');
138
+ assert.isNumber(x, 'x');
139
+ assert.isNumber(y, 'y');
134
140
 
135
141
  const size = this.size;
136
142
 
@@ -141,18 +147,20 @@ class GridObstacle {
141
147
  }
142
148
 
143
149
  /**
144
- *
150
+ * Is a given point adjacent to a blocking cell?
145
151
  * @param {number} x Obstacle-Local X position
146
152
  * @param {number} y Obstacle-Local Y position
147
153
  * @param {number[]} adjacencyMask Mask that defines adjacency, contains pairs of number for each X,Y coordinate offset from obstacle point
148
154
  * @returns {boolean}
149
155
  */
150
156
  isPointAdjacent(x, y, adjacencyMask) {
151
- assert.typeOf(x, 'number', 'x');
152
- assert.typeOf(y, 'number', 'y');
157
+ assert.isNumber(x, 'x');
158
+ assert.isNumber(y, 'y');
159
+
160
+ assert.defined(adjacencyMask, 'mask');
161
+ assert.notNull(adjacencyMask, 'mask');
153
162
 
154
- assert.notEqual(adjacencyMask, undefined, 'mask is undefined');
155
- assert.notEqual(adjacencyMask, null, 'mask is null');
163
+ assert.isArrayLike(adjacencyMask, 'mask');
156
164
 
157
165
  const size = this.size;
158
166
 
@@ -163,7 +171,8 @@ class GridObstacle {
163
171
 
164
172
  const maskLength = adjacencyMask.length;
165
173
 
166
- assert.typeOf(maskLength, 'number', 'maskLength');
174
+ assert.isNonNegativeInteger(maskLength, 'maskLength');
175
+ assert.equal(maskLength % 2, 0, `maskLength must be a multiple of 2`);
167
176
 
168
177
 
169
178
  for (let k = 0; k < maskLength; k += 2) {
@@ -203,16 +212,27 @@ class GridObstacle {
203
212
  };
204
213
  }
205
214
 
206
- fromJSON(v) {
207
- const size = v.size;
215
+ fromJSON({ size, data }) {
216
+ assert.isArrayLike(data, 'data');
217
+
208
218
  this.size.fromJSON(size);
209
219
 
210
220
  const sX = this.size.x;
211
221
  const sY = this.size.y;
212
222
 
223
+ assert.equal(data.length, sX * sY, 'invalid array length');
224
+
213
225
  this.data = new Uint8Array(sX * sY);
214
226
 
215
- this.data.set(v.data, 0);
227
+ this.data.set(data, 0);
228
+ }
229
+
230
+ static fromJSON(j) {
231
+ const r = new GridObstacle();
232
+
233
+ r.fromJSON(j);
234
+
235
+ return r;
216
236
  }
217
237
 
218
238
  /**
@@ -221,7 +241,7 @@ class GridObstacle {
221
241
  */
222
242
  hash() {
223
243
  return computeHashIntegerArray(
224
- this.size.hashCode(),
244
+ this.size.hash(),
225
245
  computeIntegerArrayHash(this.data, 0, this.data.length)
226
246
  );
227
247
  }
@@ -43,4 +43,133 @@ test('resize 1x2 to 1x1', () => {
43
43
  g.resize(1, 1);
44
44
 
45
45
  expect(g.data[0]).toBe(3);
46
- });
46
+ });
47
+
48
+ test("readPoint", () => {
49
+ const g = new GridObstacle();
50
+
51
+ g.resize(2, 2);
52
+
53
+ g.data[0] = 1;
54
+ g.data[1] = 3;
55
+ g.data[2] = 5;
56
+ g.data[3] = 7;
57
+
58
+ expect(g.readPoint(0, 0)).toBe(1);
59
+ expect(g.readPoint(1, 0)).toBe(3);
60
+ expect(g.readPoint(0, 1)).toBe(5);
61
+ expect(g.readPoint(1, 1)).toBe(7);
62
+ });
63
+
64
+ test("writePoint", () => {
65
+
66
+ const g = new GridObstacle();
67
+
68
+ g.resize(2, 2);
69
+
70
+ g.writePoint(0, 0, 1);
71
+ g.writePoint(1, 0, 3);
72
+ g.writePoint(0, 1, 5);
73
+ g.writePoint(1, 1, 7);
74
+
75
+ expect(Array.from(g.data)).toEqual([1, 3, 5, 7]);
76
+ });
77
+
78
+
79
+ test("hash", () => {
80
+ const g = new GridObstacle();
81
+
82
+ const hash = g.hash();
83
+
84
+ expect(typeof hash).toEqual("number");
85
+ expect(Number.isInteger(hash)).toBe(true);
86
+ expect(g.hash()).toEqual(hash); // stability
87
+ });
88
+
89
+ test("to/from JSON consistency", () => {
90
+
91
+ const a = new GridObstacle();
92
+ a.resize(1, 3);
93
+
94
+ a.writePoint(0, 0, 1);
95
+ a.writePoint(0, 1, 3);
96
+ a.writePoint(0, 2, 7);
97
+
98
+ const b = new GridObstacle();
99
+
100
+ b.fromJSON(a.toJSON());
101
+
102
+ expect(b.size.x).toEqual(1);
103
+ expect(b.size.y).toEqual(3);
104
+
105
+ expect(b.readPoint(0, 0)).toEqual(1);
106
+ expect(b.readPoint(0, 1)).toEqual(3);
107
+ expect(b.readPoint(0, 2)).toEqual(7);
108
+ });
109
+
110
+ test("equals", () => {
111
+ const a = new GridObstacle();
112
+ const b = new GridObstacle();
113
+
114
+ const c = GridObstacle.fromJSON({
115
+ size: { x: 1, y: 1 },
116
+ data: [
117
+ 7
118
+ ]
119
+ });
120
+
121
+ const d = GridObstacle.fromJSON({
122
+ size: { x: 2, y: 3 },
123
+ data: [
124
+ 1, 3,
125
+ 5, 7,
126
+ 11, 13
127
+ ]
128
+ });
129
+
130
+ const f = GridObstacle.fromJSON({
131
+ size: { x: 2, y: 3 },
132
+ data: [
133
+ 1, 3,
134
+ 5, 7,
135
+ 11, 13
136
+ ]
137
+ });
138
+
139
+ const g = GridObstacle.fromJSON({
140
+ size: { x: 3, y: 2 },
141
+ data: [
142
+ 1, 3,
143
+ 5, 7,
144
+ 11, 13
145
+ ]
146
+ });
147
+
148
+ const h = GridObstacle.fromJSON({
149
+ size: { x: 3, y: 2 },
150
+ data: [
151
+ 1, 3,
152
+ 5, 7,
153
+ 17, 13
154
+ ]
155
+ });
156
+
157
+ expect(a.equals(b)).toBe(true);
158
+ expect(a.equals(c)).toBe(false);
159
+ expect(a.equals(d)).toBe(false);
160
+
161
+ expect(f.equals(g)).toBe(false);
162
+ expect(g.equals(h)).toBe(false);
163
+ });
164
+
165
+ test("isPointAdjacent", () => {
166
+ const grid = new GridObstacle();
167
+
168
+ grid.writePoint(0, 0, 7);
169
+
170
+ expect(grid.isPointAdjacent(0, 0, [0, 0])).toBe(true);
171
+
172
+ grid.writePoint(0, 0, 0);
173
+
174
+ expect(grid.isPointAdjacent(0, 0, [0, 0])).toBe(false);
175
+ });
@@ -4,23 +4,11 @@
4
4
 
5
5
  import Vector2 from '../../../core/geom/Vector2.js';
6
6
 
7
- class GridPosition extends Vector2{
8
- /**
9
- * @extends {Vector2}
10
- * @constructor
11
- */
12
- constructor() {
13
- super();
14
- }
15
-
16
- /**
17
- *
18
- * @param {GridPosition|Vector2} other
19
- */
20
- copy(other) {
21
- Vector2.prototype.copy.call(this, other);
22
- return this;
23
- }
7
+ /**
8
+ * @extends {Vector2}
9
+ * @class
10
+ */
11
+ class GridPosition extends Vector2 {
24
12
 
25
13
  clone() {
26
14
  const clone = new GridPosition();
@@ -1,5 +1,4 @@
1
1
  import Vector2 from "../../../core/geom/Vector2.js";
2
- import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
3
2
  import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
4
3
  import { GridPosition2TransformFlags } from "./GridPosition2TransformFlags.js";
5
4
 
@@ -116,7 +115,7 @@ export class GridPosition2Transform {
116
115
  * @returns {number}
117
116
  */
118
117
  hash() {
119
- return this.offset.hashCode();
118
+ return this.offset.hash();
120
119
  }
121
120
 
122
121
  }
@@ -124,74 +123,6 @@ export class GridPosition2Transform {
124
123
  GridPosition2Transform.typeName = "GridPosition2Transform";
125
124
 
126
125
 
127
- export class GridPosition2TransformSerializationAdapter extends BinaryClassSerializationAdapter {
128
- constructor() {
129
- super();
130
-
131
- this.klass = GridPosition2Transform;
132
- this.version = 1;
133
- }
134
-
135
- /**
136
- *
137
- * @param {BinaryBuffer} buffer
138
- * @param {GridPosition2Transform} value
139
- */
140
- serialize(buffer, value) {
141
- const offsetX = value.offset.x;
142
- const offsetY = value.offset.y;
143
-
144
- let header = 3;
145
- if (offsetX === 0 && offsetY === 0) {
146
- header = 0;
147
- } else if (offsetX === 0) {
148
- header = 2;
149
- } else if (offsetY === 0) {
150
- header = 1;
151
- } else {
152
- //both coordinates are present
153
- header = 3;
154
- }
155
-
156
- buffer.writeUint8(header);
157
-
158
- if ((header & 1) !== 0) {
159
- //write X
160
- buffer.writeFloat32(offsetX);
161
- }
162
-
163
- if ((header & 2) !== 0) {
164
- //write Y
165
- buffer.writeFloat32(offsetY);
166
- }
167
- }
168
-
169
- /**
170
- *
171
- * @param {BinaryBuffer} buffer
172
- * @param {GridPosition2Transform} value
173
- */
174
- deserialize(buffer, value) {
175
- //read header
176
- const header = buffer.readUint8();
177
-
178
-
179
- let offsetX = 0, offsetY = 0;
180
-
181
- if ((header & 1) !== 0) {
182
- //write X
183
- offsetX = buffer.readFloat32();
184
- }
185
-
186
- if ((header & 2) !== 0) {
187
- //write Y
188
- offsetY = buffer.readFloat32();
189
- }
190
-
191
- value.offset.set(offsetX, offsetY);
192
- }
193
- }
194
-
195
126
  export class GridPosition2TransformSerializationUpgrader_0_1 extends BinaryClassUpgrader {
196
127
  constructor() {
197
128
  super();
@@ -0,0 +1,70 @@
1
+ import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
+ import { GridPosition2Transform } from "./GridPosition2Transform.js";
3
+
4
+ export class GridPosition2TransformSerializationAdapter extends BinaryClassSerializationAdapter {
5
+ constructor() {
6
+ super();
7
+
8
+ this.klass = GridPosition2Transform;
9
+ this.version = 1;
10
+ }
11
+
12
+ /**
13
+ *
14
+ * @param {BinaryBuffer} buffer
15
+ * @param {GridPosition2Transform} value
16
+ */
17
+ serialize(buffer, value) {
18
+ const offsetX = value.offset.x;
19
+ const offsetY = value.offset.y;
20
+
21
+ let header = 3;
22
+ if (offsetX === 0 && offsetY === 0) {
23
+ header = 0;
24
+ } else if (offsetX === 0) {
25
+ header = 2;
26
+ } else if (offsetY === 0) {
27
+ header = 1;
28
+ } else {
29
+ //both coordinates are present
30
+ header = 3;
31
+ }
32
+
33
+ buffer.writeUint8(header);
34
+
35
+ if ((header & 1) !== 0) {
36
+ //write X
37
+ buffer.writeFloat32(offsetX);
38
+ }
39
+
40
+ if ((header & 2) !== 0) {
41
+ //write Y
42
+ buffer.writeFloat32(offsetY);
43
+ }
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @param {BinaryBuffer} buffer
49
+ * @param {GridPosition2Transform} value
50
+ */
51
+ deserialize(buffer, value) {
52
+ //read header
53
+ const header = buffer.readUint8();
54
+
55
+
56
+ let offsetX = 0, offsetY = 0;
57
+
58
+ if ((header & 1) !== 0) {
59
+ //write X
60
+ offsetX = buffer.readFloat32();
61
+ }
62
+
63
+ if ((header & 2) !== 0) {
64
+ //write Y
65
+ offsetY = buffer.readFloat32();
66
+ }
67
+
68
+ value.offset.set(offsetX, offsetY);
69
+ }
70
+ }
@@ -2,22 +2,20 @@ import { BaseProcess } from "../../core/process/BaseProcess.js";
2
2
  import { assert } from "../../core/assert.js";
3
3
 
4
4
  export class EnginePlugin extends BaseProcess {
5
- constructor() {
6
- super();
7
5
 
8
- /**
9
- *
10
- * @type {Class<EnginePlugin>[]}
11
- * @private
12
- */
13
- this.__dependencies = [];
6
+ /**
7
+ *
8
+ * @type {Class<EnginePlugin>[]}
9
+ * @private
10
+ */
11
+ __dependencies = [];
12
+
13
+ /**
14
+ *
15
+ * @type {Engine|null}
16
+ */
17
+ engine = null;
14
18
 
15
- /**
16
- *
17
- * @type {Engine|null}
18
- */
19
- this.engine = null;
20
- }
21
19
 
22
20
  attach() {
23
21
  /**
@@ -0,0 +1,5 @@
1
+ import { EnginePlugin } from "./EnginePlugin.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ new EnginePlugin();
5
+ });
@@ -6,29 +6,25 @@ import { isSubclassOf } from "./isSubclassOf.js";
6
6
  import { assert } from "../../core/assert.js";
7
7
 
8
8
  export class EnginePluginManager extends BaseProcess {
9
- constructor() {
10
- super();
11
-
12
- /**
13
- * @private
14
- * @type {Map<Class, PluginReferenceContext>}
15
- */
16
- this.__plugins = new Map();
17
-
18
- /**
19
- *
20
- * @type {Engine}
21
- */
22
- this.engine = null;
23
-
24
- /**
25
- *
26
- * @type {number}
27
- * @private
28
- */
29
- this.__version = 0;
30
- }
31
9
 
10
+ /**
11
+ * @private
12
+ * @type {Map<Class, PluginReferenceContext>}
13
+ */
14
+ __plugins = new Map();
15
+
16
+ /**
17
+ *
18
+ * @type {Engine}
19
+ */
20
+ engine = null;
21
+
22
+ /**
23
+ *
24
+ * @type {number}
25
+ * @private
26
+ */
27
+ __version = 0;
32
28
 
33
29
  /**
34
30
  *
@@ -9,6 +9,7 @@ import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
9
9
  import { actionTask } from "../../core/process/task/util/actionTask.js";
10
10
  import { delayTask } from "../../core/process/task/util/delayTask.js";
11
11
  import { wrapTaskIgnoreFailure } from "../../core/process/task/util/wrapTaskIgnoreFailure.js";
12
+ import { assert } from "../../core/assert.js";
12
13
 
13
14
 
14
15
  /**
@@ -19,7 +20,17 @@ import { wrapTaskIgnoreFailure } from "../../core/process/task/util/wrapTaskIgno
19
20
  * @param {string} [name]
20
21
  * @return {Promise}
21
22
  */
22
- export function transitionToScene({ tasks = [], scene, engine, name }) {
23
+ export function transitionToScene({
24
+ tasks = [],
25
+ scene,
26
+ engine,
27
+ name
28
+ }) {
29
+
30
+ assert.defined(engine, 'engine');
31
+ assert.defined(scene, 'scene');
32
+ assert.isArray(tasks, 'tasks');
33
+
23
34
  if (name === undefined) {
24
35
  if (tasks.length > 0) {
25
36
  //assume name of the first task
@@ -51,7 +51,7 @@ class Ticker {
51
51
  * @param {*} [thisArg]
52
52
  */
53
53
  unsubscribe(callback, thisArg) {
54
- assert.typeOf(callback, 'function', 'callback');
54
+ assert.isFunction(callback, 'callback');
55
55
 
56
56
  const callbacks = this.callbacks;
57
57
  const n = callbacks.length;
@@ -17,7 +17,7 @@ export class TerrainLayerDescription {
17
17
  }
18
18
 
19
19
  hash() {
20
- return computeStringHash(this.diffuse) ^ this.size.hashCode();
20
+ return computeStringHash(this.diffuse) ^ this.size.hash();
21
21
  }
22
22
 
23
23
  /**