瀏覽代碼

Merge pull request #7990 from bghgary/draco-ie-fix

Update Draco decoder and fix IE compatibility
David Catuhe 5 年之前
父節點
當前提交
81748e9a7b

文件差異過大導致無法顯示
+ 48 - 30
dist/preview release/draco_decoder_gltf.js


二進制
dist/preview release/draco_decoder_gltf.wasm


文件差異過大導致無法顯示
+ 119 - 115
dist/preview release/draco_wasm_wrapper_gltf.js


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

@@ -20,6 +20,7 @@
 
 - Allow logging of shader code when a compilation error occurs ([Popov72](https://github.com/Popov72))
 - Add back support for selecting textures based on engine capabilities ([bghgary](https://github.com/bghgary))
+- Fix Draco decoder when running on IE11 ([bghgary](https://github.com/bghgary))
 
 ### NME
 

+ 13 - 0
src/Meshes/Compression/building-draco.md

@@ -0,0 +1,13 @@
+## Instructions for building the JavaScript version of Draco with IE compatibility
+
+Draco prebuilt libraries are not compatible with IE. Thus we must build the JavaScript fallback version of the Draco decoder ourselves.
+
+Follow the instructions for building Draco from https://github.com/google/draco/blob/master/BUILDING.md#javascript-encoderdecoder except enable the BUILD_FOR_GLTF and IE_COMPATIBLE flags when running `cmake`.
+
+```
+$ cmake ../ -DCMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake -DBUILD_FOR_GLTF=ON -DIE_COMPATIBLE=ON`
+```
+
+Then copy the output `draco_decoder.js` to Babylon.js dist folder.
+
+_Note that the WebAssembly versions are copied directly from the Draco repo._

+ 4 - 4
src/Meshes/Compression/dracoCompression.ts

@@ -133,7 +133,7 @@ function decodeMesh(decoderModule: any, dataView: ArrayBufferView, attributes: {
  * The worker function that gets converted to a blob url to pass into a worker.
  */
 function worker(): void {
-    let decoderPromise: Promise<any> | undefined;
+    let decoderPromise: PromiseLike<any> | undefined;
 
     onmessage = (event) => {
         const data = event.data;
@@ -142,7 +142,7 @@ function worker(): void {
                 const decoder = data.decoder;
                 if (decoder.url) {
                     importScripts(decoder.url);
-                    decoderPromise = createDecoderAsync(decoder.wasmBinary);
+                    decoderPromise = DracoDecoderModule({ wasmBinary: decoder.wasmBinary });
                 }
                 postMessage("done");
                 break;
@@ -152,7 +152,7 @@ function worker(): void {
                     throw new Error("Draco decoder module is not available");
                 }
                 decoderPromise.then((decoder) => {
-                    decodeMesh(decoder.module, data.dataView, data.attributes, (indices) => {
+                    decodeMesh(decoder, data.dataView, data.attributes, (indices) => {
                         postMessage({ id: "indices", value: indices }, [indices.buffer]);
                     }, (kind, data) => {
                         postMessage({ id: kind, value: data }, [data.buffer]);
@@ -304,7 +304,7 @@ export class DracoCompression implements IDisposable {
 
         if (numWorkers && typeof Worker === "function") {
             this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {
-                const workerContent = `${createDecoderAsync}${decodeMesh}(${worker})()`;
+                const workerContent = `${decodeMesh}(${worker})()`;
                 const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
                 const workerPromises = new Array<Promise<Worker>>(numWorkers);
                 for (let i = 0; i < workerPromises.length; i++) {