浏览代码

Implement support for KHR_mesh_quantization (#7157)

* Implement support for KHR_quantized_geometry

This change advertises support for KHR_quantized_geometry and allows to
specify it as part of required extensions when loading glTF files.

The reason why the actual extension class is empty is that the extension
doesn't define any new JSON metadata, and merely allows the use of
various quantized attributes in glTF file - and as far as I can tell
Babylon.js already supports these quantized formats either by directly
using the encoded data, or by decoding it into floating-point arrays.

* Rename KHR_quantized_geometry to KHR_mesh_quantization

* Rename KHR_quantized_geometry to KHR_mesh_quantization

Also clean up unnecessary member variable

* Update what's new
Arseny Kapoulkine 5 年之前
父节点
当前提交
2d204fc134

+ 1 - 0
dist/preview release/what's new.md

@@ -112,6 +112,7 @@
 - Added support for GLTF clearcoat extension [Sebavan](https://github.com/sebavan/)
 - Added support for GLTF specular extension [Sebavan](https://github.com/sebavan/)
 - Added support for GLTF sheen extension [Sebavan](https://github.com/sebavan/)
+- Added support for GLTF mesh quantization extension ([zeux](https://github.com/zeux))
 
 ### Materials
 

+ 30 - 0
loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts

@@ -0,0 +1,30 @@
+import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
+import { GLTFLoader } from "../glTFLoader";
+
+const NAME = "KHR_mesh_quantization";
+
+/**
+ * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
+ */
+export class KHR_mesh_quantization implements IGLTFLoaderExtension {
+    /**
+     * The name of this extension.
+     */
+    public readonly name = NAME;
+
+    /**
+     * Defines whether this extension is enabled.
+     */
+    public enabled: boolean;
+
+    /** @hidden */
+    constructor(loader: GLTFLoader) {
+        this.enabled = loader.isExtensionUsed(NAME);
+    }
+
+    /** @hidden */
+    public dispose() {
+    }
+}
+
+GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_mesh_quantization(loader));

+ 2 - 1
loaders/src/glTF/2.0/Extensions/index.ts

@@ -6,9 +6,10 @@ export * from "./KHR_materials_unlit";
 export * from "./KHR_materials_clearcoat";
 export * from "./KHR_materials_sheen";
 export * from "./KHR_materials_specular";
+export * from "./KHR_mesh_quantization";
 export * from "./KHR_texture_transform";
 export * from "./MSFT_audio_emitter";
 export * from "./MSFT_lod";
 export * from "./MSFT_minecraftMesh";
 export * from "./MSFT_sRGBFactors";
-export * from "./ExtrasAsMetadata";
+export * from "./ExtrasAsMetadata";