@woosh/meep-engine 3.81.0 → 3.82.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/CHANGELOG.md +42 -0
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/ecs/component/editors/common/BitFlagsEditor.d.ts.map +1 -1
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +11 -0
- package/editor/prototypeEditorShell.d.ts.map +1 -1
- package/editor/prototypeEditorShell.js +4 -1
- package/package.json +1 -1
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts +13 -0
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.js +12 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts +64 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.js +89 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts +1 -1
- package/src/engine/graphics/ecs/mesh-v2/MeshSkin.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.d.ts +1 -0
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +10 -3
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts +14 -0
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.js +21 -0
- package/src/engine/graphics3/HairSystem.js +1 -1
- package/src/engine/graphics3/MeshMorphSystem.d.ts +48 -0
- package/src/engine/graphics3/MeshMorphSystem.d.ts.map +1 -0
- package/src/engine/graphics3/MeshMorphSystem.js +355 -0
- package/src/engine/graphics3/MeshSkinSystem.js +2 -2
- package/src/engine/graphics3/MeshSystem.d.ts +2 -1
- package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
- package/src/engine/graphics3/MeshSystem.js +2 -1
- package/src/engine/graphics3/ShadedGeometrySystem.d.ts +1 -1
- package/src/engine/graphics3/ShadedGeometrySystem.js +2 -2
- package/src/engine/graphics3/prefab/Prefab.d.ts +14 -0
- package/src/engine/graphics3/prefab/Prefab.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/Prefab.js +16 -0
- package/src/engine/graphics3/prefab/prefab_compile.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_compile.js +8 -1
- package/src/engine/graphics3/prefab/prefab_instantiate.d.ts +3 -2
- package/src/engine/graphics3/prefab/prefab_instantiate.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_instantiate.js +17 -4
- package/src/engine/graphics3/prefab/prefab_place.d.ts +27 -9
- package/src/engine/graphics3/prefab/prefab_place.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_place.js +69 -13
- package/src/engine/graphics3/register_clips.d.ts.map +1 -1
- package/src/engine/graphics3/register_clips.js +8 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/playground/hair_skinned/skinned_hair.js +2 -2
- package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.js +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_instance_bounds.js +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.js +1 -1
- package/src/shade/playground/skinned_mesh_soup/main.js +1 -1
- package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.js +2 -2
- package/src/shade/renderer/Renderer.js +2 -2
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts +5 -0
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts.map +1 -1
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.js +19 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts +8 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.js +19 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts +6 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.js +13 -0
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts +71 -0
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.js +559 -9
- package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts +23 -2
- package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationChannel.js +43 -2
- package/src/shade/renderer/animation/ShadeAnimationClip.d.ts +9 -3
- package/src/shade/renderer/animation/ShadeAnimationClip.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClip.js +67 -3
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +3 -2
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +6 -3
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts +14 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.js +49 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts +12 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.js +30 -0
- package/src/shade/renderer/animation/Skin.d.ts +1 -1
- package/src/shade/renderer/animation/Skin.js +1 -1
- package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts +26 -0
- package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/SKINNING_BINDING_STRUCT.js → deformation/DEFORMATION_BINDING_STRUCT.js} +33 -8
- package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.d.ts → deformation/GPUMeshDeformationContext.d.ts} +60 -17
- package/src/shade/renderer/animation/deformation/GPUMeshDeformationContext.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.js → deformation/GPUMeshDeformationContext.js} +458 -55
- package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts} +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.js → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.js} +3 -3
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.js +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.js +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.js +2 -2
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts +24 -0
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts.map +1 -0
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.js +257 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts +18 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts.map +1 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.js +75 -0
- package/src/shade/renderer/animation/shader_animation_apply.d.ts.map +1 -1
- package/src/shade/renderer/animation/shader_animation_apply.js +3 -1
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.d.ts.map +1 -1
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +31 -7
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.d.ts +8 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.js +18 -1
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts +1 -1
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.js +1 -1
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts +9 -0
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.js +30 -2
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts +27 -0
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +85 -6
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts +5 -1
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.js +8 -3
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts +13 -0
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.js +47 -4
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts +51 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.js +60 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts +12 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.js +11 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts +73 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.js +130 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts +34 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.js +126 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts +50 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.js +81 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts +22 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.js +375 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts +25 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.js +134 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts +15 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.js +110 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts +22 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.js +32 -0
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.js +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +3 -3
- package/src/shade/renderer/hair/GPUHairSystem.js +1 -1
- package/src/shade/renderer/loader/SceneNode.d.ts +20 -1
- package/src/shade/renderer/loader/SceneNode.d.ts.map +1 -1
- package/src/shade/renderer/loader/SceneNode.js +142 -114
- package/src/shade/renderer/loader/gltf/load_gltf.d.ts +1 -0
- package/src/shade/renderer/loader/gltf/load_gltf.d.ts.map +1 -1
- package/src/shade/renderer/loader/gltf/load_gltf.js +214 -30
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts +41 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.js +60 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts +31 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.js +108 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +3 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +4 -1
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_export.js +7 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +6 -3
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_read_scene.js +43 -3
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +2 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +9 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts +3 -1
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_write.js +20 -1
- package/src/shade/renderer/object_property/ObjectType.d.ts +1 -0
- package/src/shade/renderer/object_property/ObjectType.js +8 -0
- package/src/shade/renderer/object_property/chunk_write_object_property.d.ts +6 -7
- package/src/shade/renderer/object_property/chunk_write_object_property.d.ts.map +1 -1
- package/src/shade/renderer/object_property/chunk_write_object_property.js +13 -7
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts +17 -0
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts.map +1 -0
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.js +38 -0
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.d.ts +5 -6
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +17 -20
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts +1 -1
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.js +2 -2
- package/src/shade/renderer/scene/chunk_mesh_flags.js +3 -3
- package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts +1 -1
- package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts.map +1 -1
- package/src/shade/renderer/scene/movers/graph_scene_movers.js +20 -13
- package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts +25 -0
- package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts.map +1 -0
- package/src/shade/renderer/scene/movers/{shader_scene_skinned_movers.js → shader_scene_deformed_movers.js} +28 -18
- package/src/shade/renderer/scene/movers/shader_scene_movers.d.ts +1 -1
- package/src/shade/renderer/scene/movers/shader_scene_movers.js +2 -2
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +13 -13
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
- package/src/shade/renderer/scene/rows/GPUSceneRows.js +30 -30
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts +17 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.js +78 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts +2 -1
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.js +10 -54
- package/src/shade/renderer/shadow/vsm/VSMPageManager.d.ts.map +1 -1
- package/src/shade/renderer/shadow/vsm/VSMPageManager.js +33 -163
- package/src/shade/renderer/texture/virtual/README.md +12 -4
- package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts +116 -0
- package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts.map +1 -0
- package/src/shade/renderer/texture/virtual/VTLodBiasController.js +301 -0
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +8 -3
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +110 -20
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts +0 -22
- package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts.map +0 -1
- package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts +0 -24
- package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts.map +0 -1
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.d.ts +0 -0
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.d.ts +0 -0
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.d.ts +0 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import {
|
|
3
|
+
geometry_compute_vertex_normals_indexed
|
|
4
|
+
} from "../../../../engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.js";
|
|
5
|
+
import { Attribute } from "../Attribute.js";
|
|
6
|
+
import { Geometry } from "../Geometry.js";
|
|
7
|
+
import { geometry_deduplicate_vertices } from "../geometry_deduplicate_vertices.js";
|
|
8
|
+
import { GEOMETRY_MESHLET_VERTEX_LIMIT } from "../meshlet/GEOMETRY_MESHLET_TRIANGLE_LIMIT.js";
|
|
9
|
+
import { meshlet_position_encode } from "../meshlet/encoding/meshlet_position_encode.js";
|
|
10
|
+
import { meshlet_position_exponent } from "../meshlet/encoding/meshlet_position_exponent.js";
|
|
11
|
+
import { MESHLET_POSITION_EXPONENT_FLOOR } from "../meshlet/encoding/MESHLET_POSITION_EXPONENT_FLOOR.js";
|
|
12
|
+
import { meshlet_position_words } from "../meshlet/encoding/meshlet_position_words.js";
|
|
13
|
+
import { StandardAttributes } from "../StandardAttributes.js";
|
|
14
|
+
import {
|
|
15
|
+
MESHLET_MORPH_BLOCK_HEADER_WORDS,
|
|
16
|
+
MESHLET_MORPH_BLOCK_NORMAL_FLAGS,
|
|
17
|
+
MESHLET_MORPH_BLOCK_NORMAL_ORIGIN,
|
|
18
|
+
MESHLET_MORPH_BLOCK_POSITION_FLAGS,
|
|
19
|
+
MESHLET_MORPH_BLOCK_POSITION_ORIGIN,
|
|
20
|
+
MESHLET_MORPH_BLOCK_TARGET,
|
|
21
|
+
MESHLET_MORPH_RANGE_WORDS,
|
|
22
|
+
meshlet_morph_mask_words
|
|
23
|
+
} from "./MESHLET_MORPH_LAYOUT.js";
|
|
24
|
+
import { MESHLET_MORPH_NORMAL_EXPONENT } from "./MESHLET_MORPH_NORMAL_EXPONENT.js";
|
|
25
|
+
import { MeshletMorphTargets } from "./MeshletMorphTargets.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {import("./MorphedGeometry.js").MorphedGeometry} MorphedGeometry
|
|
29
|
+
* @typedef {import("../MeshletGeometry.js").MeshletGeometry} MeshletGeometry
|
|
30
|
+
* @typedef {import("../meshlet/MeshletBatch.js").MeshletVertexSources} MeshletVertexSources
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const GATHERED_POSITIONS = new Float64Array(GEOMETRY_MESHLET_VERTEX_LIMIT * 3);
|
|
34
|
+
const GATHERED_NORMALS = new Float64Array(GEOMETRY_MESHLET_VERTEX_LIMIT * 3);
|
|
35
|
+
const ENCODED_POSITIONS = new Uint32Array(GEOMETRY_MESHLET_VERTEX_LIMIT * 3);
|
|
36
|
+
const ENCODED_NORMALS = new Uint32Array(GEOMETRY_MESHLET_VERTEX_LIMIT * 3);
|
|
37
|
+
const TOUCHED = new Uint16Array(GEOMETRY_MESHLET_VERTEX_LIMIT);
|
|
38
|
+
const ORIGIN = new Int32Array(6);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether a delta survives rounding to a lattice of `1 / scale`: a vertex is in a block exactly when its
|
|
42
|
+
* position or its normal delta does.
|
|
43
|
+
*
|
|
44
|
+
* @param {Float32Array|Float64Array} delta
|
|
45
|
+
* @param {number} offset
|
|
46
|
+
* @param {number} scale
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
function survives(delta, offset, scale) {
|
|
50
|
+
// written so that a NaN survives, and is stored as one
|
|
51
|
+
return !(Math.round(delta[offset] * scale) === 0
|
|
52
|
+
&& Math.round(delta[offset + 1] * scale) === 0
|
|
53
|
+
&& Math.round(delta[offset + 2] * scale) === 0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The base's vertices welded by position: vertices a source keeps apart only for a UV seam or a hard edge,
|
|
58
|
+
* at one point, become one, so a normal derived over the welded triangles is one normal on both sides of
|
|
59
|
+
* the split. The weld is {@link geometry_deduplicate_vertices} over the positions alone, so only exactly
|
|
60
|
+
* equal positions join.
|
|
61
|
+
*
|
|
62
|
+
* @param {ArrayLike<number>} positions
|
|
63
|
+
* @param {ArrayLike<number>} index
|
|
64
|
+
* @param {number} vertex_count
|
|
65
|
+
* @returns {{weld_of: Int32Array, index: ArrayLike<number>, count: number}} `weld_of[v]` is vertex v's welded
|
|
66
|
+
* vertex, -1 for one no triangle uses; `index` the triangles over welded vertices
|
|
67
|
+
*/
|
|
68
|
+
function weld_by_position(positions, index, vertex_count) {
|
|
69
|
+
const source = new Geometry();
|
|
70
|
+
|
|
71
|
+
source.addAttribute(Attribute.from(Float32Array.from(positions).subarray(0, vertex_count * 3), 3, StandardAttributes.Position));
|
|
72
|
+
source.index = Attribute.from(Uint32Array.from(index), 1, 'index');
|
|
73
|
+
|
|
74
|
+
const welded = geometry_deduplicate_vertices(source);
|
|
75
|
+
const welded_index = welded.index.data;
|
|
76
|
+
|
|
77
|
+
const weld_of = new Int32Array(vertex_count).fill(-1);
|
|
78
|
+
|
|
79
|
+
for (let c = 0; c < welded_index.length; c++) {
|
|
80
|
+
weld_of[index[c]] = welded_index[c];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return { weld_of, index: welded_index, count: welded.getVertexCount() };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The normals {@link geometry_compute_vertex_normals_indexed} gives `positions` over the welded triangles,
|
|
88
|
+
* read back per source vertex into `out`.
|
|
89
|
+
*
|
|
90
|
+
* @param {Float32Array} out per source vertex
|
|
91
|
+
* @param {ArrayLike<number>} positions per source vertex
|
|
92
|
+
* @param {{weld_of: Int32Array, index: ArrayLike<number>, count: number}} weld
|
|
93
|
+
* @param {Float32Array} welded_positions scratch, `weld.count * 3`
|
|
94
|
+
* @param {Float32Array} welded_normals scratch, `weld.count * 3`
|
|
95
|
+
*/
|
|
96
|
+
function welded_normals_of(out, positions, weld, welded_positions, welded_normals) {
|
|
97
|
+
const weld_of = weld.weld_of;
|
|
98
|
+
const vertex_count = weld_of.length;
|
|
99
|
+
|
|
100
|
+
// vertices welded together sit at one point of the base; of a target, the shape gives each its own
|
|
101
|
+
// displaced point, and the first one met stands for them
|
|
102
|
+
welded_positions.fill(NaN);
|
|
103
|
+
|
|
104
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
105
|
+
const w = weld_of[v];
|
|
106
|
+
|
|
107
|
+
if (w !== -1 && Number.isNaN(welded_positions[w * 3])) {
|
|
108
|
+
welded_positions[w * 3] = positions[v * 3];
|
|
109
|
+
welded_positions[w * 3 + 1] = positions[v * 3 + 1];
|
|
110
|
+
welded_positions[w * 3 + 2] = positions[v * 3 + 2];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
welded_normals.fill(0);
|
|
115
|
+
|
|
116
|
+
geometry_compute_vertex_normals_indexed(welded_positions, welded_normals, weld.index);
|
|
117
|
+
|
|
118
|
+
out.fill(0);
|
|
119
|
+
|
|
120
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
121
|
+
const w = weld_of[v];
|
|
122
|
+
|
|
123
|
+
if (w !== -1) {
|
|
124
|
+
out[v * 3] = welded_normals[w * 3];
|
|
125
|
+
out[v * 3 + 1] = welded_normals[w * 3 + 1];
|
|
126
|
+
out[v * 3 + 2] = welded_normals[w * 3 + 2];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Lay a {@link MorphedGeometry}'s targets out in the meshlet order of the geometry its base was built
|
|
133
|
+
* into, as {@link MESHLET_MORPH_LAYOUT} states.
|
|
134
|
+
*
|
|
135
|
+
* The base has been built with {@link meshlet_geometry_build_deformed}, which also gave it normals if it
|
|
136
|
+
* had none. Every target's normal deltas are stored: a target's own normals less the base's, or, for a
|
|
137
|
+
* target with none, the normals the base's own normal operator gives the target's shape less those it
|
|
138
|
+
* gives the base's, both over the base's vertices welded by position (see {@link weld_by_position}), so a
|
|
139
|
+
* vertex split for a seam takes the delta its twin does. Faces a target does not move come out the same
|
|
140
|
+
* both ways, so their vertices get no normal delta and stay out of the blocks.
|
|
141
|
+
*
|
|
142
|
+
* @param {MorphedGeometry} morphed
|
|
143
|
+
* @param {MeshletGeometry} geometry the base, built
|
|
144
|
+
* @param {MeshletVertexSources} sources the base's vertex behind each meshlet vertex
|
|
145
|
+
* @returns {MeshletMorphTargets}
|
|
146
|
+
*/
|
|
147
|
+
export function meshlet_morph_targets_build(morphed, geometry, sources) {
|
|
148
|
+
assert.defined(morphed, 'morphed');
|
|
149
|
+
assert.equal(morphed.isMorphedGeometry, true, 'morphed.isMorphedGeometry !== true');
|
|
150
|
+
assert.defined(geometry, 'geometry');
|
|
151
|
+
assert.defined(sources, 'sources');
|
|
152
|
+
|
|
153
|
+
const base = morphed.base;
|
|
154
|
+
const vertex_count = base.getVertexCount();
|
|
155
|
+
const meshlet_count = sources.first.length - 1;
|
|
156
|
+
|
|
157
|
+
assert.equal(meshlet_count, geometry.meshlets.count, 'sources describe a different number of meshlets');
|
|
158
|
+
|
|
159
|
+
const base_positions = base.getAttribute(StandardAttributes.Position).data;
|
|
160
|
+
const base_normals = base.getAttribute(StandardAttributes.Normal).data;
|
|
161
|
+
const index = base.index.data;
|
|
162
|
+
|
|
163
|
+
// the lattice the base's own positions were stored on
|
|
164
|
+
const position_exponent = meshlet_position_exponent(
|
|
165
|
+
base_positions, vertex_count,
|
|
166
|
+
index, base.getIndexCount(),
|
|
167
|
+
MESHLET_POSITION_EXPONENT_FLOOR
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const position_scale = 2 ** position_exponent;
|
|
171
|
+
const normal_scale = 2 ** MESHLET_MORPH_NORMAL_EXPONENT;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Each meshlet's blocks, appended target by target, which is target order.
|
|
175
|
+
*
|
|
176
|
+
* @type {Uint32Array[][]}
|
|
177
|
+
*/
|
|
178
|
+
const blocks_of = new Array(meshlet_count);
|
|
179
|
+
|
|
180
|
+
for (let m = 0; m < meshlet_count; m++) {
|
|
181
|
+
blocks_of[m] = [];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const delta_position = new Float64Array(vertex_count * 3);
|
|
185
|
+
const delta_normal = new Float64Array(vertex_count * 3);
|
|
186
|
+
|
|
187
|
+
// the base's shape under the normal operator, for targets that bring no normals of their own
|
|
188
|
+
let base_derived_normals = null;
|
|
189
|
+
let target_derived_normals = null;
|
|
190
|
+
let weld = null;
|
|
191
|
+
let welded_positions = null;
|
|
192
|
+
let welded_normals = null;
|
|
193
|
+
|
|
194
|
+
const targets = morphed.targets;
|
|
195
|
+
|
|
196
|
+
for (let t = 0; t < targets.length; t++) {
|
|
197
|
+
const target = targets[t];
|
|
198
|
+
|
|
199
|
+
const target_positions = target.getAttribute(StandardAttributes.Position).data;
|
|
200
|
+
const target_normal_attribute = target.getAttribute(StandardAttributes.Normal);
|
|
201
|
+
|
|
202
|
+
for (let i = 0; i < vertex_count * 3; i++) {
|
|
203
|
+
delta_position[i] = target_positions[i] - base_positions[i];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (target_normal_attribute !== undefined) {
|
|
207
|
+
const target_normals = target_normal_attribute.data;
|
|
208
|
+
|
|
209
|
+
for (let i = 0; i < vertex_count * 3; i++) {
|
|
210
|
+
delta_normal[i] = target_normals[i] - base_normals[i];
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
if (base_derived_normals === null) {
|
|
214
|
+
weld = weld_by_position(base_positions, index, vertex_count);
|
|
215
|
+
|
|
216
|
+
welded_positions = new Float32Array(weld.count * 3);
|
|
217
|
+
welded_normals = new Float32Array(weld.count * 3);
|
|
218
|
+
|
|
219
|
+
base_derived_normals = new Float32Array(vertex_count * 3);
|
|
220
|
+
target_derived_normals = new Float32Array(vertex_count * 3);
|
|
221
|
+
|
|
222
|
+
welded_normals_of(base_derived_normals, base_positions, weld, welded_positions, welded_normals);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
welded_normals_of(target_derived_normals, target_positions, weld, welded_positions, welded_normals);
|
|
226
|
+
|
|
227
|
+
for (let i = 0; i < vertex_count * 3; i++) {
|
|
228
|
+
delta_normal[i] = target_derived_normals[i] - base_derived_normals[i];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
for (let m = 0; m < meshlet_count; m++) {
|
|
233
|
+
const block = encode_block(
|
|
234
|
+
t, sources, m,
|
|
235
|
+
delta_position, delta_normal,
|
|
236
|
+
position_exponent, position_scale, normal_scale
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
if (block !== null) {
|
|
240
|
+
blocks_of[m].push(block);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// assemble: ranges, then each meshlet's blocks
|
|
246
|
+
let words = meshlet_count * MESHLET_MORPH_RANGE_WORDS;
|
|
247
|
+
let largest_block_count = 0;
|
|
248
|
+
|
|
249
|
+
for (let m = 0; m < meshlet_count; m++) {
|
|
250
|
+
const blocks = blocks_of[m];
|
|
251
|
+
|
|
252
|
+
largest_block_count = Math.max(largest_block_count, blocks.length);
|
|
253
|
+
|
|
254
|
+
for (let b = 0; b < blocks.length; b++) {
|
|
255
|
+
words += blocks[b].length;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const data = new Uint32Array(words);
|
|
260
|
+
|
|
261
|
+
let cursor = meshlet_count * MESHLET_MORPH_RANGE_WORDS;
|
|
262
|
+
|
|
263
|
+
for (let m = 0; m < meshlet_count; m++) {
|
|
264
|
+
const blocks = blocks_of[m];
|
|
265
|
+
|
|
266
|
+
data[m * MESHLET_MORPH_RANGE_WORDS] = cursor;
|
|
267
|
+
data[m * MESHLET_MORPH_RANGE_WORDS + 1] = blocks.length;
|
|
268
|
+
|
|
269
|
+
for (let b = 0; b < blocks.length; b++) {
|
|
270
|
+
data.set(blocks[b], cursor);
|
|
271
|
+
|
|
272
|
+
cursor += blocks[b].length;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const r = new MeshletMorphTargets();
|
|
277
|
+
|
|
278
|
+
r.names = morphed.names.slice();
|
|
279
|
+
r.geometry = geometry;
|
|
280
|
+
r.data = data.buffer;
|
|
281
|
+
r.largest_block_count = largest_block_count;
|
|
282
|
+
|
|
283
|
+
return r;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* One target's block for one meshlet, or null where the target moves none of its vertices.
|
|
288
|
+
*
|
|
289
|
+
* @param {number} target
|
|
290
|
+
* @param {MeshletVertexSources} sources
|
|
291
|
+
* @param {number} meshlet
|
|
292
|
+
* @param {Float64Array} delta_position per geometry vertex
|
|
293
|
+
* @param {Float64Array} delta_normal per geometry vertex
|
|
294
|
+
* @param {number} position_exponent
|
|
295
|
+
* @param {number} position_scale
|
|
296
|
+
* @param {number} normal_scale
|
|
297
|
+
* @returns {Uint32Array|null}
|
|
298
|
+
*/
|
|
299
|
+
function encode_block(
|
|
300
|
+
target, sources, meshlet,
|
|
301
|
+
delta_position, delta_normal,
|
|
302
|
+
position_exponent, position_scale, normal_scale
|
|
303
|
+
) {
|
|
304
|
+
const first = sources.first[meshlet];
|
|
305
|
+
const vertex_count = sources.first[meshlet + 1] - first;
|
|
306
|
+
|
|
307
|
+
let touched = 0;
|
|
308
|
+
|
|
309
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
310
|
+
const source = sources.vertex[first + v] * 3;
|
|
311
|
+
|
|
312
|
+
if (survives(delta_position, source, position_scale) || survives(delta_normal, source, normal_scale)) {
|
|
313
|
+
TOUCHED[touched] = v;
|
|
314
|
+
|
|
315
|
+
const g = touched * 3;
|
|
316
|
+
|
|
317
|
+
GATHERED_POSITIONS[g] = delta_position[source];
|
|
318
|
+
GATHERED_POSITIONS[g + 1] = delta_position[source + 1];
|
|
319
|
+
GATHERED_POSITIONS[g + 2] = delta_position[source + 2];
|
|
320
|
+
|
|
321
|
+
GATHERED_NORMALS[g] = delta_normal[source];
|
|
322
|
+
GATHERED_NORMALS[g + 1] = delta_normal[source + 1];
|
|
323
|
+
GATHERED_NORMALS[g + 2] = delta_normal[source + 2];
|
|
324
|
+
|
|
325
|
+
touched++;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (touched === 0) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const position_flags = meshlet_position_encode(
|
|
334
|
+
ENCODED_POSITIONS, 0,
|
|
335
|
+
ORIGIN, 0,
|
|
336
|
+
GATHERED_POSITIONS, 0,
|
|
337
|
+
touched,
|
|
338
|
+
position_exponent
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
const normal_flags = meshlet_position_encode(
|
|
342
|
+
ENCODED_NORMALS, 0,
|
|
343
|
+
ORIGIN, 3,
|
|
344
|
+
GATHERED_NORMALS, 0,
|
|
345
|
+
touched,
|
|
346
|
+
MESHLET_MORPH_NORMAL_EXPONENT
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
const mask_words = meshlet_morph_mask_words(vertex_count);
|
|
350
|
+
const position_words = touched * meshlet_position_words(position_flags);
|
|
351
|
+
const normal_words = touched * meshlet_position_words(normal_flags);
|
|
352
|
+
|
|
353
|
+
const block = new Uint32Array(MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words + position_words + normal_words);
|
|
354
|
+
|
|
355
|
+
block[MESHLET_MORPH_BLOCK_TARGET] = target;
|
|
356
|
+
block[MESHLET_MORPH_BLOCK_POSITION_FLAGS] = position_flags;
|
|
357
|
+
block[MESHLET_MORPH_BLOCK_POSITION_ORIGIN] = ORIGIN[0];
|
|
358
|
+
block[MESHLET_MORPH_BLOCK_POSITION_ORIGIN + 1] = ORIGIN[1];
|
|
359
|
+
block[MESHLET_MORPH_BLOCK_POSITION_ORIGIN + 2] = ORIGIN[2];
|
|
360
|
+
block[MESHLET_MORPH_BLOCK_NORMAL_FLAGS] = normal_flags;
|
|
361
|
+
block[MESHLET_MORPH_BLOCK_NORMAL_ORIGIN] = ORIGIN[3];
|
|
362
|
+
block[MESHLET_MORPH_BLOCK_NORMAL_ORIGIN + 1] = ORIGIN[4];
|
|
363
|
+
block[MESHLET_MORPH_BLOCK_NORMAL_ORIGIN + 2] = ORIGIN[5];
|
|
364
|
+
|
|
365
|
+
for (let i = 0; i < touched; i++) {
|
|
366
|
+
const v = TOUCHED[i];
|
|
367
|
+
|
|
368
|
+
block[MESHLET_MORPH_BLOCK_HEADER_WORDS + (v >>> 5)] |= (1 << (v & 31)) >>> 0;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
block.set(ENCODED_POSITIONS.subarray(0, position_words), MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words);
|
|
372
|
+
block.set(ENCODED_NORMALS.subarray(0, normal_words), MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words + position_words);
|
|
373
|
+
|
|
374
|
+
return block;
|
|
375
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Words one block of a meshlet with `vertex_count` vertices takes, read off its own header and mask.
|
|
3
|
+
*
|
|
4
|
+
* @param {Uint32Array} words the section
|
|
5
|
+
* @param {number} block where the block starts
|
|
6
|
+
* @param {number} vertex_count
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function meshlet_morph_block_words(words: Uint32Array, block: number, vertex_count: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* What one target stores for one vertex of one meshlet, as the morph pass decodes it: the CPU twin of its
|
|
12
|
+
* block walk, bit for bit.
|
|
13
|
+
*
|
|
14
|
+
* @param {Float32Array|number[]} out_position receives the position delta, zeros where there is none
|
|
15
|
+
* @param {Float32Array|number[]} out_normal receives the normal delta, zeros where there is none
|
|
16
|
+
* @param {MeshletMorphTargets} targets
|
|
17
|
+
* @param {number} meshlet
|
|
18
|
+
* @param {number} vertex_count the meshlet's
|
|
19
|
+
* @param {number} vertex
|
|
20
|
+
* @param {number} target
|
|
21
|
+
* @returns {boolean} whether the target moves that vertex
|
|
22
|
+
*/
|
|
23
|
+
export function meshlet_morph_targets_read(out_position: Float32Array | number[], out_normal: Float32Array | number[], targets: MeshletMorphTargets, meshlet: number, vertex_count: number, vertex: number, target: number): boolean;
|
|
24
|
+
export type MeshletMorphTargets = import("./MeshletMorphTargets.js").MeshletMorphTargets;
|
|
25
|
+
//# sourceMappingURL=meshlet_morph_targets_read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshlet_morph_targets_read.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/morph/meshlet_morph_targets_read.js"],"names":[],"mappings":"AA+BA;;;;;;;GAOG;AACH,iDALW,WAAW,SACX,MAAM,gBACN,MAAM,GACJ,MAAM,CAclB;AAED;;;;;;;;;;;;GAYG;AACH,yDATW,YAAY,GAAC,MAAM,EAAE,cACrB,YAAY,GAAC,MAAM,EAAE,WACrB,mBAAmB,WACnB,MAAM,gBACN,MAAM,UACN,MAAM,UACN,MAAM,GACJ,OAAO,CAqEnB;kCAtHY,OAAO,0BAA0B,EAAE,mBAAmB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { meshlet_position_decode } from "../meshlet/encoding/meshlet_position_decode.js";
|
|
3
|
+
import { meshlet_position_words } from "../meshlet/encoding/meshlet_position_words.js";
|
|
4
|
+
import {
|
|
5
|
+
MESHLET_MORPH_BLOCK_HEADER_WORDS,
|
|
6
|
+
MESHLET_MORPH_BLOCK_NORMAL_FLAGS,
|
|
7
|
+
MESHLET_MORPH_BLOCK_NORMAL_ORIGIN,
|
|
8
|
+
MESHLET_MORPH_BLOCK_POSITION_FLAGS,
|
|
9
|
+
MESHLET_MORPH_BLOCK_POSITION_ORIGIN,
|
|
10
|
+
MESHLET_MORPH_BLOCK_TARGET,
|
|
11
|
+
MESHLET_MORPH_RANGE_WORDS,
|
|
12
|
+
meshlet_morph_mask_words
|
|
13
|
+
} from "./MESHLET_MORPH_LAYOUT.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import("./MeshletMorphTargets.js").MeshletMorphTargets} MeshletMorphTargets
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const ORIGIN = new Int32Array(3);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {number} word
|
|
23
|
+
* @returns {number}
|
|
24
|
+
*/
|
|
25
|
+
function count_ones(word) {
|
|
26
|
+
let v = word - ((word >>> 1) & 0x55555555);
|
|
27
|
+
v = (v & 0x33333333) + ((v >>> 2) & 0x33333333);
|
|
28
|
+
|
|
29
|
+
return (((v + (v >>> 4)) & 0x0F0F0F0F) * 0x01010101) >>> 24;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Words one block of a meshlet with `vertex_count` vertices takes, read off its own header and mask.
|
|
34
|
+
*
|
|
35
|
+
* @param {Uint32Array} words the section
|
|
36
|
+
* @param {number} block where the block starts
|
|
37
|
+
* @param {number} vertex_count
|
|
38
|
+
* @returns {number}
|
|
39
|
+
*/
|
|
40
|
+
export function meshlet_morph_block_words(words, block, vertex_count) {
|
|
41
|
+
const mask_words = meshlet_morph_mask_words(vertex_count);
|
|
42
|
+
|
|
43
|
+
let touched = 0;
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < mask_words; i++) {
|
|
46
|
+
touched += count_ones(words[block + MESHLET_MORPH_BLOCK_HEADER_WORDS + i]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words
|
|
50
|
+
+ touched * meshlet_position_words(words[block + MESHLET_MORPH_BLOCK_POSITION_FLAGS])
|
|
51
|
+
+ touched * meshlet_position_words(words[block + MESHLET_MORPH_BLOCK_NORMAL_FLAGS]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* What one target stores for one vertex of one meshlet, as the morph pass decodes it: the CPU twin of its
|
|
56
|
+
* block walk, bit for bit.
|
|
57
|
+
*
|
|
58
|
+
* @param {Float32Array|number[]} out_position receives the position delta, zeros where there is none
|
|
59
|
+
* @param {Float32Array|number[]} out_normal receives the normal delta, zeros where there is none
|
|
60
|
+
* @param {MeshletMorphTargets} targets
|
|
61
|
+
* @param {number} meshlet
|
|
62
|
+
* @param {number} vertex_count the meshlet's
|
|
63
|
+
* @param {number} vertex
|
|
64
|
+
* @param {number} target
|
|
65
|
+
* @returns {boolean} whether the target moves that vertex
|
|
66
|
+
*/
|
|
67
|
+
export function meshlet_morph_targets_read(out_position, out_normal, targets, meshlet, vertex_count, vertex, target) {
|
|
68
|
+
assert.isNonNegativeInteger(meshlet, 'meshlet');
|
|
69
|
+
assert.lessThan(vertex, vertex_count, 'vertex');
|
|
70
|
+
|
|
71
|
+
out_position[0] = 0;
|
|
72
|
+
out_position[1] = 0;
|
|
73
|
+
out_position[2] = 0;
|
|
74
|
+
out_normal[0] = 0;
|
|
75
|
+
out_normal[1] = 0;
|
|
76
|
+
out_normal[2] = 0;
|
|
77
|
+
|
|
78
|
+
const words = new Uint32Array(targets.data);
|
|
79
|
+
|
|
80
|
+
let block = words[meshlet * MESHLET_MORPH_RANGE_WORDS];
|
|
81
|
+
const block_count = words[meshlet * MESHLET_MORPH_RANGE_WORDS + 1];
|
|
82
|
+
|
|
83
|
+
const mask_words = meshlet_morph_mask_words(vertex_count);
|
|
84
|
+
|
|
85
|
+
for (let b = 0; b < block_count; b++) {
|
|
86
|
+
const size = meshlet_morph_block_words(words, block, vertex_count);
|
|
87
|
+
|
|
88
|
+
if (words[block + MESHLET_MORPH_BLOCK_TARGET] === target) {
|
|
89
|
+
const mask = block + MESHLET_MORPH_BLOCK_HEADER_WORDS;
|
|
90
|
+
|
|
91
|
+
if ((words[mask + (vertex >>> 5)] & (1 << (vertex & 31))) === 0) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let rank = 0;
|
|
96
|
+
|
|
97
|
+
for (let i = 0; i < (vertex >>> 5); i++) {
|
|
98
|
+
rank += count_ones(words[mask + i]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
rank += count_ones(words[mask + (vertex >>> 5)] & ((1 << (vertex & 31)) - 1));
|
|
102
|
+
|
|
103
|
+
let touched = 0;
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < mask_words; i++) {
|
|
106
|
+
touched += count_ones(words[mask + i]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const position_flags = words[block + MESHLET_MORPH_BLOCK_POSITION_FLAGS];
|
|
110
|
+
const normal_flags = words[block + MESHLET_MORPH_BLOCK_NORMAL_FLAGS];
|
|
111
|
+
|
|
112
|
+
const positions = mask + mask_words;
|
|
113
|
+
const normals = positions + touched * meshlet_position_words(position_flags);
|
|
114
|
+
|
|
115
|
+
ORIGIN[0] = words[block + MESHLET_MORPH_BLOCK_POSITION_ORIGIN];
|
|
116
|
+
ORIGIN[1] = words[block + MESHLET_MORPH_BLOCK_POSITION_ORIGIN + 1];
|
|
117
|
+
ORIGIN[2] = words[block + MESHLET_MORPH_BLOCK_POSITION_ORIGIN + 2];
|
|
118
|
+
|
|
119
|
+
meshlet_position_decode(out_position, 0, words, positions, rank, position_flags, ORIGIN, 0);
|
|
120
|
+
|
|
121
|
+
ORIGIN[0] = words[block + MESHLET_MORPH_BLOCK_NORMAL_ORIGIN];
|
|
122
|
+
ORIGIN[1] = words[block + MESHLET_MORPH_BLOCK_NORMAL_ORIGIN + 1];
|
|
123
|
+
ORIGIN[2] = words[block + MESHLET_MORPH_BLOCK_NORMAL_ORIGIN + 2];
|
|
124
|
+
|
|
125
|
+
meshlet_position_decode(out_normal, 0, words, normals, rank, normal_flags, ORIGIN, 0);
|
|
126
|
+
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
block += size;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throw unless `targets` is a section the morph pass can walk over its geometry's meshlets without reading
|
|
3
|
+
* past it: a range per meshlet; every meshlet's blocks inside the section, after the ranges, as many as
|
|
4
|
+
* {@link MeshletMorphTargets#largest_block_count} at most; each block naming one of the set's targets, in a
|
|
5
|
+
* position form the pass decodes, its mask naming no vertex past the meshlet's own.
|
|
6
|
+
*
|
|
7
|
+
* What a reader runs over a set it did not build. Thrown rather than asserted: a file is outside data, and
|
|
8
|
+
* a section that passes is all the morph pass bounds its walk by.
|
|
9
|
+
*
|
|
10
|
+
* @param {MeshletMorphTargets} targets with its geometry
|
|
11
|
+
* @throws {Error} naming the first thing wrong
|
|
12
|
+
*/
|
|
13
|
+
export function meshlet_morph_targets_validate(targets: MeshletMorphTargets): void;
|
|
14
|
+
export type MeshletMorphTargets = import("./MeshletMorphTargets.js").MeshletMorphTargets;
|
|
15
|
+
//# sourceMappingURL=meshlet_morph_targets_validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshlet_morph_targets_validate.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;GAWG;AACH,wDAHW,mBAAmB,QAkE7B;kCA/FY,OAAO,0BAA0B,EAAE,mBAAmB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MESHLET_FLAG_FIELD } from "../meshlet/encoding/MESHLET_FLAG_FIELD.js";
|
|
2
|
+
import { MESHLET_METADATA_STRUCT } from "../meshlet/encoding/MESHLET_METADATA_STRUCT.js";
|
|
3
|
+
import { MESHLET_POSITION_FORM } from "../meshlet/encoding/MESHLET_POSITION_FORM.js";
|
|
4
|
+
import {
|
|
5
|
+
MESHLET_MORPH_BLOCK_HEADER_WORDS,
|
|
6
|
+
MESHLET_MORPH_BLOCK_NORMAL_FLAGS,
|
|
7
|
+
MESHLET_MORPH_BLOCK_POSITION_FLAGS,
|
|
8
|
+
MESHLET_MORPH_BLOCK_TARGET,
|
|
9
|
+
MESHLET_MORPH_RANGE_WORDS,
|
|
10
|
+
meshlet_morph_mask_words
|
|
11
|
+
} from "./MESHLET_MORPH_LAYOUT.js";
|
|
12
|
+
import { meshlet_morph_block_words } from "./meshlet_morph_targets_read.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("./MeshletMorphTargets.js").MeshletMorphTargets} MeshletMorphTargets
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const ROW_WORDS = MESHLET_METADATA_STRUCT.size >>> 2;
|
|
19
|
+
const ROW_VERTEX_COUNT = MESHLET_METADATA_STRUCT.get('vertex_count').offset >>> 2;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether a block's flags name a position form the morph pass decodes.
|
|
23
|
+
*
|
|
24
|
+
* @param {number} flags
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
function is_known_form(flags) {
|
|
28
|
+
const form = (flags >>> MESHLET_FLAG_FIELD.POSITION_FORM) & 3;
|
|
29
|
+
|
|
30
|
+
return form === MESHLET_POSITION_FORM.Float32
|
|
31
|
+
|| form === MESHLET_POSITION_FORM.OneWord
|
|
32
|
+
|| form === MESHLET_POSITION_FORM.TwoWords;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Throw unless `targets` is a section the morph pass can walk over its geometry's meshlets without reading
|
|
37
|
+
* past it: a range per meshlet; every meshlet's blocks inside the section, after the ranges, as many as
|
|
38
|
+
* {@link MeshletMorphTargets#largest_block_count} at most; each block naming one of the set's targets, in a
|
|
39
|
+
* position form the pass decodes, its mask naming no vertex past the meshlet's own.
|
|
40
|
+
*
|
|
41
|
+
* What a reader runs over a set it did not build. Thrown rather than asserted: a file is outside data, and
|
|
42
|
+
* a section that passes is all the morph pass bounds its walk by.
|
|
43
|
+
*
|
|
44
|
+
* @param {MeshletMorphTargets} targets with its geometry
|
|
45
|
+
* @throws {Error} naming the first thing wrong
|
|
46
|
+
*/
|
|
47
|
+
export function meshlet_morph_targets_validate(targets) {
|
|
48
|
+
const words = new Uint32Array(targets.data);
|
|
49
|
+
const meshlets = targets.geometry.meshlets;
|
|
50
|
+
const meshlet_count = meshlets.count;
|
|
51
|
+
const target_count = targets.count;
|
|
52
|
+
|
|
53
|
+
const rows = new Uint32Array(meshlets.metadata_buffer);
|
|
54
|
+
|
|
55
|
+
const ranges_end = meshlet_count * MESHLET_MORPH_RANGE_WORDS;
|
|
56
|
+
|
|
57
|
+
if (words.length < ranges_end) {
|
|
58
|
+
throw new Error(`morph target section of ${words.length} words holds no range for each of its geometry's ${meshlet_count} meshlets`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (let m = 0; m < meshlet_count; m++) {
|
|
62
|
+
const first = words[m * MESHLET_MORPH_RANGE_WORDS];
|
|
63
|
+
const block_count = words[m * MESHLET_MORPH_RANGE_WORDS + 1];
|
|
64
|
+
|
|
65
|
+
if (block_count > targets.largest_block_count) {
|
|
66
|
+
throw new Error(`meshlet ${m} has ${block_count} morph blocks, more than the set's largest, ${targets.largest_block_count}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (block_count === 0) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (first < ranges_end) {
|
|
74
|
+
throw new Error(`meshlet ${m}'s morph blocks start at word ${first}, inside the ranges`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const vertex_count = rows[m * ROW_WORDS + ROW_VERTEX_COUNT];
|
|
78
|
+
const mask_words = meshlet_morph_mask_words(vertex_count);
|
|
79
|
+
|
|
80
|
+
let block = first;
|
|
81
|
+
|
|
82
|
+
for (let b = 0; b < block_count; b++) {
|
|
83
|
+
if (block + MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words > words.length) {
|
|
84
|
+
throw new Error(`meshlet ${m}'s morph block ${b} runs past the section`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (words[block + MESHLET_MORPH_BLOCK_TARGET] >= target_count) {
|
|
88
|
+
throw new Error(`meshlet ${m}'s morph block ${b} names target ${words[block + MESHLET_MORPH_BLOCK_TARGET]} of ${target_count}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!is_known_form(words[block + MESHLET_MORPH_BLOCK_POSITION_FLAGS])
|
|
92
|
+
|| !is_known_form(words[block + MESHLET_MORPH_BLOCK_NORMAL_FLAGS])) {
|
|
93
|
+
throw new Error(`meshlet ${m}'s morph block ${b} names no position form the morph pass decodes`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// bits past the meshlet's vertices would count vertices that are not there
|
|
97
|
+
const spare = mask_words * 32 - vertex_count;
|
|
98
|
+
|
|
99
|
+
if (spare > 0 && (words[block + MESHLET_MORPH_BLOCK_HEADER_WORDS + mask_words - 1] >>> (32 - spare)) !== 0) {
|
|
100
|
+
throw new Error(`meshlet ${m}'s morph block ${b} names a vertex past the meshlet's ${vertex_count}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
block += meshlet_morph_block_words(words, block, vertex_count);
|
|
104
|
+
|
|
105
|
+
if (block > words.length) {
|
|
106
|
+
throw new Error(`meshlet ${m}'s morph block ${b} runs past the section`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|