@loaders.gl/draco
Advanced tools
Comparing version 1.2.0-beta.2 to 1.2.0-beta.3
@@ -12,3 +12,3 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -19,2 +19,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var draco3d = require('draco3d'); | ||
@@ -79,3 +83,3 @@ | ||
value: function _getAttributesFromMesh(mesh) { | ||
var attributes = (0, _objectSpread2["default"])({}, mesh, mesh.attributes); | ||
var attributes = _objectSpread({}, mesh, {}, mesh.attributes); | ||
@@ -82,0 +86,0 @@ if (mesh.indices) { |
@@ -1,4 +0,4 @@ | ||
const moduleExports = require('./index'); | ||
var moduleExports = require('./index'); | ||
const _global = typeof window === 'undefined' ? global : window; | ||
var _global = typeof window === 'undefined' ? global : window; | ||
@@ -5,0 +5,0 @@ _global.loaders = _global.loaders || {}; |
@@ -1,6 +0,10 @@ | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
const draco3d = require('draco3d'); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
const GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = { | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var draco3d = require('draco3d'); | ||
var GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = { | ||
POSITION: 'POSITION', | ||
@@ -15,7 +19,7 @@ NORMAL: 'NORMAL', | ||
function dracoInt8ArrayToArrayBuffer(dracoData) { | ||
const byteLength = dracoData.size(); | ||
const outputBuffer = new ArrayBuffer(byteLength); | ||
const outputData = new Int8Array(outputBuffer); | ||
var byteLength = dracoData.size(); | ||
var outputBuffer = new ArrayBuffer(byteLength); | ||
var outputData = new Int8Array(outputBuffer); | ||
for (let i = 0; i < byteLength; ++i) { | ||
for (var i = 0; i < byteLength; ++i) { | ||
outputData[i] = dracoData.GetValue(i); | ||
@@ -29,3 +33,3 @@ } | ||
constructor() { | ||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
this.dracoEncoderModule = draco3d.createEncoderModule({}); | ||
@@ -58,3 +62,3 @@ this.dracoEncoder = new this.dracoEncoderModule.Encoder(); | ||
_getAttributesFromMesh(mesh) { | ||
const attributes = _objectSpread({}, mesh, mesh.attributes); | ||
var attributes = _objectSpread({}, mesh, {}, mesh.attributes); | ||
@@ -69,10 +73,10 @@ if (mesh.indices) { | ||
_encodePointCloud(pointcloud) { | ||
const attributes = this._getAttributesFromMesh(pointcloud); | ||
var attributes = this._getAttributesFromMesh(pointcloud); | ||
const dracoPointCloud = this._createDracoPointCloud(attributes); | ||
var dracoPointCloud = this._createDracoPointCloud(attributes); | ||
const dracoData = new this.dracoEncoderModule.DracoInt8Array(); | ||
var dracoData = new this.dracoEncoderModule.DracoInt8Array(); | ||
try { | ||
const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData); | ||
var encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData); | ||
@@ -92,10 +96,10 @@ if (!(encodedLen > 0)) { | ||
_encodeMesh(mesh) { | ||
const attributes = this._getAttributesFromMesh(mesh); | ||
var attributes = this._getAttributesFromMesh(mesh); | ||
const dracoMesh = this._createDracoMesh(attributes); | ||
var dracoMesh = this._createDracoMesh(attributes); | ||
const dracoData = new this.dracoEncoderModule.DracoInt8Array(); | ||
var dracoData = new this.dracoEncoderModule.DracoInt8Array(); | ||
try { | ||
const encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData); | ||
var encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData); | ||
@@ -115,3 +119,3 @@ if (encodedLen <= 0) { | ||
_setOptions() { | ||
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -123,3 +127,3 @@ if ('speed' in opts) { | ||
if ('method' in opts) { | ||
const dracoMethod = this.dracoEncoderModule[opts.method]; | ||
var dracoMethod = this.dracoEncoderModule[opts.method]; | ||
this.dracoEncoder.SetEncodingMethod(dracoMethod); | ||
@@ -129,5 +133,5 @@ } | ||
if ('quantization' in opts) { | ||
for (const attribute in opts.quantization) { | ||
const bits = opts.quantization[attribute]; | ||
const dracoPosition = this.dracoEncoderModule[attribute]; | ||
for (var attribute in opts.quantization) { | ||
var bits = opts.quantization[attribute]; | ||
var dracoPosition = this.dracoEncoderModule[attribute]; | ||
this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits); | ||
@@ -139,6 +143,6 @@ } | ||
_createDracoMesh(attributes) { | ||
const dracoMesh = new this.dracoEncoderModule.Mesh(); | ||
var dracoMesh = new this.dracoEncoderModule.Mesh(); | ||
try { | ||
const positions = this._getPositionAttribute(attributes); | ||
var positions = this._getPositionAttribute(attributes); | ||
@@ -149,6 +153,6 @@ if (!positions) { | ||
const vertexCount = positions.length / 3; | ||
var vertexCount = positions.length / 3; | ||
for (let attributeName in attributes) { | ||
const attribute = attributes[attributeName]; | ||
for (var attributeName in attributes) { | ||
var attribute = attributes[attributeName]; | ||
attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName; | ||
@@ -167,6 +171,6 @@ | ||
_createDracoPointCloud(attributes) { | ||
const dracoPointCloud = new this.dracoEncoderModule.PointCloud(); | ||
var dracoPointCloud = new this.dracoEncoderModule.PointCloud(); | ||
try { | ||
const positions = this._getPositionAttribute(attributes); | ||
var positions = this._getPositionAttribute(attributes); | ||
@@ -177,6 +181,6 @@ if (!positions) { | ||
const vertexCount = positions.length / 3; | ||
var vertexCount = positions.length / 3; | ||
for (let attributeName in attributes) { | ||
const attribute = attributes[attributeName]; | ||
for (var attributeName in attributes) { | ||
var attribute = attributes[attributeName]; | ||
attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName; | ||
@@ -199,8 +203,8 @@ | ||
const dracoAttributeType = this._getDracoAttributeType(attributeName, attribute); | ||
var dracoAttributeType = this._getDracoAttributeType(attributeName, attribute); | ||
const size = attribute.length / vertexCount; | ||
var size = attribute.length / vertexCount; | ||
if (dracoAttributeType === 'indices') { | ||
const numFaces = attribute.length / 3; | ||
var numFaces = attribute.length / 3; | ||
this.log("Adding attribute ".concat(attributeName, ", size ").concat(numFaces)); | ||
@@ -273,6 +277,6 @@ this.dracoMeshBuilder.AddFacesToMesh(dracoMesh, numFaces, attribute); | ||
_getPositionAttribute(attributes) { | ||
for (const attributeName in attributes) { | ||
const attribute = attributes[attributeName]; | ||
for (var attributeName in attributes) { | ||
var attribute = attributes[attributeName]; | ||
const dracoType = this._getDracoAttributeType(attributeName, attribute); | ||
var dracoType = this._getDracoAttributeType(attributeName, attribute); | ||
@@ -279,0 +283,0 @@ if (dracoType === this.dracoEncoderModule.POSITION) { |
import DracoParser from './draco-parser'; | ||
function parseSync(arrayBuffer, options) { | ||
const dracoParser = new DracoParser(); | ||
var dracoParser = new DracoParser(); | ||
@@ -6,0 +6,0 @@ try { |
@@ -1,8 +0,8 @@ | ||
const draco3d = require('draco3d'); | ||
var draco3d = require('draco3d'); | ||
const GEOMETRY_TYPE = { | ||
var GEOMETRY_TYPE = { | ||
TRIANGULAR_MESH: 0, | ||
POINT_CLOUD: 1 | ||
}; | ||
const DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = { | ||
var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = { | ||
POSITION: 'POSITION', | ||
@@ -13,3 +13,3 @@ NORMAL: 'NORMAL', | ||
}; | ||
const DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = { | ||
var DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = { | ||
1: Int8Array, | ||
@@ -37,12 +37,12 @@ 2: Uint8Array, | ||
parseSync(arrayBuffer) { | ||
const buffer = new this.decoderModule.DecoderBuffer(); | ||
var buffer = new this.decoderModule.DecoderBuffer(); | ||
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength); | ||
const decoder = new this.decoderModule.Decoder(); | ||
const data = {}; | ||
let dracoStatus; | ||
let dracoGeometry; | ||
let header; | ||
var decoder = new this.decoderModule.Decoder(); | ||
var data = {}; | ||
var dracoStatus; | ||
var dracoGeometry; | ||
var header; | ||
try { | ||
const geometryType = decoder.GetEncodedGeometryType(buffer); | ||
var geometryType = decoder.GetEncodedGeometryType(buffer); | ||
@@ -76,3 +76,3 @@ switch (geometryType) { | ||
if (!dracoStatus.ok() || !dracoGeometry.ptr) { | ||
const message = "DRACO decompression failed: ".concat(dracoStatus.error_msg()); | ||
var message = "DRACO decompression failed: ".concat(dracoStatus.error_msg()); | ||
@@ -102,4 +102,4 @@ if (dracoGeometry) { | ||
extractDRACOGeometry(decoder, dracoGeometry, geometryType, geometry) { | ||
const attributes = this.getAttributes(decoder, dracoGeometry); | ||
const positionAttribute = attributes.POSITION; | ||
var attributes = this.getAttributes(decoder, dracoGeometry); | ||
var positionAttribute = attributes.POSITION; | ||
@@ -134,3 +134,3 @@ if (!positionAttribute) { | ||
this.metadata.attributes = this.metadata.attributes || {}; | ||
const posTransform = new this.decoderModule.AttributeQuantizationTransform(); | ||
var posTransform = new this.decoderModule.AttributeQuantizationTransform(); | ||
@@ -143,3 +143,3 @@ if (posTransform.InitFromAttribute(positionAttribute)) { | ||
for (let i = 0; i < 3; ++i) { | ||
for (var i = 0; i < 3; ++i) { | ||
this.metadata.attributes.position.minValues[i] = posTransform.min_value(i); | ||
@@ -153,12 +153,12 @@ } | ||
getAttributes(decoder, dracoGeometry) { | ||
const attributes = {}; | ||
const numPoints = dracoGeometry.num_points(); | ||
var attributes = {}; | ||
var numPoints = dracoGeometry.num_points(); | ||
for (const attributeName in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) { | ||
const attributeType = this.decoderModule[attributeName]; | ||
const attributeId = decoder.GetAttributeId(dracoGeometry, attributeType); | ||
for (var attributeName in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) { | ||
var attributeType = this.decoderModule[attributeName]; | ||
var attributeId = decoder.GetAttributeId(dracoGeometry, attributeType); | ||
if (attributeId !== -1) { | ||
const dracoAttribute = decoder.GetAttribute(dracoGeometry, attributeId); | ||
const { | ||
var dracoAttribute = decoder.GetAttribute(dracoGeometry, attributeId); | ||
var { | ||
typedArray | ||
@@ -177,10 +177,10 @@ } = this.getAttributeTypedArray(decoder, dracoGeometry, dracoAttribute, attributeName); | ||
getMeshFaceIndices(decoder, dracoGeometry) { | ||
const numFaces = dracoGeometry.num_faces(); | ||
const numIndices = numFaces * 3; | ||
const indices = new Uint32Array(numIndices); | ||
const dracoArray = new this.decoderModule.DracoInt32Array(); | ||
var numFaces = dracoGeometry.num_faces(); | ||
var numIndices = numFaces * 3; | ||
var indices = new Uint32Array(numIndices); | ||
var dracoArray = new this.decoderModule.DracoInt32Array(); | ||
for (let i = 0; i < numFaces; ++i) { | ||
for (var i = 0; i < numFaces; ++i) { | ||
decoder.GetFaceFromMesh(dracoGeometry, i, dracoArray); | ||
const index = i * 3; | ||
var index = i * 3; | ||
indices[index] = dracoArray.GetValue(0); | ||
@@ -196,7 +196,7 @@ indices[index + 1] = dracoArray.GetValue(1); | ||
getMeshStripIndices(decoder, dracoGeometry) { | ||
const dracoArray = new this.decoderModule.DracoInt32Array(); | ||
var dracoArray = new this.decoderModule.DracoInt32Array(); | ||
decoder.GetTriangleStripsFromMesh(dracoGeometry, dracoArray); | ||
const indices = new Uint32Array(dracoArray.size()); | ||
var indices = new Uint32Array(dracoArray.size()); | ||
for (let i = 0; i < dracoArray.size(); ++i) { | ||
for (var i = 0; i < dracoArray.size(); ++i) { | ||
indices[i] = dracoArray.GetValue(i); | ||
@@ -211,12 +211,12 @@ } | ||
if (dracoAttribute.ptr === 0) { | ||
const message = "DRACO decode bad attribute ".concat(attributeName); | ||
var message = "DRACO decode bad attribute ".concat(attributeName); | ||
throw new Error(message); | ||
} | ||
const attributeType = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[dracoAttribute.data_type()]; | ||
const numComponents = dracoAttribute.num_components(); | ||
const numPoints = dracoGeometry.num_points(); | ||
const numValues = numPoints * numComponents; | ||
let dracoArray; | ||
let typedArray; | ||
var attributeType = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[dracoAttribute.data_type()]; | ||
var numComponents = dracoAttribute.num_components(); | ||
var numPoints = dracoGeometry.num_points(); | ||
var numValues = numPoints * numComponents; | ||
var dracoArray; | ||
var typedArray; | ||
@@ -267,7 +267,7 @@ switch (attributeType) { | ||
default: | ||
const errorMsg = 'DRACO decoder: unexpected attribute type.'; | ||
var errorMsg = 'DRACO decoder: unexpected attribute type.'; | ||
throw new Error(errorMsg); | ||
} | ||
for (let i = 0; i < numValues; i++) { | ||
for (var i = 0; i < numValues; i++) { | ||
typedArray[i] = dracoArray.GetValue(i); | ||
@@ -274,0 +274,0 @@ } |
import DRACOBuilder from './draco-builder'; | ||
function encodeSync(data, options) { | ||
const dracoBuilder = new DRACOBuilder(); | ||
var dracoBuilder = new DRACOBuilder(); | ||
@@ -6,0 +6,0 @@ try { |
@@ -8,3 +8,3 @@ export { default as DracoLoader } from './draco-loader'; | ||
function parseSync(arrayBuffer, options) { | ||
const dracoParser = new DracoParser(); | ||
var dracoParser = new DracoParser(); | ||
@@ -18,3 +18,3 @@ try { | ||
export const DracoWorkerLoader = { | ||
export var DracoWorkerLoader = { | ||
name: 'DRACO', | ||
@@ -21,0 +21,0 @@ extensions: ['drc'], |
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var draco3d = require('draco3d'); | ||
@@ -67,3 +71,3 @@ | ||
value: function _getAttributesFromMesh(mesh) { | ||
var attributes = _objectSpread({}, mesh, mesh.attributes); | ||
var attributes = _objectSpread({}, mesh, {}, mesh.attributes); | ||
@@ -70,0 +74,0 @@ if (mesh.indices) { |
{ | ||
"name": "@loaders.gl/draco", | ||
"version": "1.2.0-beta.2", | ||
"version": "1.2.0-beta.3", | ||
"description": "Framework-independent loader and writer for Draco compressed meshes and point clouds", | ||
@@ -41,6 +41,6 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/loader-utils": "1.2.0-beta.2", | ||
"@loaders.gl/loader-utils": "1.2.0-beta.3", | ||
"draco3d": "^1.3.4" | ||
}, | ||
"gitHead": "82626f4ecad7c816c70780376d661f267b6c523e" | ||
"gitHead": "39442622efe0e06323db958c53c9805fc9b7699d" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10197230
58
29211
1
+ Added@loaders.gl/loader-utils@1.2.0-beta.3(transitive)
- Removed@loaders.gl/loader-utils@1.2.0-beta.2(transitive)