Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/gltf

Package Overview
Dependencies
Maintainers
8
Versions
342
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/gltf - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

dist/es5/gltf/gltf-utils.js

18

dist/es5/glb/unpack-glb-buffers.js

@@ -64,13 +64,15 @@ "use strict";

(0, _core.assert)(accessor);
var bufferView = bufferViews[accessor.bufferView];
(0, _core.assert)(bufferView); // Create a new typed array as a view into the combined buffer
var bufferView = bufferViews[accessor.bufferView]; // Draco encoded meshes don't have bufferView in accessor
var _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
if (bufferView) {
// Create a new typed array as a view into the combined buffer
var _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
var array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
var array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
array.accessor = accessor;
accessorBuffers.push(array);
array.accessor = accessor;
accessorBuffers.push(array);
}
}

@@ -77,0 +79,0 @@

@@ -30,2 +30,4 @@ "use strict";

var _gltfUtils = require("./gltf-utils");
var DEFAULT_OPTIONS = {

@@ -89,3 +91,3 @@ fetchLinkedResources: true,

postProcessor = new _gltfPostProcessor.default();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -148,3 +150,3 @@

var postProcessor = new _gltfPostProcessor.default();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -326,3 +328,3 @@

fetch = options.fetch || window.fetch;
uri = this._getFullUri(buffer.uri, options.uri);
uri = (0, _gltfUtils.getFullUri)(buffer.uri, options.uri);
_context3.next = 5;

@@ -346,3 +348,3 @@ return fetch(uri);

}
}, _callee3, this);
}, _callee3);
}));

@@ -355,9 +357,3 @@

return _loadBuffer;
}()
}, {
key: "_getFullUri",
value: function _getFullUri(uri, base) {
var absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
} // POST PROCESSING
}() // POST PROCESSING

@@ -454,3 +450,3 @@ }, {

var decodedData = dracoDecoder.decodeMesh(buffer);
var decodedData = dracoDecoder.decode(buffer);
primitive.attributes = decodedData.attributes;

@@ -497,9 +493,11 @@

value: function _getBufferViewArray(bufferViewIndex) {
var bufferView = this.gltf.bufferViews[bufferViewIndex];
if (this.glbParser) {
return this.glbParser.getBufferView(bufferViewIndex);
return this.glbParser.getBufferView(bufferView);
}
var bufferView = this.gltf.bufferViews[bufferViewIndex];
var buffer = this.gltf.buffers[bufferView.buffer].data;
var byteOffset = bufferView.byteOffset || 0;
return new Uint8Array(bufferView.buffer.data, byteOffset, bufferView.byteLength);
return new Uint8Array(buffer, byteOffset, bufferView.byteLength);
} // Removes an extension from the top-level list

@@ -506,0 +504,0 @@

@@ -16,2 +16,4 @@ "use strict";

var _gltfUtils = require("./gltf-utils");
// This is a post processor for loaded glTF files

@@ -78,5 +80,6 @@ // The goal is to make the loaded data easier to use in WebGL applications

key: "postProcess",
value: function postProcess(gltf) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
value: function postProcess(gltf, glbParser) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.gltf = gltf;
this.glbParser = glbParser;

@@ -324,4 +327,9 @@ this._resolveToTree(options);

accessor.id = "accessor-".concat(index);
accessor.bufferView = this.getBufferView(accessor.bufferView); // Look up enums
if (accessor.bufferView !== undefined) {
// Draco encoded meshes don't have bufferView
accessor.bufferView = this.getBufferView(accessor.bufferView);
} // Look up enums
accessor.bytesPerComponent = getBytesFromComponentType(accessor);

@@ -392,3 +400,3 @@ accessor.components = getSizeFromAccessorType(accessor);

img.src = _this4._getFullUri(image.uri, options.uri);
img.src = (0, _gltfUtils.getFullUri)(image.uri, options.uri);
});

@@ -395,0 +403,0 @@ } // cannot get image

@@ -55,13 +55,15 @@ import { assert } from '@loaders.gl/core';

assert(accessor);
const bufferView = bufferViews[accessor.bufferView];
assert(bufferView); // Create a new typed array as a view into the combined buffer
const bufferView = bufferViews[accessor.bufferView]; // Draco encoded meshes don't have bufferView in accessor
const _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
if (bufferView) {
// Create a new typed array as a view into the combined buffer
const _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
const array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
const array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
array.accessor = accessor;
accessorBuffers.push(array);
array.accessor = accessor;
accessorBuffers.push(array);
}
}

@@ -68,0 +70,0 @@

@@ -6,2 +6,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";

import { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './gltf-constants';
import { getFullUri } from './gltf-utils';
const DEFAULT_OPTIONS = {

@@ -41,3 +42,3 @@ fetchLinkedResources: true,

const postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -85,3 +86,3 @@

const postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -197,5 +198,3 @@

const fetch = options.fetch || window.fetch;
const uri = this._getFullUri(buffer.uri, options.uri);
const uri = getFullUri(buffer.uri, options.uri);
const response = await fetch(uri);

@@ -206,7 +205,2 @@ const arrayBuffer = await response.arrayBuffer();

}
}
_getFullUri(uri, base) {
const absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
} // POST PROCESSING

@@ -261,3 +255,3 @@

const decodedData = dracoDecoder.decodeMesh(buffer);
const decodedData = dracoDecoder.decode(buffer);
primitive.attributes = decodedData.attributes;

@@ -302,9 +296,11 @@

_getBufferViewArray(bufferViewIndex) {
const bufferView = this.gltf.bufferViews[bufferViewIndex];
if (this.glbParser) {
return this.glbParser.getBufferView(bufferViewIndex);
return this.glbParser.getBufferView(bufferView);
}
const bufferView = this.gltf.bufferViews[bufferViewIndex];
const buffer = this.gltf.buffers[bufferView.buffer].data;
const byteOffset = bufferView.byteOffset || 0;
return new Uint8Array(bufferView.buffer.data, byteOffset, bufferView.byteLength);
return new Uint8Array(buffer, byteOffset, bufferView.byteLength);
} // Removes an extension from the top-level list

@@ -311,0 +307,0 @@

@@ -1,2 +0,2 @@

// This is a post processor for loaded glTF files
import { getFullUri } from './gltf-utils'; // This is a post processor for loaded glTF files
// The goal is to make the loaded data easier to use in WebGL applications

@@ -9,2 +9,3 @@ //

// ENUM LOOKUP
const COMPONENTS = {

@@ -55,5 +56,6 @@ SCALAR: 1,

export default class GLTFPostProcessor {
postProcess(gltf) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
postProcess(gltf, glbParser) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.gltf = gltf;
this.glbParser = glbParser;

@@ -231,4 +233,9 @@ this._resolveToTree(options);

accessor.id = `accessor-${index}`;
accessor.bufferView = this.getBufferView(accessor.bufferView); // Look up enums
if (accessor.bufferView !== undefined) {
// Draco encoded meshes don't have bufferView
accessor.bufferView = this.getBufferView(accessor.bufferView);
} // Look up enums
accessor.bytesPerComponent = getBytesFromComponentType(accessor);

@@ -291,3 +298,3 @@ accessor.components = getSizeFromAccessorType(accessor);

img.src = this._getFullUri(image.uri, options.uri);
img.src = getFullUri(image.uri, options.uri);
});

@@ -294,0 +301,0 @@ } // cannot get image

@@ -55,13 +55,15 @@ import { assert } from '@loaders.gl/core';

assert(accessor);
var bufferView = bufferViews[accessor.bufferView];
assert(bufferView); // Create a new typed array as a view into the combined buffer
var bufferView = bufferViews[accessor.bufferView]; // Draco encoded meshes don't have bufferView in accessor
var _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
if (bufferView) {
// Create a new typed array as a view into the combined buffer
var _getArrayTypeAndLengt = getArrayTypeAndLength(accessor, bufferView),
ArrayType = _getArrayTypeAndLengt.ArrayType,
length = _getArrayTypeAndLengt.length;
var array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
var array = new ArrayType(arrayBuffer, bufferView.byteOffset, length); // Store the metadata on the array (e.g. needed to determine number of components per element)
array.accessor = accessor;
accessorBuffers.push(array);
array.accessor = accessor;
accessorBuffers.push(array);
}
}

@@ -68,0 +70,0 @@

@@ -11,2 +11,3 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

import { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './gltf-constants';
import { getFullUri } from './gltf-utils';
var DEFAULT_OPTIONS = {

@@ -70,3 +71,3 @@ fetchLinkedResources: true,

postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -129,3 +130,3 @@

var postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -307,3 +308,3 @@

fetch = options.fetch || window.fetch;
uri = this._getFullUri(buffer.uri, options.uri);
uri = getFullUri(buffer.uri, options.uri);
_context3.next = 5;

@@ -327,3 +328,3 @@ return fetch(uri);

}
}, _callee3, this);
}, _callee3);
}));

@@ -336,9 +337,3 @@

return _loadBuffer;
}()
}, {
key: "_getFullUri",
value: function _getFullUri(uri, base) {
var absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
} // POST PROCESSING
}() // POST PROCESSING

@@ -435,3 +430,3 @@ }, {

var decodedData = dracoDecoder.decodeMesh(buffer);
var decodedData = dracoDecoder.decode(buffer);
primitive.attributes = decodedData.attributes;

@@ -478,9 +473,11 @@

value: function _getBufferViewArray(bufferViewIndex) {
var bufferView = this.gltf.bufferViews[bufferViewIndex];
if (this.glbParser) {
return this.glbParser.getBufferView(bufferViewIndex);
return this.glbParser.getBufferView(bufferView);
}
var bufferView = this.gltf.bufferViews[bufferViewIndex];
var buffer = this.gltf.buffers[bufferView.buffer].data;
var byteOffset = bufferView.byteOffset || 0;
return new Uint8Array(bufferView.buffer.data, byteOffset, bufferView.byteLength);
return new Uint8Array(buffer, byteOffset, bufferView.byteLength);
} // Removes an extension from the top-level list

@@ -487,0 +484,0 @@

import _typeof from "@babel/runtime/helpers/esm/typeof";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// This is a post processor for loaded glTF files
import { getFullUri } from './gltf-utils'; // This is a post processor for loaded glTF files
// The goal is to make the loaded data easier to use in WebGL applications

@@ -12,2 +12,3 @@ //

// ENUM LOOKUP
var COMPONENTS = {

@@ -66,5 +67,6 @@ SCALAR: 1,

key: "postProcess",
value: function postProcess(gltf) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
value: function postProcess(gltf, glbParser) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.gltf = gltf;
this.glbParser = glbParser;

@@ -312,4 +314,9 @@ this._resolveToTree(options);

accessor.id = "accessor-".concat(index);
accessor.bufferView = this.getBufferView(accessor.bufferView); // Look up enums
if (accessor.bufferView !== undefined) {
// Draco encoded meshes don't have bufferView
accessor.bufferView = this.getBufferView(accessor.bufferView);
} // Look up enums
accessor.bytesPerComponent = getBytesFromComponentType(accessor);

@@ -380,3 +387,3 @@ accessor.components = getSizeFromAccessorType(accessor);

img.src = _this4._getFullUri(image.uri, options.uri);
img.src = getFullUri(image.uri, options.uri);
});

@@ -383,0 +390,0 @@ } // cannot get image

{
"name": "@loaders.gl/gltf",
"version": "0.8.0",
"version": "0.8.1",
"description": "Framework-independent loader for the glTF format",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -62,10 +62,11 @@ import {assert} from '@loaders.gl/core';

const bufferView = bufferViews[accessor.bufferView];
assert(bufferView);
// Create a new typed array as a view into the combined buffer
const {ArrayType, length} = getArrayTypeAndLength(accessor, bufferView);
const array = new ArrayType(arrayBuffer, bufferView.byteOffset, length);
// Store the metadata on the array (e.g. needed to determine number of components per element)
array.accessor = accessor;
accessorBuffers.push(array);
// Draco encoded meshes don't have bufferView in accessor
if (bufferView) {
// Create a new typed array as a view into the combined buffer
const {ArrayType, length} = getArrayTypeAndLength(accessor, bufferView);
const array = new ArrayType(arrayBuffer, bufferView.byteOffset, length);
// Store the metadata on the array (e.g. needed to determine number of components per element)
array.accessor = accessor;
accessorBuffers.push(array);
}
}

@@ -72,0 +73,0 @@

@@ -5,2 +5,3 @@ import {TextDecoder, fetchFile} from '@loaders.gl/core';

import {KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION} from './gltf-constants';
import {getFullUri} from './gltf-utils';

@@ -36,3 +37,3 @@ const DEFAULT_OPTIONS = {

const postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -82,3 +83,3 @@

const postProcessor = new GLTFPostProcessor();
postProcessor.postProcess(gltf, options);
postProcessor.postProcess(this.gltf, this.glbParser, options);
}

@@ -194,3 +195,3 @@

const fetch = options.fetch || window.fetch;
const uri = this._getFullUri(buffer.uri, options.uri);
const uri = getFullUri(buffer.uri, options.uri);
const response = await fetch(uri);

@@ -203,7 +204,2 @@ const arrayBuffer = await response.arrayBuffer();

_getFullUri(uri, base) {
const absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
}
// POST PROCESSING

@@ -253,3 +249,3 @@

const buffer = this._getBufferViewArray(compressedMesh.bufferView);
const decodedData = dracoDecoder.decodeMesh(buffer);
const decodedData = dracoDecoder.decode(buffer);
primitive.attributes = decodedData.attributes;

@@ -292,9 +288,10 @@ if (decodedData.indices) {

_getBufferViewArray(bufferViewIndex) {
const bufferView = this.gltf.bufferViews[bufferViewIndex];
if (this.glbParser) {
return this.glbParser.getBufferView(bufferViewIndex);
return this.glbParser.getBufferView(bufferView);
}
const bufferView = this.gltf.bufferViews[bufferViewIndex];
const buffer = this.gltf.buffers[bufferView.buffer].data;
const byteOffset = bufferView.byteOffset || 0;
return new Uint8Array(bufferView.buffer.data, byteOffset, bufferView.byteLength);
return new Uint8Array(buffer, byteOffset, bufferView.byteLength);
}

@@ -301,0 +298,0 @@

@@ -0,1 +1,3 @@

import {getFullUri} from './gltf-utils';
// This is a post processor for loaded glTF files

@@ -54,4 +56,6 @@ // The goal is to make the loaded data easier to use in WebGL applications

postProcess(gltf, options = {}) {
postProcess(gltf, glbParser, options = {}) {
this.gltf = gltf;
this.glbParser = glbParser;
this._resolveToTree(options);

@@ -217,3 +221,7 @@ return this.gltf;

accessor.id = `accessor-${index}`;
accessor.bufferView = this.getBufferView(accessor.bufferView);
if (accessor.bufferView !== undefined) {
// Draco encoded meshes don't have bufferView
accessor.bufferView = this.getBufferView(accessor.bufferView);
}
// Look up enums

@@ -270,3 +278,3 @@ accessor.bytesPerComponent = getBytesFromComponentType(accessor);

img.onload = () => resolve(img);
img.src = this._getFullUri(image.uri, options.uri);
img.src = getFullUri(image.uri, options.uri);
});

@@ -273,0 +281,0 @@ }

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 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 not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc