How to use the draco3d.createEncoderModule 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 AnalyticalGraphicsInc / gltf-pipeline / lib / compressDracoMeshes.js View on Github external
const removeUnusedElements = require('./removeUnusedElements');
const replaceWithDecompressedPrimitive = require('./replaceWithDecompressedPrimitive');
const splitPrimitives = require('./splitPrimitives');

const arrayFill = Cesium.arrayFill;
const Cartesian3 = Cesium.Cartesian3;
const Check = Cesium.Check;
const clone = Cesium.clone;
const ComponentDatatype = Cesium.ComponentDatatype;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;
const RuntimeError = Cesium.RuntimeError;
const WebGLConstants = Cesium.WebGLConstants;

// Prepare encoder for compressing meshes.
const encoderModule = draco3d.createEncoderModule({});

module.exports = compressDracoMeshes;

/**
 * Compresses meshes using Draco compression in the glTF model.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @param {Object} options The same options object as {@link processGltf}
 * @param {Object} options.dracoOptions Options defining Draco compression settings.
 * @param {Number} [options.dracoOptions.compressionLevel=7] A value between 0 and 10 specifying the quality of the Draco compression. Higher values produce better quality compression but may take longer to decompress. A value of 0 will apply sequential encoding and preserve face order.
 * @param {Number} [options.dracoOptions.quantizePositionBits=14] A value between 0 and 30 specifying the number of bits used for positions. Lower values produce better compression, but will lose precision. A value of 0 does not set quantization.
 * @param {Number} [options.dracoOptions.quantizeNormalBits=10] A value between 0 and 30 specifying the number of bits used for normals. Lower values produce better compression, but will lose precision. A value of 0 does not set quantization.
 * @param {Number} [options.dracoOptions.quantizeTexcoordBits=12] A value between 0 and 30 specifying the number of bits used for texture coordinates. Lower values produce better compression, but will lose precision. A value of 0 does not set quantization.
 * @param {Number} [options.dracoOptions.quantizeColorBits=8] A value between 0 and 30 specifying the number of bits used for color attributes. Lower values produce better compression, but will lose precision. A value of 0 does not set quantization.
 * @param {Number} [options.dracoOptions.quantizeGenericBits=12] A value between 0 and 30 specifying the number of bits used for skinning attributes (joint indices and joint weights) and custom attributes. Lower values produce better compression, but will lose precision. A value of 0 does not set quantization.
 * @param {Boolean} [options.dracoOptions.uncompressedFallback=false] If set, add uncompressed fallback versions of the compressed meshes.
github AnalyticalGraphicsInc / 3d-tiles-tools / samples-generator / lib / createPointCloudTile.js View on Github external
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var Matrix4 = Cesium.Matrix4;
var WebGLConstants = Cesium.WebGLConstants;

module.exports = createPointCloudTile;

var sizeOfUint8 = 1;
var sizeOfUint16 = 2;
var sizeOfUint32 = 4;
var sizeOfFloat32 = 4;

CesiumMath.setRandomNumberSeed(0);
var simplex = new SimplexNoise(CesiumMath.nextRandomNumber);

var encoderModule = draco3d.createEncoderModule({});

/**
 * Creates a pnts tile that represents a point cloud.
 *
 * @param {Object} [options] Object with the following properties:
 * @param {Number} [options.tileWidth=10.0] The width of the tile in meters.
 * @param {Matrix4} [options.transform=Matrix4.IDENTITY] A transform to bake into the tile, for example a transform into WGS84.
 * @param {Number} [options.pointsLength=1000] The number of points in the point cloud.
 * @param {String} [options.colorMode='rgb'] The mode in which colors are saved. Possible values are 'rgb', 'rgba', 'rgb565', 'constant', 'none'.
 * @param {String} [options.color='random'] Determines the method for generating point colors. Possible values are 'random', 'gradient', 'noise'.
 * @param {String} [options.shape='box'] The shape of the point cloud. Possible values are 'sphere', 'box'.
 * @param {Boolean} [options.generateNormals=false] Generate per-point normals.
 * @param {Boolean} [options.draco=false] Use draco encoding.
 * @param {String[]} [options.dracoSemantics] An array of semantics to draco encode. If undefined, all semantics are encoded.
 * @param {Boolean} [options.octEncodeNormals=false] Apply oct16p encoding on the point normals.
 * @param {Boolean} [options.quantizePositions=false] Quantize point positions so each x, y, z takes up 16 bits rather than 32 bits.

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