@woosh/meep-engine 2.49.6 → 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 (85) 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/cache/LoadingCache.d.ts +2 -0
  6. package/src/core/cache/LoadingCache.js +45 -18
  7. package/src/core/collection/HashSet.js +1 -1
  8. package/src/core/collection/table/RowFirstTableSpec.js +110 -92
  9. package/src/core/collection/table/RowFirstTableSpec.spec.js +49 -0
  10. package/src/core/color/Color.d.ts +4 -2
  11. package/src/core/color/Color.js +7 -8
  12. package/src/core/color/Color.spec.js +93 -0
  13. package/src/core/color/hex2rgb.spec.js +10 -0
  14. package/src/core/color/rgb2hex.js +1 -1
  15. package/src/core/color/rgb2hex.spec.js +13 -0
  16. package/src/core/fsm/simple/SimpleStateMachine.spec.js +75 -0
  17. package/src/core/fsm/simple/SimpleStateMachineDescription.js +1 -1
  18. package/src/core/fsm/simple/SimpleStateMachineDescription.spec.js +32 -0
  19. package/src/core/geom/2d/Rectangle.spec.js +51 -0
  20. package/src/core/geom/3d/aabb/aabb3_intersects_ray.spec.js +90 -0
  21. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.spec.js +61 -0
  22. package/src/core/geom/3d/morton/mortonEncode_magicbits.js +1 -34
  23. package/src/core/geom/3d/morton/split_by_2.js +17 -0
  24. package/src/core/geom/3d/morton/split_by_3.js +16 -0
  25. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +6 -1
  26. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +11 -0
  27. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.spec.js +8 -0
  28. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +3 -3
  29. package/src/core/geom/3d/topology/struct/binary/io/OrderedEdge.js +1 -1
  30. package/src/core/geom/random/randomPointOnBox.spec.js +57 -0
  31. package/src/core/math/computeGreatestCommonDivisor.spec.js +9 -0
  32. package/src/core/math/statistics/computeStatisticalMean.spec.js +9 -0
  33. package/src/core/math/statistics/halton_sequence.spec.js +6 -1
  34. package/src/core/model/node-graph/node/Port.spec.js +10 -1
  35. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +5 -8
  36. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +41 -0
  37. package/src/core/model/reactive/trigger/BlackboardTrigger.js +5 -0
  38. package/src/core/model/reactive/trigger/BlackboardTrigger.spec.js +24 -0
  39. package/src/core/parser/simple/readBooleanToken.js +38 -0
  40. package/src/core/parser/simple/readHexToken.js +95 -0
  41. package/src/core/parser/simple/readHexToken.spec.js +21 -0
  42. package/src/core/parser/simple/readIdentifierToken.js +43 -0
  43. package/src/core/parser/simple/readIdentifierToken.spec.js +32 -0
  44. package/src/core/parser/simple/readLiteralToken.js +96 -0
  45. package/src/core/parser/simple/readNumberToken.js +73 -0
  46. package/src/core/parser/simple/readNumberToken.spec.js +17 -0
  47. package/src/core/parser/simple/readReferenceToken.js +48 -0
  48. package/src/core/parser/simple/readReferenceToken.spec.js +18 -0
  49. package/src/core/parser/simple/readStringToken.js +94 -0
  50. package/src/core/parser/simple/readStringToken.spec.js +57 -0
  51. package/src/core/parser/simple/{readUnsignedInteger.js → readUnsignedIntegerToken.js} +1 -1
  52. package/src/core/parser/simple/readUnsignedIntegerToken.spec.js +6 -0
  53. package/src/core/process/executor/ConcurrentExecutor.js +147 -234
  54. package/src/engine/Engine.d.ts +4 -2
  55. package/src/engine/Engine.js +62 -41
  56. package/src/engine/Engine.spec.js +11 -0
  57. package/src/engine/InputEngine.js +12 -0
  58. package/src/engine/graphics/GraphicsEngine.js +2 -13
  59. package/src/engine/graphics/ecs/compileAllMaterials.js +1 -1
  60. package/src/engine/graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js +1 -1
  61. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
  62. package/src/engine/graphics/load_and_set_cubemap_v0.js +21 -0
  63. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  64. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -5
  65. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -4
  66. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  67. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  68. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -4
  69. package/src/engine/graphics/sh3/prototypeSH3Probe.js +4 -4
  70. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +4 -3
  71. package/src/engine/graphics/texture/virtual/VirtualTexture.js +9 -0
  72. package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +5 -4
  73. package/src/engine/graphics/texture/virtual/tile/TileLoader.js +5 -0
  74. package/src/engine/input/devices/PointerDevice.spec.js +7 -0
  75. package/src/engine/intelligence/blackboard/Blackboard.d.ts +4 -0
  76. package/src/engine/intelligence/blackboard/Blackboard.js +11 -0
  77. package/src/engine/platform/InMemoryEnginePlatform.js +20 -0
  78. package/src/engine/save/Storage.d.ts +7 -7
  79. package/src/engine/save/storage/InMemoryStorage.js +34 -0
  80. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  81. package/src/view/tooltip/gml/parser/readReferenceValueToken.js +2 -2
  82. package/src/core/parser/simple/SimpleParser.js +0 -464
  83. package/src/core/parser/simple/SimpleParser.spec.js +0 -105
  84. /package/src/core/collection/{IteratorUtils.js → collectIteratorValueToArray.js} +0 -0
  85. /package/src/core/color/{ColorUtils.js → parseColor.js} +0 -0
@@ -1,464 +0,0 @@
1
- import DataType from "./DataType.js";
2
- import ParserError from "./ParserError.js";
3
- import Token from "./Token.js";
4
- import TokenType from "./TokenType.js";
5
- import { readUnsignedInteger } from "./readUnsignedInteger.js";
6
- import { skipWhitespace } from "./skipWhitespace.js";
7
-
8
-
9
- const RX_IDENTIFIER_CHAR = /^[a-zA-Z0-9_]/;
10
- /**
11
- * @readonly
12
- * @type {RegExp}
13
- */
14
- export const RX_IDENTIFIER_FIRST_CHAR = /^[a-zA-Z_]/;
15
-
16
- /**
17
- * @readonly
18
- * @type {RegExp}
19
- */
20
- export const RX_DIGIT = /^[0-9]/i;
21
-
22
- /**
23
- *
24
- * @param {String} text
25
- * @param {number} cursor
26
- * @param {number} length
27
- * @returns {Token}
28
- */
29
- export function readReferenceToken(text, cursor, length) {
30
- let i = cursor;
31
-
32
- const identifiers = [];
33
-
34
- let identifier;
35
-
36
- identifier = readIdentifierToken(text, i, length);
37
-
38
- identifiers.push(identifier);
39
-
40
- i = identifier.end;
41
-
42
- for (; ;) {
43
-
44
- const firstChar = text.charAt(i);
45
-
46
- if (firstChar !== '.') {
47
- break;
48
- }
49
-
50
- //skip over the separator
51
- i++;
52
-
53
- identifier = readIdentifierToken(text, i, length);
54
-
55
- identifiers.push(identifier);
56
-
57
- i = identifier.end;
58
- }
59
-
60
- return new Token(identifiers, cursor, i, TokenType.Reference, DataType.String);
61
- }
62
-
63
- /**
64
- * Read C99 style IDENTIFIER token
65
- * @param {string} text
66
- * @param {number} cursor
67
- * @param {number} length
68
- * @returns {Token}
69
- */
70
- export function readIdentifierToken(text, cursor, length) {
71
- let i = cursor;
72
-
73
-
74
- const firstChar = text.charAt(i);
75
-
76
- if (!RX_IDENTIFIER_FIRST_CHAR.test(firstChar)) {
77
- throw new ParserError(i, `Expected first character to match /${RX_IDENTIFIER_FIRST_CHAR.toString()}/, instead got '${firstChar}'`, text);
78
- }
79
-
80
- i++;
81
-
82
- for (; i < length; i++) {
83
- const char = text.charAt(i);
84
-
85
- if (!RX_IDENTIFIER_CHAR.test(char)) {
86
- break;
87
- }
88
- }
89
-
90
- const value = text.substring(cursor, i);
91
-
92
- return new Token(value, cursor, i, TokenType.Identifier, DataType.String);
93
- }
94
-
95
- /**
96
- *
97
- * @param {string} text
98
- * @param {number} cursor
99
- * @returns {string}
100
- */
101
- function readQuote(text, cursor) {
102
- const char = text.charAt(cursor);
103
-
104
- if (char !== '"' && char !== '\'') {
105
- throw new ParserError(cursor, "Expected \", found " + char + " instead", text);
106
- }
107
-
108
- return char;
109
- }
110
-
111
- /**
112
- *
113
- * @param {string} text
114
- * @param {number} cursor
115
- * @param {number} length
116
- * @returns {Token}
117
- */
118
- function readStringToken(text, cursor, length) {
119
- let i = cursor;
120
-
121
- const openingQuote = readQuote(text, i);
122
-
123
- i++;
124
-
125
- let char;
126
-
127
- let value = '';
128
- const lastPossibleChar = length - 1;
129
-
130
- for (; i < lastPossibleChar; i++) {
131
- char = text.charAt(i);
132
-
133
- if (char === '\\') {
134
- i++;
135
- //read escape sequence
136
- char = text.charAt(i);
137
-
138
- switch (char) {
139
- case 'n':
140
- value += '\n';
141
- break;
142
- case 't':
143
- value += '\t';
144
- break;
145
- case 'r':
146
- value += '\r';
147
- break;
148
- case 'b':
149
- value += '\b';
150
- break;
151
- case 'f':
152
- value += '\f';
153
- break;
154
- case 'v':
155
- value += '\v';
156
- break;
157
- case '0':
158
- value += '\0';
159
- break;
160
- case '\\':
161
- case "'":
162
- case '"':
163
- default:
164
- value += char;
165
- break;
166
- }
167
- } else if (char !== openingQuote) {
168
- value += char;
169
- } else {
170
- break;
171
- }
172
- }
173
-
174
- char = text.charAt(i);
175
-
176
- if (char !== openingQuote) {
177
- throw new ParserError(cursor, "Expected string terminator : " + openingQuote + ", but found '" + char + "' instead", text);
178
- }
179
-
180
- i++;
181
-
182
- return new Token(value, cursor, i, TokenType.LiteralString, DataType.String);
183
- }
184
-
185
- /**
186
- *
187
- * @param {string} text
188
- * @param {number} cursor
189
- * @param {number} length
190
- * @returns {Token}
191
- */
192
- function readHex(text, cursor, length) {
193
- const c0 = text.charAt(cursor);
194
- const c1 = text.charAt(cursor + 1);
195
-
196
- if (c0 !== '0' || !(c1 === 'x' || c1 === 'X')) {
197
- throw new ParserError(cursor, 'Expected hex prefix 0x', text);
198
- }
199
-
200
- let i = cursor + 2;
201
- let value = 0;
202
-
203
- main_loop: for (; i < length;) {
204
- const char = text.charAt(i);
205
- let digit;
206
- switch (char) {
207
- case '0':
208
- digit = 0;
209
- break;
210
- case '1':
211
- digit = 1;
212
- break;
213
- case '2':
214
- digit = 2;
215
- break;
216
- case '3':
217
- digit = 3;
218
- break;
219
- case '4':
220
- digit = 4;
221
- break;
222
- case '5':
223
- digit = 5;
224
- break;
225
- case '6':
226
- digit = 6;
227
- break;
228
- case '7':
229
- digit = 7;
230
- break;
231
- case '8':
232
- digit = 8;
233
- break;
234
- case '9':
235
- digit = 9;
236
- break;
237
- case 'a':
238
- case 'A':
239
- digit = 10;
240
- break;
241
- case 'b':
242
- case 'B':
243
- digit = 11;
244
- break;
245
- case 'c':
246
- case 'C':
247
- digit = 12;
248
- break;
249
- case 'd':
250
- case 'D':
251
- digit = 13;
252
- break;
253
- case 'e':
254
- case 'E':
255
- digit = 14;
256
- break;
257
- case 'f':
258
- case 'F':
259
- digit = 15;
260
- break;
261
- default:
262
- if (i === cursor) {
263
- //first character is not a digit
264
- throw new ParserError(i, `Expected a digit [0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F] but got '${char}' instead`, text);
265
- }
266
- //not a digit
267
- break main_loop;
268
- }
269
- i++;
270
- value = value * 16 + digit;
271
- }
272
-
273
-
274
- return new Token(value, cursor, i, null, DataType.Number);
275
- }
276
-
277
-
278
- /**
279
- *
280
- * @param {string} text
281
- * @param {number} cursor
282
- * @param {number} length
283
- * @returns {Token}
284
- */
285
- function readBoolean(text, cursor, length) {
286
- const firstChar = text.charAt(cursor);
287
-
288
- let value;
289
- let end = cursor;
290
-
291
- if (firstChar === 't' && length - cursor >= 4) {
292
- if (text.substring(cursor + 1, cursor + 4) === 'rue') {
293
- value = true;
294
- end = cursor + 4;
295
- } else {
296
- throw new ParserError(cursor, `expected 'true', instead got '${text.substring(cursor, cursor + 4)}'`, text);
297
- }
298
- } else if (firstChar === 'f' && length - cursor >= 5) {
299
- if (text.substring(cursor + 1, cursor + 5) === 'alse') {
300
- value = false;
301
- end = cursor + 5;
302
- } else {
303
- throw new ParserError(cursor, `expected 'false', instead got '${text.substring(cursor, cursor + 5)}'`, text);
304
- }
305
- } else {
306
- throw new ParserError(cursor, `expected 't' or 'f', instead got '${firstChar}'`, text);
307
- }
308
-
309
- return new Token(value, cursor, end, TokenType.LiteralBoolean, DataType.Boolean);
310
- }
311
-
312
- /**
313
- *
314
- * @param {string} text
315
- * @param {number} cursor
316
- * @param {number} length
317
- * @returns {Token}
318
- */
319
- function readNumber(text, cursor, length) {
320
- let i = cursor;
321
-
322
- //read optional sign
323
- function readSign(text) {
324
- let sign = 1;
325
- const firstChar = text.charAt(i);
326
- if (firstChar === '-') {
327
- sign = -1;
328
- } else if (firstChar === '+') {
329
- sign = 1;
330
- } else {
331
- return 1;
332
- }
333
-
334
- i = skipWhitespace(text, i + 1, length);
335
-
336
- return sign;
337
- }
338
-
339
- const sign = readSign(text);
340
-
341
- let value;
342
-
343
- if (text.charAt(i) === '0' && (text.charAt(i + 1) === 'x' || text.charAt(i + 1) === 'x')) {
344
- // hex number
345
- const token = readHex(text, i, length);
346
-
347
- i = token.end;
348
-
349
- value = token.value;
350
-
351
- } else {
352
-
353
- const wholePart = readUnsignedInteger(text, i, length);
354
-
355
- i = wholePart.end;
356
-
357
- value = wholePart.value;
358
-
359
- if (i < length) {
360
- const dot = text.charAt(i);
361
- if (dot === '.') {
362
- i++;
363
- const fraction = readUnsignedInteger(text, i, length);
364
-
365
- const digits = (fraction.end - fraction.start);
366
-
367
- value += fraction.value / Math.pow(10, digits);
368
-
369
- i = fraction.end;
370
- }
371
- }
372
- }
373
-
374
- value *= sign;
375
-
376
- return new Token(value, cursor, i, TokenType.LiteralNumber, DataType.Number);
377
- }
378
-
379
- function readArrayLiteral(text, cursor, length) {
380
- let i = cursor;
381
-
382
- const firstChar = text.charAt(i);
383
- if (firstChar !== '[') {
384
- throw new ParserError(cursor, `expected array start: '[', got '${firstChar}' instead`, text);
385
- }
386
-
387
- i++;
388
-
389
- const values = [];
390
- while (i < length) {
391
- i = skipWhitespace(text, i, length);
392
-
393
- const token = readLiteral(text, i, length);
394
-
395
- i = token.end;
396
-
397
- values.push(token);
398
-
399
- //try find separator
400
- i = skipWhitespace(text, i, length);
401
- if (i < length) {
402
- const char = text.charAt(i);
403
- if (char === ',') {
404
- //separator
405
- i++;
406
- } else if (char === ']') {
407
- //end of sequence
408
- i++;
409
- break;
410
- } else {
411
- //unexpected input
412
- throw new ParserError(i, `Unexpected input '${char}', expected either separator ',' or end of sequence ']'`, text);
413
- }
414
- } else {
415
- throw new ParserError(i, `Unterminated array literal`, text);
416
- }
417
- }
418
-
419
- return new Token(values, cursor, i, 'array', DataType.Array);
420
- }
421
-
422
- /**
423
- *
424
- * @param {string} text
425
- * @param {number} cursor
426
- * @param {number} length
427
- * @returns {Token}
428
- */
429
- function readLiteral(text, cursor, length) {
430
- const firstChar = text.charAt(cursor);
431
-
432
- switch (firstChar) {
433
- case 't':
434
- case 'f':
435
- return readBoolean(text, cursor, length);
436
- case '\"':
437
- case "\'":
438
- return readStringToken(text, cursor, length);
439
- case '-':
440
- case '+':
441
- case '0':
442
- case '1':
443
- case '2':
444
- case '3':
445
- case '4':
446
- case '5':
447
- case '6':
448
- case '7':
449
- case '8':
450
- case '9':
451
- return readNumber(text, cursor, length);
452
- case '[':
453
- return readArrayLiteral(text, cursor, length);
454
- default:
455
- throw new ParserError(cursor, "Expected literal start, but found '" + firstChar + "'", text);
456
- }
457
- }
458
-
459
- export {
460
- readLiteral,
461
- readNumber,
462
- readStringToken,
463
- readBoolean
464
- };
@@ -1,105 +0,0 @@
1
- import { readIdentifierToken, readReferenceToken, readStringToken } from "./SimpleParser.js";
2
- import TokenType from "./TokenType.js";
3
-
4
- test('parse empty string literal', () => {
5
- const token = readStringToken('""', 0, 2);
6
-
7
- expect(token.value).toBe("");
8
- expect(token.start).toBe(0);
9
- expect(token.end).toBe(2);
10
- });
11
-
12
- test('parse short string literal', () => {
13
- const token = readStringToken('"1"', 0, 3);
14
-
15
- expect(token.value).toBe("1");
16
- expect(token.start).toBe(0);
17
- expect(token.end).toBe(3);
18
- });
19
-
20
- test('parse short string literal from longer input', () => {
21
- const token = readStringToken('"1" ', 0, 5);
22
-
23
- expect(token.value).toBe("1");
24
- expect(token.start).toBe(0);
25
- expect(token.end).toBe(3);
26
- });
27
-
28
- test('parse long string literal', () => {
29
- const token = readStringToken('"hello world"', 0, 13);
30
-
31
- expect(token.value).toBe("hello world");
32
- expect(token.start).toBe(0);
33
- expect(token.end).toBe(13);
34
- });
35
-
36
- test('parse a single escaped quote string literal', () => {
37
- const token = readStringToken('"\\""', 0, 4);
38
-
39
- expect(token.value).toBe('\"');
40
- expect(token.start).toBe(0);
41
- expect(token.end).toBe(4);
42
- });
43
-
44
- test('parse string literal with escaped quotes', () => {
45
- const token = readStringToken('"what is \\"?"', 0, 13);
46
-
47
- expect(token.value).toBe('what is "?');
48
- expect(token.start).toBe(0);
49
- expect(token.end).toBe(13);
50
- });
51
-
52
- test('parse string literal sequential escape sequences', () => {
53
- const token = readStringToken('"\\n\\t"', 0, 6);
54
-
55
- expect(token.value).toBe('\n\t');
56
- expect(token.start).toBe(0);
57
- expect(token.end).toBe(6);
58
- });
59
-
60
- test('parse identifier token starting with a number', () => {
61
- expect(() => readIdentifierToken('0', 0, 1)).toThrow();
62
- expect(() => readIdentifierToken('1', 0, 1)).toThrow();
63
- expect(() => readIdentifierToken('2', 0, 1)).toThrow();
64
- expect(() => readIdentifierToken('3', 0, 1)).toThrow();
65
- expect(() => readIdentifierToken('4', 0, 1)).toThrow();
66
- expect(() => readIdentifierToken('5', 0, 1)).toThrow();
67
- expect(() => readIdentifierToken('6', 0, 1)).toThrow();
68
- expect(() => readIdentifierToken('7', 0, 1)).toThrow();
69
- expect(() => readIdentifierToken('8', 0, 1)).toThrow();
70
- expect(() => readIdentifierToken('9', 0, 1)).toThrow();
71
-
72
-
73
- expect(() => readIdentifierToken('9a', 0, 2)).toThrow();
74
- });
75
-
76
- test('parse identifier token with length 1', () => {
77
- expect(readIdentifierToken('a', 0, 1).value).toBe('a');
78
- expect(readIdentifierToken('A', 0, 1).value).toBe('A');
79
- expect(readIdentifierToken('z', 0, 1).value).toBe('z');
80
- expect(readIdentifierToken('Z', 0, 1).value).toBe('Z');
81
- expect(readIdentifierToken('_', 0, 1).value).toBe('_');
82
- });
83
-
84
- test('parse identifier valid tokens', () => {
85
- expect(readIdentifierToken('aa', 0, 2).value).toBe('aa');
86
- expect(readIdentifierToken('a1', 0, 2).value).toBe('a1');
87
- expect(readIdentifierToken('z ', 0, 2).value).toBe('z');
88
- expect(readIdentifierToken('___ ', 0, 4).value).toBe('___');
89
- });
90
-
91
- test('parse reference a.b', () => {
92
- const token = readReferenceToken('a.b', 0, 3);
93
-
94
- expect(token.end).toBe(3);
95
- expect(token.start).toBe(0);
96
- expect(token.name).toBe(TokenType.Reference);
97
-
98
- const identifiers = token.value;
99
-
100
- expect(Array.isArray(identifiers)).toBe(true);
101
- expect(identifiers.length).toBe(2);
102
-
103
- expect(identifiers[0].value).toBe('a');
104
- expect(identifiers[1].value).toBe('b');
105
- });
File without changes