@woosh/meep-engine 2.49.1 → 2.49.3
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/package.json +1 -1
- package/src/core/bvh2/binary/IndexedBinaryBVH.spec.js +20 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +4 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +30 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +6 -1
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -1
- package/src/core/cache/Cache.d.ts +2 -0
- package/src/core/cache/Cache.js +1 -1
- package/src/core/cache/Cache.spec.js +19 -0
- package/src/core/codegen/LineBuilder.js +8 -1
- package/src/core/codegen/LineBuilder.spec.js +34 -0
- package/src/core/collection/CuckooFilter.js +2 -2
- package/src/core/collection/array/arrayQuickSort.js +11 -2
- package/src/core/collection/array/array_contains_duplicates.js +6 -1
- package/src/core/collection/array/typed/is_typed_array_equals.js +13 -4
- package/src/core/collection/array/typed/is_typed_array_equals.spec.js +71 -0
- package/src/core/collection/table/RowFirstTable.js +1 -1
- package/src/core/collection/table/RowFirstTable.spec.js +36 -0
- package/src/core/collection/table/RowFirstTableSpec.js +3 -0
- package/src/core/color/hsv2rgb.js +8 -3
- package/src/core/color/hsv2rgb.spec.js +43 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_ray_array.js +2 -1
- package/src/core/geom/packing/miniball/Miniball.js +8 -8
- package/src/core/geom/packing/miniball/Quality.js +6 -6
- package/src/core/geom/packing/miniball/Subspan.js +15 -15
- package/src/core/graph/SquareMatrix.js +1 -9
- package/src/core/{land → lang}/reactive/compileReactiveExpression.spec.js +2 -2
- package/src/core/model/reactive/trigger/ReactiveTrigger.js +1 -1
- package/src/engine/ecs/dynamic_actions/actions/definition/SendRequestActionDescription.js +1 -1
- package/src/engine/ecs/dynamic_actions/actions/definition/WhiteToBlackboardActionDescription.js +1 -1
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +1 -1
- package/src/engine/ecs/fow/FogOfWarRevealer.js +0 -27
- package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +29 -0
- package/src/engine/ecs/transform/TransformSerializationAdapter.spec.js +28 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +5 -0
- package/src/engine/options/Option.js +36 -14
- package/src/engine/options/Option.spec.js +69 -0
- package/src/engine/reference/v2/Reference.d.ts +2 -0
- package/src/engine/reference/v2/Reference.js +3 -0
- package/src/engine/reference/v2/Reference.spec.js +44 -0
- package/src/core/bvh2/bvh3/BVHNodeProxy.js +0 -53
- package/src/generation/GridGeneratorConfigurator.js +0 -0
- /package/src/core/{land → lang}/reactive/AbstractCachingParser.js +0 -0
- /package/src/core/{land → lang}/reactive/ReactiveOperatorType.js +0 -0
- /package/src/core/{land → lang}/reactive/compileReactiveExpression.js +0 -0
- /package/src/core/{land → lang}/reactive/nearley/Reactive.ne +0 -0
- /package/src/core/{land → lang}/reactive/pegjs/Reactive.peg +0 -0
- /package/src/core/{land → lang}/reactive/pegjs/ReactivePegCompiler.js +0 -0
- /package/src/core/{land → lang}/reactive/pegjs/ReactivePegParser.js +0 -0
- /package/src/core/{land → lang}/reactive/pegjs/parser.js +0 -0
- /package/src/core/{land → lang}/reactive/validateReactiveExpression.js +0 -0
- /package/src/generation/rules/{CellMatcherContainsTag.spec.js → CellMatcherLayerBitMaskTest.spec.js} +0 -0
package/package.json
CHANGED
|
@@ -5,3 +5,23 @@ test("constructor does not throw", () => {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
test("build a tree with a single leaf", () => {
|
|
9
|
+
const bvh = new IndexedBinaryBVH();
|
|
10
|
+
|
|
11
|
+
bvh.initialize(1);
|
|
12
|
+
bvh.writeLeaf(0, -1, -3, -7, 11, 13, 17);
|
|
13
|
+
|
|
14
|
+
bvh.unsortedBuiltIntermediate();
|
|
15
|
+
|
|
16
|
+
expect(bvh.leafNodeCount).toBe(1);
|
|
17
|
+
expect(bvh.binaryNodeCount).toBe(0);
|
|
18
|
+
|
|
19
|
+
expect(bvh.x0).toBe(-1);
|
|
20
|
+
expect(bvh.y0).toBe(-3);
|
|
21
|
+
expect(bvh.z0).toBe(-7);
|
|
22
|
+
|
|
23
|
+
expect(bvh.x1).toBe(11);
|
|
24
|
+
expect(bvh.y1).toBe(13);
|
|
25
|
+
expect(bvh.z1).toBe(17);
|
|
26
|
+
|
|
27
|
+
});
|
|
@@ -13,6 +13,8 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
13
13
|
|
|
14
14
|
collect_nodes_all(destination: ArrayLike<number>, destination_offset: number): void
|
|
15
15
|
|
|
16
|
+
node_set_aabb_primitive(node_id: number, x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void
|
|
17
|
+
|
|
16
18
|
node_set_aabb(node: number, aabb: ArrayLike<number>): void
|
|
17
19
|
|
|
18
20
|
node_get_aabb(node: number, aabb: ArrayLike<number>): void
|
|
@@ -37,6 +39,8 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
37
39
|
|
|
38
40
|
node_get_height(node: number): number
|
|
39
41
|
|
|
42
|
+
swap_nodes(node_a_id: number, node_b_id: number): boolean
|
|
43
|
+
|
|
40
44
|
release_all(): void
|
|
41
45
|
|
|
42
46
|
trim(): void
|
|
@@ -218,3 +218,33 @@ test("node property setters/getters", () => {
|
|
|
218
218
|
|
|
219
219
|
expect(actual_aabb).toEqual(Array.from(expected_aabb));
|
|
220
220
|
});
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
test("node_set_aabb_primitive", () => {
|
|
224
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
225
|
+
|
|
226
|
+
const node = bvh.allocate_node();
|
|
227
|
+
|
|
228
|
+
bvh.node_set_aabb_primitive(node, -1, -3, -5, 7, 11, 13);
|
|
229
|
+
|
|
230
|
+
const aabb = [];
|
|
231
|
+
|
|
232
|
+
bvh.node_get_aabb(node, aabb);
|
|
233
|
+
|
|
234
|
+
expect(aabb).toEqual([-1, -3, -5, 7, 11, 13]);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("swap two detached nodes", () => {
|
|
238
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
239
|
+
|
|
240
|
+
const a = bvh.allocate_node();
|
|
241
|
+
const b = bvh.allocate_node();
|
|
242
|
+
|
|
243
|
+
bvh.node_set_user_data(a, 7);
|
|
244
|
+
bvh.node_set_user_data(b, 11);
|
|
245
|
+
|
|
246
|
+
bvh.swap_nodes(a, b);
|
|
247
|
+
|
|
248
|
+
expect(bvh.node_get_user_data(a)).toBe(11);
|
|
249
|
+
expect(bvh.node_get_user_data(b)).toBe(7);
|
|
250
|
+
});
|
|
@@ -8,7 +8,12 @@ import { compute_triangle_group_aabb3 } from "../../../engine/graphics/sh3/path_
|
|
|
8
8
|
* @param {number[]|Float32Array} positions_array
|
|
9
9
|
* @param {number} [batch_size] can batch triangles in groups of up-to this many triangles per BVH leaf
|
|
10
10
|
*/
|
|
11
|
-
export function ebvh_build_for_geometry_incremental(
|
|
11
|
+
export function ebvh_build_for_geometry_incremental(
|
|
12
|
+
bvh,
|
|
13
|
+
index_array, positions_array,
|
|
14
|
+
batch_size = 1
|
|
15
|
+
) {
|
|
16
|
+
|
|
12
17
|
bvh.release_all();
|
|
13
18
|
const triangle_count = index_array.length / 3;
|
|
14
19
|
|
|
@@ -11,8 +11,12 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
11
11
|
* @param {number} destination_offset
|
|
12
12
|
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
13
13
|
* @param {number} node
|
|
14
|
+
* @returns {number} number of collected elements
|
|
14
15
|
*/
|
|
15
|
-
export function bvh_collect_user_data(
|
|
16
|
+
export function bvh_collect_user_data(
|
|
17
|
+
destination, destination_offset,
|
|
18
|
+
bvh, node
|
|
19
|
+
) {
|
|
16
20
|
|
|
17
21
|
if (node === NULL_NODE) {
|
|
18
22
|
return 0;
|
package/src/core/cache/Cache.js
CHANGED
|
@@ -18,7 +18,7 @@ export class Cache {
|
|
|
18
18
|
* @param {function(value:Value):number} [valueWeigher= value=>1]
|
|
19
19
|
* @param {function(Key):number} [keyHashFunction]
|
|
20
20
|
* @param {function(Key, Key):boolean} [keyEqualityFunction]
|
|
21
|
-
* @param {number} capacity initial capacity for the cache, helps prevent early resizing
|
|
21
|
+
* @param {number} [capacity] initial capacity for the cache, helps prevent early resizing
|
|
22
22
|
* @constructor
|
|
23
23
|
*/
|
|
24
24
|
constructor({
|
|
@@ -18,6 +18,19 @@ test("elements beyond capacity are evicted", () => {
|
|
|
18
18
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
test("trying to insert an element into the cache that's larger than the cache capacity should result in the item not being inserted", () => {
|
|
22
|
+
const cache = new Cache({
|
|
23
|
+
maxWeight: 1,
|
|
24
|
+
keyWeigher(key) {
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
cache.put(2, "hello");
|
|
30
|
+
|
|
31
|
+
expect(cache.contains(2)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
21
34
|
test("removeListener is called when element is evicted", () => {
|
|
22
35
|
|
|
23
36
|
const removeListener = jest.fn();
|
|
@@ -140,3 +153,9 @@ test("clear with a single entry", () => {
|
|
|
140
153
|
expect(cache.contains("x")).toBe(false);
|
|
141
154
|
|
|
142
155
|
});
|
|
156
|
+
|
|
157
|
+
test("calling 'evictOne' on empty cache should return false", () => {
|
|
158
|
+
const cache = new Cache();
|
|
159
|
+
|
|
160
|
+
expect(cache.evictOne()).toBe(false);
|
|
161
|
+
});
|
|
@@ -39,6 +39,14 @@ class LineBuilder {
|
|
|
39
39
|
*/
|
|
40
40
|
indentSpaces = DEFAULT_INDENT_SPACES;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Number of lines
|
|
44
|
+
* @return {number}
|
|
45
|
+
*/
|
|
46
|
+
get count() {
|
|
47
|
+
return this.lines.length;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
*
|
|
44
52
|
* @return {boolean}
|
|
@@ -115,7 +123,6 @@ class LineBuilder {
|
|
|
115
123
|
clear() {
|
|
116
124
|
this.lines = [];
|
|
117
125
|
this.indentation = 0;
|
|
118
|
-
this.indentSpaces = DEFAULT_INDENT_SPACES;
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
/**
|
|
@@ -5,3 +5,37 @@ test("Empty builder should produce empty string", () => {
|
|
|
5
5
|
|
|
6
6
|
expect(b.build()).toEqual("");
|
|
7
7
|
});
|
|
8
|
+
|
|
9
|
+
test("build simple indented fragment", () => {
|
|
10
|
+
const b = new LineBuilder();
|
|
11
|
+
|
|
12
|
+
b.indentSpaces = 1;
|
|
13
|
+
|
|
14
|
+
b.add('a');
|
|
15
|
+
b.indent();
|
|
16
|
+
b.add('b');
|
|
17
|
+
b.dedent();
|
|
18
|
+
b.add('c');
|
|
19
|
+
|
|
20
|
+
expect(b.build()).toEqual('a\n b\nc');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("adding another line builder copies lines correctly", () => {
|
|
24
|
+
const a = new LineBuilder();
|
|
25
|
+
|
|
26
|
+
const b = new LineBuilder();
|
|
27
|
+
|
|
28
|
+
b.add('a');
|
|
29
|
+
|
|
30
|
+
a.addLines(b);
|
|
31
|
+
|
|
32
|
+
expect(a.build()).toEqual('a');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("fromText parses correct number of lines", () => {
|
|
36
|
+
|
|
37
|
+
const builder = LineBuilder.fromText('a\nb');
|
|
38
|
+
|
|
39
|
+
expect(builder.count).toBe(2);
|
|
40
|
+
|
|
41
|
+
});
|
|
@@ -371,11 +371,11 @@ export class CuckooFilter {
|
|
|
371
371
|
* Puts an element into this {@link CuckooFilter}. Ensures that subsequent
|
|
372
372
|
* invocations of {@link #mightContain(Object)} with the same element will
|
|
373
373
|
* always return `true`.
|
|
374
|
-
*
|
|
374
|
+
*
|
|
375
375
|
* Note that the filter should be considered full after insertion failure.
|
|
376
376
|
* Further inserts <i>may</i> fail, although deleting items can also make
|
|
377
377
|
* the filter usable again.
|
|
378
|
-
*
|
|
378
|
+
*
|
|
379
379
|
* Also note that inserting the same item more than 8 times will cause an
|
|
380
380
|
* insertion failure.
|
|
381
381
|
*
|
|
@@ -12,7 +12,12 @@ const stack = [];
|
|
|
12
12
|
* @param {function(T[],number, number):*} [swap_operator]
|
|
13
13
|
* @param {*} [swap_context]
|
|
14
14
|
*/
|
|
15
|
-
export function arrayQuickSort(
|
|
15
|
+
export function arrayQuickSort(
|
|
16
|
+
data,
|
|
17
|
+
score_function, score_function_context,
|
|
18
|
+
start, end,
|
|
19
|
+
swap_operator = arraySwapElements, swap_context = undefined
|
|
20
|
+
) {
|
|
16
21
|
if (start >= end) {
|
|
17
22
|
// section of 0 size, nothing to sort
|
|
18
23
|
return;
|
|
@@ -79,7 +84,11 @@ export function arrayQuickSort(data, score_function, score_function_context, sta
|
|
|
79
84
|
* @param {number} start
|
|
80
85
|
* @param {number} end
|
|
81
86
|
*/
|
|
82
|
-
export function array_quick_sort_by_comparator(
|
|
87
|
+
export function array_quick_sort_by_comparator(
|
|
88
|
+
data,
|
|
89
|
+
compare_function, compare_function_context,
|
|
90
|
+
start, end
|
|
91
|
+
) {
|
|
83
92
|
if (start >= end) {
|
|
84
93
|
// section of 0 size, nothing to sort
|
|
85
94
|
return;
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* @param {number} [end_index] last index to be included in the search
|
|
6
6
|
* @return {boolean}
|
|
7
7
|
*/
|
|
8
|
-
export function array_contains_duplicates(
|
|
8
|
+
export function array_contains_duplicates(
|
|
9
|
+
source,
|
|
10
|
+
start_index = 0,
|
|
11
|
+
end_index = source.length - 1
|
|
12
|
+
) {
|
|
13
|
+
|
|
9
14
|
for (let k = start_index; k <= end_index; k++) {
|
|
10
15
|
|
|
11
16
|
const element = source[k];
|
|
@@ -3,11 +3,16 @@ import { isArrayEqualStrict } from "../isArrayEqualStrict.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
|
-
* @param {Uint8Array} a
|
|
7
|
-
* @param {Uint8Array} b
|
|
6
|
+
* @param {Uint8Array|Uint32Array} a
|
|
7
|
+
* @param {Uint8Array|Uint32Array} b
|
|
8
8
|
* @returns {boolean}
|
|
9
9
|
*/
|
|
10
10
|
export function is_typed_array_equals(a, b) {
|
|
11
|
+
if (a === b) {
|
|
12
|
+
// quick shortcut
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
const a_length = a.length;
|
|
12
17
|
const b_length = b.length;
|
|
13
18
|
|
|
@@ -26,13 +31,15 @@ export function is_typed_array_equals(a, b) {
|
|
|
26
31
|
return false;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
const
|
|
34
|
+
const a_constructor = a.constructor;
|
|
35
|
+
const b_constructor = b.constructor;
|
|
30
36
|
|
|
31
|
-
if (
|
|
37
|
+
if (a_constructor !== b_constructor) {
|
|
32
38
|
// incompatible constructors
|
|
33
39
|
return false;
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
|
|
36
43
|
const a_buffer = a.buffer;
|
|
37
44
|
const b_buffer = b.buffer;
|
|
38
45
|
|
|
@@ -45,6 +52,8 @@ export function is_typed_array_equals(a, b) {
|
|
|
45
52
|
let a_proxy = a;
|
|
46
53
|
let b_proxy = b;
|
|
47
54
|
|
|
55
|
+
const bytes_per_element = a_constructor.BYTES_PER_ELEMENT;
|
|
56
|
+
|
|
48
57
|
if (bytes_per_element < 4 && byte_length % 4 === 0) {
|
|
49
58
|
// 4 byte alignment, can use uint32
|
|
50
59
|
a_proxy = new Uint32Array(a_buffer, a.byteOffset, byte_length / 4);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { is_typed_array_equals } from "./is_typed_array_equals.js";
|
|
2
|
+
|
|
3
|
+
test("small uint32 arrays", () => {
|
|
4
|
+
expect(is_typed_array_equals(
|
|
5
|
+
new Uint32Array(0),
|
|
6
|
+
new Uint32Array(0)
|
|
7
|
+
)).toBe(true);
|
|
8
|
+
|
|
9
|
+
expect(is_typed_array_equals(
|
|
10
|
+
new Uint32Array([1, 3, 5]),
|
|
11
|
+
new Uint32Array([1, 3, 5])
|
|
12
|
+
)).toBe(true);
|
|
13
|
+
|
|
14
|
+
expect(is_typed_array_equals(
|
|
15
|
+
new Uint32Array([7, 3]),
|
|
16
|
+
new Uint32Array([1, 3])
|
|
17
|
+
)).toBe(false);
|
|
18
|
+
|
|
19
|
+
expect(is_typed_array_equals(
|
|
20
|
+
new Uint32Array([1, 3]),
|
|
21
|
+
new Uint32Array([7, 3])
|
|
22
|
+
)).toBe(false);
|
|
23
|
+
|
|
24
|
+
expect(is_typed_array_equals(
|
|
25
|
+
new Uint32Array([1, 7]),
|
|
26
|
+
new Uint32Array([1, 3])
|
|
27
|
+
)).toBe(false);
|
|
28
|
+
|
|
29
|
+
expect(is_typed_array_equals(
|
|
30
|
+
new Uint32Array([1, 3]),
|
|
31
|
+
new Uint32Array([1, 7])
|
|
32
|
+
)).toBe(false);
|
|
33
|
+
|
|
34
|
+
expect(is_typed_array_equals(
|
|
35
|
+
new Uint32Array([1, 3]),
|
|
36
|
+
new Uint32Array([1, 3, 7])
|
|
37
|
+
)).toBe(false);
|
|
38
|
+
|
|
39
|
+
expect(is_typed_array_equals(
|
|
40
|
+
new Uint32Array([1, 3, 7]),
|
|
41
|
+
new Uint32Array([1, 3])
|
|
42
|
+
)).toBe(false);
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("large uin32 array", () => {
|
|
47
|
+
expect(is_typed_array_equals(
|
|
48
|
+
new Uint32Array(1024),
|
|
49
|
+
new Uint32Array(1024),
|
|
50
|
+
)).toBe(true);
|
|
51
|
+
|
|
52
|
+
expect(is_typed_array_equals(
|
|
53
|
+
new Uint32Array(1024),
|
|
54
|
+
new Uint32Array(1023),
|
|
55
|
+
)).toBe(false);
|
|
56
|
+
|
|
57
|
+
expect(is_typed_array_equals(
|
|
58
|
+
new Uint32Array(1023),
|
|
59
|
+
new Uint32Array(1024),
|
|
60
|
+
)).toBe(false);
|
|
61
|
+
|
|
62
|
+
const a = new Uint32Array(1024);
|
|
63
|
+
const b = new Uint32Array(1024);
|
|
64
|
+
|
|
65
|
+
a[127] = 1;
|
|
66
|
+
|
|
67
|
+
expect(is_typed_array_equals(
|
|
68
|
+
a,
|
|
69
|
+
b,
|
|
70
|
+
)).toBe(false);
|
|
71
|
+
});
|
|
@@ -285,3 +285,39 @@ test('reverse_rows empty', () => {
|
|
|
285
285
|
|
|
286
286
|
expect(a.length).toBe(0);
|
|
287
287
|
});
|
|
288
|
+
|
|
289
|
+
test("hash on an empty ", () => {
|
|
290
|
+
const table = new RowFirstTable(new RowFirstTableSpec([BinaryDataType.Uint8]));
|
|
291
|
+
|
|
292
|
+
expect(() => table.hash()).not.toThrow();
|
|
293
|
+
expect(table.hash()).toEqual(table.hash());
|
|
294
|
+
expect(typeof table.hash() === "number").toBe(true);
|
|
295
|
+
expect(Number.isInteger(table.hash())).toBe(true);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
test("equals method", () => {
|
|
299
|
+
const a = new RowFirstTable(new RowFirstTableSpec([BinaryDataType.Uint8]));
|
|
300
|
+
const b = new RowFirstTable(new RowFirstTableSpec([BinaryDataType.Uint8]));
|
|
301
|
+
|
|
302
|
+
expect(a.equals(b)).toBe(true);
|
|
303
|
+
|
|
304
|
+
a.addRow([1]);
|
|
305
|
+
|
|
306
|
+
expect(a.equals(b)).toBe(false);
|
|
307
|
+
expect(b.equals(a)).toBe(false);
|
|
308
|
+
|
|
309
|
+
b.addRow([3]);
|
|
310
|
+
|
|
311
|
+
expect(a.equals(b)).toBe(false);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
test("toRowArray", () => {
|
|
315
|
+
const a = new RowFirstTable(new RowFirstTableSpec([BinaryDataType.Uint8, BinaryDataType.Float64]));
|
|
316
|
+
a.addRow([3, 7.11]);
|
|
317
|
+
a.addRow([5, 13.17]);
|
|
318
|
+
|
|
319
|
+
expect(a.toRowArray()).toEqual([
|
|
320
|
+
[3, 7.11],
|
|
321
|
+
[5, 13.17],
|
|
322
|
+
]);
|
|
323
|
+
});
|
|
@@ -9,6 +9,7 @@ import { computeStringHash } from "../../primitives/strings/computeStringHash.js
|
|
|
9
9
|
import { isArrayEqualStrict } from "../array/isArrayEqualStrict.js";
|
|
10
10
|
import { BinaryDataType } from "../../binary/type/BinaryDataType.js";
|
|
11
11
|
import { DataTypeByteSizes } from "../../binary/type/DataTypeByteSizes.js";
|
|
12
|
+
import { assert } from "../../assert.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @readonly
|
|
@@ -158,6 +159,8 @@ function genCellReader(type, offset, endianType = EndianType.BigEndian) {
|
|
|
158
159
|
* @constructor
|
|
159
160
|
*/
|
|
160
161
|
export function RowFirstTableSpec(types, endianType = EndianType.BigEndian) {
|
|
162
|
+
assert.isArray(types, 'types');
|
|
163
|
+
|
|
161
164
|
const numTypes = types.length;
|
|
162
165
|
|
|
163
166
|
/**
|
|
@@ -10,22 +10,27 @@ import { float2uint8 } from "../binary/float2uint8.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export function hsv2rgb(h, s, v) {
|
|
12
12
|
|
|
13
|
-
let _h = h
|
|
13
|
+
let _h = h;
|
|
14
14
|
|
|
15
15
|
if (_h < 0) {
|
|
16
|
-
_h =
|
|
16
|
+
_h = _h + Math.ceil(Math.abs(_h));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
_h = _h % 1;
|
|
20
|
+
|
|
19
21
|
const _s = clamp01(s);
|
|
20
22
|
const _v = clamp01(v);
|
|
21
23
|
|
|
22
24
|
let r, g, b, i, f, p, q, t;
|
|
23
25
|
|
|
24
|
-
i = Math.floor(
|
|
26
|
+
i = Math.floor(_h * 6);
|
|
27
|
+
|
|
25
28
|
f = _h * 6 - i;
|
|
29
|
+
|
|
26
30
|
p = _v * (1 - _s);
|
|
27
31
|
q = _v * (1 - f * _s);
|
|
28
32
|
t = _v * (1 - (1 - f) * _s);
|
|
33
|
+
|
|
29
34
|
switch (i % 6) {
|
|
30
35
|
case 0:
|
|
31
36
|
r = _v, g = t, b = p;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { hsv2rgb } from "./hsv2rgb.js";
|
|
2
|
+
|
|
3
|
+
function validate_element(number) {
|
|
4
|
+
expect(typeof number).toBe('number');
|
|
5
|
+
expect(Number.isNaN(number)).toBe(false);
|
|
6
|
+
|
|
7
|
+
expect(number).toBeLessThanOrEqual(255);
|
|
8
|
+
expect(number).toBeGreaterThanOrEqual(0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function validate_rgb(rgb) {
|
|
12
|
+
expect(rgb).not.toBeUndefined();
|
|
13
|
+
expect(rgb).not.toBeNull();
|
|
14
|
+
expect(typeof rgb).toBe('object');
|
|
15
|
+
|
|
16
|
+
validate_element(rgb.r);
|
|
17
|
+
validate_element(rgb.g);
|
|
18
|
+
validate_element(rgb.b);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test("sanity test", () => {
|
|
22
|
+
|
|
23
|
+
validate_rgb(hsv2rgb(0, 0, 0));
|
|
24
|
+
validate_rgb(hsv2rgb(0, 0, 1));
|
|
25
|
+
validate_rgb(hsv2rgb(0, 1, 0));
|
|
26
|
+
validate_rgb(hsv2rgb(0, 1, 1));
|
|
27
|
+
validate_rgb(hsv2rgb(1, 0, 0));
|
|
28
|
+
validate_rgb(hsv2rgb(1, 0, 1));
|
|
29
|
+
validate_rgb(hsv2rgb(1, 1, 0));
|
|
30
|
+
validate_rgb(hsv2rgb(1, 1, 1));
|
|
31
|
+
|
|
32
|
+
validate_rgb(hsv2rgb(0.5, 0.5, 0.5));
|
|
33
|
+
|
|
34
|
+
validate_rgb(hsv2rgb(0.1, 0.5, 0.5));
|
|
35
|
+
validate_rgb(hsv2rgb(0.2, 0.5, 0.5));
|
|
36
|
+
validate_rgb(hsv2rgb(0.3, 0.5, 0.5));
|
|
37
|
+
validate_rgb(hsv2rgb(0.4, 0.5, 0.5));
|
|
38
|
+
validate_rgb(hsv2rgb(0.6, 0.5, 0.5));
|
|
39
|
+
validate_rgb(hsv2rgb(0.7, 0.5, 0.5));
|
|
40
|
+
validate_rgb(hsv2rgb(0.8, 0.5, 0.5));
|
|
41
|
+
validate_rgb(hsv2rgb(0.9, 0.5, 0.5));
|
|
42
|
+
|
|
43
|
+
});
|
|
@@ -7,7 +7,8 @@ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
|
|
|
7
7
|
* @returns {boolean}
|
|
8
8
|
*/
|
|
9
9
|
export function aabb3_array_intersects_ray_array(aabb, ray) {
|
|
10
|
-
return aabb3_intersects_ray(
|
|
10
|
+
return aabb3_intersects_ray(
|
|
11
|
+
aabb[0], aabb[1], aabb[2], aabb[3], aabb[4], aabb[5],
|
|
11
12
|
ray[0], ray[1], ray[2],
|
|
12
13
|
ray[3], ray[4], ray[5]
|
|
13
14
|
);
|
|
@@ -115,7 +115,7 @@ class Miniball {
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* The radius of the miniball.
|
|
118
|
-
*
|
|
118
|
+
*
|
|
119
119
|
* Precondition: `!isEmpty()`
|
|
120
120
|
*
|
|
121
121
|
* @return {number} the radius of the miniball, a number ≥ 0
|
|
@@ -126,9 +126,9 @@ class Miniball {
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* The squared radius of the miniball.
|
|
129
|
-
*
|
|
129
|
+
*
|
|
130
130
|
* This is equivalent to `radius() * radius()`.
|
|
131
|
-
*
|
|
131
|
+
*
|
|
132
132
|
* Precondition: `!isEmpty()`
|
|
133
133
|
*
|
|
134
134
|
* @return {number} the squared radius of the miniball
|
|
@@ -139,7 +139,7 @@ class Miniball {
|
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* The Euclidean coordinates of the center of the miniball.
|
|
142
|
-
*
|
|
142
|
+
*
|
|
143
143
|
* Precondition: `!isEmpty()`
|
|
144
144
|
*
|
|
145
145
|
* @return {number[]} an array holding the coordinates of the center of the miniball
|
|
@@ -178,7 +178,7 @@ class Miniball {
|
|
|
178
178
|
* Sets up the search ball with an arbitrary point of <i>S</i> as center and with exactly one of
|
|
179
179
|
* the points farthest from center in the support. So the current ball contains all points of
|
|
180
180
|
* <i>S</i> and has radius at most twice as large as the minball.
|
|
181
|
-
*
|
|
181
|
+
*
|
|
182
182
|
* Precondition: `size > 0`
|
|
183
183
|
* @return {Subspan}
|
|
184
184
|
* @private
|
|
@@ -238,7 +238,7 @@ class Miniball {
|
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
240
|
* The main function containing the main loop.
|
|
241
|
-
*
|
|
241
|
+
*
|
|
242
242
|
* Iteratively, we compute the point in support that is closest to the current center and then
|
|
243
243
|
* walk towards this target as far as we can, i.e., we move until some new point touches the
|
|
244
244
|
* boundary of the ball and must thus be inserted into support. In each of these two alternating
|
|
@@ -301,7 +301,7 @@ class Miniball {
|
|
|
301
301
|
* {@link #successfulDrop()} elects a suitable point <i>k</i> to be removed from the support and
|
|
302
302
|
* returns true. If the center lies in the convex hull, however, false is returned (and the
|
|
303
303
|
* support remains unaltered).
|
|
304
|
-
*
|
|
304
|
+
*
|
|
305
305
|
* Precondition: center lies in <i>aff(support)</i>.
|
|
306
306
|
* @return {boolean}
|
|
307
307
|
*/
|
|
@@ -403,7 +403,7 @@ class Miniball {
|
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* Verifies that the computed ball is indeed the miniball.
|
|
406
|
-
*
|
|
406
|
+
*
|
|
407
407
|
* This method should be called for testing purposes only; it may not be very efficient.
|
|
408
408
|
* @return {Quality}
|
|
409
409
|
*/
|
|
@@ -30,7 +30,7 @@ class Quality {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* A measure for the quality of the internally used support points.
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
34
|
* The returned number should in theory be zero (but may be non-zero due to rounding errors).
|
|
35
35
|
* @return {number}
|
|
36
36
|
*/
|
|
@@ -52,11 +52,11 @@ class Quality {
|
|
|
52
52
|
/**
|
|
53
53
|
* The maximal over-length of a point from the input set, relative to the computed miniball's
|
|
54
54
|
* radius.
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
56
|
* For each point <i>p</i> from the input point set, it is computed how far it is <i>outside</i>
|
|
57
57
|
* the miniball ("over-length"). The returned number is the maximal such over-length, divided by
|
|
58
58
|
* the radius of the computed miniball.
|
|
59
|
-
*
|
|
59
|
+
*
|
|
60
60
|
* Notice that `getMaxOverlength() == 0` if and only if all points are contained in the
|
|
61
61
|
* miniball.
|
|
62
62
|
*
|
|
@@ -69,11 +69,11 @@ class Quality {
|
|
|
69
69
|
/**
|
|
70
70
|
* The maximal under-length of a point from the input set, relative to the computed miniball's
|
|
71
71
|
* radius.
|
|
72
|
-
*
|
|
72
|
+
*
|
|
73
73
|
* For each point <i>p</i> from the input point set, it is computed how far one has to walk from
|
|
74
74
|
* this point towards the boundary of the miniball ("under-length"). The returned number is the
|
|
75
75
|
* maximal such under-length, divided by the radius of the computed miniball.
|
|
76
|
-
*
|
|
76
|
+
*
|
|
77
77
|
* Notice that in theory `getMaxUnderlength()` should be zero, otherwise the computed
|
|
78
78
|
* miniball is enclosing but not minimal.
|
|
79
79
|
*
|
|
@@ -94,7 +94,7 @@ class Quality {
|
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* The size of the support.
|
|
97
|
-
*
|
|
97
|
+
*
|
|
98
98
|
* Refer to the documentation of {@link Miniball#support()} for more information on the
|
|
99
99
|
* <i>support</i>.
|
|
100
100
|
*
|
|
@@ -118,7 +118,7 @@ export class Subspan {
|
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* The size of the instance's set <i>M</i>, a number between 0 and `dim+1`.
|
|
121
|
-
*
|
|
121
|
+
*
|
|
122
122
|
* Complexity: O(1).
|
|
123
123
|
*
|
|
124
124
|
* @returns {int} <i>|M|</i>
|
|
@@ -129,7 +129,7 @@ export class Subspan {
|
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Whether <i>S[i]</i> is a member of <i>M</i>.
|
|
132
|
-
*
|
|
132
|
+
*
|
|
133
133
|
* Complexity: O(1)
|
|
134
134
|
*
|
|
135
135
|
* @param {int} i
|
|
@@ -142,9 +142,9 @@ export class Subspan {
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* The global index (into <i>S</i>) of an arbitrary element of <i>M</i>.
|
|
145
|
-
*
|
|
145
|
+
*
|
|
146
146
|
* Precondition: `size()>0`
|
|
147
|
-
*
|
|
147
|
+
*
|
|
148
148
|
* Postcondition: `isMember(anyMember())`
|
|
149
149
|
* @returns {number}
|
|
150
150
|
*/
|
|
@@ -156,7 +156,7 @@ export class Subspan {
|
|
|
156
156
|
* The index (into <i>S</i>) of the <i>i</i>th point in <i>M</i>. The points in <i>M</i> are
|
|
157
157
|
* internally ordered (in an arbitrary way) and this order only changes when {@link add()} or
|
|
158
158
|
* {@link remove()} is called.
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
160
|
* Complexity: O(1)
|
|
161
161
|
*
|
|
162
162
|
* @param {number} i
|
|
@@ -201,10 +201,10 @@ export class Subspan {
|
|
|
201
201
|
* </pre>
|
|
202
202
|
*
|
|
203
203
|
* We don't care about the signs here, for efficiency, so make sure not to rely on them anywhere.
|
|
204
|
-
*
|
|
204
|
+
*
|
|
205
205
|
* <i>Source:</i> "Matrix Computations" (2nd edition) by Gene H. B. Golub & Charles F. B. Van Loan
|
|
206
206
|
* (Johns Hopkins University Press, 1989), p. 216.
|
|
207
|
-
*
|
|
207
|
+
*
|
|
208
208
|
* Note that the code of this class sometimes does not call this method but only mentions it in a
|
|
209
209
|
* comment. The reason for this is performance; Java does not allow an efficient way of returning
|
|
210
210
|
* a pair of doubles, so we sometimes manually "inline" `givens()` for the sake of
|
|
@@ -233,7 +233,7 @@ export class Subspan {
|
|
|
233
233
|
* = QR</i>, updating <i>Q</i> and <i>R</i>. It assumes <i>r</i> to still be the old value, i.e.,
|
|
234
234
|
* the index of the column used now for insertion; <i>r</i> is not altered by this routine and
|
|
235
235
|
* should be changed by the caller afterwards.
|
|
236
|
-
*
|
|
236
|
+
*
|
|
237
237
|
* Precondition: `r<dim`
|
|
238
238
|
* @private
|
|
239
239
|
*/
|
|
@@ -268,9 +268,9 @@ export class Subspan {
|
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
270
|
* Adds the point <i>S[index]</i> to the instance's set <i>M</i>.
|
|
271
|
-
*
|
|
271
|
+
*
|
|
272
272
|
* Precondition: `!isMember(index)`
|
|
273
|
-
*
|
|
273
|
+
*
|
|
274
274
|
* Complexity: O(dim^2).
|
|
275
275
|
*
|
|
276
276
|
* @param {number} index
|
|
@@ -301,9 +301,9 @@ export class Subspan {
|
|
|
301
301
|
/**
|
|
302
302
|
* Computes the vector <i>w</i> directed from point <i>p</i> to <i>v</i>, where <i>v</i> is the
|
|
303
303
|
* point in <i>aff(M)</i> that lies nearest to <i>p</i>.
|
|
304
|
-
*
|
|
304
|
+
*
|
|
305
305
|
* Precondition: `size()>0`
|
|
306
|
-
*
|
|
306
|
+
*
|
|
307
307
|
* Complexity: O(dim^2)
|
|
308
308
|
*
|
|
309
309
|
* @param {Array} p
|
|
@@ -391,12 +391,12 @@ export class Subspan {
|
|
|
391
391
|
/**
|
|
392
392
|
* Calculates the `size()`-many coefficients in the representation of <i>p</i> as an affine
|
|
393
393
|
* combination of the points <i>M</i>.
|
|
394
|
-
*
|
|
394
|
+
*
|
|
395
395
|
* The <i>i</i>th computed coefficient `lambdas[i] `corresponds to the <i>i</i>th point in
|
|
396
396
|
* <i>M</i>, or, in other words, to the point in <i>S</i> with index `globalIndex(i)`.
|
|
397
|
-
*
|
|
397
|
+
*
|
|
398
398
|
* Complexity: O(dim^2)
|
|
399
|
-
*
|
|
399
|
+
*
|
|
400
400
|
* Preconditions: c lies in the affine hull aff(M) and size() > 0.
|
|
401
401
|
* @param {Array} p
|
|
402
402
|
* @param {Array} lambdas
|
|
@@ -53,15 +53,7 @@ export class SquareMatrix {
|
|
|
53
53
|
* @param {SquareMatrix} other
|
|
54
54
|
*/
|
|
55
55
|
subtract(other) {
|
|
56
|
-
|
|
57
|
-
const data_length = size * size;
|
|
58
|
-
|
|
59
|
-
const this_data = this.data;
|
|
60
|
-
const other_data = other.data;
|
|
61
|
-
|
|
62
|
-
for (let i = 0; i < data_length; i++) {
|
|
63
|
-
this_data[i] -= other_data[i];
|
|
64
|
-
}
|
|
56
|
+
this.subtractMatrices(this,other);
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
/**
|
|
@@ -9,11 +9,11 @@ import { ReactiveGreaterThanOrEqual } from "../../model/reactive/model/comparati
|
|
|
9
9
|
import { ReactiveLessThan } from "../../model/reactive/model/comparative/ReactiveLessThan.js";
|
|
10
10
|
import { ReactiveLessThanOrEqual } from "../../model/reactive/model/comparative/ReactiveLessThanOrEqual.js";
|
|
11
11
|
import { ReactiveNotEquals } from "../../model/reactive/model/comparative/ReactiveNotEquals.js";
|
|
12
|
-
import { ReactiveAnd } from "../../model/reactive/model/logic/ReactiveAnd.
|
|
12
|
+
import { ReactiveAnd } from "../../model/reactive/model/logic/ReactiveAnd.js";
|
|
13
13
|
import { ReactiveNot } from "../../model/reactive/model/logic/ReactiveNot.js";
|
|
14
14
|
import { ReactiveOr } from "../../model/reactive/model/logic/ReactiveOr.js";
|
|
15
15
|
import { ReactiveLiteralNumber } from "../../model/reactive/model/terminal/ReactiveLiteralNumber.js";
|
|
16
|
-
import { ReactiveReference } from "../../model/reactive/model/terminal/ReactiveReference.
|
|
16
|
+
import { ReactiveReference } from "../../model/reactive/model/terminal/ReactiveReference.js";
|
|
17
17
|
import { compileReactiveExpression } from "./compileReactiveExpression.js";
|
|
18
18
|
|
|
19
19
|
test('compile: REFERENCE', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
|
-
import { compileReactiveExpression } from "../../../
|
|
2
|
+
import { compileReactiveExpression } from "../../../lang/reactive/compileReactiveExpression.js";
|
|
3
3
|
import DataType from "../../../parser/simple/DataType.js";
|
|
4
4
|
import { inferReactiveExpressionTypes } from "../transform/ReactiveTypeInferrence.js";
|
|
5
5
|
|
|
@@ -2,7 +2,7 @@ import { AbstractActionDescription } from "./AbstractActionDescription.js";
|
|
|
2
2
|
import { assert } from "../../../../../core/assert.js";
|
|
3
3
|
import { ActionBehavior } from "../../../../intelligence/behavior/primitive/ActionBehavior.js";
|
|
4
4
|
import { Transform } from "../../../transform/Transform.js";
|
|
5
|
-
import { compileReactiveExpression } from "../../../../../core/
|
|
5
|
+
import { compileReactiveExpression } from "../../../../../core/lang/reactive/compileReactiveExpression.js";
|
|
6
6
|
|
|
7
7
|
export class SendRequestActionDescription extends AbstractActionDescription {
|
|
8
8
|
constructor() {
|
package/src/engine/ecs/dynamic_actions/actions/definition/WhiteToBlackboardActionDescription.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractActionDescription } from "./AbstractActionDescription.js";
|
|
2
2
|
import { ActionBehavior } from "../../../../intelligence/behavior/primitive/ActionBehavior.js";
|
|
3
3
|
import { Blackboard } from "../../../../intelligence/blackboard/Blackboard.js";
|
|
4
|
-
import { compileReactiveExpression } from "../../../../../core/
|
|
4
|
+
import { compileReactiveExpression } from "../../../../../core/lang/reactive/compileReactiveExpression.js";
|
|
5
5
|
import { assert } from "../../../../../core/assert.js";
|
|
6
6
|
|
|
7
7
|
export class WhiteToBlackboardActionDescription extends AbstractActionDescription {
|
|
@@ -2,7 +2,7 @@ import UUID from "../../../../core/UUID.js";
|
|
|
2
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
3
|
import { inferReactiveExpressionTypes } from "../../../../core/model/reactive/transform/ReactiveTypeInferrence.js";
|
|
4
4
|
import DataType from "../../../../core/parser/simple/DataType.js";
|
|
5
|
-
import { compileReactiveExpression } from "../../../../core/
|
|
5
|
+
import { compileReactiveExpression } from "../../../../core/lang/reactive/compileReactiveExpression.js";
|
|
6
6
|
import { deserializeActionFromJSON } from "../actions/definition/deserializeActionFromJSON.js";
|
|
7
7
|
import { DynamicRuleCooldownDescription } from "./DynamicRuleCooldownDescription.js";
|
|
8
8
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Vector1 from "../../../core/geom/Vector1.js";
|
|
2
|
-
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
3
2
|
|
|
4
3
|
export class FogOfWarRevealer {
|
|
5
4
|
constructor() {
|
|
@@ -28,29 +27,3 @@ export class FogOfWarRevealer {
|
|
|
28
27
|
FogOfWarRevealer.typeName = 'FogOfWarRevealer';
|
|
29
28
|
|
|
30
29
|
|
|
31
|
-
export class FogOfWarRevealerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
34
|
-
|
|
35
|
-
this.klass = FogOfWarRevealer;
|
|
36
|
-
this.version = 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {BinaryBuffer} buffer
|
|
42
|
-
* @param {FogOfWarRevealer} value
|
|
43
|
-
*/
|
|
44
|
-
serialize(buffer, value) {
|
|
45
|
-
value.radius.toBinaryBuffer(buffer);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {BinaryBuffer} buffer
|
|
51
|
-
* @param {FogOfWarRevealer} value
|
|
52
|
-
*/
|
|
53
|
-
deserialize(buffer, value) {
|
|
54
|
-
value.radius.fromBinaryBuffer(buffer);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { FogOfWarRevealer } from "../FogOfWarRevealer.js";
|
|
3
|
+
|
|
4
|
+
export class FogOfWarRevealerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = FogOfWarRevealer;
|
|
9
|
+
this.version = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {BinaryBuffer} buffer
|
|
15
|
+
* @param {FogOfWarRevealer} value
|
|
16
|
+
*/
|
|
17
|
+
serialize(buffer, value) {
|
|
18
|
+
value.radius.toBinaryBuffer(buffer);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {BinaryBuffer} buffer
|
|
24
|
+
* @param {FogOfWarRevealer} value
|
|
25
|
+
*/
|
|
26
|
+
deserialize(buffer, value) {
|
|
27
|
+
value.radius.fromBinaryBuffer(buffer);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TransformSerializationAdapter } from "./TransformSerializationAdapter.js";
|
|
2
|
+
import { Transform } from "./Transform.js";
|
|
3
|
+
import { BinaryBuffer } from "../../../core/binary/BinaryBuffer.js";
|
|
4
|
+
|
|
5
|
+
test("to/from consistency", () => {
|
|
6
|
+
const adapter = new TransformSerializationAdapter();
|
|
7
|
+
|
|
8
|
+
const expected = new Transform();
|
|
9
|
+
expected.position.set(1, 3, -7.3);
|
|
10
|
+
expected.scale.set(-5, 7, -13.8);
|
|
11
|
+
expected.rotation.set(17, -27, 31, 37);
|
|
12
|
+
|
|
13
|
+
expected.rotation.normalize();
|
|
14
|
+
|
|
15
|
+
const buffer = new BinaryBuffer();
|
|
16
|
+
|
|
17
|
+
adapter.serialize(buffer, expected);
|
|
18
|
+
|
|
19
|
+
buffer.position = 0;
|
|
20
|
+
|
|
21
|
+
const actual = new Transform();
|
|
22
|
+
|
|
23
|
+
adapter.deserialize(buffer, actual);
|
|
24
|
+
|
|
25
|
+
expect(actual.position.roughlyEquals(expected.position)).toBe(true);
|
|
26
|
+
expect(actual.scale.roughlyEquals(expected.scale)).toBe(true);
|
|
27
|
+
expect(actual.rotation.roughlyEquals(expected.rotation, 0.001)).toBe(true);
|
|
28
|
+
});
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { noop } from "../../core/function/Functions.js";
|
|
2
2
|
import Signal from "../../core/events/signal/Signal.js";
|
|
3
3
|
import { OptionAbstract } from "./OptionAbstract.js";
|
|
4
|
+
import { assert } from "../../core/assert.js";
|
|
4
5
|
|
|
5
6
|
export class Option extends OptionAbstract {
|
|
7
|
+
|
|
8
|
+
on = {
|
|
9
|
+
written: new Signal(),
|
|
10
|
+
writeFailed: new Signal(),
|
|
11
|
+
settingsUpdated: new Signal()
|
|
12
|
+
};
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
*
|
|
8
16
|
* @param {string} id
|
|
@@ -16,18 +24,32 @@ export class Option extends OptionAbstract {
|
|
|
16
24
|
}) {
|
|
17
25
|
super(id);
|
|
18
26
|
|
|
27
|
+
assert.isFunction(read, 'read');
|
|
28
|
+
|
|
19
29
|
const self = this;
|
|
20
30
|
|
|
21
31
|
function wrappedWrite(v) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
let result;
|
|
33
|
+
|
|
34
|
+
let exception_thrown = false;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
result = write(v);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
exception_thrown = true;
|
|
40
|
+
|
|
41
|
+
self.on.writeFailed.send2(v, e);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!exception_thrown) {
|
|
45
|
+
if (result !== undefined && typeof result.then === "function") {
|
|
46
|
+
result.then(
|
|
47
|
+
() => self.on.written.send1(v),
|
|
48
|
+
(e) => self.on.writeFailed.send2(v, e)
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
self.on.written.send1(v);
|
|
52
|
+
}
|
|
31
53
|
}
|
|
32
54
|
|
|
33
55
|
return result;
|
|
@@ -43,13 +65,13 @@ export class Option extends OptionAbstract {
|
|
|
43
65
|
*/
|
|
44
66
|
this.isTransient = (settings.transient === true);
|
|
45
67
|
|
|
46
|
-
this.on = {
|
|
47
|
-
written: new Signal(),
|
|
48
|
-
writeFailed: new Signal(),
|
|
49
|
-
settingsUpdated: new Signal()
|
|
50
|
-
};
|
|
51
68
|
}
|
|
52
69
|
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param {string} key
|
|
73
|
+
* @param {number|boolean|string} value
|
|
74
|
+
*/
|
|
53
75
|
setSetting(key, value) {
|
|
54
76
|
this.settings[key] = value;
|
|
55
77
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Option } from "./Option.js";
|
|
2
|
+
import { returnOne } from "../../core/function/Functions.js";
|
|
3
|
+
|
|
4
|
+
test("constructing a simple valid option", () => {
|
|
5
|
+
const option = new Option("x", returnOne);
|
|
6
|
+
|
|
7
|
+
expect(option.id).toEqual('x');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("'written' signal is invoked after write succeeds", () => {
|
|
11
|
+
|
|
12
|
+
let value = 13;
|
|
13
|
+
|
|
14
|
+
const opt = new Option("x", () => value, v => value = v);
|
|
15
|
+
|
|
16
|
+
const callback = jest.fn();
|
|
17
|
+
|
|
18
|
+
opt.on.written.add(callback);
|
|
19
|
+
|
|
20
|
+
opt.write(7);
|
|
21
|
+
|
|
22
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("'writeFailed' signal is invoked after write throws", () => {
|
|
27
|
+
|
|
28
|
+
let value = 13;
|
|
29
|
+
|
|
30
|
+
const opt = new Option("x", () => value, v => value = v);
|
|
31
|
+
|
|
32
|
+
const callback = jest.fn();
|
|
33
|
+
|
|
34
|
+
opt.on.written.add(callback);
|
|
35
|
+
|
|
36
|
+
opt.write(7);
|
|
37
|
+
|
|
38
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("toJSON", () => {
|
|
42
|
+
|
|
43
|
+
let value = 13;
|
|
44
|
+
|
|
45
|
+
const opt = new Option("x", () => value, v => value = v);
|
|
46
|
+
|
|
47
|
+
expect(opt.toJSON()).toBe(13);
|
|
48
|
+
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("fromJSON", () => {
|
|
52
|
+
|
|
53
|
+
let value = 1;
|
|
54
|
+
|
|
55
|
+
const opt = new Option("x", () => value, v => value = v);
|
|
56
|
+
|
|
57
|
+
opt.fromJSON(17);
|
|
58
|
+
|
|
59
|
+
expect(value).toBe(17);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("computePath on a detached option should be just the ID of that option", () => {
|
|
65
|
+
const op = new Option("x", returnOne);
|
|
66
|
+
|
|
67
|
+
expect(op.computePath()).toEqual(["x"]);
|
|
68
|
+
});
|
|
69
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Reference } from "./Reference.js";
|
|
2
|
+
|
|
3
|
+
test("constructor does not throw", () => {
|
|
4
|
+
expect(() => new Reference()).not.toThrow();
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test("newly created reference is unbound", () => {
|
|
8
|
+
|
|
9
|
+
const ref = new Reference();
|
|
10
|
+
|
|
11
|
+
expect(ref.bound).toBe(false);
|
|
12
|
+
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("bind sets value", () => {
|
|
16
|
+
const ref = new Reference();
|
|
17
|
+
|
|
18
|
+
ref.bind(7);
|
|
19
|
+
|
|
20
|
+
expect(ref.getValue()).toBe(7);
|
|
21
|
+
expect(ref.bound).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("re-binding a live reference throws an exception", () => {
|
|
25
|
+
|
|
26
|
+
const ref = new Reference();
|
|
27
|
+
|
|
28
|
+
ref.bind(7);
|
|
29
|
+
|
|
30
|
+
expect(() => ref.bind(13)).toThrow();
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("release resets reference", () => {
|
|
35
|
+
|
|
36
|
+
const ref = new Reference();
|
|
37
|
+
|
|
38
|
+
ref.bind(7);
|
|
39
|
+
|
|
40
|
+
ref.release();
|
|
41
|
+
|
|
42
|
+
expect(ref.getValue()).toBeNull();
|
|
43
|
+
expect(ref.bound).toBe(false);
|
|
44
|
+
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export class BVHNodeProxy {
|
|
2
|
-
constructor() {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @type {number}
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
this.__node = -1;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @type {ExplicitBinaryBoundingVolumeHierarchy|null}
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
this.__tree = null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {number} node
|
|
21
|
-
* @param {ExplicitBinaryBoundingVolumeHierarchy} tree
|
|
22
|
-
*/
|
|
23
|
-
bind(node, tree) {
|
|
24
|
-
this.__node = node;
|
|
25
|
-
this.__tree = tree;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {number} x0
|
|
31
|
-
* @param {number} y0
|
|
32
|
-
* @param {number} z0
|
|
33
|
-
* @param {number} x1
|
|
34
|
-
* @param {number} y1
|
|
35
|
-
* @param {number} z1
|
|
36
|
-
*/
|
|
37
|
-
set_bounds(x0, y0, z0, x1, y1, z1) {
|
|
38
|
-
this.__tree.node_set_aabb_primitive(this.__node,
|
|
39
|
-
x0, y0, z0, x1, y1, z1
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
disconnect() {
|
|
44
|
-
this.__tree.remove_leaf(this.__node);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
destroy() {
|
|
48
|
-
this.__tree.release_node(this.__node);
|
|
49
|
-
|
|
50
|
-
this.__tree = null;
|
|
51
|
-
this.__node = -1;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/generation/rules/{CellMatcherContainsTag.spec.js → CellMatcherLayerBitMaskTest.spec.js}
RENAMED
|
File without changes
|