@woosh/meep-engine 2.33.58 → 2.33.59
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/engine/ecs/gui/GUIElement.js +0 -106
- package/engine/ecs/gui/GUIElementSerializationAdapter.js +108 -0
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +0 -1
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.spec.js +8 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -0
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import Vector2 from '../../../core/geom/Vector2.js';
|
|
5
5
|
import ObservedBoolean from "../../../core/model/ObservedBoolean.js";
|
|
6
|
-
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
7
6
|
import { COMPONENT_SERIALIZATION_TRANSIENT_FIELD } from "../storage/COMPONENT_SERIALIZATION_TRANSIENT_FIELD.js";
|
|
8
7
|
import { assert } from "../../../core/assert.js";
|
|
9
8
|
import { objectDeepEquals } from "../../../core/model/object/objectDeepEquals.js";
|
|
@@ -238,108 +237,3 @@ GUIElement.serializable = true;
|
|
|
238
237
|
export default GUIElement;
|
|
239
238
|
|
|
240
239
|
|
|
241
|
-
export class GUIElementSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
242
|
-
constructor() {
|
|
243
|
-
super();
|
|
244
|
-
|
|
245
|
-
this.klass = GUIElement;
|
|
246
|
-
this.version = 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
*
|
|
251
|
-
* @param {BinaryBuffer} buffer
|
|
252
|
-
* @param {GUIElement} value
|
|
253
|
-
*/
|
|
254
|
-
serialize(buffer, value) {
|
|
255
|
-
|
|
256
|
-
if (!value.getFlag(GUIElementFlag.Managed)) {
|
|
257
|
-
throw new Error(`Expected 'Managed' flag to be set, instead it was cleared. Cannot serialize un-managed component`);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
value.anchor.toBinaryBufferFloat32(buffer);
|
|
261
|
-
buffer.writeUTF8String(value.group);
|
|
262
|
-
|
|
263
|
-
buffer.writeUint8(value.visible.getValue() ? 1 : 0);
|
|
264
|
-
|
|
265
|
-
buffer.writeUTF8String(value.klass);
|
|
266
|
-
//write parameters
|
|
267
|
-
|
|
268
|
-
const paramKeys = Object.keys(value.parameters);
|
|
269
|
-
|
|
270
|
-
const numParamKeys = paramKeys.length;
|
|
271
|
-
buffer.writeUintVar(numParamKeys);
|
|
272
|
-
|
|
273
|
-
for (let i = 0; i < numParamKeys; i++) {
|
|
274
|
-
const paramKey = paramKeys[i];
|
|
275
|
-
|
|
276
|
-
buffer.writeUTF8String(paramKey);
|
|
277
|
-
|
|
278
|
-
const parameter = value.parameters[paramKey];
|
|
279
|
-
|
|
280
|
-
const paramType = typeof parameter;
|
|
281
|
-
|
|
282
|
-
if (paramType === "number") {
|
|
283
|
-
buffer.writeUint8(1);
|
|
284
|
-
|
|
285
|
-
buffer.writeFloat64(parameter);
|
|
286
|
-
} else if (paramType === "boolean") {
|
|
287
|
-
buffer.writeUint8(2);
|
|
288
|
-
|
|
289
|
-
buffer.writeUint8(parameter ? 1 : 0);
|
|
290
|
-
} else if (paramType === "string") {
|
|
291
|
-
buffer.writeUint8(3);
|
|
292
|
-
|
|
293
|
-
buffer.writeUTF8String(parameter);
|
|
294
|
-
} else {
|
|
295
|
-
throw new TypeError(`Unsupported parameter type ${paramType}`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
*
|
|
303
|
-
* @param {BinaryBuffer} buffer
|
|
304
|
-
* @param {GUIElement} value
|
|
305
|
-
*/
|
|
306
|
-
deserialize(buffer, value) {
|
|
307
|
-
value.anchor.fromBinaryBufferFloat32(buffer);
|
|
308
|
-
|
|
309
|
-
value.group = buffer.readUTF8String();
|
|
310
|
-
|
|
311
|
-
value.visible.set(buffer.readUint8() !== 0);
|
|
312
|
-
|
|
313
|
-
value.klass = buffer.readUTF8String();
|
|
314
|
-
|
|
315
|
-
const numParamKeys = buffer.readUintVar();
|
|
316
|
-
|
|
317
|
-
const params = {};
|
|
318
|
-
|
|
319
|
-
for (let i = 0; i < numParamKeys; i++) {
|
|
320
|
-
//read key
|
|
321
|
-
const paramKey = buffer.readUTF8String();
|
|
322
|
-
|
|
323
|
-
//read type flag
|
|
324
|
-
const paramTypeHeader = buffer.readUint8();
|
|
325
|
-
|
|
326
|
-
let paramValue;
|
|
327
|
-
if (paramTypeHeader === 1) {
|
|
328
|
-
//number
|
|
329
|
-
paramValue = buffer.readFloat64();
|
|
330
|
-
} else if (paramTypeHeader === 2) {
|
|
331
|
-
//boolean
|
|
332
|
-
paramValue = buffer.readUint8() !== 0;
|
|
333
|
-
} else if (paramTypeHeader === 3) {
|
|
334
|
-
//string
|
|
335
|
-
paramValue = buffer.readUTF8String();
|
|
336
|
-
} else {
|
|
337
|
-
throw new TypeError(`Unknown type header value '${paramTypeHeader}' for parameter key '${paramKey}'`);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
params[paramKey] = paramValue;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
value.parameters = params;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import GUIElement, { GUIElementFlag } from "./GUIElement.js";
|
|
3
|
+
|
|
4
|
+
export class GUIElementSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = GUIElement;
|
|
9
|
+
this.version = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {BinaryBuffer} buffer
|
|
15
|
+
* @param {GUIElement} value
|
|
16
|
+
*/
|
|
17
|
+
serialize(buffer, value) {
|
|
18
|
+
|
|
19
|
+
if (!value.getFlag(GUIElementFlag.Managed)) {
|
|
20
|
+
throw new Error(`Expected 'Managed' flag to be set, instead it was cleared. Cannot serialize un-managed component`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
value.anchor.toBinaryBufferFloat32(buffer);
|
|
24
|
+
buffer.writeUTF8String(value.group);
|
|
25
|
+
|
|
26
|
+
buffer.writeUint8(value.visible.getValue() ? 1 : 0);
|
|
27
|
+
|
|
28
|
+
buffer.writeUTF8String(value.klass);
|
|
29
|
+
//write parameters
|
|
30
|
+
|
|
31
|
+
const paramKeys = Object.keys(value.parameters);
|
|
32
|
+
|
|
33
|
+
const numParamKeys = paramKeys.length;
|
|
34
|
+
buffer.writeUintVar(numParamKeys);
|
|
35
|
+
|
|
36
|
+
for (let i = 0; i < numParamKeys; i++) {
|
|
37
|
+
const paramKey = paramKeys[i];
|
|
38
|
+
|
|
39
|
+
buffer.writeUTF8String(paramKey);
|
|
40
|
+
|
|
41
|
+
const parameter = value.parameters[paramKey];
|
|
42
|
+
|
|
43
|
+
const paramType = typeof parameter;
|
|
44
|
+
|
|
45
|
+
if (paramType === "number") {
|
|
46
|
+
buffer.writeUint8(1);
|
|
47
|
+
|
|
48
|
+
buffer.writeFloat64(parameter);
|
|
49
|
+
} else if (paramType === "boolean") {
|
|
50
|
+
buffer.writeUint8(2);
|
|
51
|
+
|
|
52
|
+
buffer.writeUint8(parameter ? 1 : 0);
|
|
53
|
+
} else if (paramType === "string") {
|
|
54
|
+
buffer.writeUint8(3);
|
|
55
|
+
|
|
56
|
+
buffer.writeUTF8String(parameter);
|
|
57
|
+
} else {
|
|
58
|
+
throw new TypeError(`Unsupported parameter type ${paramType}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {BinaryBuffer} buffer
|
|
67
|
+
* @param {GUIElement} value
|
|
68
|
+
*/
|
|
69
|
+
deserialize(buffer, value) {
|
|
70
|
+
value.anchor.fromBinaryBufferFloat32(buffer);
|
|
71
|
+
|
|
72
|
+
value.group = buffer.readUTF8String();
|
|
73
|
+
|
|
74
|
+
value.visible.set(buffer.readUint8() !== 0);
|
|
75
|
+
|
|
76
|
+
value.klass = buffer.readUTF8String();
|
|
77
|
+
|
|
78
|
+
const numParamKeys = buffer.readUintVar();
|
|
79
|
+
|
|
80
|
+
const params = {};
|
|
81
|
+
|
|
82
|
+
for (let i = 0; i < numParamKeys; i++) {
|
|
83
|
+
//read key
|
|
84
|
+
const paramKey = buffer.readUTF8String();
|
|
85
|
+
|
|
86
|
+
//read type flag
|
|
87
|
+
const paramTypeHeader = buffer.readUint8();
|
|
88
|
+
|
|
89
|
+
let paramValue;
|
|
90
|
+
if (paramTypeHeader === 1) {
|
|
91
|
+
//number
|
|
92
|
+
paramValue = buffer.readFloat64();
|
|
93
|
+
} else if (paramTypeHeader === 2) {
|
|
94
|
+
//boolean
|
|
95
|
+
paramValue = buffer.readUint8() !== 0;
|
|
96
|
+
} else if (paramTypeHeader === 3) {
|
|
97
|
+
//string
|
|
98
|
+
paramValue = buffer.readUTF8String();
|
|
99
|
+
} else {
|
|
100
|
+
throw new TypeError(`Unknown type header value '${paramTypeHeader}' for parameter key '${paramKey}'`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
params[paramKey] = paramValue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
value.parameters = params;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -3,6 +3,14 @@ import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
|
3
3
|
import { computeTopDownTransform } from "./TopDownCameraControllerSystem.js";
|
|
4
4
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
5
5
|
|
|
6
|
+
test('setFromEyeAndTarget does not introduce roll when UP is aligned with +Y', () => {
|
|
7
|
+
const ut = new TopDownCameraController();
|
|
8
|
+
|
|
9
|
+
ut.setFromEyeAndTarget(new Vector3(0, 1, -1), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
|
|
10
|
+
|
|
11
|
+
expect(ut.roll).toBe(0);
|
|
12
|
+
});
|
|
13
|
+
|
|
6
14
|
test('setFromEyeAndTarget results in roll respecting UP vector', () => {
|
|
7
15
|
const eye = new Vector3();
|
|
8
16
|
const target = new Vector3();
|
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.33.
|
|
8
|
+
"version": "2.33.59",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|