@woosh/meep-engine 2.118.5 → 2.118.7
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/build/meep.cjs +533 -485
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +533 -485
- package/package.json +4 -4
- package/src/core/binary/BitSet.d.ts +0 -5
- package/src/core/binary/BitSet.d.ts.map +1 -1
- package/src/core/binary/BitSet.js +2 -10
- package/src/core/binary/base64/Base64.d.ts.map +1 -0
- package/src/core/binary/largest_common_alignment_uint32.d.ts.map +1 -0
- package/src/core/{collection/array/typed → binary}/largest_common_alignment_uint32.js +1 -1
- package/src/core/collection/CuckooFilter.d.ts +34 -8
- package/src/core/collection/CuckooFilter.d.ts.map +1 -1
- package/src/core/collection/CuckooFilter.js +29 -1
- package/src/core/collection/array/typed/array_buffer_copy.d.ts.map +1 -1
- package/src/core/collection/array/typed/array_buffer_copy.js +3 -1
- package/src/core/collection/array/typed/is_array_buffer_equals.js +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.js +1 -1
- package/src/core/collection/map/HashMap.js +7 -7
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +12 -5
- package/src/core/color/operations/color_desaturate.d.ts +7 -0
- package/src/core/color/operations/color_desaturate.d.ts.map +1 -0
- package/src/core/color/operations/color_desaturate.js +16 -0
- package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/AABB2.js +43 -22
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +6 -1
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts +3 -5
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +9 -19
- package/src/core/geom/2d/rectangle_to_aabb.d.ts +8 -0
- package/src/core/geom/2d/rectangle_to_aabb.d.ts.map +1 -0
- package/src/core/geom/2d/rectangle_to_aabb.js +29 -0
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
- package/src/core/graph/graph_compute_distance_matrix.d.ts +1 -1
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_distance_matrix.js +1 -1
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts +1 -1
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_laplacian_matrix.js +1 -1
- package/src/core/graph/layout/CircleLayout.js +2 -2
- package/src/core/graph/layout/box/BoxLayouter.d.ts.map +1 -1
- package/src/core/graph/layout/box/BoxLayouter.js +11 -5
- package/src/core/graph/layout/box/aabb2_force_into_container.d.ts +7 -0
- package/src/core/graph/layout/box/aabb2_force_into_container.d.ts.map +1 -0
- package/src/core/graph/layout/box/aabb2_force_into_container.js +56 -0
- package/src/core/graph/layout/box/applyCentralGravityAABB2.d.ts.map +1 -1
- package/src/core/graph/layout/box/applyCentralGravityAABB2.js +2 -8
- package/src/core/graph/layout/box/forceIntoBox.d.ts +4 -2
- package/src/core/graph/layout/box/forceIntoBox.d.ts.map +1 -1
- package/src/core/graph/layout/box/forceIntoBox.js +5 -31
- package/src/core/graph/layout/box/position_box_next_to_box.d.ts +10 -0
- package/src/core/graph/layout/box/position_box_next_to_box.d.ts.map +1 -0
- package/src/core/graph/layout/box/position_box_next_to_box.js +218 -0
- package/src/core/graph/layout/box/pullBoxTowardsPoint.d.ts.map +1 -1
- package/src/core/graph/layout/box/pullBoxTowardsPoint.js +8 -3
- package/src/core/graph/layout/box/resolveAABB2Overlap.d.ts +2 -2
- package/src/core/graph/layout/box/resolveAABB2Overlap.d.ts.map +1 -1
- package/src/core/graph/layout/box/resolveAABB2Overlap.js +12 -4
- package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts +1 -0
- package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts.map +1 -1
- package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.js +1 -0
- package/src/core/math/matrix/SquareMatrix.d.ts.map +1 -0
- package/src/core/{graph → math/matrix}/SquareMatrix.js +3 -3
- package/src/core/math/spline/cubicCurve.d.ts +3 -8
- package/src/core/math/spline/cubicCurve.d.ts.map +1 -1
- package/src/core/math/spline/cubicCurve.js +4 -32
- package/src/core/model/reactive/js/compileReactiveToJS.d.ts.map +1 -1
- package/src/core/model/reactive/js/compileReactiveToJS.js +56 -1
- package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -2
- package/src/core/model/reactive/trigger/ReactiveTrigger.d.ts +2 -2
- package/src/core/model/reactive/trigger/ReactiveTrigger.d.ts.map +1 -1
- package/src/core/model/reactive/trigger/ReactiveTrigger.js +1 -1
- package/src/core/process/BaseProcess.d.ts.map +1 -1
- package/src/core/process/BaseProcess.js +8 -7
- package/src/core/process/SimpleLifecycle.d.ts +5 -0
- package/src/core/process/SimpleLifecycle.d.ts.map +1 -1
- package/src/core/process/SimpleLifecycle.js +8 -0
- package/src/core/process/task/Task.js +1 -1
- package/src/engine/animation/clip/AnimationClip.d.ts.map +1 -1
- package/src/engine/animation/clip/AnimationClip.js +50 -8
- package/src/engine/animation/clip/AnimationClipBinding.js +1 -1
- package/src/engine/animation/clip/AnimationTrack.d.ts +11 -1
- package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
- package/src/engine/animation/clip/AnimationTrack.js +50 -7
- package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.d.ts +8 -0
- package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.d.ts.map +1 -0
- package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.js +16 -0
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +6 -6
- package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.d.ts +3 -3
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +6 -6
- package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.js +35 -31
- package/src/generation/grid/generation/grid/GridTaskAddNodesFixed.d.ts.map +1 -1
- package/src/generation/grid/generation/grid/GridTaskAddNodesFixed.js +8 -11
- package/src/generation/grid/generation/road/RoadConnectionNetwork.d.ts +6 -2
- package/src/generation/grid/generation/road/RoadConnectionNetwork.d.ts.map +1 -1
- package/src/generation/grid/generation/road/RoadConnectionNetwork.js +36 -30
- package/src/generation/placement/action/GridCellAction.js +1 -1
- package/src/generation/theme/AreaTheme.d.ts.map +1 -1
- package/src/generation/theme/AreaTheme.js +0 -1
- package/src/generation/theme/TerrainLayerRule.d.ts.map +1 -1
- package/src/generation/theme/TerrainLayerRule.js +2 -1
- package/src/generation/theme/TerrainLayerRuleAggregator.d.ts +5 -1
- package/src/generation/theme/TerrainLayerRuleAggregator.d.ts.map +1 -1
- package/src/generation/theme/TerrainLayerRuleAggregator.js +7 -2
- package/src/generation/theme/ThemeEngine.d.ts +2 -2
- package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
- package/src/generation/theme/ThemeEngine.js +1 -4
- package/src/generation/theme/cell/CellProcessingRule.d.ts.map +1 -1
- package/src/generation/theme/cell/CellProcessingRule.js +10 -13
- package/src/generation/theme/cell/CellProcessingRuleSet.d.ts.map +1 -1
- package/src/generation/theme/cell/CellProcessingRuleSet.js +6 -7
- package/src/view/SVG.d.ts.map +1 -1
- package/src/view/SVG.js +0 -15
- package/src/view/html_element_to_aabb.d.ts +8 -0
- package/src/view/html_element_to_aabb.d.ts.map +1 -0
- package/src/view/html_element_to_aabb.js +29 -0
- package/src/view/tooltip/TooltipManager.d.ts.map +1 -1
- package/src/view/tooltip/TooltipManager.js +7 -9
- package/src/view/tooltip/TooltipView.d.ts +0 -1
- package/src/view/tooltip/TooltipView.d.ts.map +1 -1
- package/src/view/tooltip/TooltipView.js +10 -280
- package/src/view/tooltip/gml/TooltipParser.d.ts.map +1 -1
- package/src/view/tooltip/gml/TooltipParser.js +1 -13
- package/src/core/binary/Base64.d.ts.map +0 -1
- package/src/core/collection/array/typed/largest_common_alignment_uint32.d.ts.map +0 -1
- package/src/core/graph/SquareMatrix.d.ts.map +0 -1
- package/src/engine/simulation/DormandPrince.d.ts +0 -19
- package/src/engine/simulation/DormandPrince.d.ts.map +0 -1
- package/src/engine/simulation/DormandPrince.js +0 -242
- /package/src/core/binary/{Base64.d.ts → base64/Base64.d.ts} +0 -0
- /package/src/core/binary/{Base64.js → base64/Base64.js} +0 -0
- /package/src/core/{collection/array/typed → binary}/largest_common_alignment_uint32.d.ts +0 -0
- /package/src/core/{graph → math/matrix}/SquareMatrix.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BitSet } from "../binary/BitSet.js";
|
|
2
2
|
import { BinaryDataType } from "../binary/type/BinaryDataType.js";
|
|
3
3
|
import BinaryHeap from "../collection/heap/BinaryHeap.js";
|
|
4
|
-
import { SquareMatrix } from "
|
|
4
|
+
import { SquareMatrix } from "../math/matrix/SquareMatrix.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Produce a distance matrix from an input graph, tracing distances from each node to every node specified in target vector
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* @param {Map<T,number>} node_indices
|
|
8
8
|
*/
|
|
9
9
|
export function graph_compute_laplacian_matrix<T>(graph: Graph<T>, result: SquareMatrix, node_indices: Map<T, number>): void;
|
|
10
|
-
import { SquareMatrix } from "
|
|
10
|
+
import { SquareMatrix } from "../math/matrix/SquareMatrix.js";
|
|
11
11
|
//# sourceMappingURL=graph_compute_laplacian_matrix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_compute_laplacian_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_laplacian_matrix.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,2EAHW,YAAY,sCAWtB;
|
|
1
|
+
{"version":3,"file":"graph_compute_laplacian_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_laplacian_matrix.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,2EAHW,YAAY,sCAWtB;6BApB4B,gCAAgC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BinaryDataType } from "../binary/type/BinaryDataType.js";
|
|
2
|
+
import { SquareMatrix } from "../math/matrix/SquareMatrix.js";
|
|
2
3
|
import { graph_compute_adjacency_matrix } from "./graph_compute_adjacency_matrix.js";
|
|
3
4
|
import { graph_compute_degree_matrix } from "./graph_compute_degree_matrix.js";
|
|
4
|
-
import { SquareMatrix } from "./SquareMatrix.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Laplacian matrix (graph Laplacian)
|
|
@@ -249,8 +249,8 @@ function computeBoundingBox(circles) {
|
|
|
249
249
|
*/
|
|
250
250
|
export function centerCircleCollectionOn(circles, center) {
|
|
251
251
|
const bBox = computeBoundingBox(circles);
|
|
252
|
-
const dX = bBox.
|
|
253
|
-
const dY = bBox.
|
|
252
|
+
const dX = bBox.centerX - center.x;
|
|
253
|
+
const dY = bBox.centerY - center.y;
|
|
254
254
|
circles.forEach(function (b) {
|
|
255
255
|
if (b.locked) {
|
|
256
256
|
//node is locked and can't be moved
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoxLayouter.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/BoxLayouter.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BoxLayouter.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/BoxLayouter.js"],"names":[],"mappings":"AAyaA;;;;GAIG;AACH,+CAHW,KAAK,EAAE,UACP,OAAO,QASjB;kBA/aiB,gCAAgC;oBAC9B,0BAA0B;AAub9C;;;;;GAKG;AACH,mCAJW,MAAO,KAAK,CAAC,yBAEb,OAAO,QA0FjB;AArGD,gDAKC"}
|
|
@@ -8,8 +8,8 @@ import AABB2 from "../../../geom/2d/aabb/AABB2.js";
|
|
|
8
8
|
import Vector2 from "../../../geom/Vector2.js";
|
|
9
9
|
import { computeDisconnectedSubGraphs } from "../computeDisconnectedSubGraphs.js";
|
|
10
10
|
import { Connection } from "../Connection.js";
|
|
11
|
-
import { resolveAABB2Overlap } from "./resolveAABB2Overlap.js";
|
|
12
11
|
import { applyCentralGravityAABB2 } from "./applyCentralGravityAABB2.js";
|
|
12
|
+
import { resolveAABB2Overlap } from "./resolveAABB2Overlap.js";
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -40,9 +40,15 @@ function computeBoundingBox(boxes) {
|
|
|
40
40
|
const footprint = new AABB2();
|
|
41
41
|
footprint.setNegativelyInfiniteBounds();
|
|
42
42
|
|
|
43
|
-
boxes.
|
|
43
|
+
const n = boxes.length;
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < n; i++){
|
|
46
|
+
|
|
47
|
+
const b = boxes[i];
|
|
48
|
+
|
|
44
49
|
footprint.expandToFit(b);
|
|
45
|
-
|
|
50
|
+
|
|
51
|
+
}
|
|
46
52
|
|
|
47
53
|
return footprint;
|
|
48
54
|
}
|
|
@@ -424,8 +430,8 @@ function doLayerLayout(boxes) {
|
|
|
424
430
|
*/
|
|
425
431
|
export function centerAABB2CollectionOn(boxes, center) {
|
|
426
432
|
const bBox = computeBoundingBox(boxes);
|
|
427
|
-
const dX = bBox.
|
|
428
|
-
const dY = bBox.
|
|
433
|
+
const dX = bBox.centerX - center.x;
|
|
434
|
+
const dY = bBox.centerY - center.y;
|
|
429
435
|
boxes.forEach(function (b) {
|
|
430
436
|
b.move(-dX, -dY);
|
|
431
437
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aabb2_force_into_container.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/aabb2_force_into_container.js"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,+EAMC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} subject_v0
|
|
4
|
+
* @param {number} subject_v1
|
|
5
|
+
* @param {number} bounds_v0
|
|
6
|
+
* @param {number} bounds_v1
|
|
7
|
+
* @returns {number} displacement for subject to fit into bounds
|
|
8
|
+
*/
|
|
9
|
+
function interval_force_into_bounds(
|
|
10
|
+
subject_v0, subject_v1,
|
|
11
|
+
bounds_v0, bounds_v1
|
|
12
|
+
){
|
|
13
|
+
|
|
14
|
+
let displacement = 0;
|
|
15
|
+
|
|
16
|
+
const bounds_span = bounds_v1 - bounds_v0;
|
|
17
|
+
|
|
18
|
+
const subject_span = subject_v1 - subject_v0;
|
|
19
|
+
|
|
20
|
+
if(bounds_span >= subject_span) {
|
|
21
|
+
// fits
|
|
22
|
+
|
|
23
|
+
if (subject_v0 < bounds_v0) {
|
|
24
|
+
displacement = bounds_v0 - subject_v0;
|
|
25
|
+
} else if (subject_v1 > bounds_v1) {
|
|
26
|
+
displacement = bounds_v1 - subject_v1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}else{
|
|
30
|
+
// too big to fit, pick the smallest displacement to occupy entire bounds
|
|
31
|
+
|
|
32
|
+
const a = subject_v0 - bounds_v0;
|
|
33
|
+
const b = bounds_v1 - subject_v1;
|
|
34
|
+
|
|
35
|
+
if(a > 0 && a < b){
|
|
36
|
+
displacement = -a;
|
|
37
|
+
}else if(b > 0){
|
|
38
|
+
displacement = b;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return displacement;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {AABB2} container
|
|
48
|
+
* @param {AABB2} box
|
|
49
|
+
*/
|
|
50
|
+
export function aabb2_force_into_container(container, box) {
|
|
51
|
+
|
|
52
|
+
const dX = interval_force_into_bounds(box.x0, box.x1, container.x0, container.x1);
|
|
53
|
+
const dY = interval_force_into_bounds(box.y0, box.y1, container.y0, container.y1);
|
|
54
|
+
|
|
55
|
+
box.move(dX, dY);
|
|
56
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyCentralGravityAABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/applyCentralGravityAABB2.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,gDAHW,CAAC,QAAM;IAAC,MAAM,EAAC,OAAO,CAAA;CAAC,CAAC,EAAE,YAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"applyCentralGravityAABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/applyCentralGravityAABB2.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,gDAHW,CAAC,QAAM;IAAC,MAAM,EAAC,OAAO,CAAA;CAAC,CAAC,EAAE,YAC1B,MAAM,QAgBhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aabb2_compute_center_from_multiple } from "../../../geom/2d/aabb/aabb2_compute_center_from_multiple.js";
|
|
2
|
-
import
|
|
2
|
+
import { pullBoxTowardsPoint } from "./pullBoxTowardsPoint.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -11,7 +11,6 @@ export function applyCentralGravityAABB2(boxes, strength) {
|
|
|
11
11
|
|
|
12
12
|
const center = aabb2_compute_center_from_multiple(boxes);
|
|
13
13
|
|
|
14
|
-
const delta = new Vector2();
|
|
15
14
|
for (let i = 0; i < numBoxes; i++) {
|
|
16
15
|
const box = boxes[i];
|
|
17
16
|
|
|
@@ -19,11 +18,6 @@ export function applyCentralGravityAABB2(boxes, strength) {
|
|
|
19
18
|
continue;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
delta._sub(box.midX(), box.midY());
|
|
24
|
-
|
|
25
|
-
delta.multiplyScalar(strength);
|
|
26
|
-
|
|
27
|
-
box.move(delta.x, delta.y);
|
|
21
|
+
pullBoxTowardsPoint(box, center.x, center.y, strength);
|
|
28
22
|
}
|
|
29
23
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Note: assumes that boxes to be contained are strictly smaller than the container in both dimensions
|
|
3
3
|
* @param {AABB2} container
|
|
4
|
-
* @param {Array.<AABB2>} boxes
|
|
4
|
+
* @param {Array.<AABB2|{locked?:boolean}>} boxes
|
|
5
5
|
*/
|
|
6
|
-
export function forceIntoBox(container: AABB2, boxes: Array<AABB2
|
|
6
|
+
export function forceIntoBox(container: AABB2, boxes: Array<AABB2 | {
|
|
7
|
+
locked?: boolean;
|
|
8
|
+
}>): void;
|
|
7
9
|
//# sourceMappingURL=forceIntoBox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forceIntoBox.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/forceIntoBox.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"forceIntoBox.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/forceIntoBox.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sDAFW,MAAO,QAAM;IAAC,MAAM,CAAC,EAAC,OAAO,CAAA;CAAC,CAAC,QAazC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { aabb2_force_into_container } from "./aabb2_force_into_container.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Note: assumes that boxes to be contained are strictly smaller than the container in both dimensions
|
|
3
5
|
* @param {AABB2} container
|
|
4
|
-
* @param {Array.<AABB2>} boxes
|
|
6
|
+
* @param {Array.<AABB2|{locked?:boolean}>} boxes
|
|
5
7
|
*/
|
|
6
|
-
function forceIntoBox(container, boxes) {
|
|
8
|
+
export function forceIntoBox(container, boxes) {
|
|
7
9
|
for (let i = 0, l = boxes.length; i < l; i++) {
|
|
8
10
|
const box = boxes[i];
|
|
9
11
|
|
|
@@ -11,35 +13,7 @@ function forceIntoBox(container, boxes) {
|
|
|
11
13
|
continue;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
let dY = 0;
|
|
16
|
-
|
|
17
|
-
const bx0 = box.x0;
|
|
18
|
-
const bx1 = box.x1;
|
|
19
|
-
|
|
20
|
-
const by0 = box.y0;
|
|
21
|
-
const by1 = box.y1;
|
|
22
|
-
|
|
23
|
-
const cx0 = container.x0;
|
|
24
|
-
const cx1 = container.x1;
|
|
25
|
-
|
|
26
|
-
const cy0 = container.y0;
|
|
27
|
-
const cy1 = container.y1;
|
|
28
|
-
|
|
29
|
-
if (bx0 < cx0) {
|
|
30
|
-
dX = cx0 - bx0;
|
|
31
|
-
} else if (bx1 > cx1) {
|
|
32
|
-
dX = cx1 - bx1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (by0 < cy0) {
|
|
36
|
-
dY = cy0 - by0;
|
|
37
|
-
} else if (by1 > cy1) {
|
|
38
|
-
dY = cy1 - by1;
|
|
39
|
-
}
|
|
16
|
+
aabb2_force_into_container(container, box);
|
|
40
17
|
|
|
41
|
-
box.move(dX, dY);
|
|
42
18
|
}
|
|
43
19
|
}
|
|
44
|
-
|
|
45
|
-
export { forceIntoBox };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {AABB2} box
|
|
4
|
+
* @param {AABB2} target
|
|
5
|
+
* @param {AABB2} bounds
|
|
6
|
+
* @returns {AABB2} input {@link box} parameter
|
|
7
|
+
*/
|
|
8
|
+
export function position_box_next_to_box(box: AABB2, target: AABB2, bounds: AABB2): AABB2;
|
|
9
|
+
import AABB2 from "../../../geom/2d/aabb/AABB2.js";
|
|
10
|
+
//# sourceMappingURL=position_box_next_to_box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position_box_next_to_box.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/position_box_next_to_box.js"],"names":[],"mappings":"AAyJA;;;;;;GAMG;AACH,8CALW,KAAK,UACL,KAAK,UACL,KAAK,GACH,KAAK,CA2DjB;kBAzNiB,gCAAgC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import AABB2 from "../../../geom/2d/aabb/AABB2.js";
|
|
2
|
+
import Vector2 from "../../../geom/Vector2.js";
|
|
3
|
+
import { EPSILON } from "../../../math/EPSILON.js";
|
|
4
|
+
import { forceIntoBox } from "./forceIntoBox.js";
|
|
5
|
+
import { pullBoxTowardsPoint } from "./pullBoxTowardsPoint.js";
|
|
6
|
+
import { resolveAABB2Overlap } from "./resolveAABB2Overlap.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {AABB2} box
|
|
11
|
+
* @param {AABB2} target
|
|
12
|
+
* @param {AABB2} bounds
|
|
13
|
+
* @returns {Vector2}
|
|
14
|
+
*/
|
|
15
|
+
function computeInitialPlacement(box, target, bounds) {
|
|
16
|
+
/**
|
|
17
|
+
* list of preferred directions, ordered. First direction is higher priority than the next, last is lowest priority
|
|
18
|
+
* @type {Vector2[]}
|
|
19
|
+
*/
|
|
20
|
+
const preferredDirections = [
|
|
21
|
+
Vector2.up,
|
|
22
|
+
Vector2.right,
|
|
23
|
+
Vector2.down,
|
|
24
|
+
Vector2.left
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const targetCenter = target.getCenter();
|
|
28
|
+
|
|
29
|
+
const targetH = target.getHeight();
|
|
30
|
+
const targetW = target.getWidth();
|
|
31
|
+
|
|
32
|
+
const targetDiagonal = Math.sqrt(targetH * targetH + targetW * targetW);
|
|
33
|
+
|
|
34
|
+
const boxWidth = box.getWidth();
|
|
35
|
+
const boxHeight = box.getHeight();
|
|
36
|
+
|
|
37
|
+
const boxWidth_2 = boxWidth / 2;
|
|
38
|
+
const boxHeight_2 = boxHeight / 2;
|
|
39
|
+
|
|
40
|
+
const intersectionPoint = new Vector2();
|
|
41
|
+
|
|
42
|
+
const placements = preferredDirections.map(function (direction) {
|
|
43
|
+
//invert Y axis, screen-space direction is Down(+) and Up(-)
|
|
44
|
+
const viewportDirection = direction.clone()._multiply(1, -1);
|
|
45
|
+
|
|
46
|
+
const pointOutside = viewportDirection.clone();
|
|
47
|
+
//scale vector to be larger than the box diagonal so it would intersect the boundary when placed in the middle
|
|
48
|
+
pointOutside.multiplyScalar(targetDiagonal + 1);
|
|
49
|
+
//move vector to the middle od the box
|
|
50
|
+
pointOutside.add(targetCenter);
|
|
51
|
+
|
|
52
|
+
target.lineIntersectionPoint(targetCenter, pointOutside, intersectionPoint);
|
|
53
|
+
|
|
54
|
+
//align placement to the opposite edge of the box
|
|
55
|
+
const offset = new Vector2(boxWidth_2, boxHeight_2);
|
|
56
|
+
|
|
57
|
+
offset.multiply(viewportDirection);
|
|
58
|
+
|
|
59
|
+
offset._sub(boxWidth_2, boxHeight_2);
|
|
60
|
+
|
|
61
|
+
offset.add(intersectionPoint);
|
|
62
|
+
|
|
63
|
+
return offset;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {Vector2} placement
|
|
69
|
+
* @returns {number}
|
|
70
|
+
*/
|
|
71
|
+
function computePlacementScore(placement) {
|
|
72
|
+
//find space for the tip between bounds and the target
|
|
73
|
+
const availableSpace = new AABB2();
|
|
74
|
+
|
|
75
|
+
const px0 = placement.x;
|
|
76
|
+
const px1 = px0 + boxWidth;
|
|
77
|
+
const py0 = placement.y;
|
|
78
|
+
const py1 = py0 + boxHeight;
|
|
79
|
+
|
|
80
|
+
if (px1 <= target.x0) {
|
|
81
|
+
//left
|
|
82
|
+
availableSpace.set(
|
|
83
|
+
bounds.x0,
|
|
84
|
+
bounds.y0,
|
|
85
|
+
target.x0,
|
|
86
|
+
bounds.y1
|
|
87
|
+
);
|
|
88
|
+
} else if (px0 >= target.x1) {
|
|
89
|
+
//right
|
|
90
|
+
availableSpace.set(
|
|
91
|
+
target.x1,
|
|
92
|
+
bounds.y0,
|
|
93
|
+
bounds.x1,
|
|
94
|
+
bounds.y1
|
|
95
|
+
);
|
|
96
|
+
} else if (py1 <= target.y0) {
|
|
97
|
+
//up
|
|
98
|
+
availableSpace.set(
|
|
99
|
+
bounds.x0,
|
|
100
|
+
bounds.y0,
|
|
101
|
+
bounds.x1,
|
|
102
|
+
target.y0
|
|
103
|
+
);
|
|
104
|
+
} else if (py0 >= target.y1) {
|
|
105
|
+
//bottom
|
|
106
|
+
availableSpace.set(
|
|
107
|
+
bounds.x0,
|
|
108
|
+
target.y1,
|
|
109
|
+
bounds.x1,
|
|
110
|
+
bounds.y1
|
|
111
|
+
);
|
|
112
|
+
} else {
|
|
113
|
+
//tip is inside, no arbitration
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let score = 0;
|
|
117
|
+
|
|
118
|
+
const availableWidth = availableSpace.getWidth();
|
|
119
|
+
const availableHeight = availableSpace.getHeight();
|
|
120
|
+
|
|
121
|
+
const spareWidth = availableWidth - boxWidth;
|
|
122
|
+
const spareHeight = availableHeight - boxHeight;
|
|
123
|
+
|
|
124
|
+
if (spareHeight < 0) {
|
|
125
|
+
score--;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (spareWidth < 0) {
|
|
129
|
+
score--;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return score;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//score placements
|
|
136
|
+
const scores = placements.map(computePlacementScore);
|
|
137
|
+
|
|
138
|
+
//find best placement
|
|
139
|
+
let bestIndex = 0;
|
|
140
|
+
let bestScore = scores[0];
|
|
141
|
+
|
|
142
|
+
for (let i = 1; i < scores.length; i++) {
|
|
143
|
+
const score = scores[i];
|
|
144
|
+
|
|
145
|
+
if (score > bestScore + EPSILON) {
|
|
146
|
+
bestScore = score;
|
|
147
|
+
bestIndex = i;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return placements[bestIndex];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* @param {AABB2} box
|
|
157
|
+
* @param {AABB2} target
|
|
158
|
+
* @param {AABB2} bounds
|
|
159
|
+
* @returns {AABB2} input {@link box} parameter
|
|
160
|
+
*/
|
|
161
|
+
export function position_box_next_to_box(box, target, bounds) {
|
|
162
|
+
const b = box.clone();
|
|
163
|
+
const t = target.clone();
|
|
164
|
+
|
|
165
|
+
//center box inside the bounds
|
|
166
|
+
const y0 = (bounds.height + b.height) / 2;
|
|
167
|
+
const x0 = (bounds.width + b.width) / 2;
|
|
168
|
+
|
|
169
|
+
b.set(x0, y0, x0 + b.width, y0 + b.height);
|
|
170
|
+
|
|
171
|
+
const targetCenter = new Vector2(t.centerX, t.centerY);
|
|
172
|
+
|
|
173
|
+
t.locked = true;
|
|
174
|
+
|
|
175
|
+
function touch() {
|
|
176
|
+
|
|
177
|
+
const bC = new Vector2(b.centerX, b.centerY);
|
|
178
|
+
|
|
179
|
+
const bE = new Vector2();
|
|
180
|
+
const tE = new Vector2();
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
t.lineIntersectionPoint(bC, targetCenter, tE);
|
|
184
|
+
const delta = new Vector2();
|
|
185
|
+
|
|
186
|
+
if (b.lineIntersectionPoint(bC, targetCenter, bE)) {
|
|
187
|
+
delta.copy(tE).sub(bE);
|
|
188
|
+
} else {
|
|
189
|
+
delta.copy(tE).sub(bC);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
b.move(delta.x, delta.y);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
const initialPosition = computeInitialPlacement(b, t, bounds);
|
|
197
|
+
//set bounds to initial position
|
|
198
|
+
b.set(initialPosition.x, initialPosition.y, initialPosition.x + b.width, initialPosition.y + b.height);
|
|
199
|
+
|
|
200
|
+
// touch();
|
|
201
|
+
|
|
202
|
+
function step() {
|
|
203
|
+
//pull
|
|
204
|
+
pullBoxTowardsPoint(b, initialPosition.x + b.width / 2, initialPosition.y + b.height / 2, 0.1);
|
|
205
|
+
|
|
206
|
+
resolveAABB2Overlap([b, t], 10);
|
|
207
|
+
|
|
208
|
+
forceIntoBox(bounds, [b]);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
for (let i = 0; i < 5; i++) {
|
|
212
|
+
step();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
box.copy(b);
|
|
216
|
+
|
|
217
|
+
return box;
|
|
218
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullBoxTowardsPoint.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/pullBoxTowardsPoint.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,yDAJW,MAAM,WACN,MAAM,YACN,MAAM,
|
|
1
|
+
{"version":3,"file":"pullBoxTowardsPoint.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/pullBoxTowardsPoint.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,yDAJW,MAAM,WACN,MAAM,YACN,MAAM,QAmBhB"}
|
|
@@ -5,9 +5,14 @@
|
|
|
5
5
|
* @param {number} targetY target point Y coordinate
|
|
6
6
|
* @param {number} strength
|
|
7
7
|
*/
|
|
8
|
-
export function pullBoxTowardsPoint(
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export function pullBoxTowardsPoint(
|
|
9
|
+
box,
|
|
10
|
+
targetX, targetY,
|
|
11
|
+
strength
|
|
12
|
+
) {
|
|
13
|
+
|
|
14
|
+
const midX = box.centerX;
|
|
15
|
+
const midY = box.centerY;
|
|
11
16
|
|
|
12
17
|
const deltaX = targetX - midX;
|
|
13
18
|
const deltaY = targetY - midY;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {AABB2[]} boxes
|
|
4
|
-
* @param {number} maxSteps
|
|
4
|
+
* @param {number} [maxSteps]
|
|
5
5
|
*/
|
|
6
|
-
export function resolveAABB2Overlap(boxes: AABB2[], maxSteps
|
|
6
|
+
export function resolveAABB2Overlap(boxes: AABB2[], maxSteps?: number): void;
|
|
7
7
|
//# sourceMappingURL=resolveAABB2Overlap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAABB2Overlap.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveAABB2Overlap.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,2CAHW,OAAO,
|
|
1
|
+
{"version":3,"file":"resolveAABB2Overlap.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveAABB2Overlap.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,2CAHW,OAAO,aACP,MAAM,QAuBhB"}
|
|
@@ -4,19 +4,27 @@ import { resolveBoxOverlapUsingForce } from "./resolveBoxOverlapUsingForce.js";
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {AABB2[]} boxes
|
|
7
|
-
* @param {number} maxSteps
|
|
7
|
+
* @param {number} [maxSteps]
|
|
8
8
|
*/
|
|
9
|
-
export function resolveAABB2Overlap(boxes, maxSteps) {
|
|
9
|
+
export function resolveAABB2Overlap(boxes, maxSteps=3) {
|
|
10
10
|
const forces = [];
|
|
11
11
|
|
|
12
12
|
const n = boxes.length;
|
|
13
|
+
|
|
13
14
|
for (let i = 0; i < n; i++) {
|
|
14
15
|
forces.push(new Vector2(0, 0));
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
let overlapMoves = -1;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
let steps = maxSteps;
|
|
21
|
+
|
|
22
|
+
while (steps > 0 && overlapMoves !== 0) {
|
|
23
|
+
|
|
24
|
+
steps--;
|
|
25
|
+
|
|
20
26
|
overlapMoves = resolveBoxOverlapUsingForce(forces, boxes);
|
|
27
|
+
|
|
21
28
|
}
|
|
29
|
+
|
|
22
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBoxOverlapUsingForce.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveBoxOverlapUsingForce.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"resolveBoxOverlapUsingForce.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveBoxOverlapUsingForce.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,oDAJW,OAAO,EAAE,SACT,YAAa,GACX,MAAM,CA6FlB;oBAnGmB,0BAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SquareMatrix.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/matrix/SquareMatrix.js"],"names":[],"mappings":"AAIA;IACI;;;;OAIG;IACH,kBAHW,MAAM,QACN,iBAAe,MAAM,EA2B/B;IAhBG;;;OAGG;IACH,MAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,qBAAgB;IAEhB;;OAEG;IACH,MAFU,MAAM,EAAE,CAEqB;IAG3C,gBAEC;IAED,qBAEC;IAED,oBAEC;IAED,mBAEC;IAED;;;OAGG;IACH,gBAFW,YAAY,QAItB;IAED;;;;OAIG;IACH,oBAHW,YAAY,KACZ,YAAY,QAiBtB;IAED;;OAEG;IACH,eAMC;IAED;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,YAMC;IAED;;;OAGG;IACH,YAFW,YAAY,QAMtB;IAED;;;OAGG;IACH,SAFY,YAAY,CAQvB;IAED;;OAEG;IACH,kBAcC;IAED;;;OAGG;IACH,eAFW,MAAM,EAAE,QAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,EAAE,WACR,MAAM,YAMhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,gBACN,MAAM,SACN,MAAM,QAYhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,gBACN,MAAM,GACL,MAAM,CAWjB;IAED;;;OAGG;IACH,qBAFW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAU5C;CACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assert } from "
|
|
2
|
-
import { DataType2TypedArrayConstructorMapping } from "
|
|
3
|
-
import { array_copy } from "
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { DataType2TypedArrayConstructorMapping } from "../../binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
3
|
+
import { array_copy } from "../../collection/array/array_copy.js";
|
|
4
4
|
|
|
5
5
|
export class SquareMatrix {
|
|
6
6
|
/**
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Number} t
|
|
4
|
-
* @param {Number} p0
|
|
5
|
-
* @param {Number} p1
|
|
6
|
-
* @param {Number} p2
|
|
7
|
-
* @param {Number} p3
|
|
8
|
-
* @return {Number}
|
|
2
|
+
* @deprecated use {@link spline_bezier3} directly
|
|
9
3
|
*/
|
|
10
|
-
export
|
|
4
|
+
export const cubicCurve: typeof spline_bezier3;
|
|
5
|
+
import { spline_bezier3 } from "./spline_bezier3.js";
|
|
11
6
|
//# sourceMappingURL=cubicCurve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cubicCurve.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/cubicCurve.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cubicCurve.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/cubicCurve.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,+CAAyC;+BALV,qBAAqB"}
|
|
@@ -1,34 +1,6 @@
|
|
|
1
|
+
import { spline_bezier3 } from "./spline_bezier3.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Number} t
|
|
4
|
-
* @param {Number} p0
|
|
5
|
-
* @param {Number} p1
|
|
6
|
-
* @param {Number} p2
|
|
7
|
-
* @param {Number} p3
|
|
8
|
-
* @return {Number}
|
|
4
|
+
* @deprecated use {@link spline_bezier3} directly
|
|
9
5
|
*/
|
|
10
|
-
export
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @type {number}
|
|
14
|
-
*/
|
|
15
|
-
const cX = 3 * (p1 - p0);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @type {number}
|
|
20
|
-
*/
|
|
21
|
-
const bX = 3 * (p2 - p1) - cX;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
|
-
const aX = p3 - p0 - cX - bX;
|
|
28
|
-
|
|
29
|
-
const t_2 = t * t;
|
|
30
|
-
|
|
31
|
-
const t_3 = t_2 * t;
|
|
32
|
-
|
|
33
|
-
return (aX * t_3) + (bX * t_2) + (cX * t) + p0;
|
|
34
|
-
}
|
|
6
|
+
export const cubicCurve = spline_bezier3;
|