@woosh/meep-engine 2.109.25 → 2.110.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/build/meep.cjs +229 -461
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +229 -461
- package/editor/tools/GridPaintTool.js +12 -11
- package/editor/tools/engine/ToolEngine.js +2 -1
- package/package.json +1 -1
- package/src/core/collection/heap/{FastBinaryHeap.d.ts → BinaryHeap.d.ts} +4 -4
- package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -0
- package/src/core/collection/heap/{FastBinaryHeap.js → BinaryHeap.js} +3 -3
- package/src/core/collection/heap/BinaryHeap.spec.d.ts +2 -0
- package/src/core/collection/heap/BinaryHeap.spec.d.ts.map +1 -0
- package/src/core/collection/heap/{FastBinaryHeap.spec.js → BinaryHeap.spec.js} +10 -10
- package/src/core/collection/heap/Uint32Heap.spec.d.ts +2 -0
- package/src/core/collection/heap/Uint32Heap.spec.d.ts.map +1 -0
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +1 -0
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +5 -5
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +14 -8
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +2 -2
- package/src/core/graph/Edge.d.ts +1 -0
- package/src/core/graph/Edge.d.ts.map +1 -1
- package/src/core/graph/Edge.js +5 -0
- package/src/core/graph/graph_compute_distance_matrix.js +2 -2
- package/src/core/graph/metis/cluster_mesh_metis.d.ts +9 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -0
- package/src/core/graph/metis/cluster_mesh_metis.js +31 -0
- package/src/core/graph/metis/mesh_to_metis_graph.d.ts +10 -0
- package/src/core/graph/metis/mesh_to_metis_graph.d.ts.map +1 -0
- package/src/core/graph/metis/mesh_to_metis_graph.js +64 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts +12 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -0
- package/src/core/graph/{cluster_mesh_metis.js → metis/metis_cluster_bs.js} +12 -98
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
- package/src/core/graph/mn_graph_coarsen.js +7 -3
- package/src/core/graph/mn_graph_coarsen.spec.js +2 -0
- package/src/core/math/interval/NumericInterval.d.ts +13 -7
- package/src/core/math/interval/NumericInterval.d.ts.map +1 -1
- package/src/core/math/interval/NumericInterval.js +35 -15
- package/src/engine/asset/AssetManager.js +3 -3
- package/src/engine/graphics/camera/makeOrbitalCameraController.d.ts.map +1 -1
- package/src/engine/graphics/camera/makeOrbitalCameraController.js +4 -4
- package/src/engine/graphics/geometry/VertexDataSpec.d.ts.map +1 -1
- package/src/engine/graphics/geometry/VertexDataSpec.js +4 -7
- package/src/engine/graphics/sh3/gi/material/common.glsl +45 -54
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +5 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +2 -2
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +3 -2
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +14 -7
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +17 -15
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +6 -2
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +10 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +4 -0
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -1
- package/src/engine/input/devices/LocationalInteractionMetadata.js +6 -1
- package/src/engine/input/devices/PointerDevice.d.ts +0 -3
- package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
- package/src/engine/input/devices/PointerDevice.js +49 -306
- package/src/engine/input/devices/events/PointerEvents.d.ts +14 -0
- package/src/engine/input/devices/events/PointerEvents.d.ts.map +1 -0
- package/src/engine/input/devices/events/PointerEvents.js +16 -0
- package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts.map +1 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts +10 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts.map +1 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.js +19 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.d.ts +7 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.d.ts.map +1 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.js +11 -0
- package/src/engine/input/devices/touch/TouchDevice.d.ts +20 -0
- package/src/engine/input/devices/touch/TouchDevice.d.ts.map +1 -0
- package/src/engine/input/devices/touch/TouchDevice.js +95 -0
- package/src/engine/input/devices/touch/getTouchCenter.d.ts +7 -0
- package/src/engine/input/devices/touch/getTouchCenter.d.ts.map +1 -0
- package/src/engine/input/devices/touch/getTouchCenter.js +32 -0
- package/src/engine/input/devices/touch/observePinch.d.ts +12 -0
- package/src/engine/input/devices/touch/observePinch.d.ts.map +1 -0
- package/src/engine/input/devices/touch/observePinch.js +128 -0
- package/src/engine/network/PriorityFetch.d.ts.map +1 -1
- package/src/engine/network/PriorityFetch.js +2 -2
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +3 -3
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +2 -2
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +2 -2
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
- package/src/core/collection/heap/FastBinaryHeap.d.ts.map +0 -1
- package/src/core/collection/heap/FastBinaryHeap.spec.d.ts +0 -2
- package/src/core/collection/heap/FastBinaryHeap.spec.d.ts.map +0 -1
- package/src/core/collection/heap/Uin32Heap.spec.d.ts +0 -2
- package/src/core/collection/heap/Uin32Heap.spec.d.ts.map +0 -1
- package/src/core/graph/cluster_mesh_metis.d.ts +0 -28
- package/src/core/graph/cluster_mesh_metis.d.ts.map +0 -1
- package/src/engine/input/devices/eventToSourceIdentifier.d.ts.map +0 -1
- /package/src/core/collection/heap/{Uin32Heap.spec.js → Uint32Heap.spec.js} +0 -0
- /package/src/engine/input/devices/{eventToSourceIdentifier.d.ts → events/eventToSourceIdentifier.d.ts} +0 -0
- /package/src/engine/input/devices/{eventToSourceIdentifier.js → events/eventToSourceIdentifier.js} +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import GridPosition from "../../src/engine/grid/position/GridPosition.js";
|
|
3
|
-
import GridObstacle from "../../src/engine/grid/obstacle/GridObstacle.js";
|
|
4
|
-
import Vector4 from "../../src/core/geom/Vector4.js";
|
|
5
|
-
import ObservedValue from "../../src/core/model/ObservedValue.js";
|
|
1
|
+
import { hex2rgb } from "../../src/core/color/hex/hex2rgb.js";
|
|
6
2
|
import Vector1 from "../../src/core/geom/Vector1.js";
|
|
7
|
-
import WriteGridValueAction from "../actions/concrete/WriteGridValueAction.js";
|
|
8
|
-
import PaintTerrainOverlayAction from "../actions/concrete/PaintTerrainOverlayAction.js";
|
|
9
|
-
import { decodeMouseEventButtons, PointerDevice } from "../../src/engine/input/devices/PointerDevice.js";
|
|
10
3
|
import Vector2 from "../../src/core/geom/Vector2.js";
|
|
4
|
+
import Vector4 from "../../src/core/geom/Vector4.js";
|
|
5
|
+
import ObservedValue from "../../src/core/model/ObservedValue.js";
|
|
6
|
+
import { pick } from "../../src/engine/ecs/grid/pick.js";
|
|
7
|
+
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
11
8
|
import TopDownCameraControllerSystem
|
|
12
9
|
from "../../src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
10
|
+
import GridObstacle from "../../src/engine/grid/obstacle/GridObstacle.js";
|
|
11
|
+
import GridPosition from "../../src/engine/grid/position/GridPosition.js";
|
|
12
|
+
import { decodeMouseEventButtons } from "../../src/engine/input/devices/mouse/decodeMouseEventButtons.js";
|
|
13
|
+
import { PointerDevice } from "../../src/engine/input/devices/PointerDevice.js";
|
|
14
|
+
import PaintTerrainOverlayAction from "../actions/concrete/PaintTerrainOverlayAction.js";
|
|
15
|
+
import WriteGridValueAction from "../actions/concrete/WriteGridValueAction.js";
|
|
16
|
+
import Tool from "./engine/Tool.js";
|
|
16
17
|
|
|
17
18
|
class GridPaintTool extends Tool {
|
|
18
19
|
constructor() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import List from '../../../src/core/collection/list/List.js';
|
|
2
2
|
import ObservedValue from '../../../src/core/model/ObservedValue.js';
|
|
3
3
|
import Clock from "../../../src/engine/Clock.js";
|
|
4
|
-
import { decodeMouseEventButtons
|
|
4
|
+
import { decodeMouseEventButtons } from "../../../src/engine/input/devices/mouse/decodeMouseEventButtons.js";
|
|
5
|
+
import { PointerDevice } from '../../../src/engine/input/devices/PointerDevice.js';
|
|
5
6
|
import GridPaintTool from "../GridPaintTool.js";
|
|
6
7
|
import { TerrainHeightPaintTool } from "../paint/TerrainHeightPaintTool.js";
|
|
7
8
|
import { TerrainTexturePaintTool } from "../paint/TerrainTexturePaintTool.js";
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export default BinaryHeap;
|
|
2
2
|
/**
|
|
3
3
|
* Min-Heap implementation with a score function.
|
|
4
4
|
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
5
5
|
* @template T
|
|
6
6
|
*/
|
|
7
|
-
declare class
|
|
7
|
+
declare class BinaryHeap<T> {
|
|
8
8
|
/**
|
|
9
9
|
* @template T
|
|
10
10
|
* @param {function(el:T):number} scoreFunction
|
|
@@ -93,6 +93,6 @@ declare class FastBinaryHeap<T> {
|
|
|
93
93
|
* @readonly
|
|
94
94
|
* @type {boolean}
|
|
95
95
|
*/
|
|
96
|
-
readonly
|
|
96
|
+
readonly isBinaryHeap: boolean;
|
|
97
97
|
}
|
|
98
|
-
//# sourceMappingURL=
|
|
98
|
+
//# sourceMappingURL=BinaryHeap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH;IAaI;;;;OAIG;IACH,gCAQC;IAzBD;;;OAGG;IACH,aAAU;IAEV;;;OAGG;IACH,eAAW;IASP;;;OAGG;IACH,8BAFuB,MAAM,CAEK;IAItC;;;OAGG;IACH,iBA8BC;IAED;;;OAGG;IACH,mBAmEC;IAED;;;OAGG;IACH,OAFY,CAAC,CA0BZ;IAED;;;OAGG;IACH,QAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;;OAIG;IACH,aAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAOhB;IAED;;OAEG;IACH,cAGC;IAED;;;;OAIG;IACH,eAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAWnB;IAED;;;OAGG;IACH,SAFW,CAAC,QAUX;IAGL;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;CAPhC"}
|
|
@@ -5,7 +5,7 @@ import { assert } from "../../assert.js";
|
|
|
5
5
|
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
6
6
|
* @template T
|
|
7
7
|
*/
|
|
8
|
-
class
|
|
8
|
+
class BinaryHeap {
|
|
9
9
|
/**
|
|
10
10
|
* @private
|
|
11
11
|
* @type {T[]}
|
|
@@ -278,6 +278,6 @@ class FastBinaryHeap {
|
|
|
278
278
|
* @readonly
|
|
279
279
|
* @type {boolean}
|
|
280
280
|
*/
|
|
281
|
-
|
|
281
|
+
BinaryHeap.prototype.isBinaryHeap = true;
|
|
282
282
|
|
|
283
|
-
export default
|
|
283
|
+
export default BinaryHeap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryHeap.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.spec.js"],"names":[],"mappings":""}
|
|
@@ -2,20 +2,20 @@ import { passThrough } from "../../function/passThrough.js";
|
|
|
2
2
|
import { returnZero } from "../../function/returnZero.js";
|
|
3
3
|
import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
|
|
4
4
|
import { seededRandom } from "../../math/random/seededRandom.js";
|
|
5
|
-
import
|
|
5
|
+
import BinaryHeap from "./BinaryHeap.js";
|
|
6
6
|
|
|
7
7
|
test("constructor doesn't throw", () => {
|
|
8
|
-
new
|
|
8
|
+
new BinaryHeap(returnZero);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
test("empty heap has size 0", () => {
|
|
12
|
-
const h = new
|
|
12
|
+
const h = new BinaryHeap(returnZero);
|
|
13
13
|
|
|
14
14
|
expect(h.size()).toBe(0);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
test('clear empty', () => {
|
|
18
|
-
const h = new
|
|
18
|
+
const h = new BinaryHeap(returnZero);
|
|
19
19
|
|
|
20
20
|
h.clear();
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ test('clear empty', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
test('clear heap with 1 element', () => {
|
|
27
|
-
const h = new
|
|
27
|
+
const h = new BinaryHeap(returnZero);
|
|
28
28
|
|
|
29
29
|
h.push(1);
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ test('clear heap with 1 element', () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
test("isEmpty", () => {
|
|
38
|
-
const h = new
|
|
38
|
+
const h = new BinaryHeap(returnZero);
|
|
39
39
|
|
|
40
40
|
expect(h.isEmpty()).toBe(true);
|
|
41
41
|
|
|
@@ -49,7 +49,7 @@ test("isEmpty", () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
test("push followed by a pop", () => {
|
|
52
|
-
const h = new
|
|
52
|
+
const h = new BinaryHeap(returnZero);
|
|
53
53
|
|
|
54
54
|
h.push(7);
|
|
55
55
|
|
|
@@ -63,7 +63,7 @@ test("push followed by a pop", () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
test("contains method", () => {
|
|
66
|
-
const h = new
|
|
66
|
+
const h = new BinaryHeap(returnZero);
|
|
67
67
|
|
|
68
68
|
expect(h.contains(7)).toBe(false);
|
|
69
69
|
|
|
@@ -82,7 +82,7 @@ test("contains method", () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
test("correct sorting of 4 numbers", () => {
|
|
85
|
-
const h = new
|
|
85
|
+
const h = new BinaryHeap(passThrough);
|
|
86
86
|
|
|
87
87
|
const input = [2, 7, 1, 5];
|
|
88
88
|
|
|
@@ -100,7 +100,7 @@ test("correct sorting of 4 numbers", () => {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
test.skip("performance 100k random fill -> drain", () => {
|
|
103
|
-
const h = new
|
|
103
|
+
const h = new BinaryHeap(passThrough);
|
|
104
104
|
|
|
105
105
|
const random = seededRandom(42);
|
|
106
106
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Uint32Heap.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.spec.js"],"names":[],"mappings":""}
|
|
@@ -22,4 +22,5 @@ export function collapse_edges(number_faces_to_remove: number, heap: BinaryHeap<
|
|
|
22
22
|
*/
|
|
23
23
|
export function simplifyTopoMesh(mesh: TopoMesh, num_faces_to_remove: number, restricted_vertices?: Set<number>): void;
|
|
24
24
|
import { EdgeCollapseCandidate } from "./EdgeCollapseCandidate.js";
|
|
25
|
+
import BinaryHeap from "../../../../collection/heap/BinaryHeap.js";
|
|
25
26
|
//# sourceMappingURL=simplifyTopoMesh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplifyTopoMesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/simplifyTopoMesh.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFW,qBAAqB,UAI/B;AAGD;;;;;;;GAOG;AACH,uDAPW,MAAM,
|
|
1
|
+
{"version":3,"file":"simplifyTopoMesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/simplifyTopoMesh.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFW,qBAAqB,UAI/B;AAGD;;;;;;;GAOG;AACH,uDAPW,MAAM,QACN,WAAW,qBAAqB,CAAC,wCAEjC,cAAc,qBAAqB,CAAC,qBACpC,IAAI,MAAM,aAAa,uBACvB,IAAI,MAAM,CAAC,QAyKrB;AAED;;;;;;;GAOG;AACH,sEAHW,MAAM,wBACN,IAAI,MAAM,CAAC,QAwDrB;sCAhQqC,4BAA4B;uBAJ3C,2CAA2C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import FastBinaryHeap from "../../../../collection/heap/FastBinaryHeap.js";
|
|
2
1
|
import { array_copy_unique } from "../../../../collection/array/array_copy_unique.js";
|
|
2
|
+
import BinaryHeap from "../../../../collection/heap/BinaryHeap.js";
|
|
3
|
+
import { build_edge_collapse_candidates } from "./build_edge_collapse_candidates.js";
|
|
4
|
+
import { collapse_all_degenerate_edges } from "./collapse_all_degenerate_edges.js";
|
|
5
|
+
import { collapse_degenerate_edge } from "./collapse_degenerate_edge.js";
|
|
3
6
|
import { EdgeCollapseCandidate } from "./EdgeCollapseCandidate.js";
|
|
4
7
|
import { build_vertex_quadratics } from "./quadratic/build_vertex_quadratics.js";
|
|
5
|
-
import { collapse_degenerate_edge } from "./collapse_degenerate_edge.js";
|
|
6
|
-
import { collapse_all_degenerate_edges } from "./collapse_all_degenerate_edges.js";
|
|
7
|
-
import { build_edge_collapse_candidates } from "./build_edge_collapse_candidates.js";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const scratch_array_1 = [];
|
|
@@ -220,7 +220,7 @@ export function simplifyTopoMesh(mesh, num_faces_to_remove, restricted_vertices
|
|
|
220
220
|
*
|
|
221
221
|
* @type {BinaryHeap<EdgeCollapseCandidate>}
|
|
222
222
|
*/
|
|
223
|
-
const open_set = new
|
|
223
|
+
const open_set = new BinaryHeap(extract_edge_cost);
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeTriangleRayIntersectionBarycentricEdge.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,sEAlBW,MAAM,EAAE,YACR,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,GACL,OAAO,
|
|
1
|
+
{"version":3,"file":"computeTriangleRayIntersectionBarycentricEdge.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,sEAlBW,MAAM,EAAE,YACR,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,GACL,OAAO,CAsElB"}
|
|
@@ -43,20 +43,27 @@ export function computeTriangleRayIntersectionBarycentricEdge(
|
|
|
43
43
|
//if determinant is near zero, ray lies in plane of triangle
|
|
44
44
|
const det = v3_dot(edge1_x, edge1_y, edge1_z, pvec_x, pvec_y, pvec_z);
|
|
45
45
|
|
|
46
|
+
if(det === 0){
|
|
47
|
+
// ray is parallel to the plane of the triange, no intersection possible
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
if (det <= 0) {
|
|
47
52
|
// back-face culling
|
|
48
|
-
return false;
|
|
53
|
+
// return false;
|
|
49
54
|
}
|
|
50
55
|
|
|
56
|
+
const inv_det = 1 / det;
|
|
57
|
+
|
|
51
58
|
// calculate distance from vert0 to ray origin (not really, but okay)
|
|
52
59
|
const tvec_x = origin_x - ax;
|
|
53
60
|
const tvec_y = origin_y - ay;
|
|
54
61
|
const tvec_z = origin_z - az;
|
|
55
62
|
|
|
56
63
|
// calculate u
|
|
57
|
-
const u = v3_dot(tvec_x, tvec_y, tvec_z, pvec_x, pvec_y, pvec_z);
|
|
64
|
+
const u = v3_dot(tvec_x, tvec_y, tvec_z, pvec_x, pvec_y, pvec_z)*inv_det;
|
|
58
65
|
|
|
59
|
-
if (u < 0 || u >
|
|
66
|
+
if (u < 0 || u > 1) {
|
|
60
67
|
// outside of bounds of the triangle
|
|
61
68
|
return false;
|
|
62
69
|
}
|
|
@@ -68,22 +75,21 @@ export function computeTriangleRayIntersectionBarycentricEdge(
|
|
|
68
75
|
const qvec_z = tvec_x * edge1_y - tvec_y * edge1_x;
|
|
69
76
|
|
|
70
77
|
// calculate V parameter
|
|
71
|
-
const v = v3_dot(direction_x, direction_y, direction_z, qvec_x, qvec_y, qvec_z);
|
|
78
|
+
const v = v3_dot(direction_x, direction_y, direction_z, qvec_x, qvec_y, qvec_z)*inv_det;
|
|
72
79
|
|
|
73
|
-
if (v < 0 || u + v >
|
|
80
|
+
if (v < 0 || u + v > 1) {
|
|
74
81
|
// out of bounds
|
|
75
82
|
return false;
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
|
|
79
|
-
const inv_det = 1 / det;
|
|
80
86
|
|
|
81
87
|
// calculate t, scale parameter, ray intersects triangle
|
|
82
88
|
const t = v3_dot(edge2_x, edge2_y, edge2_z, qvec_x, qvec_y, qvec_z) * inv_det;
|
|
83
89
|
|
|
84
90
|
result[0] = t;
|
|
85
|
-
result[1] = u
|
|
86
|
-
result[2] = v
|
|
91
|
+
result[1] = u ;
|
|
92
|
+
result[2] = v ;
|
|
87
93
|
|
|
88
94
|
return true;
|
|
89
95
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
|
-
import
|
|
2
|
+
import BinaryHeap from "../../../collection/heap/BinaryHeap.js";
|
|
3
3
|
import AABB2 from "../../2d/aabb/AABB2.js";
|
|
4
4
|
import { QuadTreeDatum } from "../../2d/quad-tree/QuadTreeDatum.js";
|
|
5
5
|
import { QuadTreeNode } from "../../2d/quad-tree/QuadTreeNode.js";
|
|
@@ -136,7 +136,7 @@ export class MaxRectanglesPacker {
|
|
|
136
136
|
return -Math.min(box.getWidth(), box.getHeight());
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const heap = new
|
|
139
|
+
const heap = new BinaryHeap(scoreBoxByMinSide);
|
|
140
140
|
|
|
141
141
|
for (let i = 0; i < numBoxes; i++) {
|
|
142
142
|
heap.push(i);
|
package/src/core/graph/Edge.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"gCAKU,MAAM;;;;;;AAQhB;;GAEG;AACH;IACI;;;;;OAKG;IACH,4BAmBC;IAfG;;;OAGG;IACH,WAAc;IACd;;;OAGG;IACH,YAAe;IAEf;;OAEG;IACH,WAFU,iBAAiB,CAEkB;IAGjD;;;;OAIG;IACH,eAHW,CAAC,GACA,OAAO,CAIlB;IAED;;;;;OAKG;IACH,2BAJW,CAAC,UACD,CAAC,GACC,OAAO,CASnB;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,CAAC,CAIb;IAED;;;OAGG;IACH,sBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,uBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,wBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,iBAEC;IAED,mBAEC;IAIL;;;OAGG;IACH,QAFU,OAAO,CAEI;CANpB"}
|
package/src/core/graph/Edge.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
+
import { objectKeyByValue } from "../model/object/objectKeyByValue.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -118,6 +119,10 @@ export class Edge {
|
|
|
118
119
|
return [this.first, this.second];
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
toString() {
|
|
123
|
+
return `Edge{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
|
|
124
|
+
}
|
|
125
|
+
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BitSet } from "../binary/BitSet.js";
|
|
2
2
|
import { BinaryDataType } from "../binary/type/BinaryDataType.js";
|
|
3
|
-
import
|
|
3
|
+
import BinaryHeap from "../collection/heap/BinaryHeap.js";
|
|
4
4
|
import { SquareMatrix } from "./SquareMatrix.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -40,7 +40,7 @@ export function graph_compute_distance_matrix(graph, node_array, targets, node_i
|
|
|
40
40
|
// distance to self is always 0
|
|
41
41
|
m_distances.setCellValue(source_node, source_node, 0);
|
|
42
42
|
|
|
43
|
-
const heap = new
|
|
43
|
+
const heap = new BinaryHeap(score);
|
|
44
44
|
heap.push(source_node);
|
|
45
45
|
|
|
46
46
|
while (!heap.isEmpty()) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Uint32Array} result
|
|
4
|
+
* @param {TopoMesh} mesh
|
|
5
|
+
* @param {number} patch_size
|
|
6
|
+
* @returns {number}
|
|
7
|
+
*/
|
|
8
|
+
export function cluster_mesh_metis(result: Uint32Array, mesh: TopoMesh, patch_size: number): number;
|
|
9
|
+
//# sourceMappingURL=cluster_mesh_metis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster_mesh_metis.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/cluster_mesh_metis.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,2CALW,WAAW,8BAEX,MAAM,GACJ,MAAM,CAqBlB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { mesh_to_metis_graph } from "./mesh_to_metis_graph.js";
|
|
2
|
+
import { metis_cluster_bs } from "./metis_cluster_bs.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Uint32Array} result
|
|
7
|
+
* @param {TopoMesh} mesh
|
|
8
|
+
* @param {number} patch_size
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export async function cluster_mesh_metis(result, mesh, patch_size) {
|
|
12
|
+
|
|
13
|
+
const face_set = mesh.getFaces();
|
|
14
|
+
const input_face_count = face_set.size;
|
|
15
|
+
|
|
16
|
+
const face_array = Array.from(face_set);
|
|
17
|
+
|
|
18
|
+
const metis_graph = mesh_to_metis_graph(face_array);
|
|
19
|
+
|
|
20
|
+
const partition_count = await metis_cluster_bs(
|
|
21
|
+
result,
|
|
22
|
+
input_face_count,
|
|
23
|
+
metis_graph.edge_addresses,
|
|
24
|
+
metis_graph.adjacency,
|
|
25
|
+
metis_graph.edge_weights,
|
|
26
|
+
patch_size
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return partition_count;
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {TopoTriangle[]} face_array
|
|
3
|
+
* @returns {{edge_addresses:Uint32Array, adjacency:Uint32Array, edge_weights:Uint32Array}}
|
|
4
|
+
*/
|
|
5
|
+
export function mesh_to_metis_graph(face_array: TopoTriangle[]): {
|
|
6
|
+
edge_addresses: Uint32Array;
|
|
7
|
+
adjacency: Uint32Array;
|
|
8
|
+
edge_weights: Uint32Array;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=mesh_to_metis_graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh_to_metis_graph.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/mesh_to_metis_graph.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,gDAHW,cAAc;oBACI,WAAW;eAAY,WAAW;kBAAe,WAAW;EA2DxF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {TopoTriangle[]} face_array
|
|
5
|
+
* @returns {{edge_addresses:Uint32Array, adjacency:Uint32Array, edge_weights:Uint32Array}}
|
|
6
|
+
*/
|
|
7
|
+
export function mesh_to_metis_graph(face_array) {
|
|
8
|
+
assert.isArray(face_array, 'face_array');
|
|
9
|
+
|
|
10
|
+
const input_face_count = face_array.length;
|
|
11
|
+
|
|
12
|
+
const edge_addresses = new Uint32Array(input_face_count + 1);
|
|
13
|
+
const adjacency = [];
|
|
14
|
+
const edge_weights = [];
|
|
15
|
+
|
|
16
|
+
const face_index_map = new Map();
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < input_face_count; i++) {
|
|
19
|
+
const face = face_array[i];
|
|
20
|
+
face_index_map.set(face, i);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let offset = 0;
|
|
24
|
+
edge_addresses[0] = 0;
|
|
25
|
+
for (let i = 0; i < input_face_count; i++) {
|
|
26
|
+
const face = face_array[i];
|
|
27
|
+
|
|
28
|
+
const edges = face.edges;
|
|
29
|
+
|
|
30
|
+
const edge_count = edges.length;
|
|
31
|
+
for (let j = 0; j < edge_count; j++) {
|
|
32
|
+
const topoEdge = edges[j];
|
|
33
|
+
|
|
34
|
+
const edge_faces = topoEdge.faces;
|
|
35
|
+
|
|
36
|
+
const edge_face_count = edge_faces.length;
|
|
37
|
+
for (let k = 0; k < edge_face_count; k++) {
|
|
38
|
+
const neighbour = edge_faces[k];
|
|
39
|
+
|
|
40
|
+
if (neighbour === face) {
|
|
41
|
+
//skip self
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
adjacency[offset] = face_index_map.get(neighbour);
|
|
46
|
+
edge_weights[offset] = 1;
|
|
47
|
+
|
|
48
|
+
offset++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
edge_addresses[i + 1] = offset;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const adjecency_uint32 = new Uint32Array(adjacency);
|
|
56
|
+
const edge_weights_uint32 = new Uint32Array(edge_weights);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
edge_addresses: edge_addresses,
|
|
61
|
+
adjacency: adjecency_uint32,
|
|
62
|
+
edge_weights: edge_weights_uint32
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Uint32Array} result
|
|
4
|
+
* @param {number} node_count
|
|
5
|
+
* @param {Uint32Array} edge_addresses
|
|
6
|
+
* @param {Uint32Array} adjacency_uint32
|
|
7
|
+
* @param {Uint32Array} edge_weights_uint32
|
|
8
|
+
* @param {number} patch_size
|
|
9
|
+
* @returns {Promise<number>}
|
|
10
|
+
*/
|
|
11
|
+
export function metis_cluster_bs(result: Uint32Array, node_count: number, edge_addresses: Uint32Array, adjacency_uint32: Uint32Array, edge_weights_uint32: Uint32Array, patch_size: number): Promise<number>;
|
|
12
|
+
//# sourceMappingURL=metis_cluster_bs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metis_cluster_bs.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/metis_cluster_bs.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,yCARW,WAAW,cACX,MAAM,kBACN,WAAW,oBACX,WAAW,uBACX,WAAW,cACX,MAAM,GACJ,QAAQ,MAAM,CAAC,CA6G3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Metis } from "./metis
|
|
2
|
-
import { metis_options } from "./
|
|
1
|
+
import { Metis } from "./metis.js";
|
|
2
|
+
import { metis_options } from "./metis_options.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* How many times to retry partitioning before giving up
|
|
@@ -17,7 +17,14 @@ const MAX_STEPS = 50;
|
|
|
17
17
|
* @param {number} patch_size
|
|
18
18
|
* @returns {Promise<number>}
|
|
19
19
|
*/
|
|
20
|
-
export async function metis_cluster_bs(
|
|
20
|
+
export async function metis_cluster_bs(
|
|
21
|
+
result,
|
|
22
|
+
node_count,
|
|
23
|
+
edge_addresses,
|
|
24
|
+
adjacency_uint32,
|
|
25
|
+
edge_weights_uint32,
|
|
26
|
+
patch_size
|
|
27
|
+
) {
|
|
21
28
|
|
|
22
29
|
const metis = Metis.INSTANCE;
|
|
23
30
|
|
|
@@ -35,7 +42,7 @@ export async function metis_cluster_bs(result, node_count, edge_addresses, adjac
|
|
|
35
42
|
const metisOptions = new metis_options();
|
|
36
43
|
metisOptions.seed = 0xCAFE;
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
for (; ;) {
|
|
39
46
|
passes++;
|
|
40
47
|
|
|
41
48
|
if (passes > MAX_STEPS) {
|
|
@@ -97,9 +104,6 @@ export async function metis_cluster_bs(result, node_count, edge_addresses, adjac
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
// console.log(`${partition_count}`);
|
|
100
|
-
|
|
101
|
-
continue partition_loop;
|
|
102
|
-
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
// remap P values. Metis assigns unique unsigned integer values to each cluster, but they don't necessarily start at 0, to fix this we remap values
|
|
@@ -120,94 +124,4 @@ export async function metis_cluster_bs(result, node_count, edge_addresses, adjac
|
|
|
120
124
|
|
|
121
125
|
result.set(p);
|
|
122
126
|
return partition_count;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @param {TopoTriangle[]} face_array
|
|
127
|
-
*/
|
|
128
|
-
export function mesh_to_metis_graph(face_array) {
|
|
129
|
-
const input_face_count = face_array.length;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const edge_addresses = new Uint32Array(input_face_count + 1);
|
|
133
|
-
const adjacency = [];
|
|
134
|
-
const edge_weights = [];
|
|
135
|
-
|
|
136
|
-
const face_index_map = new Map();
|
|
137
|
-
|
|
138
|
-
for (let i = 0; i < input_face_count; i++) {
|
|
139
|
-
const face = face_array[i];
|
|
140
|
-
face_index_map.set(face, i);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let offset = 0;
|
|
144
|
-
edge_addresses[0] = 0;
|
|
145
|
-
for (let i = 0; i < input_face_count; i++) {
|
|
146
|
-
const face = face_array[i];
|
|
147
|
-
|
|
148
|
-
const edges = face.edges;
|
|
149
|
-
|
|
150
|
-
const edge_count = edges.length;
|
|
151
|
-
for (let j = 0; j < edge_count; j++) {
|
|
152
|
-
const topoEdge = edges[j];
|
|
153
|
-
|
|
154
|
-
const edge_faces = topoEdge.faces;
|
|
155
|
-
|
|
156
|
-
const edge_face_count = edge_faces.length;
|
|
157
|
-
for (let k = 0; k < edge_face_count; k++) {
|
|
158
|
-
const neighbour = edge_faces[k];
|
|
159
|
-
|
|
160
|
-
if (neighbour === face) {
|
|
161
|
-
//skip self
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
adjacency[offset] = face_index_map.get(neighbour);
|
|
166
|
-
edge_weights[offset] = 1;
|
|
167
|
-
|
|
168
|
-
offset++;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
edge_addresses[i + 1] = offset;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const adjecency_uint32 = new Uint32Array(adjacency);
|
|
176
|
-
const edge_weights_uint32 = new Uint32Array(edge_weights);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
edge_addresses: edge_addresses,
|
|
181
|
-
adjacency: adjecency_uint32,
|
|
182
|
-
edge_weights: edge_weights_uint32
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
* @param {Uint32Array} result
|
|
189
|
-
* @param {TopoMesh} mesh
|
|
190
|
-
* @param {number} patch_size
|
|
191
|
-
* @returns {number}
|
|
192
|
-
*/
|
|
193
|
-
export async function cluster_mesh_metis(result, mesh, patch_size) {
|
|
194
|
-
|
|
195
|
-
const face_set = mesh.getFaces();
|
|
196
|
-
const input_face_count = face_set.size;
|
|
197
|
-
|
|
198
|
-
const face_array = Array.from(face_set);
|
|
199
|
-
|
|
200
|
-
const metis_graph = mesh_to_metis_graph(face_array);
|
|
201
|
-
|
|
202
|
-
const partition_count = await metis_cluster_bs(
|
|
203
|
-
result,
|
|
204
|
-
input_face_count,
|
|
205
|
-
metis_graph.edge_addresses,
|
|
206
|
-
metis_graph.adjacency,
|
|
207
|
-
metis_graph.edge_weights,
|
|
208
|
-
patch_size
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
return partition_count;
|
|
212
|
-
}
|
|
213
|
-
|
|
127
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mn_graph_coarsen.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/mn_graph_coarsen.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,gFAFW,MAAM,
|
|
1
|
+
{"version":3,"file":"mn_graph_coarsen.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/mn_graph_coarsen.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,gFAFW,MAAM,QA2BhB"}
|