@loaders.gl/gltf
Advanced tools
Comparing version 0.4.3 to 0.4.4
{ | ||
"name": "@loaders.gl/gltf", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Framework-independent loader for the glTF format", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -11,3 +11,2 @@ /* eslint-disable camelcase, max-statements */ | ||
} from '@loaders.gl/core'; | ||
import {DracoEncoder, DracoDecoder} from '@loaders.gl/draco'; | ||
import packBinaryJson from '../glb-writer/pack-binary-json'; | ||
@@ -28,3 +27,7 @@ | ||
export default class GLTFBuilder { | ||
constructor(rootPath) { | ||
constructor(rootPath, options = {}) { | ||
// Soft dependency on Draco, needs to be imported and supplied by app | ||
this.DracoEncoder = options.DracoDecoder || options.DracoEncoder; | ||
this.DracoDecoder = options.DracoDecoder; | ||
// Lets us keep track of how large the body will be, as well as the offset for each of the | ||
@@ -222,3 +225,7 @@ // original buffers. | ||
addCompressedMesh(attributes, mode = 4) { | ||
const dracoEncoder = new DracoEncoder(); | ||
if (!this.DracoEncoder) { | ||
throw new Error('DracoEncoder/Decoder not registered'); | ||
} | ||
const dracoEncoder = new this.DracoEncoder(); | ||
const compressedData = dracoEncoder.encodeMesh(attributes); | ||
@@ -231,3 +238,3 @@ | ||
// rather than the original source data. | ||
const dracoDecoder = new DracoDecoder(); | ||
const dracoDecoder = new this.DracoDecoder(); | ||
const decodedData = dracoDecoder.decodeMesh(attributes); | ||
@@ -259,3 +266,7 @@ const fauxAccessors = this._addFauxAttributes(decodedData.attributes); | ||
addCompressedPointCloud(attributes) { | ||
const dracoEncoder = new DracoEncoder(); | ||
if (!this.DracoEncoder) { | ||
throw new Error('DracoEncoder/Decoder not registered'); | ||
} | ||
const dracoEncoder = new this.DracoEncoder(); | ||
const compressedData = dracoEncoder.encodePointCloud(attributes); | ||
@@ -268,3 +279,3 @@ | ||
// rather than the original source data. | ||
const dracoDecoder = new DracoDecoder(); | ||
const dracoDecoder = new this.DracoDecoder(); | ||
const decodedData = dracoDecoder.decodePointCloud(compressedData); | ||
@@ -271,0 +282,0 @@ const fauxAccessors = this._addFauxAttributes(decodedData.attributes); |
444360
4845