@luma.gl/graph 10.0.0-beta.1 → 10.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +22 -9
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +11 -2
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +27 -10
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +24 -13
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +9 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +41 -14
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +24 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +10 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +29 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- 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-core/gpu-bvh-bounds.cjs +63 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts +32 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.js +56 -0
- package/dist/gpu-core/gpu-bvh-bounds.js.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.cjs +92 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts +41 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js +85 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js.map +1 -0
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +60 -15
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts +13 -2
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +69 -18
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +10 -0
- package/dist/gpu-dataframe/gpu-data-frame.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +157 -25
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +9 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +184 -25
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +100 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +35 -3
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +92 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +2 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +4 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +4 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +11 -5
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +136 -99
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +7 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +135 -97
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +286 -49
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +17 -2
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +290 -40
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +10 -8
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +7 -1
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +14 -8
- 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 +8 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +9 -9
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +38 -10
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +3 -2
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +37 -9
- 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 +12 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +3 -3
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +2 -2
- 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-batch.cjs +11 -10
- package/dist/gpu-physics/gpu-physics-batch.d.ts +1 -0
- package/dist/gpu-physics/gpu-physics-batch.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.js +14 -10
- package/dist/gpu-physics/gpu-physics-batch.js.map +1 -1
- 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 +105 -8
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +40 -2
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +109 -6
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +737 -213
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +111 -5
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +842 -231
- 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 +10 -3
- 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-cache-shaders.cjs +10 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.js +15 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.cjs +15 -2
- package/dist/gpu-physics/rigid-body-capacity.d.ts +3 -1
- package/dist/gpu-physics/rigid-body-capacity.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.js +21 -2
- package/dist/gpu-physics/rigid-body-capacity.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cast-index.cjs +192 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts +44 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-cast-index.js +194 -0
- package/dist/gpu-physics/rigid-body-cast-index.js.map +1 -0
- 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-layout.cjs +4 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.js +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +45 -14
- 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 +53 -14
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.cjs +14 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts +5 -0
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js +17 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +40 -8
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +49 -9
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-event-compaction.cjs +184 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts +35 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js +168 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.cjs +51 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts +33 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js +34 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js.map +1 -0
- package/dist/gpu-physics/rigid-body-events.cjs +57 -25
- package/dist/gpu-physics/rigid-body-events.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-events.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-events.js +60 -25
- package/dist/gpu-physics/rigid-body-events.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-joints.cjs +8 -3
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +10 -6
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- 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-queries.cjs +159 -16
- package/dist/gpu-physics/rigid-body-queries.d.ts +24 -1
- package/dist/gpu-physics/rigid-body-queries.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.js +166 -14
- package/dist/gpu-physics/rigid-body-queries.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 +13 -7
- 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 +16 -8
- 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 +54 -15
- package/dist/gpu-physics/rigid-body-triggers.d.ts +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +56 -15
- 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-physics/sphere-world-shaders.cjs +48 -20
- package/dist/gpu-physics/sphere-world-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.js +51 -21
- package/dist/gpu-physics/sphere-world-shaders.js.map +1 -1
- package/dist/gpu-project/benchmarks.cjs.map +2 -2
- 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 +3 -3
- package/dist/gpu-project/crs.d.ts +1 -1
- package/dist/gpu-project/index.cjs.map +2 -2
- 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/projection-program.cjs +2 -9
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -8
- package/dist/gpu-project/projection-program.js.map +1 -1
- 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 +269 -171
- package/dist/gpu-sql/gpu-sql.d.ts +36 -1
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +313 -181
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/index.d.ts +1 -1
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/utils/float32.cjs +35 -0
- package/dist/utils/float32.d.ts +3 -0
- package/dist/utils/float32.d.ts.map +1 -0
- package/dist/utils/float32.js +16 -0
- package/dist/utils/float32.js.map +1 -0
- package/package.json +19 -19
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +77 -25
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +52 -16
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +46 -1
- package/src/arrow/index.ts +1 -0
- package/src/experimental-models.ts +5 -0
- package/src/experimental-simulation.ts +5 -0
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/index.ts +5 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +7 -10
- package/src/gpu-dataframe/gpu-data-frame-query.ts +119 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +267 -32
- package/src/gpu-dataframe/gpu-expression.ts +186 -10
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +6 -3
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +17 -6
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +177 -105
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +469 -53
- package/src/gpu-dataframe/gpu-group-by-query.ts +29 -13
- package/src/gpu-dataframe/gpu-histogram-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-join-compiler.ts +12 -8
- package/src/gpu-dataframe/gpu-query-compiler.ts +61 -19
- 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 +16 -3
- 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-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble-terrain.ts +114 -0
- package/src/gpu-physics/gpu-physics-ensemble.ts +166 -7
- package/src/gpu-physics/gpu-rigid-body-world.ts +1085 -287
- package/src/gpu-physics/index.ts +46 -0
- package/src/gpu-physics/rigid-body-bounds-shaders.ts +16 -1
- package/src/gpu-physics/rigid-body-cache-shaders.ts +18 -6
- package/src/gpu-physics/rigid-body-capacity.ts +25 -4
- package/src/gpu-physics/rigid-body-cast-index.ts +277 -0
- package/src/gpu-physics/rigid-body-convex-shaders.ts +3 -2
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +67 -15
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +61 -10
- package/src/gpu-physics/rigid-body-event-compaction.ts +252 -0
- package/src/gpu-physics/rigid-body-event-snapshot.ts +76 -0
- package/src/gpu-physics/rigid-body-events.ts +63 -25
- 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-joints.ts +9 -11
- 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-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-query-geometry.ts +22 -4
- package/src/gpu-physics/rigid-body-shaders.ts +20 -8
- 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 +65 -20
- package/src/gpu-physics/rigid-body-vehicle.ts +108 -41
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- 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/projection-program.ts +1 -9
- 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 +535 -223
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
import { makeCoplanarFeatures } from "./rigid-body-contact-features.js";
|
|
5
|
-
|
|
5
|
+
import { packRigidBodyHeightField } from "./rigid-body-height-field.js";
|
|
6
|
+
/** Pack collider metadata and its contiguous GPU geometry uploads. */
|
|
7
|
+
export function packRigidBodyShapes(colliders, shareHeightFields = false, writableHeightFields, useTerrainAtlas = false) {
|
|
6
8
|
const geometry = [];
|
|
7
9
|
const packedMeshes = new Map();
|
|
8
|
-
const
|
|
10
|
+
const sharedHeightFields = new Map();
|
|
11
|
+
const heightFields = new Map();
|
|
12
|
+
const atlasFields = new Map();
|
|
13
|
+
const writablePayloads = new Map();
|
|
14
|
+
const shapes = colliders.map(({ shape }, colliderIndex) => {
|
|
9
15
|
const policies = [0, 0];
|
|
10
16
|
const padding = [0, 0, 0, 0];
|
|
11
17
|
let dimensions;
|
|
@@ -22,6 +28,41 @@ export function packRigidBodyShapes(colliders) {
|
|
|
22
28
|
shape.height,
|
|
23
29
|
shape.type === 'capsule' ? 4 : 5
|
|
24
30
|
];
|
|
31
|
+
else if (shape.type === 'height-field') {
|
|
32
|
+
const writable = !shareHeightFields || writableHeightFields?.has(colliderIndex);
|
|
33
|
+
const shared = writable ? undefined : sharedHeightFields.get(shape.field);
|
|
34
|
+
if (shared) {
|
|
35
|
+
padding.splice(0, padding.length, ...shared.padding);
|
|
36
|
+
policies.splice(0, policies.length, ...shared.policies);
|
|
37
|
+
dimensions = [...shared.extent, 3];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const packed = writablePayloads.get(shape.field) ?? packRigidBodyHeightField(shape.field);
|
|
41
|
+
if (shareHeightFields && writable)
|
|
42
|
+
writablePayloads.set(shape.field, packed);
|
|
43
|
+
if (useTerrainAtlas && writable) {
|
|
44
|
+
padding[1] = -shape.field.width;
|
|
45
|
+
dimensions = [...packed.extent, 3];
|
|
46
|
+
if (packed.nodeCount)
|
|
47
|
+
atlasFields.set(colliderIndex, packed);
|
|
48
|
+
return { dimensions, policies, padding };
|
|
49
|
+
}
|
|
50
|
+
const offset = geometry.length / 4;
|
|
51
|
+
padding[0] = offset;
|
|
52
|
+
// Negative vertex count distinguishes implicit height-field triangles in the mesh kernels.
|
|
53
|
+
padding[1] = -shape.field.width;
|
|
54
|
+
padding[3] = packed.triangleCount;
|
|
55
|
+
policies[0] = offset + packed.nodeOffset;
|
|
56
|
+
policies[1] = packed.nodeCount;
|
|
57
|
+
dimensions = [...packed.extent, 3];
|
|
58
|
+
for (const value of packed.data)
|
|
59
|
+
geometry.push(value);
|
|
60
|
+
if (writable)
|
|
61
|
+
heightFields.set(colliderIndex, offset);
|
|
62
|
+
else
|
|
63
|
+
sharedHeightFields.set(shape.field, { padding, policies, extent: packed.extent });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
25
66
|
else {
|
|
26
67
|
const mesh = shape.geometry;
|
|
27
68
|
const shared = packedMeshes.get(mesh);
|
|
@@ -63,6 +104,6 @@ export function packRigidBodyShapes(colliders) {
|
|
|
63
104
|
geometry.push(0);
|
|
64
105
|
return [start, excluded.length];
|
|
65
106
|
});
|
|
66
|
-
return { shapes, geometry, filters };
|
|
107
|
+
return { shapes, geometry, filters, heightFields, atlasFields };
|
|
67
108
|
}
|
|
68
109
|
//# sourceMappingURL=rigid-body-geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rigid-body-geometry.js","sourceRoot":"","sources":["../../src/gpu-physics/rigid-body-geometry.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,oBAAoB,EAAC,yCAAsC;
|
|
1
|
+
{"version":3,"file":"rigid-body-geometry.js","sour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AAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAClE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAClC,CAAC;QACF,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,QAAQ;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,2DAA2D;QAC3D,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAU,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var rigid_body_height_field_shader_exports = {};
|
|
19
|
+
__export(rigid_body_height_field_shader_exports, {
|
|
20
|
+
RIGID_BODY_HEIGHT_FIELD_SHADER: () => RIGID_BODY_HEIGHT_FIELD_SHADER
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(rigid_body_height_field_shader_exports);
|
|
23
|
+
const RIGID_BODY_HEIGHT_FIELD_SHADER = (
|
|
24
|
+
/* wgsl */
|
|
25
|
+
`
|
|
26
|
+
fn heightFieldSample(base:u32,index:u32)->f32{return readGeometry(base+2u+index/4u)[index%4u];}
|
|
27
|
+
fn heightFieldCell(width:u32,triangle:u32)->vec2u{
|
|
28
|
+
let cell=triangle/2u;
|
|
29
|
+
return vec2u(cell%(width-1u),cell/(width-1u));
|
|
30
|
+
}
|
|
31
|
+
fn heightFieldCorners(flags:u32,triangle:u32)->vec3u{
|
|
32
|
+
let second=(triangle&1u)!=0u;
|
|
33
|
+
var corners=select(vec3u(0,1,3),vec3u(0,3,2),second);
|
|
34
|
+
if((flags&1u)!=0u){corners=select(vec3u(0,1,2),vec3u(1,3,2),second);}
|
|
35
|
+
if((flags&2u)!=0u){corners=corners.xzy;}
|
|
36
|
+
return corners;
|
|
37
|
+
}
|
|
38
|
+
fn heightFieldTriangleIndices(base:u32,triangle:u32)->vec3u{
|
|
39
|
+
let header=readGeometry(base+1u);
|
|
40
|
+
let width=u32(header.z);
|
|
41
|
+
let cell=heightFieldCell(width,triangle);
|
|
42
|
+
let corners=heightFieldCorners(u32(header.w),triangle);
|
|
43
|
+
return vec3u(cell.y*width+cell.x)+(corners/2u)*width+(corners%2u);
|
|
44
|
+
}
|
|
45
|
+
fn heightFieldTriangleVertex(collider:u32,triangle:u32,corner:u32)->vec3f{
|
|
46
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
47
|
+
let steps=readGeometry(base);let header=readGeometry(base+1u);let width=u32(header.z);
|
|
48
|
+
let index=heightFieldTriangleIndices(base,triangle)[corner];
|
|
49
|
+
let position=header.xy+f32(index%width)*steps.xy+f32(index/width)*steps.zw;
|
|
50
|
+
return vec3f(position,heightFieldSample(base,index));
|
|
51
|
+
}
|
|
52
|
+
fn heightFieldTriangleActive(collider:u32,triangle:u32)->bool{
|
|
53
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
54
|
+
let indices=heightFieldTriangleIndices(base,triangle);
|
|
55
|
+
return heightFieldSample(base,indices.x)!=3.402823e38 &&
|
|
56
|
+
heightFieldSample(base,indices.y)!=3.402823e38 &&
|
|
57
|
+
heightFieldSample(base,indices.z)!=3.402823e38;
|
|
58
|
+
}
|
|
59
|
+
fn heightFieldTriangleData(collider:u32,triangle:u32)->u32{
|
|
60
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
61
|
+
let header=readGeometry(base+1u);
|
|
62
|
+
let width=u32(header.z);let flags=u32(header.w);
|
|
63
|
+
let cell=heightFieldCell(width,triangle);let start=cell.y*width+cell.x;
|
|
64
|
+
let first=heightFieldSample(base,start);let second=heightFieldSample(base,start+1u);
|
|
65
|
+
let third=heightFieldSample(base,start+width);let fourth=heightFieldSample(base,start+width+1u);
|
|
66
|
+
if(any(vec4f(first,second,third,fourth)==vec4f(3.402823e38))){return (triangle+1u)*8u;}
|
|
67
|
+
// Remove the quad diagonal only when it joins coplanar triangles.
|
|
68
|
+
if((first-second)+(fourth-third)!=0.0){return (triangle+1u)*8u;}
|
|
69
|
+
let odd=(triangle&1u)!=0u;
|
|
70
|
+
var edge=select(2u,0u,odd);
|
|
71
|
+
if((flags&1u)!=0u){edge=select(1u,2u,odd);}
|
|
72
|
+
if((flags&2u)!=0u){edge=2u-edge;}
|
|
73
|
+
return ((triangle & 0xfffffffeu)+1u)*8u+(1u<<edge);
|
|
74
|
+
}
|
|
75
|
+
`
|
|
76
|
+
);
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
RIGID_BODY_HEIGHT_FIELD_SHADER
|
|
80
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Reconstruct the same upward-oriented grid triangles used by CPU terrain meshing. */
|
|
2
|
+
export declare const RIGID_BODY_HEIGHT_FIELD_SHADER = "\nfn heightFieldSample(base:u32,index:u32)->f32{return readGeometry(base+2u+index/4u)[index%4u];}\nfn heightFieldCell(width:u32,triangle:u32)->vec2u{\n let cell=triangle/2u;\n return vec2u(cell%(width-1u),cell/(width-1u));\n}\nfn heightFieldCorners(flags:u32,triangle:u32)->vec3u{\n let second=(triangle&1u)!=0u;\n var corners=select(vec3u(0,1,3),vec3u(0,3,2),second);\n if((flags&1u)!=0u){corners=select(vec3u(0,1,2),vec3u(1,3,2),second);}\n if((flags&2u)!=0u){corners=corners.xzy;}\n return corners;\n}\nfn heightFieldTriangleIndices(base:u32,triangle:u32)->vec3u{\n let header=readGeometry(base+1u);\n let width=u32(header.z);\n let cell=heightFieldCell(width,triangle);\n let corners=heightFieldCorners(u32(header.w),triangle);\n return vec3u(cell.y*width+cell.x)+(corners/2u)*width+(corners%2u);\n}\nfn heightFieldTriangleVertex(collider:u32,triangle:u32,corner:u32)->vec3f{\n let base=u32(bodies.colliders[collider].padding.x);\n let steps=readGeometry(base);let header=readGeometry(base+1u);let width=u32(header.z);\n let index=heightFieldTriangleIndices(base,triangle)[corner];\n let position=header.xy+f32(index%width)*steps.xy+f32(index/width)*steps.zw;\n return vec3f(position,heightFieldSample(base,index));\n}\nfn heightFieldTriangleActive(collider:u32,triangle:u32)->bool{\n let base=u32(bodies.colliders[collider].padding.x);\n let indices=heightFieldTriangleIndices(base,triangle);\n return heightFieldSample(base,indices.x)!=3.402823e38 &&\n heightFieldSample(base,indices.y)!=3.402823e38 &&\n heightFieldSample(base,indices.z)!=3.402823e38;\n}\nfn heightFieldTriangleData(collider:u32,triangle:u32)->u32{\n let base=u32(bodies.colliders[collider].padding.x);\n let header=readGeometry(base+1u);\n let width=u32(header.z);let flags=u32(header.w);\n let cell=heightFieldCell(width,triangle);let start=cell.y*width+cell.x;\n let first=heightFieldSample(base,start);let second=heightFieldSample(base,start+1u);\n let third=heightFieldSample(base,start+width);let fourth=heightFieldSample(base,start+width+1u);\n if(any(vec4f(first,second,third,fourth)==vec4f(3.402823e38))){return (triangle+1u)*8u;}\n // Remove the quad diagonal only when it joins coplanar triangles.\n if((first-second)+(fourth-third)!=0.0){return (triangle+1u)*8u;}\n let odd=(triangle&1u)!=0u;\n var edge=select(2u,0u,odd);\n if((flags&1u)!=0u){edge=select(1u,2u,odd);}\n if((flags&2u)!=0u){edge=2u-edge;}\n return ((triangle & 0xfffffffeu)+1u)*8u+(1u<<edge);\n}\n";
|
|
3
|
+
//# sourceMappingURL=rigid-body-height-field-shader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rigid-body-height-field-shader.d.ts","sourceRoot":"","sources":["../../src/gpu-physics/rigid-body-height-field-shader.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,o6EAkD1C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
/** Reconstruct the same upward-oriented grid triangles used by CPU terrain meshing. */
|
|
5
|
+
export const RIGID_BODY_HEIGHT_FIELD_SHADER = /* wgsl */ `
|
|
6
|
+
fn heightFieldSample(base:u32,index:u32)->f32{return readGeometry(base+2u+index/4u)[index%4u];}
|
|
7
|
+
fn heightFieldCell(width:u32,triangle:u32)->vec2u{
|
|
8
|
+
let cell=triangle/2u;
|
|
9
|
+
return vec2u(cell%(width-1u),cell/(width-1u));
|
|
10
|
+
}
|
|
11
|
+
fn heightFieldCorners(flags:u32,triangle:u32)->vec3u{
|
|
12
|
+
let second=(triangle&1u)!=0u;
|
|
13
|
+
var corners=select(vec3u(0,1,3),vec3u(0,3,2),second);
|
|
14
|
+
if((flags&1u)!=0u){corners=select(vec3u(0,1,2),vec3u(1,3,2),second);}
|
|
15
|
+
if((flags&2u)!=0u){corners=corners.xzy;}
|
|
16
|
+
return corners;
|
|
17
|
+
}
|
|
18
|
+
fn heightFieldTriangleIndices(base:u32,triangle:u32)->vec3u{
|
|
19
|
+
let header=readGeometry(base+1u);
|
|
20
|
+
let width=u32(header.z);
|
|
21
|
+
let cell=heightFieldCell(width,triangle);
|
|
22
|
+
let corners=heightFieldCorners(u32(header.w),triangle);
|
|
23
|
+
return vec3u(cell.y*width+cell.x)+(corners/2u)*width+(corners%2u);
|
|
24
|
+
}
|
|
25
|
+
fn heightFieldTriangleVertex(collider:u32,triangle:u32,corner:u32)->vec3f{
|
|
26
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
27
|
+
let steps=readGeometry(base);let header=readGeometry(base+1u);let width=u32(header.z);
|
|
28
|
+
let index=heightFieldTriangleIndices(base,triangle)[corner];
|
|
29
|
+
let position=header.xy+f32(index%width)*steps.xy+f32(index/width)*steps.zw;
|
|
30
|
+
return vec3f(position,heightFieldSample(base,index));
|
|
31
|
+
}
|
|
32
|
+
fn heightFieldTriangleActive(collider:u32,triangle:u32)->bool{
|
|
33
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
34
|
+
let indices=heightFieldTriangleIndices(base,triangle);
|
|
35
|
+
return heightFieldSample(base,indices.x)!=3.402823e38 &&
|
|
36
|
+
heightFieldSample(base,indices.y)!=3.402823e38 &&
|
|
37
|
+
heightFieldSample(base,indices.z)!=3.402823e38;
|
|
38
|
+
}
|
|
39
|
+
fn heightFieldTriangleData(collider:u32,triangle:u32)->u32{
|
|
40
|
+
let base=u32(bodies.colliders[collider].padding.x);
|
|
41
|
+
let header=readGeometry(base+1u);
|
|
42
|
+
let width=u32(header.z);let flags=u32(header.w);
|
|
43
|
+
let cell=heightFieldCell(width,triangle);let start=cell.y*width+cell.x;
|
|
44
|
+
let first=heightFieldSample(base,start);let second=heightFieldSample(base,start+1u);
|
|
45
|
+
let third=heightFieldSample(base,start+width);let fourth=heightFieldSample(base,start+width+1u);
|
|
46
|
+
if(any(vec4f(first,second,third,fourth)==vec4f(3.402823e38))){return (triangle+1u)*8u;}
|
|
47
|
+
// Remove the quad diagonal only when it joins coplanar triangles.
|
|
48
|
+
if((first-second)+(fourth-third)!=0.0){return (triangle+1u)*8u;}
|
|
49
|
+
let odd=(triangle&1u)!=0u;
|
|
50
|
+
var edge=select(2u,0u,odd);
|
|
51
|
+
if((flags&1u)!=0u){edge=select(1u,2u,odd);}
|
|
52
|
+
if((flags&2u)!=0u){edge=2u-edge;}
|
|
53
|
+
return ((triangle & 0xfffffffeu)+1u)*8u+(1u<<edge);
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
//# sourceMappingURL=rigid-body-height-field-shader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rigid-body-height-field-shader.js","sourceRoot":"","sources":["../../src/gpu-physics/rigid-body-height-field-shader.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,uFAAuF;AACvF,MAAM,CAAC,MAAM,8BAA8B,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDxD,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var rigid_body_height_field_exports = {};
|
|
19
|
+
__export(rigid_body_height_field_exports, {
|
|
20
|
+
getRigidBodyHeightFieldPageWords: () => getRigidBodyHeightFieldPageWords,
|
|
21
|
+
makeRigidBodyHeightField: () => makeRigidBodyHeightField,
|
|
22
|
+
packRigidBodyHeightField: () => packRigidBodyHeightField
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(rigid_body_height_field_exports);
|
|
25
|
+
function makeRigidBodyHeightField(source, colliderOrigin) {
|
|
26
|
+
const samples = source.copyData();
|
|
27
|
+
const registrationOffset = source.registration === "cell" ? 0.5 : 0;
|
|
28
|
+
return {
|
|
29
|
+
width: source.width,
|
|
30
|
+
height: source.height,
|
|
31
|
+
origin: [
|
|
32
|
+
source.origin[0] - colliderOrigin[0] + registrationOffset * (source.columnStep[0] + source.rowStep[0]),
|
|
33
|
+
source.origin[1] - colliderOrigin[1] + registrationOffset * (source.columnStep[1] + source.rowStep[1])
|
|
34
|
+
],
|
|
35
|
+
columnStep: [...source.columnStep],
|
|
36
|
+
rowStep: [...source.rowStep],
|
|
37
|
+
diagonal: source.diagonal,
|
|
38
|
+
heights: Float64Array.from(samples.heights, (height) => height - colliderOrigin[2]),
|
|
39
|
+
validity: samples.validity
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const MISSING_HEIGHT = Math.fround(3402823e32);
|
|
43
|
+
const CELLS_PER_LEAF = 8;
|
|
44
|
+
function getRigidBodyHeightFieldPageWords(width, height) {
|
|
45
|
+
const sampleCount = width * height;
|
|
46
|
+
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 2 || height < 2 || sampleCount > 1e6)
|
|
47
|
+
throw new Error("Invalid height-field grid");
|
|
48
|
+
const memo = /* @__PURE__ */ new Map();
|
|
49
|
+
const countLeaves = (columns) => {
|
|
50
|
+
if (columns <= CELLS_PER_LEAF)
|
|
51
|
+
return 1;
|
|
52
|
+
const cached = memo.get(columns);
|
|
53
|
+
if (cached !== void 0)
|
|
54
|
+
return cached;
|
|
55
|
+
const half = Math.floor(columns / 2);
|
|
56
|
+
const leaves2 = countLeaves(half) + countLeaves(columns - half);
|
|
57
|
+
memo.set(columns, leaves2);
|
|
58
|
+
return leaves2;
|
|
59
|
+
};
|
|
60
|
+
const leaves = countLeaves(width - 1) * (height - 1);
|
|
61
|
+
return 8 + Math.ceil(sampleCount / 4) * 4 + (2 * leaves - 1) * 12;
|
|
62
|
+
}
|
|
63
|
+
function packRigidBodyHeightField(field) {
|
|
64
|
+
const { width, height, heights, validity, diagonal = "00-11" } = field;
|
|
65
|
+
const sampleCount = width * height;
|
|
66
|
+
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 2 || height < 2 || sampleCount > 1e6 || heights && heights.length !== sampleCount || validity && validity.length !== sampleCount || diagonal !== "00-11" && diagonal !== "10-01")
|
|
67
|
+
throw new Error("Invalid height-field grid");
|
|
68
|
+
const origin = (field.origin ?? [0, 0]).map(Math.fround);
|
|
69
|
+
const columnStep = (field.columnStep ?? [1, 0]).map(Math.fround);
|
|
70
|
+
const rowStep = (field.rowStep ?? [0, 1]).map(Math.fround);
|
|
71
|
+
const determinant = columnStep[0] * rowStep[1] - columnStep[1] * rowStep[0];
|
|
72
|
+
const horizontalScale = [0, 1].map((axis) => Math.abs(origin[axis]) + Math.abs(columnStep[axis]) * (width - 1) + Math.abs(rowStep[axis]) * (height - 1));
|
|
73
|
+
if (origin.length !== 2 || columnStep.length !== 2 || rowStep.length !== 2 || ![...origin, ...columnStep, ...rowStep, ...horizontalScale].every((value) => Number.isFinite(Math.fround(value))) || Math.abs(determinant) <= 1e-7 * Math.hypot(...columnStep) * Math.hypot(...rowStep))
|
|
74
|
+
throw new Error("Invalid height-field transform");
|
|
75
|
+
const roundingPadding = horizontalScale.map((value) => value * 2 ** -21);
|
|
76
|
+
const nodeOffset = 2 + Math.ceil(sampleCount / 4);
|
|
77
|
+
const data = new Array(nodeOffset * 4).fill(MISSING_HEIGHT);
|
|
78
|
+
data.splice(0, 8, ...columnStep, ...rowStep, ...origin, width, Number(diagonal === "10-01") + 2 * Number(determinant < 0));
|
|
79
|
+
for (let index = 0; heights && index < sampleCount; index++) {
|
|
80
|
+
if ((validity == null ? void 0 : validity[index]) === 0 || !Number.isFinite(heights[index]))
|
|
81
|
+
continue;
|
|
82
|
+
const sample = Math.fround(heights[index]);
|
|
83
|
+
if (!Number.isFinite(sample) || sample === MISSING_HEIGHT)
|
|
84
|
+
throw new Error("Height-field sample exceeds float32 range");
|
|
85
|
+
data[8 + index] = sample;
|
|
86
|
+
}
|
|
87
|
+
const appendNode = (firstColumn, firstRow, columns, rows) => {
|
|
88
|
+
const offset = data.length;
|
|
89
|
+
data.push(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
90
|
+
let minimumHeight = Infinity;
|
|
91
|
+
let maximumHeight = -Infinity;
|
|
92
|
+
if (rows === 1 && columns <= CELLS_PER_LEAF) {
|
|
93
|
+
const firstSample = firstRow * width + firstColumn;
|
|
94
|
+
for (let column = 0; column < columns; column++) {
|
|
95
|
+
const sample = 8 + firstSample + column;
|
|
96
|
+
const first = data[sample];
|
|
97
|
+
const second = data[sample + 1];
|
|
98
|
+
const third = data[sample + width];
|
|
99
|
+
const fourth = data[sample + width + 1];
|
|
100
|
+
const triangles = diagonal === "00-11" ? [first, second, fourth, first, fourth, third] : [first, second, third, second, fourth, third];
|
|
101
|
+
for (let triangle = 0; triangle < 6; triangle += 3) {
|
|
102
|
+
const cornerA = triangles[triangle];
|
|
103
|
+
const cornerB = triangles[triangle + 1];
|
|
104
|
+
const cornerC = triangles[triangle + 2];
|
|
105
|
+
if (cornerA === MISSING_HEIGHT || cornerB === MISSING_HEIGHT || cornerC === MISSING_HEIGHT)
|
|
106
|
+
continue;
|
|
107
|
+
minimumHeight = Math.min(minimumHeight, cornerA, cornerB, cornerC);
|
|
108
|
+
maximumHeight = Math.max(maximumHeight, cornerA, cornerB, cornerC);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
data[offset + 7] = minimumHeight <= maximumHeight ? columns * 2 : 0;
|
|
112
|
+
data[offset + 8] = 2 * (firstRow * (width - 1) + firstColumn);
|
|
113
|
+
} else {
|
|
114
|
+
let firstChild;
|
|
115
|
+
let secondChild;
|
|
116
|
+
if (columns > CELLS_PER_LEAF && (rows === 1 || columns >= rows * CELLS_PER_LEAF)) {
|
|
117
|
+
const split = Math.floor(columns / 2);
|
|
118
|
+
firstChild = appendNode(firstColumn, firstRow, split, rows);
|
|
119
|
+
secondChild = appendNode(firstColumn + split, firstRow, columns - split, rows);
|
|
120
|
+
} else {
|
|
121
|
+
const split = Math.floor(rows / 2);
|
|
122
|
+
firstChild = appendNode(firstColumn, firstRow, columns, split);
|
|
123
|
+
secondChild = appendNode(firstColumn, firstRow + split, columns, rows - split);
|
|
124
|
+
}
|
|
125
|
+
minimumHeight = Math.min(data[firstChild + 2], data[secondChild + 2]);
|
|
126
|
+
maximumHeight = Math.max(data[firstChild + 6], data[secondChild + 6]);
|
|
127
|
+
}
|
|
128
|
+
if (minimumHeight <= maximumHeight) {
|
|
129
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
130
|
+
const first = origin[axis] + firstColumn * columnStep[axis] + firstRow * rowStep[axis];
|
|
131
|
+
const column = columns * columnStep[axis];
|
|
132
|
+
const row = rows * rowStep[axis];
|
|
133
|
+
data[offset + axis] = first + Math.min(0, column) + Math.min(0, row) - roundingPadding[axis];
|
|
134
|
+
data[offset + 4 + axis] = first + Math.max(0, column) + Math.max(0, row) + roundingPadding[axis];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
data[offset + 2] = minimumHeight;
|
|
138
|
+
data[offset + 6] = maximumHeight;
|
|
139
|
+
data[offset + 3] = (data.length - nodeOffset * 4) / 12;
|
|
140
|
+
return offset;
|
|
141
|
+
};
|
|
142
|
+
const root = appendNode(0, 0, width - 1, height - 1);
|
|
143
|
+
const active = data[root + 2] <= data[root + 6];
|
|
144
|
+
for (let offset = root; offset < data.length; offset += 12) {
|
|
145
|
+
if (data[offset + 2] > data[offset + 6]) {
|
|
146
|
+
data[offset + 2] = 1;
|
|
147
|
+
data[offset + 6] = -1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const extent = active ? [0, 1, 2].map((axis) => Math.max(Math.abs(data[root + axis]), Math.abs(data[root + 4 + axis]))) : [0, 0, 0];
|
|
151
|
+
if (!extent.every((value) => Number.isFinite(Math.fround(value))))
|
|
152
|
+
throw new Error("Height-field bounds exceed float32 range");
|
|
153
|
+
return {
|
|
154
|
+
data,
|
|
155
|
+
extent,
|
|
156
|
+
nodeOffset,
|
|
157
|
+
nodeCount: active ? (data.length - root) / 12 : 0,
|
|
158
|
+
triangleCount: active ? (width - 1) * (height - 1) * 2 : 0
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
getRigidBodyHeightFieldPageWords,
|
|
164
|
+
makeRigidBodyHeightField,
|
|
165
|
+
packRigidBodyHeightField
|
|
166
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { RigidBodyVector } from "./rigid-body-properties.js";
|
|
2
|
+
/** Grid in the collider's local Z-up frame, with row-major scalar heights. */
|
|
3
|
+
export type GPURigidBodyHeightField = {
|
|
4
|
+
/** Number of columns, including both ends of the tile. */
|
|
5
|
+
width: number;
|
|
6
|
+
/** Number of rows, including both ends of the tile. */
|
|
7
|
+
height: number;
|
|
8
|
+
/** First sample in local XY, after any cell-registration shift. */
|
|
9
|
+
origin?: readonly [number, number];
|
|
10
|
+
/** Metric column basis vector. Defaults to a unit step along X. */
|
|
11
|
+
columnStep?: readonly [number, number];
|
|
12
|
+
/** Metric row basis vector. Defaults to a unit step along Y. */
|
|
13
|
+
rowStep?: readonly [number, number];
|
|
14
|
+
/** The diagonal connecting opposite samples in each cell. */
|
|
15
|
+
diagonal?: '00-11' | '10-01';
|
|
16
|
+
/** Missing heights allocate a vacant slot. Nonfinite or masked samples omit their triangles. */
|
|
17
|
+
heights?: Float32Array | Float64Array;
|
|
18
|
+
/** Optional row-major mask with zero for an absent sample. */
|
|
19
|
+
validity?: Uint8Array;
|
|
20
|
+
};
|
|
21
|
+
/** Structural subset of math.gl HeightField needed to create a collider without a terrain dependency. */
|
|
22
|
+
export type GPURigidBodyHeightFieldSource = {
|
|
23
|
+
/** Source column count. */
|
|
24
|
+
readonly width: number;
|
|
25
|
+
/** Source row count. */
|
|
26
|
+
readonly height: number;
|
|
27
|
+
/** Metric source origin before applying sample registration. */
|
|
28
|
+
readonly origin: readonly [number, number];
|
|
29
|
+
/** Metric column basis vector. */
|
|
30
|
+
readonly columnStep: readonly [number, number];
|
|
31
|
+
/** Metric row basis vector. */
|
|
32
|
+
readonly rowStep: readonly [number, number];
|
|
33
|
+
/** Placement of the first sample relative to the source origin. */
|
|
34
|
+
readonly registration: 'vertex' | 'cell';
|
|
35
|
+
/** Authored triangle diagonal used for each cell. */
|
|
36
|
+
readonly diagonal: '00-11' | '10-01';
|
|
37
|
+
/** Return detached row-major data and validity. */
|
|
38
|
+
copyData(): {
|
|
39
|
+
heights: Float32Array | Float64Array;
|
|
40
|
+
validity: Uint8Array;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** Detach math.gl samples and express them relative to the supplied collider origin. */
|
|
44
|
+
export declare function makeRigidBodyHeightField(source: GPURigidBodyHeightFieldSource, colliderOrigin: RigidBodyVector): GPURigidBodyHeightField;
|
|
45
|
+
/** Exact fixed payload size, independent of height values and missing-data masks. */
|
|
46
|
+
export declare function getRigidBodyHeightFieldPageWords(width: number, height: number): number;
|
|
47
|
+
/** Pack scalar samples and a bounded stackless hierarchy, with no stored vertices or triangle indices. */
|
|
48
|
+
export declare function packRigidBodyHeightField(field: GPURigidBodyHeightField): {
|
|
49
|
+
data: number[];
|
|
50
|
+
extent: number[];
|
|
51
|
+
nodeOffset: number;
|
|
52
|
+
nodeCount: number;
|
|
53
|
+
triangleCount: number;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=rigid-body-height-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rigid-body-height-field.d.ts","sourceRoot":"","sources":["../../src/gpu-physics/rigid-body-height-field.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,mCAAgC;AAE7D,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GAAG;IACpC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,mEAAmE;IACnE,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,gEAAgE;IAChE,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,gGAAgG;IAChG,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,yGAAyG;AACzG,MAAM,MAAM,6BAA6B,GAAG;IAC1C,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,mEAAmE;IACnE,QAAQ,CAAC,YAAY,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IACrC,mDAAmD;IACnD,QAAQ,IAAI;QAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAC,CAAC;CAC1E,CAAC;AAEF,wFAAwF;AACxF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,6BAA6B,EACrC,cAAc,EAAE,eAAe,GAC9B,uBAAuB,CAoBzB;AAOD,qFAAqF;AACrF,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAyBtF;AAED,0GAA0G;AAC1G,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB;;;;;;EAsJtE"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
/** Detach math.gl samples and express them relative to the supplied collider origin. */
|
|
5
|
+
export function makeRigidBodyHeightField(source, colliderOrigin) {
|
|
6
|
+
const samples = source.copyData();
|
|
7
|
+
const registrationOffset = source.registration === 'cell' ? 0.5 : 0;
|
|
8
|
+
return {
|
|
9
|
+
width: source.width,
|
|
10
|
+
height: source.height,
|
|
11
|
+
origin: [
|
|
12
|
+
source.origin[0] -
|
|
13
|
+
colliderOrigin[0] +
|
|
14
|
+
registrationOffset * (source.columnStep[0] + source.rowStep[0]),
|
|
15
|
+
source.origin[1] -
|
|
16
|
+
colliderOrigin[1] +
|
|
17
|
+
registrationOffset * (source.columnStep[1] + source.rowStep[1])
|
|
18
|
+
],
|
|
19
|
+
columnStep: [...source.columnStep],
|
|
20
|
+
rowStep: [...source.rowStep],
|
|
21
|
+
diagonal: source.diagonal,
|
|
22
|
+
heights: Float64Array.from(samples.heights, height => height - colliderOrigin[2]),
|
|
23
|
+
validity: samples.validity
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** One reserved f32 value marks a missing height in the GPU data. */
|
|
27
|
+
const MISSING_HEIGHT = Math.fround(3.402823e38);
|
|
28
|
+
/** Leaves cover a contiguous range from a single row of at most eight cells. */
|
|
29
|
+
const CELLS_PER_LEAF = 8;
|
|
30
|
+
/** Exact fixed payload size, independent of height values and missing-data masks. */
|
|
31
|
+
export function getRigidBodyHeightFieldPageWords(width, height) {
|
|
32
|
+
const sampleCount = width * height;
|
|
33
|
+
if (!Number.isSafeInteger(width) ||
|
|
34
|
+
!Number.isSafeInteger(height) ||
|
|
35
|
+
width < 2 ||
|
|
36
|
+
height < 2 ||
|
|
37
|
+
sampleCount > 1_000_000)
|
|
38
|
+
throw new Error('Invalid height-field grid');
|
|
39
|
+
// Every row eventually uses the same bisection of its columns. Interleaving the
|
|
40
|
+
// row splits changes traversal order, but the full binary tree has 2 * leaves - 1 nodes.
|
|
41
|
+
const memo = new Map();
|
|
42
|
+
/** Count single-row leaves after the same column bisection used by the packer. */
|
|
43
|
+
const countLeaves = (columns) => {
|
|
44
|
+
if (columns <= CELLS_PER_LEAF)
|
|
45
|
+
return 1;
|
|
46
|
+
const cached = memo.get(columns);
|
|
47
|
+
if (cached !== undefined)
|
|
48
|
+
return cached;
|
|
49
|
+
const half = Math.floor(columns / 2);
|
|
50
|
+
const leaves = countLeaves(half) + countLeaves(columns - half);
|
|
51
|
+
memo.set(columns, leaves);
|
|
52
|
+
return leaves;
|
|
53
|
+
};
|
|
54
|
+
const leaves = countLeaves(width - 1) * (height - 1);
|
|
55
|
+
return 8 + Math.ceil(sampleCount / 4) * 4 + (2 * leaves - 1) * 12;
|
|
56
|
+
}
|
|
57
|
+
/** Pack scalar samples and a bounded stackless hierarchy, with no stored vertices or triangle indices. */
|
|
58
|
+
export function packRigidBodyHeightField(field) {
|
|
59
|
+
const { width, height, heights, validity, diagonal = '00-11' } = field;
|
|
60
|
+
const sampleCount = width * height;
|
|
61
|
+
if (!Number.isSafeInteger(width) ||
|
|
62
|
+
!Number.isSafeInteger(height) ||
|
|
63
|
+
width < 2 ||
|
|
64
|
+
height < 2 ||
|
|
65
|
+
sampleCount > 1_000_000 ||
|
|
66
|
+
(heights && heights.length !== sampleCount) ||
|
|
67
|
+
(validity && validity.length !== sampleCount) ||
|
|
68
|
+
(diagonal !== '00-11' && diagonal !== '10-01'))
|
|
69
|
+
throw new Error('Invalid height-field grid');
|
|
70
|
+
const origin = (field.origin ?? [0, 0]).map(Math.fround);
|
|
71
|
+
const columnStep = (field.columnStep ?? [1, 0]).map(Math.fround);
|
|
72
|
+
const rowStep = (field.rowStep ?? [0, 1]).map(Math.fround);
|
|
73
|
+
const determinant = columnStep[0] * rowStep[1] - columnStep[1] * rowStep[0];
|
|
74
|
+
const horizontalScale = [0, 1].map(axis => Math.abs(origin[axis]) +
|
|
75
|
+
Math.abs(columnStep[axis]) * (width - 1) +
|
|
76
|
+
Math.abs(rowStep[axis]) * (height - 1));
|
|
77
|
+
if (origin.length !== 2 ||
|
|
78
|
+
columnStep.length !== 2 ||
|
|
79
|
+
rowStep.length !== 2 ||
|
|
80
|
+
![...origin, ...columnStep, ...rowStep, ...horizontalScale].every(value => Number.isFinite(Math.fround(value))) ||
|
|
81
|
+
Math.abs(determinant) <= 1e-7 * Math.hypot(...columnStep) * Math.hypot(...rowStep))
|
|
82
|
+
throw new Error('Invalid height-field transform');
|
|
83
|
+
// Match shader arithmetic at the sample positions, padding conservative XY bounds
|
|
84
|
+
// for separate rounding of the index products and sum.
|
|
85
|
+
const roundingPadding = horizontalScale.map(value => value * 2 ** -21);
|
|
86
|
+
const nodeOffset = 2 + Math.ceil(sampleCount / 4);
|
|
87
|
+
const data = new Array(nodeOffset * 4).fill(MISSING_HEIGHT);
|
|
88
|
+
data.splice(0, 8, ...columnStep, ...rowStep, ...origin, width, Number(diagonal === '10-01') + 2 * Number(determinant < 0));
|
|
89
|
+
for (let index = 0; heights && index < sampleCount; index++) {
|
|
90
|
+
if (validity?.[index] === 0 || !Number.isFinite(heights[index]))
|
|
91
|
+
continue;
|
|
92
|
+
const sample = Math.fround(heights[index]);
|
|
93
|
+
if (!Number.isFinite(sample) || sample === MISSING_HEIGHT)
|
|
94
|
+
throw new Error('Height-field sample exceeds float32 range');
|
|
95
|
+
data[8 + index] = sample;
|
|
96
|
+
}
|
|
97
|
+
/** Build deterministic rectangular nodes even for an empty or partially loaded slot. */
|
|
98
|
+
const appendNode = (firstColumn, firstRow, columns, rows) => {
|
|
99
|
+
const offset = data.length;
|
|
100
|
+
data.push(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
101
|
+
let minimumHeight = Infinity;
|
|
102
|
+
let maximumHeight = -Infinity;
|
|
103
|
+
if (rows === 1 && columns <= CELLS_PER_LEAF) {
|
|
104
|
+
const firstSample = firstRow * width + firstColumn;
|
|
105
|
+
for (let column = 0; column < columns; column++) {
|
|
106
|
+
const sample = 8 + firstSample + column;
|
|
107
|
+
const first = data[sample];
|
|
108
|
+
const second = data[sample + 1];
|
|
109
|
+
const third = data[sample + width];
|
|
110
|
+
const fourth = data[sample + width + 1];
|
|
111
|
+
const triangles = diagonal === '00-11'
|
|
112
|
+
? [first, second, fourth, first, fourth, third]
|
|
113
|
+
: [first, second, third, second, fourth, third];
|
|
114
|
+
for (let triangle = 0; triangle < 6; triangle += 3) {
|
|
115
|
+
const cornerA = triangles[triangle];
|
|
116
|
+
const cornerB = triangles[triangle + 1];
|
|
117
|
+
const cornerC = triangles[triangle + 2];
|
|
118
|
+
if (cornerA === MISSING_HEIGHT ||
|
|
119
|
+
cornerB === MISSING_HEIGHT ||
|
|
120
|
+
cornerC === MISSING_HEIGHT)
|
|
121
|
+
continue;
|
|
122
|
+
minimumHeight = Math.min(minimumHeight, cornerA, cornerB, cornerC);
|
|
123
|
+
maximumHeight = Math.max(maximumHeight, cornerA, cornerB, cornerC);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
data[offset + 7] = minimumHeight <= maximumHeight ? columns * 2 : 0;
|
|
127
|
+
data[offset + 8] = 2 * (firstRow * (width - 1) + firstColumn);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
let firstChild;
|
|
131
|
+
let secondChild;
|
|
132
|
+
if (columns > CELLS_PER_LEAF && (rows === 1 || columns >= rows * CELLS_PER_LEAF)) {
|
|
133
|
+
const split = Math.floor(columns / 2);
|
|
134
|
+
firstChild = appendNode(firstColumn, firstRow, split, rows);
|
|
135
|
+
secondChild = appendNode(firstColumn + split, firstRow, columns - split, rows);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const split = Math.floor(rows / 2);
|
|
139
|
+
firstChild = appendNode(firstColumn, firstRow, columns, split);
|
|
140
|
+
secondChild = appendNode(firstColumn, firstRow + split, columns, rows - split);
|
|
141
|
+
}
|
|
142
|
+
minimumHeight = Math.min(data[firstChild + 2], data[secondChild + 2]);
|
|
143
|
+
maximumHeight = Math.max(data[firstChild + 6], data[secondChild + 6]);
|
|
144
|
+
}
|
|
145
|
+
if (minimumHeight <= maximumHeight) {
|
|
146
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
147
|
+
const first = origin[axis] + firstColumn * columnStep[axis] + firstRow * rowStep[axis];
|
|
148
|
+
const column = columns * columnStep[axis];
|
|
149
|
+
const row = rows * rowStep[axis];
|
|
150
|
+
data[offset + axis] =
|
|
151
|
+
first + Math.min(0, column) + Math.min(0, row) - roundingPadding[axis];
|
|
152
|
+
data[offset + 4 + axis] =
|
|
153
|
+
first + Math.max(0, column) + Math.max(0, row) + roundingPadding[axis];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
data[offset + 2] = minimumHeight;
|
|
157
|
+
data[offset + 6] = maximumHeight;
|
|
158
|
+
data[offset + 3] = (data.length - nodeOffset * 4) / 12;
|
|
159
|
+
return offset;
|
|
160
|
+
};
|
|
161
|
+
const root = appendNode(0, 0, width - 1, height - 1);
|
|
162
|
+
const active = data[root + 2] <= data[root + 6];
|
|
163
|
+
// Empty hierarchy branches have reversed finite bounds. Readers skip them without
|
|
164
|
+
// evaluating a cast against invalid limits. The allocation stays identical on reload.
|
|
165
|
+
for (let offset = root; offset < data.length; offset += 12) {
|
|
166
|
+
if (data[offset + 2] > data[offset + 6]) {
|
|
167
|
+
data[offset + 2] = 1;
|
|
168
|
+
data[offset + 6] = -1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const extent = active
|
|
172
|
+
? [0, 1, 2].map(axis => Math.max(Math.abs(data[root + axis]), Math.abs(data[root + 4 + axis])))
|
|
173
|
+
: [0, 0, 0];
|
|
174
|
+
if (!extent.every(value => Number.isFinite(Math.fround(value))))
|
|
175
|
+
throw new Error('Height-field bounds exceed float32 range');
|
|
176
|
+
return {
|
|
177
|
+
data,
|
|
178
|
+
extent,
|
|
179
|
+
nodeOffset,
|
|
180
|
+
nodeCount: active ? (data.length - root) / 12 : 0,
|
|
181
|
+
triangleCount: active ? (width - 1) * (height - 1) * 2 : 0
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=rigid-body-height-field.js.map
|