Class DracoEncoderExperimental
Hierarchy
- DracoCodec
- DracoEncoder
Constructors
constructor
-
ExperimentalCreates a new Draco encoder.
Parameters
- configuration: IDracoCodecConfiguration = DracoEncoder.DefaultConfiguration
Optional override of the configuration for the DracoEncoder. If not provided, defaults to DracoEncoder.DefaultConfiguration.
Returns DracoEncoder
- configuration: IDracoCodecConfiguration = DracoEncoder.DefaultConfiguration
Properties
Static ExperimentalDefault Configuration
Default configuration for the DracoEncoder. Defaults to the following:
- numWorkers: 50% of the available logical processors, capped to 4. If no logical processors are available, defaults to 1.
- wasmUrl:
"https://cdn.babylonjs.com/draco_encoder_wasm_wrapper.js" - wasmBinaryUrl:
"https://cdn.babylonjs.com/draco_encoder.wasm" - fallbackUrl:
"https://cdn.babylonjs.com/draco_encoder.js"
Accessors
StaticDefault
StaticDefault Available
-
get DefaultAvailable(): boolean
ExperimentalReturns true if the encoder's
DefaultConfigurationis available.Returns boolean
Methods
dispose
-
ExperimentalStop all async operations and release resources.
Returns void
encode Mesh Async
when Ready Async
-
ExperimentalReturns a promise that resolves when ready. Call this manually to ensure the draco codec is ready before use.
Returns Promise<void>
a promise that resolves when ready
StaticReset Default
-
ExperimentalReset the default DracoEncoder object to null and disposing the removed default instance. Note that if the workerPool is a member of the static DefaultConfiguration object it is recommended not to run dispose, unless the static worker pool is no longer needed.
Parameters
OptionalskipDispose: booleanset to true to not dispose the removed default instance
Returns void
This class is subject to change.
Draco Encoder (https://google.github.io/draco/)
This class wraps the Draco encoder module.
By default, the configuration points to a copy of the Draco encoder files from the Babylon.js cdn https://cdn.babylonjs.com/draco_encoder_wasm_wrapper.js.
To update the configuration, use the following code:
Draco has two versions, one for WebAssembly and one for JavaScript. The encoder configuration can be set to only support WebAssembly or only support the JavaScript version. Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser. Use
DracoEncoder.DefaultAvailableto determine if the encoder configuration is available for the current context.To encode Draco compressed data, get the default DracoEncoder object and call encodeMeshAsync:
Currently, DracoEncoder only encodes to meshes. Encoding to point clouds is not yet supported.
Only position, normal, color, and UV attributes are supported natively by the encoder. All other attributes are treated as generic. This means that, when decoding these generic attributes later, additional information about their original Babylon types will be needed to interpret the data correctly. You can use the return value of
encodeMeshAsyncto source this information, specifically theattributesfield. E.g.,By default, DracoEncoder will encode all available attributes of the mesh. To exclude specific attributes, use the following code: