Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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) {
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;
constructor() {
this.decoderModule = draco3d.createDecoderModule({});
}
'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