How to use the draco3d.createDecoderModule function in draco3d

To help you get started, we’ve selected a few draco3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Reon90 / redcube / src / decoder.ts View on Github external
// import draco3d from 'draco3d';
const draco3d = require('draco3d');

export const decoderModule = draco3d.createDecoderModule({});

export function decodeDracoData(rawBuffer, decoder, offset, length) {
    const buffer = new decoderModule.DecoderBuffer();
    buffer.Init(new Int8Array(rawBuffer, offset, length), rawBuffer.byteLength);

    const dracoGeometry = new decoderModule.Mesh();
    decoder.DecodeBufferToMesh(buffer, dracoGeometry);
    decoderModule.destroy(buffer);

    return dracoGeometry;
}

export function getArray(type, length, decodedGeometry?, attribute?, decoder?) {
    let arr;
    let dracoArr;
    switch (type) {
github imodeljs / imodeljs / core / frontend / src / tile / DracoDecoder.ts View on Github external
public static readDracoMesh(mesh: Mesh, _primitive: any, bufferData: Uint8Array): Mesh | undefined {
    if (!DracoDecoder._dracoDecoderModule)
      DracoDecoder._dracoDecoderModule = createDecoderModule(undefined);

    const dracoModule = DracoDecoder._dracoDecoderModule;
    const dracoDecoder = new dracoModule.Decoder();

    const buffer = new dracoModule.DecoderBuffer();
    buffer.Init(bufferData, bufferData.length);

    const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
    if (geometryType !== dracoModule.TRIANGULAR_MESH)
      return undefined;

    const dracoGeometry = new dracoModule.Mesh();
    const decodingStatus = dracoDecoder.DecodeBufferToMesh(buffer, dracoGeometry);
    dracoModule.destroy(buffer);
    if (!decodingStatus.ok() || dracoGeometry.ptr === 0)
      return undefined;
github uber / luma.gl / modules / loaders.gl / src / draco-loader / draco-decoder.js View on Github external
constructor() {
    this.decoderModule = draco3d.createDecoderModule({});
  }
github AnalyticalGraphicsInc / gltf-pipeline / lib / replaceWithDecompressedPrimitive.js View on Github external
'use strict';
const Cesium = require('cesium');
const draco3d = require('draco3d');
const addBuffer = require('./addBuffer');

const RuntimeError = Cesium.RuntimeError;
const WebGLConstants = Cesium.WebGLConstants;

const decoderModule = draco3d.createDecoderModule({});

module.exports = replaceWithDecompressedPrimitive;

/**
 * Replace the accessor properties of the original primitive with the values from the decompressed primitive.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @param {Object} primitive A javascript object containing a glTF primitive.
 * @param {Object} dracoEncodedBuffer A javascript object containing a Draco encoded mesh.
 * @param {Number} dracoEncodedBuffer.numberOfPoints Number of points after the mesh is decompressed.
 * @param {Number} dracoEncodedBuffer.numberOfFaces Number of faces after the mesh is decompressed.
 * @param {Buffer} dracoEncodedBuffer.buffer A Buffer object containing a Draco compressed mesh.
 * @param {Boolean} uncompressedFallback If set, replaces the original with the decompressed data.
 * @returns {Object} The glTF asset with the decompressed primitive.
 *
 * @private

draco3d

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.

Apache-2.0
Latest version published 4 months ago

Package Health Score

91 / 100
Full package analysis