@woosh/meep-engine 3.17.2 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/actions/concrete/ComponentAddAction.d.ts +1 -0
- package/editor/actions/concrete/ComponentAddAction.d.ts.map +1 -1
- package/editor/actions/concrete/ComponentAddAction.js +4 -0
- package/editor/actions/concrete/ComponentRemoveAction.d.ts +1 -0
- package/editor/actions/concrete/ComponentRemoveAction.d.ts.map +1 -1
- package/editor/actions/concrete/ComponentRemoveAction.js +4 -0
- package/editor/actions/concrete/EntityCreateAction.d.ts +1 -0
- package/editor/actions/concrete/EntityCreateAction.d.ts.map +1 -1
- package/editor/actions/concrete/EntityCreateAction.js +7 -0
- package/editor/actions/concrete/EntityRemoveAction.d.ts +1 -0
- package/editor/actions/concrete/EntityRemoveAction.d.ts.map +1 -1
- package/editor/actions/concrete/EntityRemoveAction.js +4 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.d.ts +10 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.d.ts.map +1 -1
- package/editor/actions/concrete/PatchTerrainHeightAction.js +107 -85
- package/editor/actions/concrete/TransformModifyAction.d.ts +1 -0
- package/editor/actions/concrete/TransformModifyAction.d.ts.map +1 -1
- package/editor/actions/concrete/TransformModifyAction.js +4 -0
- package/editor/particles/effect/ParticleEffectDocument.d.ts.map +1 -1
- package/editor/particles/effect/ParticleEffectDocument.js +10 -6
- package/editor/particles/effect/ParticleReferenceSimulation.d.ts.map +1 -1
- package/editor/particles/effect/ParticleReferenceSimulation.js +98 -4
- package/editor/particles/effect/make_starter_particle_effect.d.ts.map +1 -1
- package/editor/particles/effect/make_starter_particle_effect.js +0 -2
- package/editor/tools/engine/ToolEngine.d.ts +30 -0
- package/editor/tools/engine/ToolEngine.d.ts.map +1 -1
- package/editor/tools/engine/ToolEngine.js +257 -188
- package/editor/view/ecs/EntityList.d.ts.map +1 -1
- package/editor/view/ecs/EntityList.js +6 -5
- package/editor/view/particles/effect/ParticleEmitterInspectorView.d.ts.map +1 -1
- package/editor/view/particles/effect/ParticleEmitterInspectorView.js +17 -9
- package/package.json +1 -1
- package/src/CODEC_LAYOUT_VERIFICATION.md +1 -2
- package/src/core/binary/meshopt/MESHOPT_VERTEX_BLOCK.d.ts +56 -0
- package/src/core/binary/meshopt/MESHOPT_VERTEX_BLOCK.d.ts.map +1 -0
- package/src/core/binary/meshopt/MESHOPT_VERTEX_BLOCK.js +73 -0
- package/src/core/binary/meshopt/meshopt_decode_vertex_buffer.d.ts.map +1 -1
- package/src/core/binary/meshopt/meshopt_decode_vertex_buffer.js +18 -63
- package/src/core/binary/meshopt/meshopt_encode_byte_group.d.ts +53 -0
- package/src/core/binary/meshopt/meshopt_encode_byte_group.d.ts.map +1 -0
- package/src/core/binary/meshopt/meshopt_encode_byte_group.js +140 -0
- package/src/core/binary/meshopt/meshopt_encode_data_block.d.ts +32 -0
- package/src/core/binary/meshopt/meshopt_encode_data_block.d.ts.map +1 -0
- package/src/core/binary/meshopt/meshopt_encode_data_block.js +77 -0
- package/src/core/binary/meshopt/meshopt_encode_index_sequence.d.ts +46 -0
- package/src/core/binary/meshopt/meshopt_encode_index_sequence.d.ts.map +1 -0
- package/src/core/binary/meshopt/meshopt_encode_index_sequence.js +146 -0
- package/src/core/binary/meshopt/meshopt_encode_vertex_buffer.d.ts +40 -0
- package/src/core/binary/meshopt/meshopt_encode_vertex_buffer.d.ts.map +1 -0
- package/src/core/binary/meshopt/meshopt_encode_vertex_buffer.js +700 -0
- package/src/core/binary/meshopt/meshopt_write_uint_var.d.ts +24 -0
- package/src/core/binary/meshopt/meshopt_write_uint_var.d.ts.map +1 -0
- package/src/core/binary/meshopt/meshopt_write_uint_var.js +39 -0
- package/src/core/math/random/seededRandom_Mulberry32.d.ts.map +1 -1
- package/src/core/math/random/seededRandom_Mulberry32.js +4 -2
- package/src/core/process/undo/Action.d.ts +19 -0
- package/src/core/process/undo/Action.d.ts.map +1 -1
- package/src/core/process/undo/Action.js +17 -0
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +78 -0
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -0
- package/src/engine/graphics3/GPUParticleEmitterSystem.js +310 -0
- package/src/engine/graphics3/GraphicsEngine.d.ts +17 -0
- package/src/engine/graphics3/GraphicsEngine.d.ts.map +1 -1
- package/src/engine/graphics3/GraphicsEngine.js +30 -10
- package/src/engine/graphics3/particles/particle_gpu_records.d.ts.map +1 -1
- package/src/engine/graphics3/particles/particle_gpu_records.js +0 -2
- package/src/engine/interpolation/InterpolationSystem.d.ts +7 -0
- package/src/engine/interpolation/InterpolationSystem.d.ts.map +1 -1
- package/src/engine/interpolation/InterpolationSystem.js +10 -0
- package/src/engine/network/NetworkSession.d.ts.map +1 -1
- package/src/engine/network/NetworkSession.js +14 -34
- package/src/engine/network/time/RenderPlayout.d.ts +76 -0
- package/src/engine/network/time/RenderPlayout.d.ts.map +1 -0
- package/src/engine/network/time/RenderPlayout.js +163 -0
- package/src/engine/network/transport/adapters/WebSocketTransport.d.ts.map +1 -1
- package/src/engine/network/transport/adapters/WebSocketTransport.js +11 -4
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +4 -12
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +39 -13
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/sound/simulation/core/VolumeField.d.ts.map +1 -1
- package/src/engine/sound/simulation/core/VolumeField.js +4 -1
- package/src/format/scene/gltf/MESHOPT_COMPRESSION_PLAN.md +23 -2
- package/src/shade/playground/particle_system/README.md +139 -139
- package/src/shade/playground/particle_system/particle_prototype.d.ts.map +1 -1
- package/src/shade/playground/particle_system/particle_prototype.js +0 -2
- package/src/shade/playground/particle_system/particle_scene.d.ts +6 -9
- package/src/shade/playground/particle_system/particle_scene.d.ts.map +1 -1
- package/src/shade/playground/particle_system/particle_scene.js +6 -13
- package/src/shade/playground/ssr_reprojection/README.md +103 -0
- package/src/shade/playground/ssr_reprojection/SpatialFilterProbe.d.ts +17 -0
- package/src/shade/playground/ssr_reprojection/SpatialFilterProbe.d.ts.map +1 -0
- package/src/shade/playground/ssr_reprojection/SpatialFilterProbe.js +68 -0
- package/src/shade/playground/ssr_reprojection/index.html +79 -0
- package/src/shade/playground/ssr_reprojection/main.d.ts +2 -0
- package/src/shade/playground/ssr_reprojection/main.d.ts.map +1 -0
- package/src/shade/playground/ssr_reprojection/main.js +245 -0
- package/src/shade/playground/ssr_reprojection/scene.d.ts +18 -0
- package/src/shade/playground/ssr_reprojection/scene.d.ts.map +1 -0
- package/src/shade/playground/ssr_reprojection/scene.js +51 -0
- package/src/shade/renderer/Renderer.d.ts +2 -23
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +185 -218
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts +5 -8
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.js +12 -12
- package/src/shade/renderer/buffer/table/GPUTypedTable.d.ts.map +1 -1
- package/src/shade/renderer/buffer/table/GPUTypedTable.js +6 -0
- package/src/shade/renderer/buffer/table/single/GPUSingleTypeTable.d.ts.map +1 -1
- package/src/shade/renderer/buffer/table/single/GPUSingleTypeTable.js +7 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/chunk_brick4_sample_specular.d.ts +4 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/chunk_brick4_sample_specular.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/chunk_brick4_sample_specular.js +51 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_specular.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_specular.js +5 -35
- package/src/shade/renderer/particles/DESIGN.md +703 -514
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts +16 -4
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.js +1189 -991
- package/src/shade/renderer/particles/ParticleConstants.d.ts +64 -0
- package/src/shade/renderer/particles/ParticleConstants.d.ts.map +1 -1
- package/src/shade/renderer/particles/ParticleConstants.js +71 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds.d.ts +57 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds.d.ts.map +1 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds.js +181 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds_unknown.d.ts +7 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds_unknown.d.ts.map +1 -0
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds_unknown.js +12 -0
- package/src/shade/renderer/particles/bounds/graph_particle_bounds.d.ts +33 -0
- package/src/shade/renderer/particles/bounds/graph_particle_bounds.d.ts.map +1 -0
- package/src/shade/renderer/particles/bounds/graph_particle_bounds.js +67 -0
- package/src/shade/renderer/particles/bounds/shader_particle_bounds.d.ts +40 -0
- package/src/shade/renderer/particles/bounds/shader_particle_bounds.d.ts.map +1 -0
- package/src/shade/renderer/particles/bounds/shader_particle_bounds.js +187 -0
- package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts +15 -2
- package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts.map +1 -1
- package/src/shade/renderer/particles/coherence/graph_particle_bucket.js +14 -8
- package/src/shade/renderer/particles/data/PARTICLE_COUNTERS.d.ts +58 -4
- package/src/shade/renderer/particles/data/PARTICLE_COUNTERS.d.ts.map +1 -1
- package/src/shade/renderer/particles/data/PARTICLE_COUNTERS.js +79 -4
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STATE.d.ts +23 -1
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STATE.d.ts.map +1 -1
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STATE.js +35 -2
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.d.ts +4 -2
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.js +5 -8
- package/src/shade/renderer/particles/data/particle_emitter_record.d.ts.map +1 -1
- package/src/shade/renderer/particles/data/particle_emitter_record.js +0 -6
- package/src/shade/renderer/particles/graph_particles.d.ts +25 -3
- package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles.js +108 -31
- package/src/shade/renderer/particles/graph_particles_avboit.d.ts +6 -4
- package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles_avboit.js +5 -5
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +5 -0
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/EmitterRegistry.js +27 -6
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts +4 -0
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.js +6 -1
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +35 -27
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ParticleEmitter.js +424 -425
- package/src/shade/renderer/particles/shaders/chunk_particle_emitter_warmup.d.ts +20 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_emitter_warmup.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_render_math.d.ts +4 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_render_math.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/chunk_particle_render_math.js +38 -2
- package/src/shade/renderer/particles/shaders/chunk_particle_spawn_budget.d.ts +22 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_spawn_budget.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_spawn_budget.js +42 -0
- package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_avboit_occupancy.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_avboit_occupancy.js +53 -22
- package/src/shade/renderer/particles/shaders/shader_particle_emitter_tick.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emitter_tick.js +213 -216
- package/src/shade/renderer/particles/shaders/shader_particle_reclaim.d.ts +50 -0
- package/src/shade/renderer/particles/shaders/shader_particle_reclaim.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/shader_particle_render.js +1 -1
- package/src/shade/renderer/particles/warmup/chunk_particle_warmup_step.d.ts +36 -0
- package/src/shade/renderer/particles/warmup/chunk_particle_warmup_step.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/chunk_particle_warmup_step.js +102 -0
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts +102 -0
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +329 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup.d.ts +112 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup.js +318 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts +35 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.js +108 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts +3 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.js +70 -0
- package/src/shade/renderer/particles/warmup/warmup_schedule.d.ts +62 -0
- package/src/shade/renderer/particles/warmup/warmup_schedule.d.ts.map +1 -0
- package/src/shade/renderer/particles/warmup/warmup_schedule.js +55 -0
- package/src/shade/renderer/postprocess/PostProcess.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/PostProcess.js +2 -1
- package/src/shade/renderer/postprocess/ssr/REPROJECTION_PROPOSAL.md +286 -0
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts +57 -21
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.js +230 -129
- package/src/shade/renderer/postprocess/ssr/SSRReprojectionMode.d.ts +11 -0
- package/src/shade/renderer/postprocess/ssr/SSRReprojectionMode.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/SSRReprojectionMode.js +6 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_metadata.d.ts +4 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_metadata.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_metadata.js +32 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_spatial_variance.d.ts +4 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_spatial_variance.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/chunk_ssr_spatial_variance.js +41 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_reprojection.d.ts +3 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_reprojection.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_reprojection.js +30 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_sample_history.d.ts +4 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_sample_history.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_sample_history.js +70 -0
- package/src/shade/renderer/postprocess/ssr/resolve/build_ssr_resolve_shader.d.ts +21 -0
- package/src/shade/renderer/postprocess/ssr/resolve/build_ssr_resolve_shader.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/resolve/build_ssr_resolve_shader.js +363 -0
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_get_neighbour_weight.js +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_Brick4.d.ts +2 -0
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_Brick4.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_Brick4.js +24 -0
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_IBL.d.ts +1 -6
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_IBL.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_IBL.js +16 -332
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_LPV.d.ts +1 -6
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_LPV.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader_LPV.js +25 -358
- package/src/shade/renderer/postprocess/ssr/ssr_reproject_shader.d.ts +0 -5
- package/src/shade/renderer/postprocess/ssr/ssr_reproject_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/ssr_reproject_shader.js +201 -276
- package/src/shade/renderer/postprocess/ssr/ssr_spatial_denoise_shader.d.ts +1 -0
- package/src/shade/renderer/postprocess/ssr/ssr_spatial_denoise_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/ssr_spatial_denoise_shader.js +167 -143
- package/src/shade/renderer/shader/graph/graph_create_buffer.d.ts +15 -0
- package/src/shade/renderer/shader/graph/graph_create_buffer.d.ts.map +1 -0
- package/src/shade/renderer/shader/graph/graph_create_buffer.js +20 -0
- package/src/shade/renderer/view/GPUViewContext.d.ts +3 -4
- package/src/shade/renderer/view/GPUViewContext.d.ts.map +1 -1
- package/src/shade/renderer/view/GPUViewContext.js +5 -5
- package/src/core/binary/meshopt/__meshopt_test_streams.d.ts +0 -24
- package/src/core/binary/meshopt/__meshopt_test_streams.d.ts.map +0 -1
- package/src/core/binary/meshopt/__meshopt_test_streams.js +0 -237
- package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts +0 -84
- package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts.map +0 -1
- package/src/core/geom/3d/atlas/atlas_test_fixtures.js +0 -266
- package/src/engine/asset/loaders/gltf_test_fixtures.d.ts +0 -97
- package/src/engine/asset/loaders/gltf_test_fixtures.d.ts.map +0 -1
- package/src/engine/asset/loaders/gltf_test_fixtures.js +0 -359
- package/src/shade/renderer/animation/skin_test_fixtures.d.ts +0 -86
- package/src/shade/renderer/animation/skin_test_fixtures.d.ts.map +0 -1
- package/src/shade/renderer/animation/skin_test_fixtures.js +0 -250
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_test_fixtures.d.ts +0 -16
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_test_fixtures.d.ts.map +0 -1
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_test_fixtures.js +0 -27
- package/src/shade/renderer/particles/particle_test_fixtures.d.ts +0 -151
- package/src/shade/renderer/particles/particle_test_fixtures.d.ts.map +0 -1
- package/src/shade/renderer/particles/particle_test_fixtures.js +0 -229
- package/src/shade/renderer/particles/shaders/chunk_particle_emitter_world_sphere.js +0 -23
- package/src/shade/renderer/postprocess/ssr/reproject/shader_ffx_denoiser_reflections_reproject.js +0 -457
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many elements one block holds at a given stride — the same arithmetic on both sides, because
|
|
3
|
+
* a block boundary is not stored anywhere and both sides have to arrive at it alone.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} byte_stride
|
|
6
|
+
* @returns {number}
|
|
7
|
+
*/
|
|
8
|
+
export function meshopt_max_block_elements(byte_stride: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* The shape of an attribute stream's blocks, shared by the two sides of the codec. A decoder that
|
|
11
|
+
* disagreed with an encoder about any of this would not fail — it would produce different bytes.
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_meshopt_compression
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Header nibble every attribute stream starts with; the low nibble is the codec version.
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
export const MESHOPT_VERTEX_HEADER: number;
|
|
20
|
+
/**
|
|
21
|
+
* An attribute block never holds more than this many bytes of element data, which is what keeps a
|
|
22
|
+
* block's deltas inside one scratch buffer and inside a cache level while they are transposed.
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
export const MESHOPT_MAX_BLOCK_BYTES: number;
|
|
26
|
+
/**
|
|
27
|
+
* ...nor more than this many elements, whatever the stride.
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
export const MESHOPT_MAX_BLOCK_ELEMENTS: number;
|
|
31
|
+
/**
|
|
32
|
+
* Largest element the format admits, and so the largest baseline there can be.
|
|
33
|
+
* @type {number}
|
|
34
|
+
*/
|
|
35
|
+
export const MESHOPT_MAX_BYTE_STRIDE: number;
|
|
36
|
+
/**
|
|
37
|
+
* How much of the stream sits behind the last attribute block, at the least. The tail block itself
|
|
38
|
+
* may be longer than this — a wide element's baseline is — and then there is no padding at all.
|
|
39
|
+
* @type {number[]}
|
|
40
|
+
*/
|
|
41
|
+
export const MESHOPT_TAIL_MIN_BY_VERSION: number[];
|
|
42
|
+
/**
|
|
43
|
+
* What the two bits stored per group mean, by the control mode that selected the table. Version 0
|
|
44
|
+
* has no control header and always reads {@link MESHOPT_BITS_VERSION_0}.
|
|
45
|
+
*
|
|
46
|
+
* Control mode 2 (nothing stored) and control mode 3 (literal, no header bits) have no table
|
|
47
|
+
* because they have no header bits to index one with.
|
|
48
|
+
*
|
|
49
|
+
* @type {number[][]}
|
|
50
|
+
*/
|
|
51
|
+
export const MESHOPT_BITS_BY_CONTROL: number[][];
|
|
52
|
+
/**
|
|
53
|
+
* @type {number[]}
|
|
54
|
+
*/
|
|
55
|
+
export const MESHOPT_BITS_VERSION_0: number[];
|
|
56
|
+
//# sourceMappingURL=MESHOPT_VERTEX_BLOCK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MESHOPT_VERTEX_BLOCK.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/MESHOPT_VERTEX_BLOCK.js"],"names":[],"mappings":"AA4DA;;;;;;GAMG;AACH,wDAHW,MAAM,GACJ,MAAM,CAOlB;AAtED;;;;;GAKG;AAEH;;;GAGG;AACH,oCAFU,MAAM,CAE0B;AAE1C;;;;GAIG;AACH,sCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,yCAFU,MAAM,CAE8B;AAE9C;;;GAGG;AACH,sCAFU,MAAM,CAE2B;AAE3C;;;;GAIG;AACH,0CAFU,MAAM,EAAE,CAEkC;AAEpD;;;;;;;;GAQG;AACH,sCAFU,MAAM,EAAE,EAAE,CAKlB;AAEF;;GAEG;AACH,qCAFU,MAAM,EAAE,CAEiC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MESHOPT_GROUP_SIZE } from "./MESHOPT_GROUP_SIZE.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shape of an attribute stream's blocks, shared by the two sides of the codec. A decoder that
|
|
5
|
+
* disagreed with an encoder about any of this would not fail — it would produce different bytes.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_meshopt_compression
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Header nibble every attribute stream starts with; the low nibble is the codec version.
|
|
12
|
+
* @type {number}
|
|
13
|
+
*/
|
|
14
|
+
export const MESHOPT_VERTEX_HEADER = 0xa0;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An attribute block never holds more than this many bytes of element data, which is what keeps a
|
|
18
|
+
* block's deltas inside one scratch buffer and inside a cache level while they are transposed.
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
export const MESHOPT_MAX_BLOCK_BYTES = 8192;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ...nor more than this many elements, whatever the stride.
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
export const MESHOPT_MAX_BLOCK_ELEMENTS = 256;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Largest element the format admits, and so the largest baseline there can be.
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
export const MESHOPT_MAX_BYTE_STRIDE = 256;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How much of the stream sits behind the last attribute block, at the least. The tail block itself
|
|
37
|
+
* may be longer than this — a wide element's baseline is — and then there is no padding at all.
|
|
38
|
+
* @type {number[]}
|
|
39
|
+
*/
|
|
40
|
+
export const MESHOPT_TAIL_MIN_BY_VERSION = [32, 24];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What the two bits stored per group mean, by the control mode that selected the table. Version 0
|
|
44
|
+
* has no control header and always reads {@link MESHOPT_BITS_VERSION_0}.
|
|
45
|
+
*
|
|
46
|
+
* Control mode 2 (nothing stored) and control mode 3 (literal, no header bits) have no table
|
|
47
|
+
* because they have no header bits to index one with.
|
|
48
|
+
*
|
|
49
|
+
* @type {number[][]}
|
|
50
|
+
*/
|
|
51
|
+
export const MESHOPT_BITS_BY_CONTROL = [
|
|
52
|
+
[0, 1, 2, 4],
|
|
53
|
+
[1, 2, 4, 8]
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @type {number[]}
|
|
58
|
+
*/
|
|
59
|
+
export const MESHOPT_BITS_VERSION_0 = [0, 2, 4, 8];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* How many elements one block holds at a given stride — the same arithmetic on both sides, because
|
|
63
|
+
* a block boundary is not stored anywhere and both sides have to arrive at it alone.
|
|
64
|
+
*
|
|
65
|
+
* @param {number} byte_stride
|
|
66
|
+
* @returns {number}
|
|
67
|
+
*/
|
|
68
|
+
export function meshopt_max_block_elements(byte_stride) {
|
|
69
|
+
return Math.min(
|
|
70
|
+
Math.floor(MESHOPT_MAX_BLOCK_BYTES / byte_stride) & ~(MESHOPT_GROUP_SIZE - 1),
|
|
71
|
+
MESHOPT_MAX_BLOCK_ELEMENTS
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshopt_decode_vertex_buffer.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/meshopt_decode_vertex_buffer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meshopt_decode_vertex_buffer.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/meshopt_decode_vertex_buffer.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,0DAPW,UAAU,SACV,MAAM,eACN,MAAM,UACN,UAAU,GACR,MAAM,CAsGlB"}
|
|
@@ -1,58 +1,16 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
import { MESHOPT_GROUP_SIZE } from "./MESHOPT_GROUP_SIZE.js";
|
|
3
|
+
import {
|
|
4
|
+
MESHOPT_BITS_BY_CONTROL,
|
|
5
|
+
MESHOPT_BITS_VERSION_0,
|
|
6
|
+
MESHOPT_MAX_BLOCK_BYTES,
|
|
7
|
+
MESHOPT_MAX_BYTE_STRIDE,
|
|
8
|
+
MESHOPT_TAIL_MIN_BY_VERSION,
|
|
9
|
+
MESHOPT_VERTEX_HEADER,
|
|
10
|
+
meshopt_max_block_elements
|
|
11
|
+
} from "./MESHOPT_VERTEX_BLOCK.js";
|
|
3
12
|
import { meshopt_decode_data_block } from "./meshopt_decode_data_block.js";
|
|
4
13
|
|
|
5
|
-
/**
|
|
6
|
-
* Header nibble every attribute stream starts with; the low nibble is the codec version.
|
|
7
|
-
* @type {number}
|
|
8
|
-
*/
|
|
9
|
-
const HEADER = 0xa0;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* An attribute block never holds more than this many bytes of element data, which is what keeps a
|
|
13
|
-
* block's deltas inside {@link delta_scratch} and inside a cache level while they are transposed.
|
|
14
|
-
* @type {number}
|
|
15
|
-
*/
|
|
16
|
-
const MAX_BLOCK_BYTES = 8192;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* ...nor more than this many elements, whatever the stride.
|
|
20
|
-
* @type {number}
|
|
21
|
-
*/
|
|
22
|
-
const MAX_BLOCK_ELEMENTS = 256;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Largest element the format admits, and so the largest baseline there can be.
|
|
26
|
-
* @type {number}
|
|
27
|
-
*/
|
|
28
|
-
const MAX_BYTE_STRIDE = 256;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* How much of the stream sits behind the last attribute block, at the least. The tail block itself
|
|
32
|
-
* may be longer than this - a wide element's baseline is - and then there is no padding at all.
|
|
33
|
-
* @type {number[]}
|
|
34
|
-
*/
|
|
35
|
-
const TAIL_MIN_BY_VERSION = [32, 24];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* What the two bits stored per group mean, by the control mode that selected the table. Version 0
|
|
39
|
-
* has no control header and always reads {@link BITS_VERSION_0}.
|
|
40
|
-
*
|
|
41
|
-
* Control mode 2 (nothing stored) and control mode 3 (literal, no header bits) have no table
|
|
42
|
-
* because they have no header bits to index one with.
|
|
43
|
-
*
|
|
44
|
-
* @type {number[][]}
|
|
45
|
-
*/
|
|
46
|
-
const BITS_BY_CONTROL = [
|
|
47
|
-
[0, 1, 2, 4],
|
|
48
|
-
[1, 2, 4, 8]
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @type {number[]}
|
|
53
|
-
*/
|
|
54
|
-
const BITS_VERSION_0 = [0, 2, 4, 8];
|
|
55
|
-
|
|
56
14
|
/**
|
|
57
15
|
* One attribute block's delta bytes, laid out per byte position: position `k`'s deltas are
|
|
58
16
|
* `group_count * 16` bytes at `k * aligned_count`.
|
|
@@ -62,14 +20,14 @@ const BITS_VERSION_0 = [0, 2, 4, 8];
|
|
|
62
20
|
*
|
|
63
21
|
* @type {Uint8Array}
|
|
64
22
|
*/
|
|
65
|
-
const delta_scratch = new Uint8Array(
|
|
23
|
+
const delta_scratch = new Uint8Array(MESHOPT_MAX_BLOCK_BYTES);
|
|
66
24
|
|
|
67
25
|
/**
|
|
68
26
|
* The element every block's first delta is taken against - the tail block's for the first block,
|
|
69
27
|
* and the previous block's last element after that.
|
|
70
28
|
* @type {Uint8Array}
|
|
71
29
|
*/
|
|
72
|
-
const baseline = new Uint8Array(
|
|
30
|
+
const baseline = new Uint8Array(MESHOPT_MAX_BYTE_STRIDE);
|
|
73
31
|
|
|
74
32
|
/**
|
|
75
33
|
* How each aligned group of four byte positions turns its deltas back into values. One byte per
|
|
@@ -77,7 +35,7 @@ const baseline = new Uint8Array(MAX_BYTE_STRIDE);
|
|
|
77
35
|
* mode 0.
|
|
78
36
|
* @type {Uint8Array}
|
|
79
37
|
*/
|
|
80
|
-
const channel_modes = new Uint8Array(
|
|
38
|
+
const channel_modes = new Uint8Array(MESHOPT_MAX_BYTE_STRIDE / 4);
|
|
81
39
|
|
|
82
40
|
/**
|
|
83
41
|
* Decode an attribute stream - the `"ATTRIBUTES"` mode of both meshopt extensions, codec version
|
|
@@ -102,7 +60,7 @@ export function meshopt_decode_vertex_buffer(destination, count, byte_stride, so
|
|
|
102
60
|
assert.isNonNegativeInteger(count, 'count');
|
|
103
61
|
assert.isPositiveInteger(byte_stride, 'byte_stride');
|
|
104
62
|
assert.equal(byte_stride % 4, 0, `byte_stride(=${byte_stride}) must be divisible by 4`);
|
|
105
|
-
assert.ok(byte_stride <=
|
|
63
|
+
assert.ok(byte_stride <= MESHOPT_MAX_BYTE_STRIDE, `byte_stride(=${byte_stride}) must be at most ${MESHOPT_MAX_BYTE_STRIDE}`);
|
|
106
64
|
assert.equal(
|
|
107
65
|
destination.length, count * byte_stride,
|
|
108
66
|
`destination(=${destination.length} bytes) must hold count(=${count}) * byte_stride(=${byte_stride})`
|
|
@@ -116,7 +74,7 @@ export function meshopt_decode_vertex_buffer(destination, count, byte_stride, so
|
|
|
116
74
|
|
|
117
75
|
const header = source[0];
|
|
118
76
|
|
|
119
|
-
if ((header & 0xf0) !==
|
|
77
|
+
if ((header & 0xf0) !== MESHOPT_VERTEX_HEADER) {
|
|
120
78
|
throw new Error(
|
|
121
79
|
`meshopt attribute stream starts with 0x${header.toString(16)}, expected 0xa0 or 0xa1`
|
|
122
80
|
);
|
|
@@ -137,7 +95,7 @@ export function meshopt_decode_vertex_buffer(destination, count, byte_stride, so
|
|
|
137
95
|
EXT's wording invites, and it is wrong for every stride under 32.
|
|
138
96
|
*/
|
|
139
97
|
const tail_size = byte_stride + (version === 1 ? channel_count : 0);
|
|
140
|
-
const tail_min =
|
|
98
|
+
const tail_min = MESHOPT_TAIL_MIN_BY_VERSION[version];
|
|
141
99
|
const tail_size_pad = tail_size < tail_min ? tail_min : tail_size;
|
|
142
100
|
|
|
143
101
|
if (source_end < 1 + tail_size_pad) {
|
|
@@ -171,10 +129,7 @@ export function meshopt_decode_vertex_buffer(destination, count, byte_stride, so
|
|
|
171
129
|
channel_modes.fill(0, 0, channel_count);
|
|
172
130
|
}
|
|
173
131
|
|
|
174
|
-
const max_block_elements =
|
|
175
|
-
Math.floor(MAX_BLOCK_BYTES / byte_stride) & ~(MESHOPT_GROUP_SIZE - 1),
|
|
176
|
-
MAX_BLOCK_ELEMENTS
|
|
177
|
-
);
|
|
132
|
+
const max_block_elements = meshopt_max_block_elements(byte_stride);
|
|
178
133
|
|
|
179
134
|
let offset = 1;
|
|
180
135
|
let element = 0;
|
|
@@ -240,7 +195,7 @@ function decode_block(
|
|
|
240
195
|
offset = meshopt_decode_data_block(
|
|
241
196
|
delta_scratch, deltas_offset, group_count,
|
|
242
197
|
source, offset, source_end,
|
|
243
|
-
|
|
198
|
+
MESHOPT_BITS_VERSION_0
|
|
244
199
|
);
|
|
245
200
|
|
|
246
201
|
continue;
|
|
@@ -264,7 +219,7 @@ function decode_block(
|
|
|
264
219
|
offset = meshopt_decode_data_block(
|
|
265
220
|
delta_scratch, deltas_offset, group_count,
|
|
266
221
|
source, offset, source_end,
|
|
267
|
-
|
|
222
|
+
MESHOPT_BITS_BY_CONTROL[control]
|
|
268
223
|
);
|
|
269
224
|
}
|
|
270
225
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one group of sixteen deltas costs at a given width, in bytes.
|
|
3
|
+
*
|
|
4
|
+
* The packed codes are fixed-size, so the only thing that varies is how many deltas did not fit and
|
|
5
|
+
* had to be written out whole after them. A delta *equal* to the sentinel does not fit either — the
|
|
6
|
+
* decoder would read it as an escape — which is why the comparison is `>=` and not `>`.
|
|
7
|
+
*
|
|
8
|
+
* Width 0 stores nothing and can therefore only carry a group that is entirely zero; for any other
|
|
9
|
+
* group it is not a choice at all, and this says so with an infinite price rather than a flag the
|
|
10
|
+
* caller has to remember to look at.
|
|
11
|
+
*
|
|
12
|
+
* @param {Uint8Array} deltas
|
|
13
|
+
* @param {number} offset sixteen deltas are read from here
|
|
14
|
+
* @param {number} bits 0, 1, 2, 4 or 8
|
|
15
|
+
* @returns {number} bytes, or `Number.POSITIVE_INFINITY` if the width cannot carry this group
|
|
16
|
+
*/
|
|
17
|
+
export function meshopt_byte_group_size(deltas: Uint8Array, offset: number, bits: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* The cheapest width a group can be coded at, out of the four a header value can name.
|
|
20
|
+
*
|
|
21
|
+
* @param {Uint8Array} deltas
|
|
22
|
+
* @param {number} offset
|
|
23
|
+
* @param {number[]} bit_table four entries, each 0, 1, 2, 4 or 8 — what the control mode decided
|
|
24
|
+
* the two stored header bits mean
|
|
25
|
+
* @returns {{header: number, size: number}} the header value to store, and what it costs
|
|
26
|
+
*/
|
|
27
|
+
export function meshopt_choose_byte_group_bits(deltas: Uint8Array, offset: number, bit_table: number[]): {
|
|
28
|
+
header: number;
|
|
29
|
+
size: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Encode one group of sixteen byte deltas at a chosen width — the inverse of
|
|
33
|
+
* {@link meshopt_decode_byte_group}, and laid out the same way round: the 2-bit and 4-bit packings
|
|
34
|
+
* run from the most significant bit of each byte down, the 1-bit packing the other way.
|
|
35
|
+
*
|
|
36
|
+
* PRECONDITION: `bits` can carry this group, which is what {@link meshopt_choose_byte_group_bits}
|
|
37
|
+
* returns. Passing a width that cannot produces a stream that decodes to different deltas.
|
|
38
|
+
*
|
|
39
|
+
* @param {Uint8Array} destination
|
|
40
|
+
* @param {number} destination_offset
|
|
41
|
+
* @param {Uint8Array} deltas
|
|
42
|
+
* @param {number} deltas_offset sixteen deltas are read from here
|
|
43
|
+
* @param {number} bits 0, 1, 2, 4 or 8
|
|
44
|
+
* @returns {number} the offset just past the group
|
|
45
|
+
*/
|
|
46
|
+
export function meshopt_encode_byte_group(destination: Uint8Array, destination_offset: number, deltas: Uint8Array, deltas_offset: number, bits: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* The widths a group can be coded at, cheapest first. {@link meshopt_choose_byte_group_bits} walks
|
|
49
|
+
* this in order, so a tie is settled in favour of the narrower code.
|
|
50
|
+
* @type {number[]}
|
|
51
|
+
*/
|
|
52
|
+
export const MESHOPT_GROUP_BITS: number[];
|
|
53
|
+
//# sourceMappingURL=meshopt_encode_byte_group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshopt_encode_byte_group.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/meshopt_encode_byte_group.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,gDALW,UAAU,UACV,MAAM,QACN,MAAM,GACJ,MAAM,CA8BlB;AAED;;;;;;;;GAQG;AACH,uDANW,UAAU,UACV,MAAM,aACN,MAAM,EAAE,GAEN;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAmB1C;AAED;;;;;;;;;;;;;;GAcG;AACH,uDAPW,UAAU,sBACV,MAAM,UACN,UAAU,iBACV,MAAM,QACN,MAAM,GACJ,MAAM,CA0ClB;AAxID;;;;GAIG;AACH,iCAFU,MAAM,EAAE,CAEgC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { MESHOPT_GROUP_SIZE } from "./MESHOPT_GROUP_SIZE.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The widths a group can be coded at, cheapest first. {@link meshopt_choose_byte_group_bits} walks
|
|
6
|
+
* this in order, so a tie is settled in favour of the narrower code.
|
|
7
|
+
* @type {number[]}
|
|
8
|
+
*/
|
|
9
|
+
export const MESHOPT_GROUP_BITS = [0, 1, 2, 4, 8];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* What one group of sixteen deltas costs at a given width, in bytes.
|
|
13
|
+
*
|
|
14
|
+
* The packed codes are fixed-size, so the only thing that varies is how many deltas did not fit and
|
|
15
|
+
* had to be written out whole after them. A delta *equal* to the sentinel does not fit either — the
|
|
16
|
+
* decoder would read it as an escape — which is why the comparison is `>=` and not `>`.
|
|
17
|
+
*
|
|
18
|
+
* Width 0 stores nothing and can therefore only carry a group that is entirely zero; for any other
|
|
19
|
+
* group it is not a choice at all, and this says so with an infinite price rather than a flag the
|
|
20
|
+
* caller has to remember to look at.
|
|
21
|
+
*
|
|
22
|
+
* @param {Uint8Array} deltas
|
|
23
|
+
* @param {number} offset sixteen deltas are read from here
|
|
24
|
+
* @param {number} bits 0, 1, 2, 4 or 8
|
|
25
|
+
* @returns {number} bytes, or `Number.POSITIVE_INFINITY` if the width cannot carry this group
|
|
26
|
+
*/
|
|
27
|
+
export function meshopt_byte_group_size(deltas, offset, bits) {
|
|
28
|
+
assert.isOneOf(bits, MESHOPT_GROUP_BITS, 'bits');
|
|
29
|
+
|
|
30
|
+
if (bits === 8) {
|
|
31
|
+
return MESHOPT_GROUP_SIZE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (bits === 0) {
|
|
35
|
+
for (let i = 0; i < MESHOPT_GROUP_SIZE; i++) {
|
|
36
|
+
if (deltas[offset + i] !== 0) {
|
|
37
|
+
return Number.POSITIVE_INFINITY;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const sentinel = (1 << bits) - 1;
|
|
45
|
+
|
|
46
|
+
let escapes = 0;
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < MESHOPT_GROUP_SIZE; i++) {
|
|
49
|
+
if (deltas[offset + i] >= sentinel) {
|
|
50
|
+
escapes++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return MESHOPT_GROUP_SIZE / (8 / bits) + escapes;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The cheapest width a group can be coded at, out of the four a header value can name.
|
|
59
|
+
*
|
|
60
|
+
* @param {Uint8Array} deltas
|
|
61
|
+
* @param {number} offset
|
|
62
|
+
* @param {number[]} bit_table four entries, each 0, 1, 2, 4 or 8 — what the control mode decided
|
|
63
|
+
* the two stored header bits mean
|
|
64
|
+
* @returns {{header: number, size: number}} the header value to store, and what it costs
|
|
65
|
+
*/
|
|
66
|
+
export function meshopt_choose_byte_group_bits(deltas, offset, bit_table) {
|
|
67
|
+
let best_header = 0;
|
|
68
|
+
let best_size = Number.POSITIVE_INFINITY;
|
|
69
|
+
|
|
70
|
+
for (let header = 0; header < 4; header++) {
|
|
71
|
+
const size = meshopt_byte_group_size(deltas, offset, bit_table[header]);
|
|
72
|
+
|
|
73
|
+
if (size < best_size) {
|
|
74
|
+
best_header = header;
|
|
75
|
+
best_size = size;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 8 is in every table that has no 0, and 0 is in every table that has no 8, so one of them fits
|
|
80
|
+
assert.ok(Number.isFinite(best_size), `no width in [${bit_table}] can carry the group at ${offset}`);
|
|
81
|
+
|
|
82
|
+
return { header: best_header, size: best_size };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Encode one group of sixteen byte deltas at a chosen width — the inverse of
|
|
87
|
+
* {@link meshopt_decode_byte_group}, and laid out the same way round: the 2-bit and 4-bit packings
|
|
88
|
+
* run from the most significant bit of each byte down, the 1-bit packing the other way.
|
|
89
|
+
*
|
|
90
|
+
* PRECONDITION: `bits` can carry this group, which is what {@link meshopt_choose_byte_group_bits}
|
|
91
|
+
* returns. Passing a width that cannot produces a stream that decodes to different deltas.
|
|
92
|
+
*
|
|
93
|
+
* @param {Uint8Array} destination
|
|
94
|
+
* @param {number} destination_offset
|
|
95
|
+
* @param {Uint8Array} deltas
|
|
96
|
+
* @param {number} deltas_offset sixteen deltas are read from here
|
|
97
|
+
* @param {number} bits 0, 1, 2, 4 or 8
|
|
98
|
+
* @returns {number} the offset just past the group
|
|
99
|
+
*/
|
|
100
|
+
export function meshopt_encode_byte_group(destination, destination_offset, deltas, deltas_offset, bits) {
|
|
101
|
+
assert.isOneOf(bits, MESHOPT_GROUP_BITS, 'bits');
|
|
102
|
+
|
|
103
|
+
if (bits === 0) {
|
|
104
|
+
return destination_offset;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (bits === 8) {
|
|
108
|
+
for (let i = 0; i < MESHOPT_GROUP_SIZE; i++) {
|
|
109
|
+
destination[destination_offset + i] = deltas[deltas_offset + i];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return destination_offset + MESHOPT_GROUP_SIZE;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const per_byte = 8 / bits;
|
|
116
|
+
const packed_bytes = MESHOPT_GROUP_SIZE / per_byte;
|
|
117
|
+
const sentinel = (1 << bits) - 1;
|
|
118
|
+
|
|
119
|
+
const ascending = bits === 1;
|
|
120
|
+
|
|
121
|
+
destination.fill(0, destination_offset, destination_offset + packed_bytes);
|
|
122
|
+
|
|
123
|
+
let sentinel_offset = destination_offset + packed_bytes;
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < MESHOPT_GROUP_SIZE; i++) {
|
|
126
|
+
const delta = deltas[deltas_offset + i];
|
|
127
|
+
const code = delta < sentinel ? delta : sentinel;
|
|
128
|
+
|
|
129
|
+
const lane = i % per_byte;
|
|
130
|
+
const shift = ascending ? (lane * bits) : (8 - bits - lane * bits);
|
|
131
|
+
|
|
132
|
+
destination[destination_offset + ((i / per_byte) | 0)] |= code << shift;
|
|
133
|
+
|
|
134
|
+
if (code === sentinel) {
|
|
135
|
+
destination[sentinel_offset++] = delta;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return sentinel_offset;
|
|
140
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Price one "data block" — the delta bytes for a single byte position of the element, across one
|
|
3
|
+
* attribute block's worth of groups — and record the header value each group wants.
|
|
4
|
+
*
|
|
5
|
+
* Every group is priced on its own, because the header spends two bits per group either way: a
|
|
6
|
+
* block of mostly-zero groups with one noisy one pays for the noisy one alone.
|
|
7
|
+
*
|
|
8
|
+
* @param {Uint8Array} deltas
|
|
9
|
+
* @param {number} deltas_offset
|
|
10
|
+
* @param {number} group_count
|
|
11
|
+
* @param {number[]} bit_table four entries, each 0, 1, 2, 4 or 8
|
|
12
|
+
* @param {Uint8Array} choices `group_count` header values are written here
|
|
13
|
+
* @param {number} choices_offset
|
|
14
|
+
* @returns {number} what the block costs in bytes, header included
|
|
15
|
+
*/
|
|
16
|
+
export function meshopt_choose_data_block(deltas: Uint8Array, deltas_offset: number, group_count: number, bit_table: number[], choices: Uint8Array, choices_offset: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Write a data block: `ceil(group_count / 4)` header bytes, two bits per group packed least
|
|
19
|
+
* significant first, then the groups. The inverse of {@link meshopt_decode_data_block}.
|
|
20
|
+
*
|
|
21
|
+
* @param {Uint8Array} destination
|
|
22
|
+
* @param {number} destination_offset
|
|
23
|
+
* @param {Uint8Array} deltas
|
|
24
|
+
* @param {number} deltas_offset
|
|
25
|
+
* @param {number} group_count
|
|
26
|
+
* @param {number[]} bit_table
|
|
27
|
+
* @param {Uint8Array} choices the header values {@link meshopt_choose_data_block} settled on
|
|
28
|
+
* @param {number} choices_offset
|
|
29
|
+
* @returns {number} the offset just past the data block
|
|
30
|
+
*/
|
|
31
|
+
export function meshopt_encode_data_block(destination: Uint8Array, destination_offset: number, deltas: Uint8Array, deltas_offset: number, group_count: number, bit_table: number[], choices: Uint8Array, choices_offset: number): number;
|
|
32
|
+
//# sourceMappingURL=meshopt_encode_data_block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshopt_encode_data_block.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/meshopt_encode_data_block.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,kDARW,UAAU,iBACV,MAAM,eACN,MAAM,aACN,MAAM,EAAE,WACR,UAAU,kBACV,MAAM,GACJ,MAAM,CAkBlB;AAED;;;;;;;;;;;;;GAaG;AACH,uDAVW,UAAU,sBACV,MAAM,UACN,UAAU,iBACV,MAAM,eACN,MAAM,aACN,MAAM,EAAE,WACR,UAAU,kBACV,MAAM,GACJ,MAAM,CA4BlB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { MESHOPT_GROUP_SIZE } from "./MESHOPT_GROUP_SIZE.js";
|
|
2
|
+
import { meshopt_choose_byte_group_bits, meshopt_encode_byte_group } from "./meshopt_encode_byte_group.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Price one "data block" — the delta bytes for a single byte position of the element, across one
|
|
6
|
+
* attribute block's worth of groups — and record the header value each group wants.
|
|
7
|
+
*
|
|
8
|
+
* Every group is priced on its own, because the header spends two bits per group either way: a
|
|
9
|
+
* block of mostly-zero groups with one noisy one pays for the noisy one alone.
|
|
10
|
+
*
|
|
11
|
+
* @param {Uint8Array} deltas
|
|
12
|
+
* @param {number} deltas_offset
|
|
13
|
+
* @param {number} group_count
|
|
14
|
+
* @param {number[]} bit_table four entries, each 0, 1, 2, 4 or 8
|
|
15
|
+
* @param {Uint8Array} choices `group_count` header values are written here
|
|
16
|
+
* @param {number} choices_offset
|
|
17
|
+
* @returns {number} what the block costs in bytes, header included
|
|
18
|
+
*/
|
|
19
|
+
export function meshopt_choose_data_block(
|
|
20
|
+
deltas, deltas_offset,
|
|
21
|
+
group_count,
|
|
22
|
+
bit_table,
|
|
23
|
+
choices, choices_offset
|
|
24
|
+
) {
|
|
25
|
+
let size = (group_count + 3) >> 2;
|
|
26
|
+
|
|
27
|
+
for (let g = 0; g < group_count; g++) {
|
|
28
|
+
const choice = meshopt_choose_byte_group_bits(deltas, deltas_offset + g * MESHOPT_GROUP_SIZE, bit_table);
|
|
29
|
+
|
|
30
|
+
choices[choices_offset + g] = choice.header;
|
|
31
|
+
size += choice.size;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return size;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Write a data block: `ceil(group_count / 4)` header bytes, two bits per group packed least
|
|
39
|
+
* significant first, then the groups. The inverse of {@link meshopt_decode_data_block}.
|
|
40
|
+
*
|
|
41
|
+
* @param {Uint8Array} destination
|
|
42
|
+
* @param {number} destination_offset
|
|
43
|
+
* @param {Uint8Array} deltas
|
|
44
|
+
* @param {number} deltas_offset
|
|
45
|
+
* @param {number} group_count
|
|
46
|
+
* @param {number[]} bit_table
|
|
47
|
+
* @param {Uint8Array} choices the header values {@link meshopt_choose_data_block} settled on
|
|
48
|
+
* @param {number} choices_offset
|
|
49
|
+
* @returns {number} the offset just past the data block
|
|
50
|
+
*/
|
|
51
|
+
export function meshopt_encode_data_block(
|
|
52
|
+
destination, destination_offset,
|
|
53
|
+
deltas, deltas_offset,
|
|
54
|
+
group_count,
|
|
55
|
+
bit_table,
|
|
56
|
+
choices, choices_offset
|
|
57
|
+
) {
|
|
58
|
+
const header_bytes = (group_count + 3) >> 2;
|
|
59
|
+
|
|
60
|
+
destination.fill(0, destination_offset, destination_offset + header_bytes);
|
|
61
|
+
|
|
62
|
+
let offset = destination_offset + header_bytes;
|
|
63
|
+
|
|
64
|
+
for (let g = 0; g < group_count; g++) {
|
|
65
|
+
const header = choices[choices_offset + g];
|
|
66
|
+
|
|
67
|
+
destination[destination_offset + (g >> 2)] |= header << ((g & 3) * 2);
|
|
68
|
+
|
|
69
|
+
offset = meshopt_encode_byte_group(
|
|
70
|
+
destination, offset,
|
|
71
|
+
deltas, deltas_offset + g * MESHOPT_GROUP_SIZE,
|
|
72
|
+
bit_table[header]
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return offset;
|
|
77
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode an index stream of no particular topology — the `"INDICES"` mode of both meshopt
|
|
3
|
+
* extensions, and the inverse of {@link meshopt_decode_index_sequence}.
|
|
4
|
+
*
|
|
5
|
+
* Each index is a zigzag delta against one of *two* running baselines, and which one is the low bit
|
|
6
|
+
* of the stored value. Two rather than one is what lets two independently monotonic runs be spliced
|
|
7
|
+
* together and still pay one small delta per index — a triangle strip's own indices against one, a
|
|
8
|
+
* degenerate seam against the other — so the choice is where the compression is, and it is made per
|
|
9
|
+
* index by pricing both:
|
|
10
|
+
*
|
|
11
|
+
* - the baseline whose delta encodes in fewer bytes wins;
|
|
12
|
+
* - a tie goes to the smaller delta, which leaves both baselines nearer the runs they are tracking;
|
|
13
|
+
* - a tie in that too goes to baseline 0, which keeps baseline 1 free for a run that has not
|
|
14
|
+
* started yet.
|
|
15
|
+
*
|
|
16
|
+
* Greedy, and deliberately so: a baseline that is cheap now is cheap because it is near, and near is
|
|
17
|
+
* what makes it cheap again next time.
|
|
18
|
+
*
|
|
19
|
+
* A baseline both of whose deltas are further away than {@link MESHOPT_INDEX_SEQUENCE_MAX_DELTA} is
|
|
20
|
+
* not a choice at all, and an index that is out of reach of both is refused.
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_meshopt_compression
|
|
23
|
+
*
|
|
24
|
+
* @param {ArrayLike<number>} indices unsigned 32-bit
|
|
25
|
+
* @param {Object} [options]
|
|
26
|
+
* @param {number} [options.version] 0 or 1, defaulting to 1 — the two are the same bitstream, and
|
|
27
|
+
* the nibble is there for a codec change that has not happened
|
|
28
|
+
* @returns {Uint8Array} the whole compressed stream, reserved tail included
|
|
29
|
+
* @throws {Error} on an index further than {@link MESHOPT_INDEX_SEQUENCE_MAX_DELTA} from both
|
|
30
|
+
* baselines, which the format has no way to write down
|
|
31
|
+
*/
|
|
32
|
+
export function meshopt_encode_index_sequence(indices: ArrayLike<number>, options?: {
|
|
33
|
+
version?: number;
|
|
34
|
+
}): Uint8Array;
|
|
35
|
+
/**
|
|
36
|
+
* How far one index may sit from the baseline it is coded against.
|
|
37
|
+
*
|
|
38
|
+
* The stored value spends its low bit on which baseline, leaving thirty-one for the zigzag, whose
|
|
39
|
+
* own low bit is the sign — so the delta has thirty bits and a sign, and half of the 32-bit index
|
|
40
|
+
* range is out of reach of any one step. Nothing that indexes a real vertex buffer comes near it,
|
|
41
|
+
* but a stream that crossed it would decode to different indices rather than fail, so it is checked.
|
|
42
|
+
*
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
export const MESHOPT_INDEX_SEQUENCE_MAX_DELTA: number;
|
|
46
|
+
//# sourceMappingURL=meshopt_encode_index_sequence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshopt_encode_index_sequence.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/meshopt/meshopt_encode_index_sequence.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,uDARW,UAAU,MAAM,CAAC;IAEA,OAAO,GAAxB,MAAM;IAEJ,UAAU,CA2DtB;AAlGD;;;;;;;;;GASG;AACH,+CAFU,MAAM,CAEwC"}
|