Class DracoCompression
Constructors
constructor
-
Creates a new DracoCompression object.
Parameters
- numWorkersOrOptions: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers
Overrides for the Configuration. Either:
- The number of workers for async operations or a config object. Specify
0to disable web workers and run synchronously in the current context. - An options object
- The number of workers for async operations or a config object. Specify
Returns DracoCompression
- numWorkersOrOptions: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers
Properties
StaticDefault Num Workers
Default number of workers to create when creating the draco compression object.
Accessors
StaticConfiguration
-
The configuration. Defaults to the following urls:
- wasmUrl: "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"
- wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm"
- fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js"
Returns IDracoCompressionConfiguration
-
Parameters
Returns void
StaticDecoder Available
-
get DecoderAvailable(): boolean
Returns true if the decoder configuration is available.
Returns boolean
StaticDefault
-
Default instance for the DracoCompression.
Returns DracoCompression
Methods
decode Mesh Async
-
decodeMeshAsync(
data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>,
attributes?: { [kind: string]: number },
): Promise<VertexData>Decode Draco compressed mesh data to Babylon vertex data.
Parameters
- data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
The ArrayBuffer or ArrayBufferView for the Draco compression data
Optionalattributes: { [kind: string]: number }A map of attributes from vertex buffer kinds to Draco unique ids
Returns Promise<VertexData>
A promise that resolves with the decoded vertex data
Deprecated
Use decodeMeshToGeometryAsync for better performance in some cases
- data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
decode Mesh To Geometry Async
-
decodeMeshToGeometryAsync(
name: string,
scene: Scene,
data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>,
attributes?: { [kind: string]: number },
): Promise<Geometry>Decode Draco compressed mesh data to Babylon geometry.
Parameters
- name: string
The name to use when creating the geometry
- scene: Scene
The scene to use when creating the geometry
- data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
The ArrayBuffer or ArrayBufferView for the Draco compression data
Optionalattributes: { [kind: string]: number }A map of attributes from vertex buffer kinds to Draco unique ids
Returns Promise<Geometry>
A promise that resolves with the decoded geometry
- name: string
decode Mesh To Mesh Data Async
-
decodeMeshToMeshDataAsync(
data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>,
attributes?: { [kind: string]: number },
gltfNormalizedOverride?: { [kind: string]: boolean },
): Promise<MeshData>Decode Draco compressed mesh data to mesh data.
Parameters
- data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
The ArrayBuffer or ArrayBufferView for the Draco compression data
Optionalattributes: { [kind: string]: number }A map of attributes from vertex buffer kinds to Draco unique ids
OptionalgltfNormalizedOverride: { [kind: string]: boolean }A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization
Returns Promise<MeshData>
A promise that resolves with the decoded mesh data
- data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
dispose
-
Stop all async operations and release resources.
Returns void
when Ready Async
-
Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
Returns Promise<void>
a promise that resolves when ready
StaticReset Default
-
Reset the default draco compression object to null and disposing the removed default instance. Note that if the workerPool is a member of the static Configuration 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
Draco compression (https://google.github.io/draco/)
This class wraps the Draco module.
Encoder
The encoder is not currently implemented.
Decoder
By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js cdn https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js. The configuration is shared with the DracoDecoder class.
To update the configuration, use the following code:
Draco has two versions, one for WebAssembly and one for JavaScript. The decoder 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
DracoCompression.DecoderAvailableto determine if the decoder configuration is available for the current context.To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:
See
https://playground.babylonjs.com/#DMZIBD#0