Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

Add support for draco compression to Core

Open pandaGaume opened this issue 2 years ago • 13 comments

This PR add support for draco compression to the Core lib. For the purpose, we divided the DracoCompression class into an Encoder and a Decoder, keeping the old API with a deprecated flag. We now have a

  • DracoCommons file which encompass all the standard declarations and interfaces
  • DracoEncoder for encoding purpose
  • DracoDecoder for decoding purpose.
  • DracoCompression has been kept for backward compatibility, but greatly reduced as kind of decorator.

NO regression has been observed using GLTF Loader with KHR_draco_mesh_compression Test has been Also conducted by compressing and decompressing mesh on the fly using

  // encode the mesh
  var encoder = new BABYLON.DracoEncoder();
  return encoder.encodeMeshAsync(mesh).then((encoded)=> {
          // once done decode the mesh
          var decoder = new BABYLON.DracoDecoder();
          return decoder
              .decodeMeshAsync(encoded.data, encoded.attributes)
              .then((babylonVertexData) => {
                  // and apply the geometry to new mesh
                  const name = mesh.Name + "Dracoized"
                  const babylonMesh = new BABYLON.Mesh(name, scene);
                  babylonVertexData.applyToMesh(babylonMesh)
                  // finally return the mesh
                  return babylonMesh;
              })
              .catch((error) => {
                  throw new Error(`${error.message}`);
              });

from playground Note the above playround will not be functional until the PR will be merge. Test has been conducted changing the Draco wasm configuration to local

    let baseEncoderUrl = "http://localhost:1337/";
    
    const codecConfiguration  =  {
        decoder: {
            wasmUrl: baseEncoderUrl + "draco_wasm_wrapper_gltf.js",
            wasmBinaryUrl: baseEncoderUrl + "draco_decoder_gltf.wasm",
            fallbackUrl: baseEncoderUrl + "draco_decoder_gltf.js",
        },
        encoder: {
            wasmUrl: baseEncoderUrl + "draco_encoder_wrapper.js",
            wasmBinaryUrl: baseEncoderUrl + "draco_encoder.wasm",
            fallbackUrl: baseEncoderUrl + "draco_encoder.js",
        },

    };
    BABYLON.DracoEncoder.Configuration = codecConfiguration.encoder;
    BABYLON.DracoDecoder.Configuration = codecConfiguration.decoder;

pandaGaume avatar Jun 02 '22 10:06 pandaGaume

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jun 02 '22 10:06 azure-pipelines[bot]

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jun 02 '22 10:06 azure-pipelines[bot]

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jun 02 '22 11:06 azure-pipelines[bot]

Snapshot stored with reference name: refs/pull/12628/merge

Test environment: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html

To test a playground add it to the URL, for example:

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html#WGZLGJ#4600

Links to test babylon tools with this snapshot:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge https://sandbox.babylonjs.com/?snapshot=refs/pull/12628/merge https://gui.babylonjs.com/?snapshot=refs/pull/12628/merge https://nme.babylonjs.com/?snapshot=refs/pull/12628/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge#BCU1XR#0

azure-pipelines[bot] avatar Jun 02 '22 11:06 azure-pipelines[bot]

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

azure-pipelines[bot] avatar Jun 02 '22 12:06 azure-pipelines[bot]

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

azure-pipelines[bot] avatar Jun 02 '22 12:06 azure-pipelines[bot]

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jul 07 '22 09:07 azure-pipelines[bot]

Snapshot stored with reference name: refs/pull/12628/merge

Test environment: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html

To test a playground add it to the URL, for example:

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html#WGZLGJ#4600

Links to test babylon tools with this snapshot:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge https://sandbox.babylonjs.com/?snapshot=refs/pull/12628/merge https://gui.babylonjs.com/?snapshot=refs/pull/12628/merge https://nme.babylonjs.com/?snapshot=refs/pull/12628/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge#BCU1XR#0

azure-pipelines[bot] avatar Jul 07 '22 09:07 azure-pipelines[bot]

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jul 07 '22 13:07 azure-pipelines[bot]

Snapshot stored with reference name: refs/pull/12628/merge

Test environment: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html

To test a playground add it to the URL, for example:

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html#WGZLGJ#4600

Links to test babylon tools with this snapshot:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge https://sandbox.babylonjs.com/?snapshot=refs/pull/12628/merge https://gui.babylonjs.com/?snapshot=refs/pull/12628/merge https://nme.babylonjs.com/?snapshot=refs/pull/12628/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge#BCU1XR#0

azure-pipelines[bot] avatar Jul 07 '22 13:07 azure-pipelines[bot]

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). To prevent this PR from going to the changelog marked it with the "skip changelog" label.

azure-pipelines[bot] avatar Jul 07 '22 14:07 azure-pipelines[bot]

Snapshot stored with reference name: refs/pull/12628/merge

Test environment: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html

To test a playground add it to the URL, for example:

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12628/merge/index.html#WGZLGJ#4600

Links to test babylon tools with this snapshot:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge https://sandbox.babylonjs.com/?snapshot=refs/pull/12628/merge https://gui.babylonjs.com/?snapshot=refs/pull/12628/merge https://nme.babylonjs.com/?snapshot=refs/pull/12628/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/12628/merge#BCU1XR#0

azure-pipelines[bot] avatar Jul 07 '22 14:07 azure-pipelines[bot]

cc @pandaGaume to see if he has a few cycles to finish this one? Thanks a million!

deltakosh avatar Aug 02 '22 16:08 deltakosh

@pandaGaume, do you think you ll be able to finish this one ? or should we flag as draft until someone can pick up where it is ?

sebavan avatar Sep 23 '22 14:09 sebavan

@pandaGaume I'm closing this PR for now. We can reopen if it becomes active again.

bghgary avatar Nov 15 '22 01:11 bghgary