@woosh/meep-engine 2.37.16 → 2.37.17
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/core/assert.js +15 -1
- package/core/collection/array/typedArrayToDataType.js +1 -1
- package/engine/asset/AssetManager.js +1 -1
- package/engine/ecs/EntityBlueprint.js +1 -1
- package/engine/ecs/EntityBuilder.js +2 -2
- package/engine/ecs/EntityManager.js +1 -1
- package/engine/ecs/parent/EntityNode.js +3 -0
- package/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter.js +1 -1
- package/engine/ecs/transform/Transform.js +3 -0
- package/engine/ecs/util/hideEntityGracefully.js +4 -2
- package/engine/knowledge/database/StaticKnowledgeDatabase.js +1 -1
- package/engine/sound/material/concrete/json/serializeSoundMaterialToJSON.js +1 -1
- package/package.json +1 -1
package/core/assert.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isTypedArray } from "./json/JsonUtils.js";
|
|
2
|
+
import { isArrayEqualStrict } from "./collection/array/isArrayEqualStrict.js";
|
|
2
3
|
|
|
3
4
|
function equal(a, b, m) {
|
|
4
5
|
assert(a === b, m) // eslint-disable-line eqeqeq
|
|
@@ -164,6 +165,18 @@ function arrayHasNo(haystack, needle, message = 'Array contains the item') {
|
|
|
164
165
|
assert.equal(haystack.indexOf(needle), -1, message);
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
/**
|
|
169
|
+
* @template T
|
|
170
|
+
* @param {T[]|ArrayLike<T>|Float32Array} a
|
|
171
|
+
* @param {T[]|ArrayLike<T>|Float32Array} b
|
|
172
|
+
* @param {string} [message]
|
|
173
|
+
*/
|
|
174
|
+
function arrayEqual(a, b, message = 'Arrays are not equal') {
|
|
175
|
+
if (!isArrayEqualStrict(a, b)) {
|
|
176
|
+
throw new Error(message);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
167
180
|
/**
|
|
168
181
|
* @template T
|
|
169
182
|
* @param {T} value
|
|
@@ -195,6 +208,7 @@ assert.lessThanOrEqual = lessThanOrEqual;
|
|
|
195
208
|
assert.typeOf = typeOf;
|
|
196
209
|
assert.arrayHas = arrayHas;
|
|
197
210
|
assert.arrayHasNo = arrayHasNo;
|
|
211
|
+
assert.arrayEqual = arrayEqual;
|
|
198
212
|
|
|
199
213
|
/**
|
|
200
214
|
*
|
|
@@ -321,7 +335,7 @@ assert.defined = function (value, name = "value") {
|
|
|
321
335
|
* @param {*} value
|
|
322
336
|
* @param {String} [name]
|
|
323
337
|
*/
|
|
324
|
-
assert.isNull = function (value, name){
|
|
338
|
+
assert.isNull = function (value, name) {
|
|
325
339
|
if (value !== null) {
|
|
326
340
|
throw new Error(`${name} is NOT null`);
|
|
327
341
|
}
|
|
@@ -409,7 +409,7 @@ AssetManager.prototype.registerLoader = async function (type, loader) {
|
|
|
409
409
|
if (existing_loader === loader) {
|
|
410
410
|
// all is well, already registered
|
|
411
411
|
return existing_loader;
|
|
412
|
-
} else if (existing_loader
|
|
412
|
+
} else if (Object.getPrototypeOf(existing_loader) === Object.getPrototypeOf(loader)) {
|
|
413
413
|
console.warn(`Another instance of this loader is already registered for type '${type}'. Ignoring.`);
|
|
414
414
|
return existing_loader;
|
|
415
415
|
} else {
|
|
@@ -87,7 +87,7 @@ export class EntityBlueprint {
|
|
|
87
87
|
* @param {Object} component
|
|
88
88
|
*/
|
|
89
89
|
add(component) {
|
|
90
|
-
const constructor = component.
|
|
90
|
+
const constructor = Object.getPrototypeOf(component).constructor;
|
|
91
91
|
|
|
92
92
|
this.addJSON(constructor, component.toJSON());
|
|
93
93
|
}
|
|
@@ -118,7 +118,7 @@ class EntityBuilder {
|
|
|
118
118
|
for (let i = n - 1; i >= 0; i--) {
|
|
119
119
|
const component = elements[i];
|
|
120
120
|
|
|
121
|
-
this.removeComponent(component.
|
|
121
|
+
this.removeComponent(Object.getPrototypeOf(component).constructor);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -132,7 +132,7 @@ class EntityBuilder {
|
|
|
132
132
|
throw new Error("Can not add " + componentInstance + " to EntityBuilder");
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
assert.notOk(this.getComponent(componentInstance.
|
|
135
|
+
assert.notOk(this.getComponent(Object.getPrototypeOf(componentInstance).constructor) !== null, 'Component of this type already exists');
|
|
136
136
|
|
|
137
137
|
this.element.push(componentInstance);
|
|
138
138
|
|
|
@@ -478,7 +478,7 @@ EntityManager.prototype.addSystem = async function (system) {
|
|
|
478
478
|
assert.defined(system, "system");
|
|
479
479
|
assert.isInstanceOf(system, System, 'system', 'System');
|
|
480
480
|
|
|
481
|
-
const existing = this.getSystem(system.
|
|
481
|
+
const existing = this.getSystem(Object.getPrototypeOf(system).constructor);
|
|
482
482
|
|
|
483
483
|
if (existing !== null) {
|
|
484
484
|
if (existing === system) {
|
|
@@ -253,6 +253,7 @@ export class EntityNode {
|
|
|
253
253
|
* @param {EntityComponentDataset} ecd
|
|
254
254
|
*/
|
|
255
255
|
build(ecd) {
|
|
256
|
+
assert.notOk(this.__entity.isBuilt, 'Already built');
|
|
256
257
|
|
|
257
258
|
// assume that parent is built
|
|
258
259
|
const parent = this.__parent;
|
|
@@ -305,6 +306,8 @@ export class EntityNode {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
destroy() {
|
|
309
|
+
assert.ok(this.__entity.isBuilt, 'Not built');
|
|
310
|
+
|
|
308
311
|
// remove listeners
|
|
309
312
|
this.__transform.position.onChanged.remove(this.__transform_sync_down, this);
|
|
310
313
|
this.__transform.scale.onChanged.remove(this.__transform_sync_down, this);
|
|
@@ -56,7 +56,7 @@ export class BinaryObjectSerializationAdapter {
|
|
|
56
56
|
if (className === undefined) {
|
|
57
57
|
//class name is not specified, try to infer it
|
|
58
58
|
|
|
59
|
-
const Klass = object.
|
|
59
|
+
const Klass = Object.getPrototypeOf(object).constructor;
|
|
60
60
|
|
|
61
61
|
const typeName = Klass.typeName;
|
|
62
62
|
|
|
@@ -9,6 +9,7 @@ import { mat4 } from "gl-matrix";
|
|
|
9
9
|
import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
|
|
10
10
|
import { TransformFlags } from "./TransformFlags.js";
|
|
11
11
|
import { allocate_transform_m4 } from "../../graphics/ecs/mesh-v2/allocate_transform_m4.js";
|
|
12
|
+
import { assert } from "../../../core/assert.js";
|
|
12
13
|
|
|
13
14
|
const delta = new Vector3();
|
|
14
15
|
|
|
@@ -180,6 +181,8 @@ export class Transform {
|
|
|
180
181
|
this.rotation.copy(other.rotation);
|
|
181
182
|
this.scale.copy(other.scale);
|
|
182
183
|
|
|
184
|
+
assert.arrayEqual(this.matrix, other.matrix, 'matrices must be equal after copy');
|
|
185
|
+
|
|
183
186
|
this.flags = other.flags;
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -13,7 +13,9 @@ import { SoundEmitter } from "../../sound/ecs/emitter/SoundEmitter.js";
|
|
|
13
13
|
import { TweenVector1Behavior } from "../../../../model/game/util/behavior/TweenVector1Behavior.js";
|
|
14
14
|
import { DelayBehavior } from "../../intelligence/behavior/util/DelayBehavior.js";
|
|
15
15
|
import { Light } from "../../graphics/ecs/light/Light.js";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
TransitionPropertyVectorXBehavior
|
|
18
|
+
} from "../../../../model/game/story/behaviors/generic/TransitionPropertyVectorXBehavior.js";
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* @readonly
|
|
@@ -179,7 +181,7 @@ export function hideEntityGracefully(builder, createEntity, createEntityThisArg)
|
|
|
179
181
|
for (let i = 0; i < component_count; i++) {
|
|
180
182
|
const component = components[i];
|
|
181
183
|
|
|
182
|
-
const shutdown_method = component_shutdown.get(component.
|
|
184
|
+
const shutdown_method = component_shutdown.get(Object.getPrototypeOf(component).constructor);
|
|
183
185
|
|
|
184
186
|
if (shutdown_method === undefined) {
|
|
185
187
|
continue;
|
|
@@ -66,7 +66,7 @@ export class StaticKnowledgeDatabase {
|
|
|
66
66
|
const existing = this.getDescriptorById(id);
|
|
67
67
|
if (existing !== undefined) {
|
|
68
68
|
|
|
69
|
-
if (existing.id === id && existing.source === path && existing.table
|
|
69
|
+
if (existing.id === id && existing.source === path && Object.getPrototypeOf(existing.table) === Object.getPrototypeOf(table)) {
|
|
70
70
|
// attempting to add the same thing
|
|
71
71
|
|
|
72
72
|
console.warn(`Attempting to ad the same table again, ignoring. id='${id}', path='${path}' (table prototype matching)`);
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.37.
|
|
8
|
+
"version": "2.37.17",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|