@woosh/meep-engine 3.78.4 → 3.80.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 +93 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/engine/asset/GameAssetType.d.ts +2 -0
- package/src/engine/asset/GameAssetType.js +10 -0
- package/src/engine/asset/guessAssetType.d.ts.map +1 -1
- package/src/engine/asset/guessAssetType.js +4 -0
- package/src/engine/asset/load_model_scene_bundle.d.ts +1 -1
- package/src/engine/asset/load_model_scene_bundle.js +2 -2
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts +42 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.js +83 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts +36 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.js +78 -0
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts +6 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts.map +1 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +8 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_decode.js +756 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_predict.js +290 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_tables.js +350 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_transform.js +114 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
- package/src/format/image/webp/webp_decode.d.ts +23 -0
- package/src/format/image/webp/webp_decode.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode.js +179 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode_alpha.js +84 -0
- package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
- package/src/format/texture/astc/astc_block.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_block.js +284 -164
- package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
- package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
- package/src/format/texture/astc/astc_decode_block.js +1119 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
- package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
- package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
- package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
- package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
- package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
- package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
- package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
- package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
- package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
- package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_block.js +22 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_colors.js +100 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc2_decode_block.js +28 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc3_decode_block.js +23 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_decode_channel.js +138 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_encode_block.js +324 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_encode_block.js +34 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_decode_block.js +232 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_encode_block.js +423 -0
- package/src/format/texture/bc/bc7_tables.d.ts +126 -0
- package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
- package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
- package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
- package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
- package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
- package/src/format/texture/etc/eac_decode_channel.js +142 -0
- package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
- package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
- package/src/format/texture/etc/eac_modifiers.js +31 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_decode_color.js +370 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
- package/src/format/texture/fit/fit_line.d.ts +23 -0
- package/src/format/texture/fit/fit_line.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line.js +123 -0
- package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
- package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_refine.js +69 -0
- package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
- package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_solve.js +71 -0
- package/src/format/texture/texel_decode_image.d.ts +44 -0
- package/src/format/texture/texel_decode_image.d.ts.map +1 -0
- package/src/format/texture/texel_decode_image.js +251 -0
- package/src/format/texture/texel_encode_image.d.ts +77 -0
- package/src/format/texture/texel_encode_image.d.ts.map +1 -0
- package/src/format/texture/texel_encode_image.js +187 -0
- package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
- 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/ShadeAnimationClipSerializationAdapter.d.ts +33 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +196 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts +25 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.js +85 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
- package/src/shade/renderer/hair/GPUHairSystem.js +16 -7
- package/src/shade/renderer/hair/HAIR.d.ts +5 -3
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR.js +6 -4
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts +10 -10
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_shadow_draw.js +21 -17
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_cull.js +6 -2
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +5 -4
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_shadow_list.js +10 -12
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts +38 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.js +198 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts +88 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.js +159 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts +30 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.js +136 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +8 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.js +6 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts +41 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/load_mtf.js +73 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.js +57 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +10 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +152 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts +45 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_export.js +161 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts +9 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.js +12 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.js +37 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +27 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.js +121 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts +18 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.js +51 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts +21 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.js +98 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +25 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +51 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts +20 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.js +80 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.js +42 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts +31 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.js +87 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts +36 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write.js +137 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts +39 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.js +207 -0
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.d.ts.map +1 -1
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.js +3 -1
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.d.ts +5 -5
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.js +5 -5
- package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/deserialize_scene.js +491 -528
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts +0 -10
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/serialize_scene.js +15 -71
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
- package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
- package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
- package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts +11 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.js +14 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
- package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
- package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
- package/src/shade/renderer/texture/texture_role_image_quality.d.ts +10 -0
- package/src/shade/renderer/texture/texture_role_image_quality.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_role_image_quality.js +29 -0
- package/src/format/texture/basis/astc_block.d.ts.map +0 -1
- package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
- package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
- package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
- /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
- /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { scene_optimize } from "../../scene/optimization/scene_optimize.js";
|
|
3
|
+
import { mtf_bundle_textures } from "./mtf_bundle_textures.js";
|
|
4
|
+
import { mtf_encode_texture } from "./mtf_encode_texture.js";
|
|
5
|
+
import { mtf_write } from "./mtf_write.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("../SceneBundle.js").SceneBundle} SceneBundle
|
|
9
|
+
* @typedef {import("../../texture/ShadeTexture.js").ShadeTexture} ShadeTexture
|
|
10
|
+
* @typedef {import("../../texture/TextureVariantSet.js").TextureVariantSet} TextureVariantSet
|
|
11
|
+
* @typedef {import("./mtf_encode_texture.js").MTFTextureEncoder} MTFTextureEncoder
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What a file name may hold wherever it ends up: a file system, a URL, a shell.
|
|
16
|
+
*
|
|
17
|
+
* @type {RegExp}
|
|
18
|
+
*/
|
|
19
|
+
const UNSAFE_IN_A_FILE_NAME = /[^A-Za-z0-9._-]/g;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How much of a texture's label goes into its file name. A label can be a whole path, and a name is for telling
|
|
23
|
+
* files apart by eye: the number in front of it is what makes it unique.
|
|
24
|
+
*
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
const LABEL_IN_A_FILE_NAME = 48;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {number} index
|
|
31
|
+
* @param {string} label
|
|
32
|
+
* @returns {string} a file name, without an extension, that no other index gets
|
|
33
|
+
*/
|
|
34
|
+
function texture_file_stem(index, label) {
|
|
35
|
+
const number = String(index).padStart(4, "0");
|
|
36
|
+
const safe = label.replace(UNSAFE_IN_A_FILE_NAME, () => "_").substring(0, LABEL_IN_A_FILE_NAME);
|
|
37
|
+
|
|
38
|
+
return safe.length === 0 ? number : `${number}_${safe}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A model as the files of an MTF export: its package, and beside it a folder of the files its textures are in.
|
|
43
|
+
*
|
|
44
|
+
* <pre>
|
|
45
|
+
* <name>.mtf
|
|
46
|
+
* <name>_textures/0000_<label>.avif
|
|
47
|
+
* <name>_textures/0001_<label>.mtt
|
|
48
|
+
* ...
|
|
49
|
+
* </pre>
|
|
50
|
+
*
|
|
51
|
+
* The steps, in order:
|
|
52
|
+
*
|
|
53
|
+
* 1. With `optimize`, {@link scene_optimize} first: geometries that are alike become one, pieces that repeat are
|
|
54
|
+
* shared, and images that are the same pixels become one image. **It rewrites the bundle in place**, so the
|
|
55
|
+
* bundle is the caller's to give away. A model with skins is refused: the optimizer does not carry skinning.
|
|
56
|
+
* 2. The files of each texture are asked of `encode_texture`, once for each image a role is met with: textures
|
|
57
|
+
* over one image share its files.
|
|
58
|
+
* 3. {@link mtf_write}.
|
|
59
|
+
*
|
|
60
|
+
* Nothing is put anywhere. What comes back is the files by where they go relative to one another, and writing
|
|
61
|
+
* them out is the caller's.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} options
|
|
64
|
+
* @param {SceneBundle} options.bundle
|
|
65
|
+
* @param {string} options.name what the package's file is called, without a folder or an extension
|
|
66
|
+
* @param {boolean} [options.optimize] whether to optimize the bundle before it is written
|
|
67
|
+
* @param {MTFTextureEncoder} [options.encode_texture] what builds a texture's files. The default builds a
|
|
68
|
+
* fallback and no block formats ({@link mtf_encode_texture})
|
|
69
|
+
* @returns {Promise<Map<string, ArrayBuffer>>} every file by its path, the package first. A texture's path is
|
|
70
|
+
* the URI the package names it by
|
|
71
|
+
*
|
|
72
|
+
* @author Alex Goldring
|
|
73
|
+
* @copyright Company Named Limited (c) 2026
|
|
74
|
+
*/
|
|
75
|
+
export async function mtf_export({
|
|
76
|
+
bundle,
|
|
77
|
+
name,
|
|
78
|
+
optimize = false,
|
|
79
|
+
encode_texture = mtf_encode_texture,
|
|
80
|
+
}) {
|
|
81
|
+
assert.defined(bundle, 'bundle');
|
|
82
|
+
assert.equal(bundle.isSceneBundle, true, 'bundle.isSceneBundle !== true');
|
|
83
|
+
assert.isString(name, 'name');
|
|
84
|
+
if (name.length === 0 || name.includes("/") || name.includes("\\")) {
|
|
85
|
+
// not an assert: a texture's URI is built from the name and resolved against the package's own folder, so
|
|
86
|
+
// a name with a folder in it writes a package whose textures are not where it says
|
|
87
|
+
throw new Error(`the package's name is a file's name without a folder or an extension, got '${name}'`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert.isBoolean(optimize, 'optimize');
|
|
91
|
+
assert.isFunction(encode_texture, 'encode_texture');
|
|
92
|
+
|
|
93
|
+
if (optimize) {
|
|
94
|
+
if (bundle.skins.length > 0) {
|
|
95
|
+
// the optimizer rebuilds the pieces it shares without their joints and weights, and makes a node it
|
|
96
|
+
// splits a parent of pieces while its skin still names the node
|
|
97
|
+
throw new Error(`the model has ${bundle.skins.length} skin(s), and scene optimization does not carry skinning: export it as it is`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
scene_optimize(bundle);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** @type {Map<string, ArrayBuffer>} */
|
|
104
|
+
const files = new Map();
|
|
105
|
+
|
|
106
|
+
const package_path = `${name}.mtf`;
|
|
107
|
+
|
|
108
|
+
// its place is the first; its bytes come last, when every texture's files are known
|
|
109
|
+
files.set(package_path, null);
|
|
110
|
+
|
|
111
|
+
/** @type {ShadeTexture[]} */
|
|
112
|
+
const textures = [];
|
|
113
|
+
|
|
114
|
+
/** @type {Promise<TextureVariantSet>[]} one a texture, shared by textures over one image in one role */
|
|
115
|
+
const encodings = [];
|
|
116
|
+
|
|
117
|
+
/** @type {Map<*, Map<number, Promise<TextureVariantSet>>>} image source, then role */
|
|
118
|
+
const encoded = new Map();
|
|
119
|
+
|
|
120
|
+
let file_count = 0;
|
|
121
|
+
|
|
122
|
+
for (const [texture, role] of mtf_bundle_textures(bundle)) {
|
|
123
|
+
const source = texture.image.source;
|
|
124
|
+
|
|
125
|
+
let by_role = encoded.get(source);
|
|
126
|
+
|
|
127
|
+
if (by_role === undefined) {
|
|
128
|
+
by_role = new Map();
|
|
129
|
+
|
|
130
|
+
encoded.set(source, by_role);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let encoding = by_role.get(role);
|
|
134
|
+
|
|
135
|
+
if (encoding === undefined) {
|
|
136
|
+
const stem = `${name}_textures/${texture_file_stem(file_count, texture.label)}`;
|
|
137
|
+
|
|
138
|
+
file_count++;
|
|
139
|
+
|
|
140
|
+
encoding = encode_texture(texture, role, stem, files);
|
|
141
|
+
|
|
142
|
+
by_role.set(role, encoding);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
textures.push(texture);
|
|
146
|
+
encodings.push(encoding);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const variant_sets = await Promise.all(encodings);
|
|
150
|
+
|
|
151
|
+
/** @type {Map<ShadeTexture, TextureVariantSet>} */
|
|
152
|
+
const texture_variants = new Map();
|
|
153
|
+
|
|
154
|
+
for (let i = 0; i < textures.length; i++) {
|
|
155
|
+
texture_variants.set(textures[i], variant_sets[i]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
files.set(package_path, mtf_write(bundle, texture_variants));
|
|
159
|
+
|
|
160
|
+
return files;
|
|
161
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether bytes are an MTF texture file, by how they open. What a texture's fallback is — a texture file or an
|
|
3
|
+
* image — is told this way and not from its URI.
|
|
4
|
+
*
|
|
5
|
+
* @param {ArrayBuffer} data
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
export function mtf_is_texture(data: ArrayBuffer): boolean;
|
|
9
|
+
//# sourceMappingURL=mtf_is_texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_is_texture.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_is_texture.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qCAHW,WAAW,GACT,OAAO,CAInB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MTF_TEXTURE_MAGIC } from "./MTF_TEXTURE_MAGIC.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether bytes are an MTF texture file, by how they open. What a texture's fallback is — a texture file or an
|
|
5
|
+
* image — is told this way and not from its URI.
|
|
6
|
+
*
|
|
7
|
+
* @param {ArrayBuffer} data
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function mtf_is_texture(data) {
|
|
11
|
+
return data.byteLength >= 4 && new DataView(data).getUint32(0, true) === MTF_TEXTURE_MAGIC;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
|
|
3
|
+
* @typedef {import("../../../../engine/ecs/storage/binary/BinarySerializationRegistry.js").BinarySerializationRegistry} BinarySerializationRegistry
|
|
4
|
+
* @typedef {import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js").BinaryCollectionDeSerializer} BinaryCollectionDeSerializer
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Read the collection at the deserializer's buffer position, which a package holds as its next one, and append
|
|
8
|
+
* its elements to `out` in the order they were written.
|
|
9
|
+
*
|
|
10
|
+
* A collection written at an earlier version of its class is brought up to this one by the registry's upgraders,
|
|
11
|
+
* element by element; one written at a later version is refused by the deserializer.
|
|
12
|
+
*
|
|
13
|
+
* @template T
|
|
14
|
+
* @param {BinaryCollectionDeSerializer} deserializer with its registry and buffer set
|
|
15
|
+
* @param {string} class_name what a package holds at this point
|
|
16
|
+
* @param {Array} adapter_options what the class's adapter is initialized with
|
|
17
|
+
* @param {T[]} out
|
|
18
|
+
* @throws {Error} if the collection is of another class
|
|
19
|
+
*/
|
|
20
|
+
export function mtf_read_collection<T>(deserializer: BinaryCollectionDeSerializer, class_name: string, adapter_options: any[], out: T[]): void;
|
|
21
|
+
export type BinaryBuffer = import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer;
|
|
22
|
+
export type BinarySerializationRegistry = import("../../../../engine/ecs/storage/binary/BinarySerializationRegistry.js").BinarySerializationRegistry;
|
|
23
|
+
export type BinaryCollectionDeSerializer = import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js").BinaryCollectionDeSerializer;
|
|
24
|
+
//# sourceMappingURL=mtf_read_collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_read_collection.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_read_collection.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH,qDANW,4BAA4B,cAC5B,MAAM,0CAqBhB;2BAnCY,OAAO,yCAAyC,EAAE,YAAY;0CAC9D,OAAO,sEAAsE,EAAE,2BAA2B;2CAC1G,OAAO,kFAAkF,EAAE,4BAA4B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
|
|
3
|
+
* @typedef {import("../../../../engine/ecs/storage/binary/BinarySerializationRegistry.js").BinarySerializationRegistry} BinarySerializationRegistry
|
|
4
|
+
* @typedef {import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js").BinaryCollectionDeSerializer} BinaryCollectionDeSerializer
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read the collection at the deserializer's buffer position, which a package holds as its next one, and append
|
|
9
|
+
* its elements to `out` in the order they were written.
|
|
10
|
+
*
|
|
11
|
+
* A collection written at an earlier version of its class is brought up to this one by the registry's upgraders,
|
|
12
|
+
* element by element; one written at a later version is refused by the deserializer.
|
|
13
|
+
*
|
|
14
|
+
* @template T
|
|
15
|
+
* @param {BinaryCollectionDeSerializer} deserializer with its registry and buffer set
|
|
16
|
+
* @param {string} class_name what a package holds at this point
|
|
17
|
+
* @param {Array} adapter_options what the class's adapter is initialized with
|
|
18
|
+
* @param {T[]} out
|
|
19
|
+
* @throws {Error} if the collection is of another class
|
|
20
|
+
*/
|
|
21
|
+
export function mtf_read_collection(deserializer, class_name, adapter_options, out) {
|
|
22
|
+
const expected = deserializer.getRegistry().getAdapter(class_name);
|
|
23
|
+
|
|
24
|
+
deserializer.initialize({ adapterOptionsSupplier: () => adapter_options });
|
|
25
|
+
|
|
26
|
+
if (deserializer.getElementClass() !== expected.klass) {
|
|
27
|
+
throw new Error(`the MTF package holds a collection of another class where its '${class_name}' are due`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const count = deserializer.getElementCount();
|
|
31
|
+
|
|
32
|
+
for (let i = 0; i < count; i++) {
|
|
33
|
+
out.push(deserializer.read().value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
deserializer.finalize();
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The second half of reading an MTF package: its materials, geometries, nodes, skins and clips, as the bundle
|
|
3
|
+
* every loader produces.
|
|
4
|
+
*
|
|
5
|
+
* A geometry or a material several nodes draw is one object in the bundle, as it is one record in the package.
|
|
6
|
+
* Nothing is built: a geometry comes back with the tree it was written with, and a clip with its curves as they
|
|
7
|
+
* were.
|
|
8
|
+
*
|
|
9
|
+
* Every refusal is a thrown error and none is an assert: a file is outside data.
|
|
10
|
+
*
|
|
11
|
+
* @param {BinaryBuffer} buffer where {@link mtf_read_textures} left it
|
|
12
|
+
* @param {ShadeTexture[]} textures one for each record {@link mtf_read_textures} returned, in that order
|
|
13
|
+
* @returns {SceneBundle}
|
|
14
|
+
* @throws {Error} if a record names something the package does not hold, a node comes before its parent, or
|
|
15
|
+
* bytes follow the last collection
|
|
16
|
+
*
|
|
17
|
+
* @author Alex Goldring
|
|
18
|
+
* @copyright Company Named Limited (c) 2026
|
|
19
|
+
*/
|
|
20
|
+
export function mtf_read_scene(buffer: BinaryBuffer, textures: ShadeTexture[]): SceneBundle;
|
|
21
|
+
export type BinaryBuffer = import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer;
|
|
22
|
+
export type ShadeTexture = import("../../texture/ShadeTexture.js").ShadeTexture;
|
|
23
|
+
export type StandardShadeMaterial = import("../../material/StandardShadeMaterial.js").StandardShadeMaterial;
|
|
24
|
+
export type MeshletGeometry = import("../../geometry/MeshletGeometry.js").MeshletGeometry;
|
|
25
|
+
export type SceneNode = import("../SceneNode.js").SceneNode;
|
|
26
|
+
import { SceneBundle } from "../SceneBundle.js";
|
|
27
|
+
//# sourceMappingURL=mtf_read_scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_read_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_read_scene.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,uCATW,YAAY,YACZ,YAAY,EAAE,GACZ,WAAW,CAuEvB;2BA3GY,OAAO,yCAAyC,EAAE,YAAY;2BAC9D,OAAO,+BAA+B,EAAE,YAAY;oCACpD,OAAO,yCAAyC,EAAE,qBAAqB;8BACvE,OAAO,mCAAmC,EAAE,eAAe;wBAC3D,OAAO,iBAAiB,EAAE,SAAS;4BAhBpB,mBAAmB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BinaryCollectionDeSerializer } from "../../../../engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js";
|
|
2
|
+
import { SceneBundle } from "../SceneBundle.js";
|
|
3
|
+
import { mtf_read_collection } from "./mtf_read_collection.js";
|
|
4
|
+
import {
|
|
5
|
+
MTF_CLASS_CLIP,
|
|
6
|
+
MTF_CLASS_GEOMETRY,
|
|
7
|
+
MTF_CLASS_MATERIAL,
|
|
8
|
+
MTF_CLASS_NODE,
|
|
9
|
+
MTF_CLASS_SKIN,
|
|
10
|
+
mtf_serialization_registry
|
|
11
|
+
} from "./mtf_serialization_registry.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
|
|
15
|
+
* @typedef {import("../../texture/ShadeTexture.js").ShadeTexture} ShadeTexture
|
|
16
|
+
* @typedef {import("../../material/StandardShadeMaterial.js").StandardShadeMaterial} StandardShadeMaterial
|
|
17
|
+
* @typedef {import("../../geometry/MeshletGeometry.js").MeshletGeometry} MeshletGeometry
|
|
18
|
+
* @typedef {import("../SceneNode.js").SceneNode} SceneNode
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const NO_OPTIONS = [];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} owner what names the nodes, for the refusal
|
|
25
|
+
* @param {number[]} indices
|
|
26
|
+
* @param {number} node_count
|
|
27
|
+
*/
|
|
28
|
+
function check_node_indices(owner, indices, node_count) {
|
|
29
|
+
for (let i = 0; i < indices.length; i++) {
|
|
30
|
+
const index = indices[i];
|
|
31
|
+
|
|
32
|
+
if (index >= node_count) {
|
|
33
|
+
throw new Error(`${owner} names node ${index}, and the MTF package holds ${node_count}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The second half of reading an MTF package: its materials, geometries, nodes, skins and clips, as the bundle
|
|
40
|
+
* every loader produces.
|
|
41
|
+
*
|
|
42
|
+
* A geometry or a material several nodes draw is one object in the bundle, as it is one record in the package.
|
|
43
|
+
* Nothing is built: a geometry comes back with the tree it was written with, and a clip with its curves as they
|
|
44
|
+
* were.
|
|
45
|
+
*
|
|
46
|
+
* Every refusal is a thrown error and none is an assert: a file is outside data.
|
|
47
|
+
*
|
|
48
|
+
* @param {BinaryBuffer} buffer where {@link mtf_read_textures} left it
|
|
49
|
+
* @param {ShadeTexture[]} textures one for each record {@link mtf_read_textures} returned, in that order
|
|
50
|
+
* @returns {SceneBundle}
|
|
51
|
+
* @throws {Error} if a record names something the package does not hold, a node comes before its parent, or
|
|
52
|
+
* bytes follow the last collection
|
|
53
|
+
*
|
|
54
|
+
* @author Alex Goldring
|
|
55
|
+
* @copyright Company Named Limited (c) 2026
|
|
56
|
+
*/
|
|
57
|
+
export function mtf_read_scene(buffer, textures) {
|
|
58
|
+
const deserializer = new BinaryCollectionDeSerializer();
|
|
59
|
+
|
|
60
|
+
deserializer.setRegistry(mtf_serialization_registry());
|
|
61
|
+
deserializer.setBuffer(buffer);
|
|
62
|
+
|
|
63
|
+
/** @type {StandardShadeMaterial[]} */
|
|
64
|
+
const materials = [];
|
|
65
|
+
|
|
66
|
+
/** @type {MeshletGeometry[]} */
|
|
67
|
+
const geometries = [];
|
|
68
|
+
|
|
69
|
+
/** @type {SceneNode[]} */
|
|
70
|
+
const nodes = [];
|
|
71
|
+
|
|
72
|
+
mtf_read_collection(deserializer, MTF_CLASS_MATERIAL, [textures], materials);
|
|
73
|
+
mtf_read_collection(deserializer, MTF_CLASS_GEOMETRY, NO_OPTIONS, geometries);
|
|
74
|
+
mtf_read_collection(deserializer, MTF_CLASS_NODE, [geometries, materials], nodes);
|
|
75
|
+
|
|
76
|
+
const bundle = new SceneBundle();
|
|
77
|
+
const node_count = nodes.length;
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < node_count; i++) {
|
|
80
|
+
const node = nodes[i];
|
|
81
|
+
|
|
82
|
+
// pre-order is what lets every reader of a bundle compose worlds in one forward pass
|
|
83
|
+
if (node.parent < -1 || node.parent >= i) {
|
|
84
|
+
throw new Error(`node ${i} '${node.name}' of the MTF package names parent ${node.parent}: a parent comes before its children`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
bundle.add_node(node);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const skins = bundle.skins;
|
|
91
|
+
const clips = bundle.clips;
|
|
92
|
+
|
|
93
|
+
mtf_read_collection(deserializer, MTF_CLASS_SKIN, NO_OPTIONS, skins);
|
|
94
|
+
mtf_read_collection(deserializer, MTF_CLASS_CLIP, NO_OPTIONS, clips);
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < skins.length; i++) {
|
|
97
|
+
const skin = skins[i];
|
|
98
|
+
|
|
99
|
+
check_node_indices(`skin '${skin.name}'`, skin.joints, node_count);
|
|
100
|
+
check_node_indices(`skin '${skin.name}'`, skin.meshes, node_count);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (let i = 0; i < clips.length; i++) {
|
|
104
|
+
const clip = clips[i];
|
|
105
|
+
const channels = clip.channels;
|
|
106
|
+
|
|
107
|
+
for (let c = 0; c < channels.length; c++) {
|
|
108
|
+
const target = channels[c].target;
|
|
109
|
+
|
|
110
|
+
if (target >= node_count) {
|
|
111
|
+
throw new Error(`clip '${clip.name}' names node ${target}, and the MTF package holds ${node_count}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (buffer.position !== buffer.capacity) {
|
|
117
|
+
throw new Error(`the MTF package holds ${buffer.capacity - buffer.position} bytes after its last collection`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return bundle;
|
|
121
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first half of reading an MTF package: its header and its texture records.
|
|
3
|
+
*
|
|
4
|
+
* A package holds no texels, so between this and {@link mtf_read_scene} somebody fetches them: a record says
|
|
5
|
+
* which encodings exist and where, the caller picks one for its device and makes a texture of what arrives, and
|
|
6
|
+
* the second half is given those textures in the order of these records.
|
|
7
|
+
*
|
|
8
|
+
* @param {BinaryBuffer} buffer at the start of a package; left at the start of what {@link mtf_read_scene} reads
|
|
9
|
+
* @returns {MTFTexture[]} in the order materials name them by
|
|
10
|
+
* @throws {Error} if the bytes are not a package, or are of a version newer than {@link MTF_PACKAGE_VERSION}
|
|
11
|
+
*
|
|
12
|
+
* @author Alex Goldring
|
|
13
|
+
* @copyright Company Named Limited (c) 2026
|
|
14
|
+
*/
|
|
15
|
+
export function mtf_read_textures(buffer: BinaryBuffer): MTFTexture[];
|
|
16
|
+
export type BinaryBuffer = import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer;
|
|
17
|
+
export type MTFTexture = import("./MTFTexture.js").MTFTexture;
|
|
18
|
+
//# sourceMappingURL=mtf_read_textures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_read_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_read_textures.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;GAaG;AACH,0CAPW,YAAY,GACV,UAAU,EAAE,CA6BxB;2BA3CY,OAAO,yCAAyC,EAAE,YAAY;yBAC9D,OAAO,iBAAiB,EAAE,UAAU"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BinaryCollectionDeSerializer } from "../../../../engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js";
|
|
2
|
+
import { MTF_PACKAGE_MAGIC } from "./MTF_PACKAGE_MAGIC.js";
|
|
3
|
+
import { MTF_PACKAGE_VERSION } from "./MTF_PACKAGE_VERSION.js";
|
|
4
|
+
import { mtf_read_collection } from "./mtf_read_collection.js";
|
|
5
|
+
import { MTF_CLASS_TEXTURE, mtf_serialization_registry } from "./mtf_serialization_registry.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
|
|
9
|
+
* @typedef {import("./MTFTexture.js").MTFTexture} MTFTexture
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const NO_OPTIONS = [];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The first half of reading an MTF package: its header and its texture records.
|
|
16
|
+
*
|
|
17
|
+
* A package holds no texels, so between this and {@link mtf_read_scene} somebody fetches them: a record says
|
|
18
|
+
* which encodings exist and where, the caller picks one for its device and makes a texture of what arrives, and
|
|
19
|
+
* the second half is given those textures in the order of these records.
|
|
20
|
+
*
|
|
21
|
+
* @param {BinaryBuffer} buffer at the start of a package; left at the start of what {@link mtf_read_scene} reads
|
|
22
|
+
* @returns {MTFTexture[]} in the order materials name them by
|
|
23
|
+
* @throws {Error} if the bytes are not a package, or are of a version newer than {@link MTF_PACKAGE_VERSION}
|
|
24
|
+
*
|
|
25
|
+
* @author Alex Goldring
|
|
26
|
+
* @copyright Company Named Limited (c) 2026
|
|
27
|
+
*/
|
|
28
|
+
export function mtf_read_textures(buffer) {
|
|
29
|
+
// thrown, not asserted: a file is outside data, and a wrong one is refused with asserts stripped too
|
|
30
|
+
if (buffer.capacity - buffer.position < 8 || buffer.readUint32() !== MTF_PACKAGE_MAGIC) {
|
|
31
|
+
throw new Error("not an MTF package: it does not open with 'MTFP'");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const version = buffer.readUint32();
|
|
35
|
+
|
|
36
|
+
if (version > MTF_PACKAGE_VERSION) {
|
|
37
|
+
throw new Error(`an MTF package of version ${version}, newer than this engine reads (${MTF_PACKAGE_VERSION})`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const deserializer = new BinaryCollectionDeSerializer();
|
|
41
|
+
|
|
42
|
+
deserializer.setRegistry(mtf_serialization_registry());
|
|
43
|
+
deserializer.setBuffer(buffer);
|
|
44
|
+
|
|
45
|
+
/** @type {MTFTexture[]} */
|
|
46
|
+
const records = [];
|
|
47
|
+
|
|
48
|
+
mtf_read_collection(deserializer, MTF_CLASS_TEXTURE, NO_OPTIONS, records);
|
|
49
|
+
|
|
50
|
+
return records;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A package with its texture records replaced and everything after them as it was: the materials, geometries, nodes,
|
|
3
|
+
* skins and clips are carried over byte for byte, never read.
|
|
4
|
+
*
|
|
5
|
+
* This is how a package gains or loses encodings of its textures, a block format built after it was written say,
|
|
6
|
+
* without the model it was made from. The package keeps its version: what follows the records is as that version
|
|
7
|
+
* wrote it.
|
|
8
|
+
*
|
|
9
|
+
* @param {ArrayBuffer} file the package
|
|
10
|
+
* @param {MTFTexture[]} records one for each record the package holds, in its order: materials name records by index
|
|
11
|
+
* @returns {ArrayBuffer} the new package
|
|
12
|
+
* @throws {Error} if the bytes are not a package, or `records` is not as many as the package holds
|
|
13
|
+
*
|
|
14
|
+
* @author Alex Goldring
|
|
15
|
+
* @copyright Company Named Limited (c) 2026
|
|
16
|
+
*/
|
|
17
|
+
export function mtf_replace_textures(file: ArrayBuffer, records: MTFTexture[]): ArrayBuffer;
|
|
18
|
+
export type MTFTexture = import("./MTFTexture.js").MTFTexture;
|
|
19
|
+
//# sourceMappingURL=mtf_replace_textures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_replace_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_replace_textures.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,2CARW,WAAW,WACX,UAAU,EAAE,GACV,WAAW,CAoCvB;yBAnDY,OAAO,iBAAiB,EAAE,UAAU"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { BinaryCollectionSerializer } from "../../../../engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js";
|
|
3
|
+
import { MTF_PACKAGE_MAGIC } from "./MTF_PACKAGE_MAGIC.js";
|
|
4
|
+
import { mtf_read_textures } from "./mtf_read_textures.js";
|
|
5
|
+
import { MTF_CLASS_TEXTURE, mtf_serialization_registry } from "./mtf_serialization_registry.js";
|
|
6
|
+
import { mtf_write_collection } from "./mtf_write_collection.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import("./MTFTexture.js").MTFTexture} MTFTexture
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const NO_OPTIONS = [];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A package with its texture records replaced and everything after them as it was: the materials, geometries, nodes,
|
|
16
|
+
* skins and clips are carried over byte for byte, never read.
|
|
17
|
+
*
|
|
18
|
+
* This is how a package gains or loses encodings of its textures, a block format built after it was written say,
|
|
19
|
+
* without the model it was made from. The package keeps its version: what follows the records is as that version
|
|
20
|
+
* wrote it.
|
|
21
|
+
*
|
|
22
|
+
* @param {ArrayBuffer} file the package
|
|
23
|
+
* @param {MTFTexture[]} records one for each record the package holds, in its order: materials name records by index
|
|
24
|
+
* @returns {ArrayBuffer} the new package
|
|
25
|
+
* @throws {Error} if the bytes are not a package, or `records` is not as many as the package holds
|
|
26
|
+
*
|
|
27
|
+
* @author Alex Goldring
|
|
28
|
+
* @copyright Company Named Limited (c) 2026
|
|
29
|
+
*/
|
|
30
|
+
export function mtf_replace_textures(file, records) {
|
|
31
|
+
const source = BinaryBuffer.fromArrayBuffer(file);
|
|
32
|
+
|
|
33
|
+
const held = mtf_read_textures(source);
|
|
34
|
+
|
|
35
|
+
if (records.length !== held.length) {
|
|
36
|
+
throw new Error(`the package holds ${held.length} texture records, and ${records.length} were given to replace them`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const rest_start = source.position;
|
|
40
|
+
|
|
41
|
+
const version = new DataView(file).getUint32(4, true);
|
|
42
|
+
|
|
43
|
+
const buffer = new BinaryBuffer();
|
|
44
|
+
|
|
45
|
+
buffer.writeUint32(MTF_PACKAGE_MAGIC);
|
|
46
|
+
buffer.writeUint32(version);
|
|
47
|
+
|
|
48
|
+
const serializer = new BinaryCollectionSerializer();
|
|
49
|
+
|
|
50
|
+
serializer.setRegistry(mtf_serialization_registry());
|
|
51
|
+
serializer.setBuffer(buffer);
|
|
52
|
+
|
|
53
|
+
mtf_write_collection(serializer, MTF_CLASS_TEXTURE, records, NO_OPTIONS);
|
|
54
|
+
|
|
55
|
+
buffer.writeBytes(new Uint8Array(file, rest_start), 0, file.byteLength - rest_start);
|
|
56
|
+
|
|
57
|
+
buffer.trim();
|
|
58
|
+
|
|
59
|
+
return buffer.data;
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a file an MTF package names is: the URI as the package holds it, resolved against the package's own URL
|
|
3
|
+
* the way a browser resolves a link against the page it is on.
|
|
4
|
+
*
|
|
5
|
+
* The result has no `.` or `..` left in it wherever the package's URL allows, and that is the point of doing it
|
|
6
|
+
* here rather than leaving it to the fetch: a texture is shared by being asked for under one name. Two packages
|
|
7
|
+
* in different folders reach the same file by different relative URIs, and an asset manager that keyed on the
|
|
8
|
+
* unresolved forms would fetch it twice and hold two images.
|
|
9
|
+
*
|
|
10
|
+
* Characters are left as they are. Nothing is percent-encoded or decoded, so a path that names a file comes back
|
|
11
|
+
* as a path that names it.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} uri relative to the package, from a root, or whole
|
|
14
|
+
* @param {string} package_url what the package was asked for by: a URL, or a path
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*
|
|
17
|
+
* @author Alex Goldring
|
|
18
|
+
* @copyright Company Named Limited (c) 2026
|
|
19
|
+
*/
|
|
20
|
+
export function mtf_resolve_uri(uri: string, package_url: string): string;
|
|
21
|
+
//# sourceMappingURL=mtf_resolve_uri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtf_resolve_uri.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_resolve_uri.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qCAPW,MAAM,eACN,MAAM,GACJ,MAAM,CA8DlB"}
|