@woosh/meep-engine 2.55.0 → 2.56.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.
- package/editor/view/node-graph/PortView.js +2 -2
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.js +2 -1
- package/src/core/cache/LoadingCache.js +10 -5
- package/src/core/collection/array/array_remove_element.js +6 -9
- package/src/core/collection/array/array_remove_first.js +13 -6
- package/src/core/collection/array/array_remove_first.spec.js +39 -0
- package/src/core/collection/array/binarySearchHighIndex.spec.js +10 -9
- package/src/core/collection/heap/Uin32Heap.spec.js +36 -0
- package/src/core/collection/heap/Uint32Heap.js +10 -5
- package/src/core/function/FunctionCompiler.js +4 -4
- package/src/core/function/Functions.js +0 -19
- package/src/core/geom/3d/SurfacePoint3.js +30 -20
- package/src/core/geom/3d/SurfacePoint3.spec.js +116 -0
- package/src/core/geom/3d/aabb/AABB3.js +10 -9
- package/src/core/geom/3d/aabb/{aabb3_array_contains_point.js → aabb3_array_intersects_point.js} +4 -1
- package/src/core/geom/3d/aabb/aabb3_from_min_max.js +25 -1
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +2 -25
- package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +5 -1
- package/src/core/geom/3d/apply_mat4_transform_to_direction_v3_array.js +5 -1
- package/src/core/geom/3d/apply_mat4_transform_to_v3_array.js +5 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +2 -2
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.spec.js +26 -0
- package/src/core/geom/3d/v3_compute_triangle_normal.spec.js +18 -0
- package/src/core/geom/Vector2.js +1 -1
- package/src/core/geom/Vector3.js +1 -1
- package/src/core/geom/packing/miniball/Miniball.spec.js +24 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.js +2 -2
- package/src/core/model/object/read_property.js +2 -2
- package/src/core/model/object/write_property.js +3 -3
- package/src/core/primitives/numbers/compareNumbers.js +4 -4
- package/src/core/primitives/numbers/number_compare_ascending.js +9 -0
- package/src/core/primitives/numbers/number_compare_ascending.spec.js +9 -0
- package/src/core/primitives/numbers/number_compare_descending.js +9 -0
- package/src/core/primitives/numbers/number_compare_descending.spec.js +9 -0
- package/src/core/primitives/numbers/number_format_by_thousands.spec.js +12 -0
- package/src/core/primitives/numbers/number_pretty_print.js +1 -1
- package/src/core/primitives/strings/compareStrings.spec.js +12 -0
- package/src/core/primitives/strings/string_capitalize.js +15 -0
- package/src/core/primitives/strings/string_capitalize.spec.js +13 -0
- package/src/core/primitives/strings/string_compute_byte_size.js +21 -0
- package/src/core/primitives/strings/string_compute_common_prefix.js +44 -0
- package/src/core/primitives/strings/string_compute_common_prefix.spec.js +23 -0
- package/src/core/primitives/strings/string_format_camel_to_kebab.js +9 -0
- package/src/core/primitives/strings/string_format_camel_to_kebab.spec.js +8 -0
- package/src/core/primitives/strings/string_format_kebab_to_underscore.js +8 -0
- package/src/core/time/current_time_in_seconds.js +11 -0
- package/src/engine/Clock.js +3 -13
- package/src/engine/animation/curve/AnimationCurve.spec.js +27 -0
- package/src/engine/asset/AssetManager.js +2 -2
- package/src/engine/ecs/EntityManager.js +8 -1
- package/src/engine/ecs/EntityManager.spec.js +56 -6
- package/src/engine/ecs/animation/Animation.spec.js +22 -0
- package/src/engine/ecs/attachment/Attachment.js +24 -25
- package/src/engine/ecs/attachment/AttachmentBinding.js +27 -30
- package/src/engine/ecs/attachment/AttachmentSystem.js +21 -24
- package/src/engine/ecs/attachment/BoneAttachmentBinding.js +6 -9
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +0 -3
- package/src/engine/ecs/components/CharacterController.js +24 -18
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +3 -2
- package/src/engine/ecs/fow/FogOfWarRevealer.js +2 -3
- package/src/engine/ecs/ik/IKMath.js +6 -1
- package/src/engine/ecs/ik/IKProblem.js +17 -17
- package/src/engine/ecs/ik/InverseKinematics.js +6 -7
- package/src/engine/ecs/ik/InverseKinematicsSystem.js +24 -26
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +3 -3
- package/src/engine/ecs/systems/TagSystem.js +1 -6
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +2 -2
- package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +14 -0
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.js +21 -9
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.spec.js +79 -0
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.spec.js +7 -6
- package/src/engine/simulation/Ticker.js +17 -20
- package/src/generation/GridTaskGroup.js +5 -9
- package/src/generation/filtering/numeric/CellFilterCache.js +12 -16
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +31 -32
- package/src/generation/filtering/numeric/complex/CellFilterLookupTable.js +6 -9
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +7 -10
- package/src/generation/filtering/numeric/complex/CellFilterSobel.js +6 -9
- package/src/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +18 -21
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +24 -25
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +1 -1
- package/src/generation/grid/GridData.js +23 -22
- package/src/generation/grid/GridData.spec.js +41 -0
- package/src/generation/grid/GridTaskGenerator.js +7 -8
- package/src/generation/grid/layers/GridDataLayer.js +23 -25
- package/src/generation/markers/GridActionRuleSet.js +20 -22
- package/src/generation/markers/GridCellActionPlaceMarker.js +40 -43
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.js +7 -9
- package/src/generation/markers/MarkerNode.js +44 -44
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +15 -18
- package/src/generation/markers/actions/MarkerNodeActionSequence.js +6 -9
- package/src/generation/markers/actions/MarkerNodeProcessingRuleSet.js +5 -7
- package/src/generation/markers/actions/MarkerProcessingRule.js +25 -26
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +12 -15
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.js +2 -5
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.js +6 -9
- package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.js +8 -11
- package/src/generation/markers/actions/probability/MarkerNodeActionWeightedElement.js +13 -13
- package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +5 -8
- package/src/generation/markers/actions/util/GridCellActionLogToConsole.js +1 -4
- package/src/generation/markers/emitter/MarkerNodeConsumerBuffer.js +10 -13
- package/src/generation/markers/emitter/MarkerNodeEmitterFromAction.js +5 -9
- package/src/generation/markers/emitter/MarkerNodeEmitterGridCellAction.js +12 -15
- package/src/generation/markers/emitter/MarkerNodeEmitterGroup.js +5 -8
- package/src/generation/markers/emitter/MarkerNodeEmitterPredicated.js +18 -21
- package/src/generation/markers/matcher/MarkerNodeMatcher.js +2 -1
- package/src/generation/markers/matcher/MarkerNodeMatcherBinary.js +12 -13
- package/src/generation/markers/matcher/MarkerNodeMatcherContainsTag.js +7 -9
- package/src/generation/markers/matcher/MarkerNodeMatcherNot.js +7 -9
- package/src/generation/markers/predicate/GridDataNodePredicateBinary.js +10 -14
- package/src/generation/markers/predicate/GridDataNodePredicateNot.js +9 -11
- package/src/generation/markers/predicate/GridDataNodePredicateOverlaps.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.js +2 -6
- package/src/generation/markers/transform/MarkerNodeTransformerAddPositionYFromFilter.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -4
- package/src/generation/markers/transform/MarkerNodeTransformerRecordProperty.js +12 -15
- package/src/generation/markers/transform/MarkerNodeTransformerRecordPropertyClosure.js +14 -17
- package/src/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +21 -23
- package/src/generation/markers/transform/MarkerNodeTransformerRemoveTag.js +1 -4
- package/src/generation/markers/transform/MarkerNodeTransformerSequence.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js +13 -17
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js +12 -16
- package/src/generation/placement/GridCellActionTransformNearbyMarkers.js +26 -29
- package/src/generation/placement/GridCellPlacementRule.js +30 -32
- package/src/generation/placement/action/GridCellActionPlaceTags.js +26 -28
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +16 -20
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +13 -16
- package/src/generation/placement/action/random/weighted/WeightedGridCellAction.js +11 -14
- package/src/generation/placement/action/util/CellMatcherWithinAABB.js +2 -6
- package/src/generation/placement/action/util/GridCellActionSequence.js +7 -9
- package/src/generation/placement/action/util/GridCellDisplacedAction.js +9 -12
- package/src/generation/rules/CellMatcherFromFilter.js +6 -9
- package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -9
- package/src/generation/rules/GridLayerCellMatcher.js +11 -14
- package/src/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +11 -14
- package/src/generation/rules/cell/CellMatcherGridPattern.js +6 -8
- package/src/generation/rules/cell/GridPatternMatcherCell.js +11 -12
- package/src/generation/rules/logic/CellMatcherBinary.js +10 -14
- package/src/generation/rules/logic/CellMatcherDecorator.js +5 -8
- package/src/generation/theme/AreaMask.js +15 -17
- package/src/generation/theme/AreaTheme.js +7 -8
- package/src/generation/theme/TerrainLayerDescription.js +10 -12
- package/src/generation/theme/TerrainLayerRule.js +11 -13
- package/src/generation/theme/TerrainTheme.js +6 -7
- package/src/generation/theme/Theme.js +15 -17
- package/src/generation/theme/ThemeEngine.js +16 -18
- package/src/view/string_tag_to_css_class_name.js +2 -2
- package/src/view/tooltip/gml/TooltipParser.js +2 -2
- package/src/core/cache/PersistentCacheAdapter.js +0 -378
- package/src/core/primitives/strings/StringUtils.js +0 -105
- package/src/core/primitives/strings/StringUtils.spec.js +0 -42
- package/src/engine/ecs/components/MonsterAI.js +0 -15
- package/src/generation/markers/MarkerRelation.js +0 -13
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { DrawMode } from "../../DrawMode.js";
|
|
2
2
|
|
|
3
3
|
export class SGCacheKey {
|
|
4
|
+
/**
|
|
5
|
+
* ID of geometry
|
|
6
|
+
* @type {number}
|
|
7
|
+
*/
|
|
4
8
|
geometry = -1;
|
|
9
|
+
/**
|
|
10
|
+
* ID of material
|
|
11
|
+
* @type {number}
|
|
12
|
+
*/
|
|
5
13
|
material = -1;
|
|
6
14
|
/**
|
|
7
15
|
*
|
|
@@ -9,9 +17,13 @@ export class SGCacheKey {
|
|
|
9
17
|
*/
|
|
10
18
|
mode = DrawMode.Triangles;
|
|
11
19
|
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
12
24
|
flags = 0;
|
|
13
25
|
|
|
14
|
-
hash(){
|
|
26
|
+
hash() {
|
|
15
27
|
return this.geometry ^ this.material;
|
|
16
28
|
}
|
|
17
29
|
|
|
@@ -20,29 +32,29 @@ export class SGCacheKey {
|
|
|
20
32
|
* @param {SGCacheKey} other
|
|
21
33
|
* @returns {boolean}
|
|
22
34
|
*/
|
|
23
|
-
equals(other){
|
|
35
|
+
equals(other) {
|
|
24
36
|
return this.geometry === other.geometry
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
&& this.material === other.material
|
|
38
|
+
&& this.mode === other.mode
|
|
39
|
+
&& this.flags === other.flags;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
/**
|
|
31
43
|
*
|
|
32
44
|
* @param {SGCacheKey} other
|
|
33
45
|
*/
|
|
34
|
-
copy(other){
|
|
46
|
+
copy(other) {
|
|
35
47
|
this.geometry = other.geometry;
|
|
36
48
|
this.material = other.material;
|
|
37
49
|
this.mode = other.mode;
|
|
38
50
|
this.flags = other.flags;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
|
-
clone(){
|
|
53
|
+
clone() {
|
|
42
54
|
const r = new SGCacheKey();
|
|
43
55
|
|
|
44
56
|
r.copy(this);
|
|
45
|
-
|
|
57
|
+
|
|
46
58
|
return r;
|
|
47
59
|
}
|
|
48
60
|
|
|
@@ -50,7 +62,7 @@ export class SGCacheKey {
|
|
|
50
62
|
*
|
|
51
63
|
* @param {ShadedGeometry} sg
|
|
52
64
|
*/
|
|
53
|
-
fromSG(sg){
|
|
65
|
+
fromSG(sg) {
|
|
54
66
|
this.geometry = sg.geometry.id;
|
|
55
67
|
this.material = sg.material.id;
|
|
56
68
|
this.mode = sg.mode;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SGCacheKey } from "./SGCacheKey.js";
|
|
2
|
+
import { DrawMode } from "../../DrawMode.js";
|
|
3
|
+
|
|
4
|
+
test("constructor does not throw", () => {
|
|
5
|
+
new SGCacheKey()
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("equals", () => {
|
|
9
|
+
const a = new SGCacheKey();
|
|
10
|
+
|
|
11
|
+
a.geometry = 3;
|
|
12
|
+
a.material = 7;
|
|
13
|
+
a.mode = DrawMode.Triangles;
|
|
14
|
+
a.flags = 0xBEEF;
|
|
15
|
+
|
|
16
|
+
const b = new SGCacheKey();
|
|
17
|
+
|
|
18
|
+
b.geometry = 3;
|
|
19
|
+
b.material = 7;
|
|
20
|
+
b.mode = DrawMode.Triangles;
|
|
21
|
+
b.flags = 0xBEEF;
|
|
22
|
+
|
|
23
|
+
expect(a.equals(b)).toBe(true);
|
|
24
|
+
|
|
25
|
+
const c = new SGCacheKey();
|
|
26
|
+
|
|
27
|
+
c.geometry = 5;
|
|
28
|
+
c.material = 7;
|
|
29
|
+
c.mode = DrawMode.Triangles;
|
|
30
|
+
c.flags = 0xBEEF;
|
|
31
|
+
|
|
32
|
+
expect(a.equals(c)).toBe(false);
|
|
33
|
+
|
|
34
|
+
const d = new SGCacheKey();
|
|
35
|
+
|
|
36
|
+
d.geometry = 3;
|
|
37
|
+
d.material = 11;
|
|
38
|
+
d.mode = DrawMode.Triangles;
|
|
39
|
+
d.flags = 0xBEEF;
|
|
40
|
+
|
|
41
|
+
expect(a.equals(d)).toBe(false);
|
|
42
|
+
|
|
43
|
+
const e = new SGCacheKey();
|
|
44
|
+
|
|
45
|
+
e.geometry = 3;
|
|
46
|
+
e.material = 7;
|
|
47
|
+
e.mode = DrawMode.Points;
|
|
48
|
+
e.flags = 0xBEEF;
|
|
49
|
+
|
|
50
|
+
expect(a.equals(e)).toBe(false);
|
|
51
|
+
|
|
52
|
+
const f = new SGCacheKey();
|
|
53
|
+
|
|
54
|
+
f.geometry = 3;
|
|
55
|
+
f.material = 7;
|
|
56
|
+
f.mode = DrawMode.Triangles;
|
|
57
|
+
f.flags = 0xCAFE;
|
|
58
|
+
|
|
59
|
+
expect(a.equals(f)).toBe(false);
|
|
60
|
+
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("copy", () => {
|
|
64
|
+
const a = new SGCacheKey();
|
|
65
|
+
|
|
66
|
+
a.geometry = 3;
|
|
67
|
+
a.material = 7;
|
|
68
|
+
a.mode = DrawMode.Triangles;
|
|
69
|
+
a.flags = 0xBEEF;
|
|
70
|
+
|
|
71
|
+
const b = new SGCacheKey();
|
|
72
|
+
|
|
73
|
+
b.copy(a);
|
|
74
|
+
|
|
75
|
+
expect(b.geometry).toEqual(3);
|
|
76
|
+
expect(b.material).toEqual(7);
|
|
77
|
+
expect(b.mode).toEqual(DrawMode.Triangles);
|
|
78
|
+
expect(b.flags).toEqual(0xBEEF);
|
|
79
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IncrementalDeltaSet } from "./IncrementalDeltaSet.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
3
4
|
|
|
4
5
|
test('set is sorted after insert, push 1,2', () => {
|
|
5
|
-
const set = new IncrementalDeltaSet(
|
|
6
|
+
const set = new IncrementalDeltaSet(number_compare_ascending);
|
|
6
7
|
|
|
7
8
|
set.initializeUpdate();
|
|
8
9
|
|
|
@@ -16,7 +17,7 @@ test('set is sorted after insert, push 1,2', () => {
|
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
test('set is sorted after insert, push 2,1', () => {
|
|
19
|
-
const set = new IncrementalDeltaSet(
|
|
20
|
+
const set = new IncrementalDeltaSet(number_compare_ascending);
|
|
20
21
|
|
|
21
22
|
set.initializeUpdate();
|
|
22
23
|
|
|
@@ -30,7 +31,7 @@ test('set is sorted after insert, push 2,1', () => {
|
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
test('set is sorted after insert, push 1,2,3', () => {
|
|
33
|
-
const set = new IncrementalDeltaSet(
|
|
34
|
+
const set = new IncrementalDeltaSet(number_compare_ascending);
|
|
34
35
|
|
|
35
36
|
set.initializeUpdate();
|
|
36
37
|
|
|
@@ -46,7 +47,7 @@ test('set is sorted after insert, push 1,2,3', () => {
|
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
test('set is sorted after insert, push 3,2,1', () => {
|
|
49
|
-
const set = new IncrementalDeltaSet(
|
|
50
|
+
const set = new IncrementalDeltaSet(number_compare_ascending);
|
|
50
51
|
|
|
51
52
|
set.initializeUpdate();
|
|
52
53
|
|
|
@@ -63,7 +64,7 @@ test('set is sorted after insert, push 3,2,1', () => {
|
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
test('add/remove callbacks', () => {
|
|
66
|
-
const set = new IncrementalDeltaSet(
|
|
67
|
+
const set = new IncrementalDeltaSet(number_compare_ascending);
|
|
67
68
|
|
|
68
69
|
const add_listener = jest.fn();
|
|
69
70
|
const remove_listener = jest.fn();
|
|
@@ -6,32 +6,29 @@ import { SignalHandler } from "../../core/events/signal/SignalHandler.js";
|
|
|
6
6
|
import { assert } from "../../core/assert.js";
|
|
7
7
|
|
|
8
8
|
class Ticker {
|
|
9
|
+
/**
|
|
10
|
+
* @readonly
|
|
11
|
+
* @type {Clock}
|
|
12
|
+
*/
|
|
13
|
+
clock = new Clock();
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
18
|
+
isRunning = false;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {SignalHandler[]}
|
|
23
|
+
*/
|
|
24
|
+
callbacks = [];
|
|
25
|
+
|
|
9
26
|
/**
|
|
10
27
|
*
|
|
11
28
|
* @constructor
|
|
12
29
|
*/
|
|
13
30
|
constructor() {
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @readonly
|
|
17
|
-
* @type {Clock}
|
|
18
|
-
*/
|
|
19
|
-
this.clock = new Clock();
|
|
20
|
-
|
|
21
|
-
|
|
22
31
|
this.clock.pause();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @private
|
|
26
|
-
* @type {boolean}
|
|
27
|
-
*/
|
|
28
|
-
this.isRunning = false;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @type {SignalHandler[]}
|
|
33
|
-
*/
|
|
34
|
-
this.callbacks = [];
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
/**
|
|
@@ -2,16 +2,12 @@ import TaskGroup from "../core/process/task/TaskGroup.js";
|
|
|
2
2
|
import { GridTaskGenerator } from "./grid/GridTaskGenerator.js";
|
|
3
3
|
|
|
4
4
|
export class GridTaskGroup extends GridTaskGenerator {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {GridTaskGenerator[]}
|
|
9
|
+
*/
|
|
10
|
+
children = [];
|
|
15
11
|
|
|
16
12
|
|
|
17
13
|
/**
|
|
@@ -4,22 +4,18 @@ import { assert } from "../../../core/assert.js";
|
|
|
4
4
|
|
|
5
5
|
export class CellFilterCache extends CellFilterUnaryOperation {
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @type {number}
|
|
20
|
-
*/
|
|
21
|
-
this.scale = 1;
|
|
22
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {Sampler2D}
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
__cache = Sampler2D.float32(1, 1, 1);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {number}
|
|
17
|
+
*/
|
|
18
|
+
scale = 1;
|
|
23
19
|
|
|
24
20
|
/**
|
|
25
21
|
*
|
|
@@ -7,38 +7,37 @@ import { CellFilter } from "../../CellFilter.js";
|
|
|
7
7
|
* Based on FXAA algorithm by NVidia
|
|
8
8
|
*/
|
|
9
9
|
export class CellFilterFXAA extends CellFilter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {CellFilter}
|
|
15
|
+
*/
|
|
16
|
+
source = null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 0.125 leaves less aliasing, but is softer (default!!!)
|
|
20
|
+
* 0.25 leaves more aliasing, and is sharper
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
edge_threshold = 0.25;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 0.06 - faster but more aliasing in darks
|
|
27
|
+
* 0.05 - default
|
|
28
|
+
* 0.04 - slower and less aliasing in darks
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
console_edge_threshold_min = 0.05;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 8.0 is sharper (default!!!)
|
|
35
|
+
* 4.0 is softer
|
|
36
|
+
* 2.0 is really soft (good only for vector renderer inputs)
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
console_edge_sharpness = 2;
|
|
40
|
+
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
43
|
*
|
|
@@ -5,15 +5,12 @@ import { assert } from "../../../../core/assert.js";
|
|
|
5
5
|
const sample = [];
|
|
6
6
|
|
|
7
7
|
export class CellFilterLookupTable extends CellFilterUnaryOperation {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
this.lut = null;
|
|
16
|
-
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {ParameterLookupTable}
|
|
12
|
+
*/
|
|
13
|
+
lut = null;
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
*
|
|
@@ -7,34 +7,31 @@ import { CellFilterDivide } from "../math/algebra/CellFilterDivide.js";
|
|
|
7
7
|
import { create_simplex_noise_2d } from "../../../../core/math/noise/create_simplex_noise_2d.js";
|
|
8
8
|
|
|
9
9
|
export class CellFilterSimplexNoise extends CellFilter {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* @private
|
|
15
13
|
* @type {function(x:number,y:number):number}
|
|
16
14
|
*/
|
|
17
|
-
|
|
15
|
+
noise = null;
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* @private
|
|
21
19
|
* @type {function}
|
|
22
20
|
*/
|
|
23
|
-
|
|
21
|
+
random = seededRandom(0);
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
scale_x = 1;
|
|
24
|
+
scale_y = 1;
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
inv_scale_x = 1;
|
|
27
|
+
inv_scale_y = 1;
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
* RNG Seed offset
|
|
33
31
|
* @type {number}
|
|
34
32
|
* @private
|
|
35
33
|
*/
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
__seed = 0;
|
|
38
35
|
|
|
39
36
|
/**
|
|
40
37
|
* Build a fractal noise filter with a given number of octaves
|
|
@@ -5,15 +5,12 @@ import { assert } from "../../../../core/assert.js";
|
|
|
5
5
|
* Sobel edge-detection filter
|
|
6
6
|
*/
|
|
7
7
|
export class CellFilterSobel extends CellFilter {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
this.source = null;
|
|
16
|
-
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {CellFilter}
|
|
12
|
+
*/
|
|
13
|
+
source = null;
|
|
17
14
|
|
|
18
15
|
initialize(grid, seed) {
|
|
19
16
|
super.initialize(grid, seed);
|
|
@@ -8,27 +8,24 @@ import { bell_membership_function } from "../../../../core/math/bell_membership_
|
|
|
8
8
|
* @see https://researchhubs.com/post/maths/fundamentals/bell-shaped-function.html
|
|
9
9
|
*/
|
|
10
10
|
export class CellFilterMembershipGeneralizedBell extends CellFilterUnaryOperation {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
this.c = 0;
|
|
31
|
-
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Controls window, larger value = larger window. Function will return exactly 0.5 at this distance away from center
|
|
14
|
+
* @type {number}
|
|
15
|
+
*/
|
|
16
|
+
a = 1;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Slope, larger slope makes function's tails sharper, meaning that values fall off faster away from center
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
b = 1;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Controls center of the bell
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
c = 0;
|
|
32
29
|
|
|
33
30
|
static from(source, a = 1, b = 1, c = 0) {
|
|
34
31
|
assert.equal(source.isCellFilter, true, 'source.isCellFilter !== true');
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { CellFilter } from "../../CellFilter.js";
|
|
2
2
|
|
|
3
3
|
export class AbstractCellFilterSampleGridLayer extends CellFilter {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
layerId = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {GridDataLayer}
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
__layer = null;
|
|
18
|
+
|
|
19
|
+
__u_scale = 0;
|
|
20
|
+
__v_scale = 0;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @type {Sampler2D}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
__sampler = null;
|
|
27
|
+
|
|
29
28
|
|
|
30
29
|
initialize(grid, seed) {
|
|
31
30
|
super.initialize(grid, seed);
|
|
@@ -9,7 +9,7 @@ export class CellFilterSampleLayerLinear extends AbstractCellFilterSampleGridLay
|
|
|
9
9
|
* @returns {CellFilterSampleLayerLinear}
|
|
10
10
|
*/
|
|
11
11
|
static from(layer) {
|
|
12
|
-
assert.
|
|
12
|
+
assert.isString(layer, 'layer');
|
|
13
13
|
|
|
14
14
|
const r = new CellFilterSampleLayerLinear();
|
|
15
15
|
|
|
@@ -11,28 +11,29 @@ import { qt_collect_by_circle } from "../../core/geom/2d/quad-tree/qt_collect_by
|
|
|
11
11
|
const marker_collection = [];
|
|
12
12
|
|
|
13
13
|
export class GridData {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
|
|
15
|
+
width = 0;
|
|
16
|
+
height = 0;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @readonly
|
|
20
|
+
* @type {OffsetScaleTransform2D}
|
|
21
|
+
*/
|
|
22
|
+
transform = new OffsetScaleTransform2D();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @readonly
|
|
26
|
+
* @type {QuadTreeNode<MarkerNode>}
|
|
27
|
+
*/
|
|
28
|
+
markers = new QuadTreeNode();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Discrete data layers
|
|
32
|
+
* @readonly
|
|
33
|
+
* @type {GridDataLayer[]}
|
|
34
|
+
*/
|
|
35
|
+
layers = [];
|
|
36
|
+
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
*
|
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
import { GridData } from "./GridData.js";
|
|
2
|
+
import { MarkerNode } from "../markers/MarkerNode.js";
|
|
3
|
+
import { MarkerNodeMatcherAny } from "../markers/matcher/MarkerNodeMatcherAny.js";
|
|
2
4
|
|
|
3
5
|
test("constructor does not throw", () => {
|
|
4
6
|
expect(() => new GridData()).not.toThrow()
|
|
5
7
|
});
|
|
8
|
+
|
|
9
|
+
test("addMarker", () => {
|
|
10
|
+
|
|
11
|
+
const data = new GridData();
|
|
12
|
+
|
|
13
|
+
const node = new MarkerNode();
|
|
14
|
+
|
|
15
|
+
data.addMarker(node);
|
|
16
|
+
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("countMarkerInCircle", () => {
|
|
20
|
+
|
|
21
|
+
const data = new GridData();
|
|
22
|
+
|
|
23
|
+
const a = new MarkerNode();
|
|
24
|
+
a.position.set(1, 0);
|
|
25
|
+
a.size = 1;
|
|
26
|
+
|
|
27
|
+
data.addMarker(a);
|
|
28
|
+
|
|
29
|
+
const b = new MarkerNode();
|
|
30
|
+
b.position.set(1.5, 0);
|
|
31
|
+
b.size = 1;
|
|
32
|
+
|
|
33
|
+
data.addMarker(b);
|
|
34
|
+
|
|
35
|
+
expect(data.countMarkerInCircle(-1.1, 0, 1, MarkerNodeMatcherAny.INSTANCE))
|
|
36
|
+
.toBe(0);
|
|
37
|
+
|
|
38
|
+
expect(data.countMarkerInCircle(0, -2, 1, MarkerNodeMatcherAny.INSTANCE))
|
|
39
|
+
.toBe(0);
|
|
40
|
+
|
|
41
|
+
expect(data.countMarkerInCircle(-0.6, 0, 1, MarkerNodeMatcherAny.INSTANCE))
|
|
42
|
+
.toBe(1);
|
|
43
|
+
|
|
44
|
+
expect(data.countMarkerInCircle(0, 0, 1, MarkerNodeMatcherAny.INSTANCE))
|
|
45
|
+
.toBe(2);
|
|
46
|
+
});
|