@luma.gl/graph 10.0.0-beta.1 → 10.0.0-beta.2
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/dist/experimental-models.cjs +21 -0
- package/dist/experimental-models.d.ts +2 -0
- package/dist/experimental-models.d.ts.map +1 -0
- package/dist/experimental-models.js +5 -0
- package/dist/experimental-models.js.map +1 -0
- package/dist/experimental-simulation.cjs +21 -0
- package/dist/experimental-simulation.d.ts +2 -0
- package/dist/experimental-simulation.d.ts.map +1 -0
- package/dist/experimental-simulation.js +5 -0
- package/dist/experimental-simulation.js.map +1 -0
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +7 -3
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +14 -4
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +87 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +2 -1
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +101 -5
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +86 -0
- package/dist/gpu-dataframe/gpu-expression.d.ts +23 -2
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +81 -0
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +2 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +5 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +23 -11
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +24 -12
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +2 -2
- package/dist/gpu-dataframe/gpu-group-by-query.js +5 -3
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +0 -2
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +0 -2
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +3 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +0 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +3 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.cjs +13 -5
- package/dist/gpu-dataframe/gpu-sort-query.d.ts +4 -1
- package/dist/gpu-dataframe/gpu-sort-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.js +14 -5
- package/dist/gpu-dataframe/gpu-sort-query.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +8 -0
- package/dist/gpu-dataframe/index.cjs.map +2 -2
- package/dist/gpu-dataframe/index.d.ts +2 -2
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +1 -1
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-dataframe/portable-expression.cjs +68 -4
- package/dist/gpu-dataframe/portable-expression.d.ts +3 -1
- package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/portable-expression.js +69 -5
- package/dist/gpu-dataframe/portable-expression.js.map +1 -1
- package/dist/gpu-dggs-benchmarks.cjs +21 -0
- package/dist/gpu-dggs-benchmarks.d.ts +2 -0
- package/dist/gpu-dggs-benchmarks.d.ts.map +1 -0
- package/dist/gpu-dggs-benchmarks.js +5 -0
- package/dist/gpu-dggs-benchmarks.js.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.cjs +21 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts +2 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.js +5 -0
- package/dist/gpu-graph-algorithms-benchmarks.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.cjs +116 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts +42 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js +90 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +97 -5
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +31 -2
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +99 -3
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +483 -152
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +64 -3
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +523 -161
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +23 -2
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +8 -2
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +6 -1
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.cjs +21 -8
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.js +15 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.cjs +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.js +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +36 -7
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.js +42 -7
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +23 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +4 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +25 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-geometry.cjs +41 -4
- package/dist/gpu-physics/rigid-body-geometry.d.ts +10 -1
- package/dist/gpu-physics/rigid-body-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-geometry.js +44 -3
- package/dist/gpu-physics/rigid-body-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-height-field-shader.cjs +80 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js +56 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.cjs +166 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts +55 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.js +184 -0
- package/dist/gpu-physics/rigid-body-height-field.js.map +1 -0
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.cjs +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.cjs +72 -17
- package/dist/gpu-physics/rigid-body-mesh.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-mesh.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.js +76 -20
- package/dist/gpu-physics/rigid-body-mesh.js.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.cjs +4 -4
- package/dist/gpu-physics/rigid-body-properties.d.ts +6 -0
- package/dist/gpu-physics/rigid-body-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.js +1 -1
- package/dist/gpu-physics/rigid-body-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-publication.cjs +2 -2
- package/dist/gpu-physics/rigid-body-publication.js +1 -1
- package/dist/gpu-physics/rigid-body-publication.js.map +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.cjs +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.js +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +11 -5
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +14 -6
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.cjs +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.js +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-terrain-atlas.cjs +287 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts +87 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js +275 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.cjs +240 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts +76 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js +247 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.cjs +215 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts +25 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js +218 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.cjs +263 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts +97 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js +250 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js.map +1 -0
- package/dist/gpu-physics/rigid-body-triggers.cjs +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +1 -0
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.cjs +99 -44
- package/dist/gpu-physics/rigid-body-vehicle.d.ts +15 -3
- package/dist/gpu-physics/rigid-body-vehicle.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.js +93 -40
- package/dist/gpu-physics/rigid-body-vehicle.js.map +1 -1
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts +1 -1
- package/dist/gpu-project/cpu-projection-operation.d.ts +1 -1
- package/dist/gpu-project/crs.cjs.map +2 -2
- package/dist/gpu-project/crs.d.ts +1 -1
- package/dist/gpu-project/projection-crs-benchmark.cjs +2 -2
- package/dist/gpu-project/projection-crs-benchmark.d.ts +1 -1
- package/dist/gpu-project/projection-crs-benchmark.js +1 -1
- package/dist/gpu-project/projection-crs-input.cjs +7 -7
- package/dist/gpu-project/projection-crs-input.d.ts +1 -1
- package/dist/gpu-project/projection-crs-input.js +4 -4
- package/dist/gpu-project/projection-engine.d.ts +2 -2
- package/dist/gpu-project-benchmarks.cjs +21 -0
- package/dist/gpu-project-benchmarks.d.ts +2 -0
- package/dist/gpu-project-benchmarks.d.ts.map +1 -0
- package/dist/gpu-project-benchmarks.js +5 -0
- package/dist/gpu-project-benchmarks.js.map +1 -0
- package/dist/gpu-project-crs.cjs +21 -0
- package/dist/gpu-project-crs.d.ts +2 -0
- package/dist/gpu-project-crs.d.ts.map +1 -0
- package/dist/gpu-project-crs.js +5 -0
- package/dist/gpu-project-crs.js.map +1 -0
- package/dist/gpu-project-geoarrow.cjs +21 -0
- package/dist/gpu-project-geoarrow.d.ts +2 -0
- package/dist/gpu-project-geoarrow.d.ts.map +1 -0
- package/dist/gpu-project-geoarrow.js +5 -0
- package/dist/gpu-project-geoarrow.js.map +1 -0
- package/dist/gpu-project-graph.cjs +21 -0
- package/dist/gpu-project-graph.d.ts +2 -0
- package/dist/gpu-project-graph.d.ts.map +1 -0
- package/dist/gpu-project-graph.js +5 -0
- package/dist/gpu-project-graph.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts.map +1 -1
- package/dist/gpu-simple-graph-cpu.cjs +21 -0
- package/dist/gpu-simple-graph-cpu.d.ts +2 -0
- package/dist/gpu-simple-graph-cpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-cpu.js +5 -0
- package/dist/gpu-simple-graph-cpu.js.map +1 -0
- package/dist/gpu-simple-graph-webgl.cjs +21 -0
- package/dist/gpu-simple-graph-webgl.d.ts +2 -0
- package/dist/gpu-simple-graph-webgl.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgl.js +5 -0
- package/dist/gpu-simple-graph-webgl.js.map +1 -0
- package/dist/gpu-simple-graph-webgpu.cjs +21 -0
- package/dist/gpu-simple-graph-webgpu.d.ts +2 -0
- package/dist/gpu-simple-graph-webgpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgpu.js +5 -0
- package/dist/gpu-simple-graph-webgpu.js.map +1 -0
- package/dist/gpu-sql/gpu-sql.cjs +76 -122
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +99 -130
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +2 -2
- package/package.json +19 -19
- package/src/experimental-models.ts +5 -0
- package/src/experimental-simulation.ts +5 -0
- package/src/gpu-dataframe/gpu-data-frame-query.ts +18 -5
- package/src/gpu-dataframe/gpu-expression-shader.ts +128 -7
- package/src/gpu-dataframe/gpu-expression.ts +124 -1
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +5 -3
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +26 -12
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-group-by-query.ts +5 -3
- package/src/gpu-dataframe/gpu-histogram-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-join-compiler.ts +0 -2
- package/src/gpu-dataframe/gpu-query-compiler.ts +3 -3
- package/src/gpu-dataframe/gpu-sort-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-sort-query.ts +31 -5
- package/src/gpu-dataframe/index.ts +15 -2
- package/src/gpu-dataframe/portable-expression.ts +81 -4
- package/src/gpu-dggs-benchmarks.ts +5 -0
- package/src/gpu-graph-algorithms-benchmarks.ts +5 -0
- package/src/gpu-physics/gpu-physics-ensemble-terrain.ts +114 -0
- package/src/gpu-physics/gpu-physics-ensemble.ts +147 -4
- package/src/gpu-physics/gpu-rigid-body-world.ts +668 -198
- package/src/gpu-physics/index.ts +37 -0
- package/src/gpu-physics/rigid-body-bounds-shaders.ts +16 -1
- package/src/gpu-physics/rigid-body-convex-shaders.ts +3 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +48 -8
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +34 -1
- package/src/gpu-physics/rigid-body-geometry.ts +49 -4
- package/src/gpu-physics/rigid-body-height-field-shader.ts +56 -0
- package/src/gpu-physics/rigid-body-height-field.ts +257 -0
- package/src/gpu-physics/rigid-body-mesh-query-shaders.ts +4 -2
- package/src/gpu-physics/rigid-body-mesh.ts +97 -26
- package/src/gpu-physics/rigid-body-properties.ts +5 -2
- package/src/gpu-physics/rigid-body-publication.ts +1 -1
- package/src/gpu-physics/rigid-body-query-geometry.ts +22 -4
- package/src/gpu-physics/rigid-body-shaders.ts +17 -6
- package/src/gpu-physics/rigid-body-shape-properties.ts +2 -0
- package/src/gpu-physics/rigid-body-terrain-atlas.ts +378 -0
- package/src/gpu-physics/rigid-body-terrain-lod.ts +332 -0
- package/src/gpu-physics/rigid-body-terrain-stitch.ts +286 -0
- package/src/gpu-physics/rigid-body-terrain-stream.ts +323 -0
- package/src/gpu-physics/rigid-body-triggers.ts +1 -0
- package/src/gpu-physics/rigid-body-vehicle.ts +108 -41
- package/src/gpu-project/README.md +2 -2
- package/src/gpu-project/cpu-geometry-pipelines.ts +1 -1
- package/src/gpu-project/cpu-projection-operation.ts +1 -1
- package/src/gpu-project/crs.ts +2 -2
- package/src/gpu-project/projection-crs-benchmark.ts +2 -2
- package/src/gpu-project/projection-crs-input.ts +4 -4
- package/src/gpu-project/projection-engine.ts +2 -2
- package/src/gpu-project-benchmarks.ts +5 -0
- package/src/gpu-project-crs.ts +5 -0
- package/src/gpu-project-geoarrow.ts +5 -0
- package/src/gpu-project-graph.ts +5 -0
- package/src/gpu-simple-graph/gpu-simple-graph-transfer.ts +1 -1
- package/src/gpu-simple-graph/gpu-simple-graph-value.ts +1 -1
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +1 -1
- package/src/gpu-simple-graph/operation/operation.ts +1 -1
- package/src/gpu-simple-graph/operations/swizzle.ts +1 -1
- package/src/gpu-simple-graph-cpu.ts +5 -0
- package/src/gpu-simple-graph-webgl.ts +5 -0
- package/src/gpu-simple-graph-webgpu.ts +5 -0
- package/src/gpu-sql/gpu-sql.ts +150 -152
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {RigidBodyVector} from './rigid-body-properties';
|
|
6
|
+
|
|
7
|
+
/** Grid in the collider's local Z-up frame, with row-major scalar heights. */
|
|
8
|
+
export type GPURigidBodyHeightField = {
|
|
9
|
+
/** Number of columns, including both ends of the tile. */
|
|
10
|
+
width: number;
|
|
11
|
+
/** Number of rows, including both ends of the tile. */
|
|
12
|
+
height: number;
|
|
13
|
+
/** First sample in local XY, after any cell-registration shift. */
|
|
14
|
+
origin?: readonly [number, number];
|
|
15
|
+
/** Metric column basis vector. Defaults to a unit step along X. */
|
|
16
|
+
columnStep?: readonly [number, number];
|
|
17
|
+
/** Metric row basis vector. Defaults to a unit step along Y. */
|
|
18
|
+
rowStep?: readonly [number, number];
|
|
19
|
+
/** The diagonal connecting opposite samples in each cell. */
|
|
20
|
+
diagonal?: '00-11' | '10-01';
|
|
21
|
+
/** Missing heights allocate a vacant slot. Nonfinite or masked samples omit their triangles. */
|
|
22
|
+
heights?: Float32Array | Float64Array;
|
|
23
|
+
/** Optional row-major mask with zero for an absent sample. */
|
|
24
|
+
validity?: Uint8Array;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Structural subset of math.gl HeightField needed to create a collider without a terrain dependency. */
|
|
28
|
+
export type GPURigidBodyHeightFieldSource = {
|
|
29
|
+
/** Source column count. */
|
|
30
|
+
readonly width: number;
|
|
31
|
+
/** Source row count. */
|
|
32
|
+
readonly height: number;
|
|
33
|
+
/** Metric source origin before applying sample registration. */
|
|
34
|
+
readonly origin: readonly [number, number];
|
|
35
|
+
/** Metric column basis vector. */
|
|
36
|
+
readonly columnStep: readonly [number, number];
|
|
37
|
+
/** Metric row basis vector. */
|
|
38
|
+
readonly rowStep: readonly [number, number];
|
|
39
|
+
/** Placement of the first sample relative to the source origin. */
|
|
40
|
+
readonly registration: 'vertex' | 'cell';
|
|
41
|
+
/** Authored triangle diagonal used for each cell. */
|
|
42
|
+
readonly diagonal: '00-11' | '10-01';
|
|
43
|
+
/** Return detached row-major data and validity. */
|
|
44
|
+
copyData(): {heights: Float32Array | Float64Array; validity: Uint8Array};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Detach math.gl samples and express them relative to the supplied collider origin. */
|
|
48
|
+
export function makeRigidBodyHeightField(
|
|
49
|
+
source: GPURigidBodyHeightFieldSource,
|
|
50
|
+
colliderOrigin: RigidBodyVector
|
|
51
|
+
): GPURigidBodyHeightField {
|
|
52
|
+
const samples = source.copyData();
|
|
53
|
+
const registrationOffset = source.registration === 'cell' ? 0.5 : 0;
|
|
54
|
+
return {
|
|
55
|
+
width: source.width,
|
|
56
|
+
height: source.height,
|
|
57
|
+
origin: [
|
|
58
|
+
source.origin[0] -
|
|
59
|
+
colliderOrigin[0] +
|
|
60
|
+
registrationOffset * (source.columnStep[0] + source.rowStep[0]),
|
|
61
|
+
source.origin[1] -
|
|
62
|
+
colliderOrigin[1] +
|
|
63
|
+
registrationOffset * (source.columnStep[1] + source.rowStep[1])
|
|
64
|
+
],
|
|
65
|
+
columnStep: [...source.columnStep],
|
|
66
|
+
rowStep: [...source.rowStep],
|
|
67
|
+
diagonal: source.diagonal,
|
|
68
|
+
heights: Float64Array.from(samples.heights, height => height - colliderOrigin[2]),
|
|
69
|
+
validity: samples.validity
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** One reserved f32 value marks a missing height in the GPU data. */
|
|
74
|
+
const MISSING_HEIGHT = Math.fround(3.402823e38);
|
|
75
|
+
/** Leaves cover a contiguous range from a single row of at most eight cells. */
|
|
76
|
+
const CELLS_PER_LEAF = 8;
|
|
77
|
+
|
|
78
|
+
/** Exact fixed payload size, independent of height values and missing-data masks. */
|
|
79
|
+
export function getRigidBodyHeightFieldPageWords(width: number, height: number): number {
|
|
80
|
+
const sampleCount = width * height;
|
|
81
|
+
if (
|
|
82
|
+
!Number.isSafeInteger(width) ||
|
|
83
|
+
!Number.isSafeInteger(height) ||
|
|
84
|
+
width < 2 ||
|
|
85
|
+
height < 2 ||
|
|
86
|
+
sampleCount > 1_000_000
|
|
87
|
+
)
|
|
88
|
+
throw new Error('Invalid height-field grid');
|
|
89
|
+
// Every row eventually uses the same bisection of its columns. Interleaving the
|
|
90
|
+
// row splits changes traversal order, but the full binary tree has 2 * leaves - 1 nodes.
|
|
91
|
+
const memo = new Map<number, number>();
|
|
92
|
+
/** Count single-row leaves after the same column bisection used by the packer. */
|
|
93
|
+
const countLeaves = (columns: number): number => {
|
|
94
|
+
if (columns <= CELLS_PER_LEAF) return 1;
|
|
95
|
+
const cached = memo.get(columns);
|
|
96
|
+
if (cached !== undefined) return cached;
|
|
97
|
+
const half = Math.floor(columns / 2);
|
|
98
|
+
const leaves = countLeaves(half) + countLeaves(columns - half);
|
|
99
|
+
memo.set(columns, leaves);
|
|
100
|
+
return leaves;
|
|
101
|
+
};
|
|
102
|
+
const leaves = countLeaves(width - 1) * (height - 1);
|
|
103
|
+
return 8 + Math.ceil(sampleCount / 4) * 4 + (2 * leaves - 1) * 12;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Pack scalar samples and a bounded stackless hierarchy, with no stored vertices or triangle indices. */
|
|
107
|
+
export function packRigidBodyHeightField(field: GPURigidBodyHeightField) {
|
|
108
|
+
const {width, height, heights, validity, diagonal = '00-11'} = field;
|
|
109
|
+
const sampleCount = width * height;
|
|
110
|
+
if (
|
|
111
|
+
!Number.isSafeInteger(width) ||
|
|
112
|
+
!Number.isSafeInteger(height) ||
|
|
113
|
+
width < 2 ||
|
|
114
|
+
height < 2 ||
|
|
115
|
+
sampleCount > 1_000_000 ||
|
|
116
|
+
(heights && heights.length !== sampleCount) ||
|
|
117
|
+
(validity && validity.length !== sampleCount) ||
|
|
118
|
+
(diagonal !== '00-11' && diagonal !== '10-01')
|
|
119
|
+
)
|
|
120
|
+
throw new Error('Invalid height-field grid');
|
|
121
|
+
|
|
122
|
+
const origin = (field.origin ?? [0, 0]).map(Math.fround);
|
|
123
|
+
const columnStep = (field.columnStep ?? [1, 0]).map(Math.fround);
|
|
124
|
+
const rowStep = (field.rowStep ?? [0, 1]).map(Math.fround);
|
|
125
|
+
const determinant = columnStep[0] * rowStep[1] - columnStep[1] * rowStep[0];
|
|
126
|
+
const horizontalScale = [0, 1].map(
|
|
127
|
+
axis =>
|
|
128
|
+
Math.abs(origin[axis]) +
|
|
129
|
+
Math.abs(columnStep[axis]) * (width - 1) +
|
|
130
|
+
Math.abs(rowStep[axis]) * (height - 1)
|
|
131
|
+
);
|
|
132
|
+
if (
|
|
133
|
+
origin.length !== 2 ||
|
|
134
|
+
columnStep.length !== 2 ||
|
|
135
|
+
rowStep.length !== 2 ||
|
|
136
|
+
![...origin, ...columnStep, ...rowStep, ...horizontalScale].every(value =>
|
|
137
|
+
Number.isFinite(Math.fround(value))
|
|
138
|
+
) ||
|
|
139
|
+
Math.abs(determinant) <= 1e-7 * Math.hypot(...columnStep) * Math.hypot(...rowStep)
|
|
140
|
+
)
|
|
141
|
+
throw new Error('Invalid height-field transform');
|
|
142
|
+
|
|
143
|
+
// Match shader arithmetic at the sample positions, padding conservative XY bounds
|
|
144
|
+
// for separate rounding of the index products and sum.
|
|
145
|
+
const roundingPadding = horizontalScale.map(value => value * 2 ** -21);
|
|
146
|
+
const nodeOffset = 2 + Math.ceil(sampleCount / 4);
|
|
147
|
+
const data = new Array<number>(nodeOffset * 4).fill(MISSING_HEIGHT);
|
|
148
|
+
data.splice(
|
|
149
|
+
0,
|
|
150
|
+
8,
|
|
151
|
+
...columnStep,
|
|
152
|
+
...rowStep,
|
|
153
|
+
...origin,
|
|
154
|
+
width,
|
|
155
|
+
Number(diagonal === '10-01') + 2 * Number(determinant < 0)
|
|
156
|
+
);
|
|
157
|
+
for (let index = 0; heights && index < sampleCount; index++) {
|
|
158
|
+
if (validity?.[index] === 0 || !Number.isFinite(heights[index])) continue;
|
|
159
|
+
const sample = Math.fround(heights[index]);
|
|
160
|
+
if (!Number.isFinite(sample) || sample === MISSING_HEIGHT)
|
|
161
|
+
throw new Error('Height-field sample exceeds float32 range');
|
|
162
|
+
data[8 + index] = sample;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Build deterministic rectangular nodes even for an empty or partially loaded slot. */
|
|
166
|
+
const appendNode = (
|
|
167
|
+
firstColumn: number,
|
|
168
|
+
firstRow: number,
|
|
169
|
+
columns: number,
|
|
170
|
+
rows: number
|
|
171
|
+
): number => {
|
|
172
|
+
const offset = data.length;
|
|
173
|
+
data.push(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
174
|
+
let minimumHeight = Infinity;
|
|
175
|
+
let maximumHeight = -Infinity;
|
|
176
|
+
if (rows === 1 && columns <= CELLS_PER_LEAF) {
|
|
177
|
+
const firstSample = firstRow * width + firstColumn;
|
|
178
|
+
for (let column = 0; column < columns; column++) {
|
|
179
|
+
const sample = 8 + firstSample + column;
|
|
180
|
+
const first = data[sample];
|
|
181
|
+
const second = data[sample + 1];
|
|
182
|
+
const third = data[sample + width];
|
|
183
|
+
const fourth = data[sample + width + 1];
|
|
184
|
+
const triangles =
|
|
185
|
+
diagonal === '00-11'
|
|
186
|
+
? [first, second, fourth, first, fourth, third]
|
|
187
|
+
: [first, second, third, second, fourth, third];
|
|
188
|
+
for (let triangle = 0; triangle < 6; triangle += 3) {
|
|
189
|
+
const cornerA = triangles[triangle];
|
|
190
|
+
const cornerB = triangles[triangle + 1];
|
|
191
|
+
const cornerC = triangles[triangle + 2];
|
|
192
|
+
if (
|
|
193
|
+
cornerA === MISSING_HEIGHT ||
|
|
194
|
+
cornerB === MISSING_HEIGHT ||
|
|
195
|
+
cornerC === MISSING_HEIGHT
|
|
196
|
+
)
|
|
197
|
+
continue;
|
|
198
|
+
minimumHeight = Math.min(minimumHeight, cornerA, cornerB, cornerC);
|
|
199
|
+
maximumHeight = Math.max(maximumHeight, cornerA, cornerB, cornerC);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
data[offset + 7] = minimumHeight <= maximumHeight ? columns * 2 : 0;
|
|
203
|
+
data[offset + 8] = 2 * (firstRow * (width - 1) + firstColumn);
|
|
204
|
+
} else {
|
|
205
|
+
let firstChild: number;
|
|
206
|
+
let secondChild: number;
|
|
207
|
+
if (columns > CELLS_PER_LEAF && (rows === 1 || columns >= rows * CELLS_PER_LEAF)) {
|
|
208
|
+
const split = Math.floor(columns / 2);
|
|
209
|
+
firstChild = appendNode(firstColumn, firstRow, split, rows);
|
|
210
|
+
secondChild = appendNode(firstColumn + split, firstRow, columns - split, rows);
|
|
211
|
+
} else {
|
|
212
|
+
const split = Math.floor(rows / 2);
|
|
213
|
+
firstChild = appendNode(firstColumn, firstRow, columns, split);
|
|
214
|
+
secondChild = appendNode(firstColumn, firstRow + split, columns, rows - split);
|
|
215
|
+
}
|
|
216
|
+
minimumHeight = Math.min(data[firstChild + 2], data[secondChild + 2]);
|
|
217
|
+
maximumHeight = Math.max(data[firstChild + 6], data[secondChild + 6]);
|
|
218
|
+
}
|
|
219
|
+
if (minimumHeight <= maximumHeight) {
|
|
220
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
221
|
+
const first = origin[axis] + firstColumn * columnStep[axis] + firstRow * rowStep[axis];
|
|
222
|
+
const column = columns * columnStep[axis];
|
|
223
|
+
const row = rows * rowStep[axis];
|
|
224
|
+
data[offset + axis] =
|
|
225
|
+
first + Math.min(0, column) + Math.min(0, row) - roundingPadding[axis];
|
|
226
|
+
data[offset + 4 + axis] =
|
|
227
|
+
first + Math.max(0, column) + Math.max(0, row) + roundingPadding[axis];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
data[offset + 2] = minimumHeight;
|
|
231
|
+
data[offset + 6] = maximumHeight;
|
|
232
|
+
data[offset + 3] = (data.length - nodeOffset * 4) / 12;
|
|
233
|
+
return offset;
|
|
234
|
+
};
|
|
235
|
+
const root = appendNode(0, 0, width - 1, height - 1);
|
|
236
|
+
const active = data[root + 2] <= data[root + 6];
|
|
237
|
+
// Empty hierarchy branches have reversed finite bounds. Readers skip them without
|
|
238
|
+
// evaluating a cast against invalid limits. The allocation stays identical on reload.
|
|
239
|
+
for (let offset = root; offset < data.length; offset += 12) {
|
|
240
|
+
if (data[offset + 2] > data[offset + 6]) {
|
|
241
|
+
data[offset + 2] = 1;
|
|
242
|
+
data[offset + 6] = -1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const extent = active
|
|
246
|
+
? [0, 1, 2].map(axis => Math.max(Math.abs(data[root + axis]), Math.abs(data[root + 4 + axis])))
|
|
247
|
+
: [0, 0, 0];
|
|
248
|
+
if (!extent.every(value => Number.isFinite(Math.fround(value))))
|
|
249
|
+
throw new Error('Height-field bounds exceed float32 range');
|
|
250
|
+
return {
|
|
251
|
+
data,
|
|
252
|
+
extent,
|
|
253
|
+
nodeOffset,
|
|
254
|
+
nodeCount: active ? (data.length - root) / 12 : 0,
|
|
255
|
+
triangleCount: active ? (width - 1) * (height - 1) * 2 : 0
|
|
256
|
+
};
|
|
257
|
+
}
|
|
@@ -44,12 +44,13 @@ fn queueMeshPairContacts(pair:u32,first:u32,second:u32,previous:Manifold){
|
|
|
44
44
|
if(work>=MESH_TRAVERSAL_BUDGET){exhausted=true;break;}work++;
|
|
45
45
|
let minimum=readGeometry(outerOffset+outerNode*3u);
|
|
46
46
|
let maximum=readGeometry(outerOffset+outerNode*3u+1u);
|
|
47
|
-
if(any(maximum.xyz<outerLower)||any(minimum.xyz>outerUpper)){outerNode=u32(minimum.w);continue;}
|
|
47
|
+
if(any(minimum.xyz>maximum.xyz)||any(maximum.xyz<outerLower)||any(minimum.xyz>outerUpper)){outerNode=u32(minimum.w);continue;}
|
|
48
48
|
if(maximum.w>0.0){
|
|
49
49
|
let start=u32(readGeometry(outerOffset+outerNode*3u+2u).x);
|
|
50
50
|
for(var offset=0u;offset<u32(maximum.w);offset++){
|
|
51
51
|
if(work>=MESH_TRAVERSAL_BUDGET){exhausted=true;break;}work++;
|
|
52
52
|
let outerTriangle=start+offset;
|
|
53
|
+
if(!meshTriangleActive(outerMesh,outerTriangle)){continue;}
|
|
53
54
|
var lower=vec3f(3.402823e38);var upper=vec3f(-3.402823e38);
|
|
54
55
|
for(var corner=0u;corner<3u;corner++){
|
|
55
56
|
let worldPoint=colliderPosition(outerMesh)+rotate(colliderRotation(outerMesh),triangleVertex(outerMesh,outerTriangle,corner));
|
|
@@ -63,12 +64,13 @@ fn queueMeshPairContacts(pair:u32,first:u32,second:u32,previous:Manifold){
|
|
|
63
64
|
if(work>=MESH_TRAVERSAL_BUDGET){exhausted=true;break;}work++;
|
|
64
65
|
let queryMinimum=readGeometry(queryOffset+queryNode*3u);
|
|
65
66
|
let queryMaximum=readGeometry(queryOffset+queryNode*3u+1u);
|
|
66
|
-
if(any(queryMaximum.xyz<lower)||any(queryMinimum.xyz>upper)){queryNode=u32(queryMinimum.w);continue;}
|
|
67
|
+
if(any(queryMinimum.xyz>queryMaximum.xyz)||any(queryMaximum.xyz<lower)||any(queryMinimum.xyz>upper)){queryNode=u32(queryMinimum.w);continue;}
|
|
67
68
|
if(queryMaximum.w>0.0){
|
|
68
69
|
let queryStart=u32(readGeometry(queryOffset+queryNode*3u+2u).x);
|
|
69
70
|
for(var queryIndex=0u;queryIndex<u32(queryMaximum.w);queryIndex++){
|
|
70
71
|
if(work>=MESH_TRAVERSAL_BUDGET){exhausted=true;break;}work++;
|
|
71
72
|
let queryTriangle=queryStart+queryIndex;
|
|
73
|
+
if(!meshTriangleActive(queryMesh,queryTriangle)){continue;}
|
|
72
74
|
let firstPoint=triangleVertex(queryMesh,queryTriangle,0u);
|
|
73
75
|
let secondPoint=triangleVertex(queryMesh,queryTriangle,1u);
|
|
74
76
|
let thirdPoint=triangleVertex(queryMesh,queryTriangle,2u);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {Geometry} from '@math.gl/geometry/primitives';
|
|
5
6
|
import {makeExactOrientation} from './rigid-body-orientation';
|
|
6
7
|
|
|
7
8
|
export type RigidBodyMeshGeometry = {
|
|
@@ -151,6 +152,31 @@ export function makeConvexHullGeometry(positions: ArrayLike<number>): RigidBodyM
|
|
|
151
152
|
export function makeTriangleMeshGeometry(
|
|
152
153
|
positions: ArrayLike<number>,
|
|
153
154
|
indices: ArrayLike<number>
|
|
155
|
+
): RigidBodyMeshGeometry {
|
|
156
|
+
return cookTriangleMeshGeometry(positions, indices, false);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Cook a CPU triangle surface, including a math.gl HeightFieldGeometry, for a static collider. */
|
|
160
|
+
export function makeStaticTriangleMeshGeometry(geometry: Geometry): RigidBodyMeshGeometry {
|
|
161
|
+
const position = geometry.attributes['POSITION'];
|
|
162
|
+
if (geometry.topology !== 'triangle-list' || position?.size !== 3)
|
|
163
|
+
throw new Error('Static surfaces require triangle-list POSITION geometry');
|
|
164
|
+
const sourceIndices = geometry.indices?.value;
|
|
165
|
+
if (
|
|
166
|
+
geometry.vertexCount > Math.min(sourceIndices?.length ?? position.value.length / 3, 3_000_000)
|
|
167
|
+
)
|
|
168
|
+
throw new Error('Invalid mesh vertex count');
|
|
169
|
+
const indices =
|
|
170
|
+
sourceIndices?.subarray(0, geometry.vertexCount) ??
|
|
171
|
+
Array.from({length: geometry.vertexCount}, (_, index) => index);
|
|
172
|
+
return cookTriangleMeshGeometry(position.value, indices, true);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Build collision data from authored triangles, with optional mass properties for dynamic meshes. */
|
|
176
|
+
function cookTriangleMeshGeometry(
|
|
177
|
+
positions: ArrayLike<number>,
|
|
178
|
+
indices: ArrayLike<number>,
|
|
179
|
+
staticSurface: boolean
|
|
154
180
|
): RigidBodyMeshGeometry {
|
|
155
181
|
if (
|
|
156
182
|
!Number.isSafeInteger(positions.length) ||
|
|
@@ -163,25 +189,34 @@ export function makeTriangleMeshGeometry(
|
|
|
163
189
|
throw new Error('Incomplete mesh geometry');
|
|
164
190
|
if (positions.length > 3_000_000 || indices.length > 3_000_000)
|
|
165
191
|
throw new Error('Mesh geometry capacity exceeded');
|
|
166
|
-
const vertices = Array.from(positions, Math.fround);
|
|
167
192
|
const triangles = Array.from(indices);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
triangles.some(index => !Number.isInteger(index) || index < 0 || index >= vertices.length / 3)
|
|
171
|
-
)
|
|
193
|
+
const vertexCount = positions.length / 3;
|
|
194
|
+
if (triangles.some(index => !Number.isInteger(index) || index < 0 || index >= vertexCount))
|
|
172
195
|
throw new Error('Invalid mesh geometry');
|
|
196
|
+
const vertices = staticSurface
|
|
197
|
+
? compactSurfaceVertices(positions, triangles)
|
|
198
|
+
: Array.from(positions, Math.fround);
|
|
199
|
+
if (!vertices.every(Number.isFinite)) throw new Error('Invalid mesh geometry');
|
|
173
200
|
const point = (index: number): Point => [
|
|
174
201
|
vertices[index * 3],
|
|
175
202
|
vertices[index * 3 + 1],
|
|
176
203
|
vertices[index * 3 + 2]
|
|
177
204
|
];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
);
|
|
205
|
+
// Cache each face's bounds and centroid key once. BVH sorting must not allocate per comparison.
|
|
206
|
+
const triangleCount = triangles.length / 3;
|
|
207
|
+
const triangleBounds = new Float32Array(triangleCount * 6);
|
|
208
|
+
const triangleCentroids = new Float64Array(triangleCount * 3);
|
|
209
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
210
|
+
const first = point(triangles[triangle * 3]);
|
|
211
|
+
const second = point(triangles[triangle * 3 + 1]);
|
|
212
|
+
const third = point(triangles[triangle * 3 + 2]);
|
|
213
|
+
const normal = cross(subtract(second, first), subtract(third, first));
|
|
184
214
|
if (normal.every(value => value === 0)) throw new Error('Degenerate mesh triangle');
|
|
215
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
216
|
+
triangleBounds[triangle * 6 + axis] = Math.min(first[axis], second[axis], third[axis]);
|
|
217
|
+
triangleBounds[triangle * 6 + axis + 3] = Math.max(first[axis], second[axis], third[axis]);
|
|
218
|
+
triangleCentroids[triangle * 3 + axis] = first[axis] + second[axis] + third[axis];
|
|
219
|
+
}
|
|
185
220
|
}
|
|
186
221
|
const minimum: Point = [Infinity, Infinity, Infinity],
|
|
187
222
|
maximum: Point = [-Infinity, -Infinity, -Infinity];
|
|
@@ -198,36 +233,51 @@ export function makeTriangleMeshGeometry(
|
|
|
198
233
|
const lower: Point = [Infinity, Infinity, Infinity],
|
|
199
234
|
upper: Point = [-Infinity, -Infinity, -Infinity];
|
|
200
235
|
for (const triangle of faces)
|
|
201
|
-
for (let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lower[axis] = Math.min(lower[axis], vertex[axis]);
|
|
205
|
-
upper[axis] = Math.max(upper[axis], vertex[axis]);
|
|
206
|
-
}
|
|
236
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
237
|
+
lower[axis] = Math.min(lower[axis], triangleBounds[triangle * 6 + axis]);
|
|
238
|
+
upper[axis] = Math.max(upper[axis], triangleBounds[triangle * 6 + axis + 3]);
|
|
207
239
|
}
|
|
208
240
|
if (faces.length <= 4) {
|
|
209
241
|
nodes[offset + 7] = faces.length;
|
|
210
242
|
nodes[offset + 8] = ordered.length / 3;
|
|
211
243
|
for (const triangle of faces)
|
|
212
|
-
ordered.push(
|
|
244
|
+
ordered.push(
|
|
245
|
+
triangles[triangle * 3],
|
|
246
|
+
triangles[triangle * 3 + 1],
|
|
247
|
+
triangles[triangle * 3 + 2]
|
|
248
|
+
);
|
|
213
249
|
} else {
|
|
214
250
|
let axis = 0;
|
|
215
251
|
for (let candidate = 1; candidate < 3; candidate++)
|
|
216
252
|
if (upper[candidate] - lower[candidate] > upper[axis] - lower[axis]) axis = candidate;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
faces.sort((first, second) => centroid(first) - centroid(second));
|
|
253
|
+
faces.sort(
|
|
254
|
+
(first, second) =>
|
|
255
|
+
triangleCentroids[first * 3 + axis] - triangleCentroids[second * 3 + axis]
|
|
256
|
+
);
|
|
222
257
|
const middle = faces.length >> 1;
|
|
223
258
|
build(faces.slice(0, middle));
|
|
224
259
|
build(faces.slice(middle));
|
|
225
260
|
}
|
|
226
|
-
|
|
227
|
-
|
|
261
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
262
|
+
nodes[offset + axis] = lower[axis];
|
|
263
|
+
nodes[offset + 4 + axis] = upper[axis];
|
|
264
|
+
}
|
|
228
265
|
nodes[offset + 3] = nodes.length / 12;
|
|
229
266
|
};
|
|
230
|
-
build(Array.from({length:
|
|
267
|
+
build(Array.from({length: triangleCount}, (_, index) => index));
|
|
268
|
+
if (staticSurface) {
|
|
269
|
+
return {
|
|
270
|
+
positions: vertices,
|
|
271
|
+
indices: ordered,
|
|
272
|
+
minimum,
|
|
273
|
+
maximum,
|
|
274
|
+
nodes,
|
|
275
|
+
closed: false,
|
|
276
|
+
volume: 0,
|
|
277
|
+
center: [0, 0, 0],
|
|
278
|
+
tensor: Array<number>(9).fill(0)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
231
281
|
// Weld by coordinates for topology checks: glTF often splits vertices at UV seams.
|
|
232
282
|
const vertexKeys = Array.from({length: vertices.length / 3}, (_, index) =>
|
|
233
283
|
point(index).join(',')
|
|
@@ -294,3 +344,24 @@ export function makeTriangleMeshGeometry(
|
|
|
294
344
|
tensor
|
|
295
345
|
};
|
|
296
346
|
}
|
|
347
|
+
|
|
348
|
+
/** Remap a detached index list and retain only vertices referenced by the surface. */
|
|
349
|
+
function compactSurfaceVertices(positions: ArrayLike<number>, triangles: number[]): number[] {
|
|
350
|
+
const remapped = new Int32Array(positions.length / 3);
|
|
351
|
+
remapped.fill(-1);
|
|
352
|
+
const vertices: number[] = [];
|
|
353
|
+
for (let index = 0; index < triangles.length; index++) {
|
|
354
|
+
const sourceVertex = triangles[index];
|
|
355
|
+
if (remapped[sourceVertex] < 0) {
|
|
356
|
+
remapped[sourceVertex] = vertices.length / 3;
|
|
357
|
+
const offset = sourceVertex * 3;
|
|
358
|
+
vertices.push(
|
|
359
|
+
Math.fround(positions[offset]),
|
|
360
|
+
Math.fround(positions[offset + 1]),
|
|
361
|
+
Math.fround(positions[offset + 2])
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
triangles[index] = remapped[sourceVertex];
|
|
365
|
+
}
|
|
366
|
+
return vertices;
|
|
367
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Matrix4, Quaternion} from '@math.gl/core';
|
|
5
|
+
import {Matrix4, Quaternion} from '@math.gl/core/matrix';
|
|
6
|
+
import type {GPURigidBodyHeightField} from './rigid-body-height-field';
|
|
6
7
|
import type {RigidBodyMeshGeometry} from './rigid-body-mesh';
|
|
7
8
|
import {getRigidBodyShapeProperties} from './rigid-body-shape-properties';
|
|
8
9
|
|
|
@@ -16,7 +17,9 @@ export type GPURigidBodyShape =
|
|
|
16
17
|
| {type: 'capsule'; height: number; radiusBottom: number; radiusTop: number}
|
|
17
18
|
| {type: 'cylinder'; height: number; radiusBottom: number; radiusTop: number}
|
|
18
19
|
| {type: 'convex-hull'; geometry: RigidBodyMeshGeometry}
|
|
19
|
-
| {type: 'triangle-mesh'; geometry: RigidBodyMeshGeometry}
|
|
20
|
+
| {type: 'triangle-mesh'; geometry: RigidBodyMeshGeometry}
|
|
21
|
+
/** Static Z-up terrain with on-GPU triangle reconstruction. */
|
|
22
|
+
| {type: 'height-field'; field: GPURigidBodyHeightField};
|
|
20
23
|
export type GPURigidBodyMaterial = {
|
|
21
24
|
restitution?: number;
|
|
22
25
|
staticFriction?: number;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createBoundKernelAsync
|
|
9
9
|
} from '../gpu-core/utils/bound-kernel';
|
|
10
10
|
import {Buffer, type CommandEncoder} from '@luma.gl/core';
|
|
11
|
-
import {Matrix4} from '@math.gl/core';
|
|
11
|
+
import {Matrix4} from '@math.gl/core/matrix';
|
|
12
12
|
import {normalizeRigidBodyRotation} from './rigid-body-properties';
|
|
13
13
|
|
|
14
14
|
import type {
|
|
@@ -63,15 +63,17 @@ fn closestSurface(collider:u32,point:vec3f)->SurfacePoint{
|
|
|
63
63
|
loop{
|
|
64
64
|
if(node>=nodeCount){break;}if(work>=MESH_TRAVERSAL_BUDGET){complete=0u;break;}work++;
|
|
65
65
|
let lower=readGeometry(nodeOffset+node*3u);let upper=readGeometry(nodeOffset+node*3u+1u);
|
|
66
|
-
if(distance(point,clamp(point,lower.xyz,upper.xyz))>best){node=u32(lower.w);continue;}
|
|
66
|
+
if(any(lower.xyz>upper.xyz)||distance(point,clamp(point,lower.xyz,upper.xyz))>best){node=u32(lower.w);continue;}
|
|
67
67
|
if(upper.w>0.0){let start=u32(readGeometry(nodeOffset+node*3u+2u).x);
|
|
68
68
|
for(var offset=0u;offset<u32(upper.w);offset++){
|
|
69
69
|
if(work>=MESH_TRAVERSAL_BUDGET){complete=0u;break;}work++;
|
|
70
|
+
if(!meshTriangleActive(collider,start+offset)){continue;}
|
|
70
71
|
let candidate=closestTriangle(point,triangleVertex(collider,start+offset,0u),triangleVertex(collider,start+offset,1u),triangleVertex(collider,start+offset,2u));
|
|
71
72
|
let separation=distance(point,candidate);if(separation<best){best=separation;nearest=candidate;}
|
|
72
73
|
}
|
|
73
74
|
}if(complete==0u){break;}node++;
|
|
74
75
|
}
|
|
76
|
+
if(best==3.402823e38){return SurfacePoint(point,best,complete);}
|
|
75
77
|
}
|
|
76
78
|
return SurfacePoint(nearest,select(distance(point,nearest),0.0,inside),complete);
|
|
77
79
|
}
|
|
@@ -125,6 +127,12 @@ fn sweepBox(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,extent:v
|
|
|
125
127
|
if(result.hit!=0u){result.distance=nearest;result.point=origin+direction*nearest-result.normal*radius;}
|
|
126
128
|
return result;
|
|
127
129
|
}
|
|
130
|
+
// Drop the dominant normal component for ray edge tests. An on-edge ray can
|
|
131
|
+
// otherwise look outside when the computed plane intersection rounds off-plane.
|
|
132
|
+
fn rayTriangleEdge(edge:vec3f,offset:vec3f,normal:vec3f,axis:u32)->bool{
|
|
133
|
+
let horizontal=(axis+1u)%3u;let vertical=(axis+2u)%3u;
|
|
134
|
+
return (edge[horizontal]*offset[vertical]-edge[vertical]*offset[horizontal])*normal[axis]>=0.0;
|
|
135
|
+
}
|
|
128
136
|
// A triangle's sphere expansion is convex. Ignore only a departing initial touch
|
|
129
137
|
// on that triangle; other triangles in the same nonconvex mesh remain candidates.
|
|
130
138
|
fn sweepTriangle(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,first:vec3f,second:vec3f,third:vec3f,skipSeparating:bool)->SphereSweep{
|
|
@@ -161,9 +169,18 @@ fn sweepTriangle(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,fir
|
|
|
161
169
|
let travelled=(sign*radius-dot(origin-first,normal))/denominator;
|
|
162
170
|
let point=origin+direction*travelled-normal*(sign*radius);
|
|
163
171
|
if(travelled<0.0||travelled>nearest){continue;}
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
let firstSide=(second-first)/edgeScale;let secondSide=(third-second)/edgeScale;let thirdSide=(first-third)/edgeScale;
|
|
173
|
+
let firstOffset=(point-first)/edgeScale;let secondOffset=(point-second)/edgeScale;let thirdOffset=(point-third)/edgeScale;
|
|
174
|
+
var inside=false;
|
|
175
|
+
if(radius==0.0){
|
|
176
|
+
let magnitude=abs(normal);
|
|
177
|
+
var axis=select(0u,1u,magnitude.y>magnitude.x);
|
|
178
|
+
if(magnitude.z>magnitude[axis]){axis=2u;}
|
|
179
|
+
inside=rayTriangleEdge(firstSide,firstOffset,normal,axis)&&rayTriangleEdge(secondSide,secondOffset,normal,axis)&&rayTriangleEdge(thirdSide,thirdOffset,normal,axis);
|
|
180
|
+
}else{
|
|
181
|
+
inside=dot(cross(firstSide,firstOffset),normal)>=0.0&&dot(cross(secondSide,secondOffset),normal)>=0.0&&dot(cross(thirdSide,thirdOffset),normal)>=0.0;
|
|
166
182
|
}
|
|
183
|
+
if(inside){nearest=travelled;result.hit=1u;result.normal=normal*sign;}
|
|
167
184
|
}}
|
|
168
185
|
if(radius>0.0){
|
|
169
186
|
var vertices=array<vec3f,3>(first,second,third);
|
|
@@ -205,10 +222,11 @@ fn sweepMesh(collider:u32,origin:vec3f,direction:vec3f,maximumDistance:f32,radiu
|
|
|
205
222
|
loop{
|
|
206
223
|
if(node>=nodeCount){break;}if(work>=MESH_TRAVERSAL_BUDGET){result.complete=0u;return result;}work++;
|
|
207
224
|
let lower=readGeometry(nodeOffset+node*3u);let upper=readGeometry(nodeOffset+node*3u+1u);
|
|
208
|
-
if(
|
|
225
|
+
if(any(lower.xyz>upper.xyz)||!intersectsSweepBounds(origin,direction,nearest,lower.xyz-vec3f(radius),upper.xyz+vec3f(radius))){node=u32(lower.w);continue;}
|
|
209
226
|
if(upper.w>0.0){let start=u32(readGeometry(nodeOffset+node*3u+2u).x);
|
|
210
227
|
for(var offset=0u;offset<u32(upper.w);offset++){
|
|
211
228
|
if(work>=MESH_TRAVERSAL_BUDGET){result.complete=0u;return result;}work++;
|
|
229
|
+
if(!meshTriangleActive(collider,start+offset)){continue;}
|
|
212
230
|
let candidate=sweepTriangle(origin,direction,nearest,radius,triangleVertex(collider,start+offset,0u),triangleVertex(collider,start+offset,1u),triangleVertex(collider,start+offset,2u),skipSeparating);
|
|
213
231
|
if(candidate.hit!=0u){nearest=candidate.distance;result=candidate;}
|
|
214
232
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** Bounded rigid-body reference path. Pair discovery is parallel; impulses are ordered on GPU. */
|
|
6
6
|
import {getEnsembleShader} from './rigid-body-ensemble-shaders';
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
getRigidBodyBoundsShader,
|
|
9
9
|
RIGID_BODY_BOUND_PUBLICATION_SHADER
|
|
10
10
|
} from './rigid-body-bounds-shaders';
|
|
11
11
|
import {getRigidBodyParallelShader} from './rigid-body-parallel-shaders';
|
|
@@ -30,7 +30,8 @@ export function getRigidBodyShader(
|
|
|
30
30
|
compactContacts = true,
|
|
31
31
|
collisionPartitionSize?: number,
|
|
32
32
|
ensembleBodiesPerInstance?: number,
|
|
33
|
-
blockContacts = false
|
|
33
|
+
blockContacts = false,
|
|
34
|
+
heightFields = false
|
|
34
35
|
): string {
|
|
35
36
|
return /* wgsl */ `
|
|
36
37
|
const COMPACT_CONTACTS:bool=${compactContacts};
|
|
@@ -48,7 +49,7 @@ struct GeneralConstraint {axes:vec4f,limits:vec4f,control:vec4f,drive:vec4f}
|
|
|
48
49
|
struct JointState {impulses:array<f32,8>, control:vec4f, limits:vec4f, motor:vec4f, drive:vec4f, spring:vec4f, general:GeneralConstraint}
|
|
49
50
|
struct Targets { entries:array<Target,BODY_COUNT>, dispatch:atomic<u32>, vertical:u32, depth:u32 ${sparse ? `, frame:u32, cacheDropped:atomic<u32>, reserved0:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved1:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved2:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, keys:array<CacheKey,PAIR_CAPACITY>` : ''}${ensembleBodiesPerInstance ? `, instanceHeads:array<atomic<u32>,${count / ensembleBodiesPerInstance}>, instanceFrames:array<u32,${count / ensembleBodiesPerInstance}>, links:array<u32,PAIR_CAPACITY>, journalMarks:array<u32,PAIR_CAPACITY>, journalSlots:array<u32,PAIR_CAPACITY>, journalKeys:array<vec2u,PAIR_CAPACITY>, journalLinks:array<u32,PAIR_CAPACITY>, savedHeads:array<u32,${count / ensembleBodiesPerInstance}>, savedFrames:array<u32,${count / ensembleBodiesPerInstance}>, savedHeader:array<u32,8>, journalManifolds:array<Manifold,PAIR_CAPACITY>` : ''}${jointCount ? `, joints:array<JointState,${jointCount}>` : ''} }
|
|
50
51
|
struct Contact { point: vec4f, normal: vec4f, impulse: vec4f, tangent: vec4f, firstAnchor:vec4f, secondAnchor:vec4f }
|
|
51
|
-
struct Manifold { contacts: array<Contact, 4>, count: u32, first:u32, second:u32, previousCount:u32, padding: vec3u }
|
|
52
|
+
struct Manifold { contacts: array<Contact, 4>, count: u32, first:u32, second:u32, previousCount:u32, padding: vec3u, terrainRevision:u32 }
|
|
52
53
|
struct Settings { gravity: vec4f, solver: vec4f, sleep: vec4f, stability: vec4f }
|
|
53
54
|
@group(0) @binding(0) var<uniform> settings: Settings;
|
|
54
55
|
@group(0) @binding(1) var<storage, read_write> positions: array<vec4f>;
|
|
@@ -210,11 +211,11 @@ fn contactFeature(collider:u32,point:vec3f,normal:vec3f)->u32 {
|
|
|
210
211
|
let score=separation+(1.0-alignment)*settings.solver.w;
|
|
211
212
|
if(score<nearest){nearest=score;feature=triangle;}
|
|
212
213
|
}
|
|
213
|
-
return
|
|
214
|
+
return meshTriangleData(collider,feature)/8u;
|
|
214
215
|
}
|
|
215
216
|
fn cookedContactFeature(collider:u32,triangle:i32,fallback:u32)->u32 {
|
|
216
217
|
if(triangle<0){return fallback;}
|
|
217
|
-
return
|
|
218
|
+
return meshTriangleData(collider,u32(triangle))/8u;
|
|
218
219
|
}
|
|
219
220
|
fn storeFeatureContact(pair: u32, slot: u32, point: vec3f, normal: vec3f, depth: f32, previous: Manifold, firstCollider: u32, secondCollider: u32, firstTriangle:i32, secondTriangle:i32) {
|
|
220
221
|
let first=colliderBody(firstCollider);let second=colliderBody(secondCollider);
|
|
@@ -285,7 +286,7 @@ fn clipBoxContact(reference:u32,incident:u32,faceAxis:u32,referenceNormal:vec3f,
|
|
|
285
286
|
fn storeContact(pair:u32,slot:u32,point:vec3f,normal:vec3f,depth:f32,previous:Manifold,first:u32,second:u32){
|
|
286
287
|
storeFeatureContact(pair,slot,point,normal,depth,previous,first,second,-1,-1);
|
|
287
288
|
}
|
|
288
|
-
${
|
|
289
|
+
${getRigidBodyBoundsShader(heightFields)}
|
|
289
290
|
${sparse ? RIGID_BODY_BOUND_PUBLICATION_SHADER : ''}
|
|
290
291
|
${
|
|
291
292
|
extended
|
|
@@ -315,6 +316,16 @@ ${
|
|
|
315
316
|
}
|
|
316
317
|
var previous=manifolds[pair]; ${sparse ? 'previous.count=previous.previousCount;' : ''} manifolds[pair].count=0u;
|
|
317
318
|
${extended ? 'manifolds[pair].padding=vec3u(0);' : ''}
|
|
319
|
+
${
|
|
320
|
+
heightFields
|
|
321
|
+
? `
|
|
322
|
+
// Only one side can be a static height field. Ignore ordinary mesh triangle offsets.
|
|
323
|
+
let firstTerrain=bodies.colliders[first].padding;let secondTerrain=bodies.colliders[second].padding;
|
|
324
|
+
let revision=max(select(0u,u32(firstTerrain.z),firstTerrain.y<0.0),select(0u,u32(secondTerrain.z),secondTerrain.y<0.0));
|
|
325
|
+
if(previous.terrainRevision!=revision){previous.count=0u;}
|
|
326
|
+
manifolds[pair].terrainRevision=revision;`
|
|
327
|
+
: ''
|
|
328
|
+
}
|
|
318
329
|
let firstBody=colliderBody(first);let secondBody=colliderBody(second);
|
|
319
330
|
if(bodies.colliders[first].material.w!=0.0 || bodies.colliders[second].material.w!=0.0 || first>=second || firstBody==secondBody || (excludes(first,second)||excludes(second,first)) || (!dynamic(firstBody) && !dynamic(secondBody))) {return;}
|
|
320
331
|
${extended ? 'manifolds[pair].padding=vec3u(0); if(bodies.colliders[first].shape.w>=2.0 || bodies.colliders[second].shape.w>=2.0){collideExtended(pair,first,second,previous);return;}' : ''}
|
|
@@ -14,6 +14,8 @@ export type RigidBodyShapeProperties = {
|
|
|
14
14
|
/** Geometric properties at unit density, with the tensor measured about its own COM. */
|
|
15
15
|
export function getRigidBodyShapeProperties(shape: GPURigidBodyShape): RigidBodyShapeProperties {
|
|
16
16
|
if (shape.type === 'convex-hull' || shape.type === 'triangle-mesh') return shape.geometry;
|
|
17
|
+
if (shape.type === 'height-field')
|
|
18
|
+
return {volume: 0, center: [0, 0, 0], tensor: Array<number>(9).fill(0)};
|
|
17
19
|
if (shape.type === 'plane') {
|
|
18
20
|
if (
|
|
19
21
|
[shape.sizeX, shape.sizeZ].some(
|