Socket
Socket
Sign inDemoInstall

@loaders.gl/gltf

Package Overview
Dependencies
19
Maintainers
9
Versions
326
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-alpha.21 to 4.0.0-alpha.22

13

dist/es5/lib/extensions/KHR_draco_mesh_compression.js

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

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _loaderUtils = require("@loaders.gl/loader-utils");
var _draco = require("@loaders.gl/draco");
var _loaderUtils = require("@loaders.gl/loader-utils");
var _gltfScenegraph = require("../api/gltf-scenegraph");

@@ -110,3 +110,3 @@ var _gltfAttributeUtils = require("../gltf-utils/gltf-attribute-utils");

_decompressPrimitive = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(scenegraph, primitive, options, context) {
var dracoExtension, buffer, bufferCopy, parse, dracoOptions, decodedData, decodedAttributes, _i, _Object$entries, _Object$entries$_i, attributeName, decodedAttribute, accessorIndex, accessor;
var dracoExtension, buffer, bufferCopy, dracoOptions, decodedData, decodedAttributes, _i, _Object$entries, _Object$entries$_i, attributeName, decodedAttribute, accessorIndex, accessor;
return _regenerator.default.wrap(function _callee2$(_context3) {

@@ -124,8 +124,7 @@ while (1) switch (_context3.prev = _context3.next) {

bufferCopy = (0, _loaderUtils.sliceArrayBuffer)(buffer.buffer, buffer.byteOffset);
parse = context.parse;
dracoOptions = _objectSpread({}, options);
delete dracoOptions['3d-tiles'];
_context3.next = 10;
return parse(bufferCopy, _draco.DracoLoader, dracoOptions, context);
case 10:
_context3.next = 9;
return (0, _loaderUtils.parseFromContext)(bufferCopy, _draco.DracoLoader, dracoOptions, context);
case 9:
decodedData = _context3.sent;

@@ -150,3 +149,3 @@ decodedAttributes = (0, _gltfAttributeUtils.getGLTFAccessors)(decodedData.attributes);

checkPrimitive(primitive);
case 17:
case 16:
case "end":

@@ -153,0 +152,0 @@ return _context3.stop();

@@ -228,7 +228,6 @@ "use strict";

_loadImage = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(gltf, image, index, options, context) {
var fetch, parse, arrayBuffer, uri, response, array, parsedImage;
var arrayBuffer, uri, fetch, response, array, parsedImage;
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
fetch = context.fetch, parse = context.parse;
if (!(image.uri && !image.hasOwnProperty('bufferView'))) {

@@ -239,2 +238,3 @@ _context4.next = 10;

uri = (0, _resolveUrl.resolveUrl)(image.uri, options);
fetch = context.fetch;
_context4.next = 5;

@@ -258,3 +258,3 @@ return fetch(uri);

_context4.next = 14;
return parse(arrayBuffer, [_images.ImageLoader, _textures.BasisLoader], _objectSpread(_objectSpread({}, options), {}, {
return (0, _loaderUtils.parseFromContext)(arrayBuffer, [_images.ImageLoader, _textures.BasisLoader], _objectSpread(_objectSpread({}, options), {}, {
mimeType: image.mimeType,

@@ -261,0 +261,0 @@ basis: options.basis || {

@@ -7,4 +7,4 @@ "use strict";

exports.VERSION = void 0;
var VERSION = typeof "4.0.0-alpha.21" !== 'undefined' ? "4.0.0-alpha.21" : 'latest';
var VERSION = typeof "4.0.0-alpha.22" !== 'undefined' ? "4.0.0-alpha.22" : 'latest';
exports.VERSION = VERSION;
//# sourceMappingURL=version.js.map

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

import { sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
import { DracoLoader } from '@loaders.gl/draco';
import { sliceArrayBuffer } from '@loaders.gl/loader-utils';
import { GLTFScenegraph } from '../api/gltf-scenegraph';

@@ -43,5 +43,2 @@ import { getGLTFAccessors, getGLTFAccessor } from '../gltf-utils/gltf-attribute-utils';

const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
const {
parse
} = context;
const dracoOptions = {

@@ -51,3 +48,3 @@ ...options

delete dracoOptions['3d-tiles'];
const decodedData = await parse(bufferCopy, DracoLoader, dracoOptions, context);
const decodedData = await parseFromContext(bufferCopy, DracoLoader, dracoOptions, context);
const decodedAttributes = getGLTFAccessors(decodedData.attributes);

@@ -54,0 +51,0 @@ for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {

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

import { parseJSON, sliceArrayBuffer } from '@loaders.gl/loader-utils';
import { parseJSON, sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
import { ImageLoader } from '@loaders.gl/images';

@@ -115,9 +115,8 @@ import { BasisLoader, selectSupportedBasisFormat } from '@loaders.gl/textures';

async function loadImage(gltf, image, index, options, context) {
const {
fetch,
parse
} = context;
let arrayBuffer;
if (image.uri && !image.hasOwnProperty('bufferView')) {
const uri = resolveUrl(image.uri, options);
const {
fetch
} = context;
const response = await fetch(uri);

@@ -134,3 +133,3 @@ arrayBuffer = await response.arrayBuffer();

assert(arrayBuffer, 'glTF image has no data');
let parsedImage = await parse(arrayBuffer, [ImageLoader, BasisLoader], {
let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], {
...options,

@@ -137,0 +136,0 @@ mimeType: image.mimeType,

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

export const VERSION = typeof "4.0.0-alpha.21" !== 'undefined' ? "4.0.0-alpha.21" : 'latest';
export const VERSION = typeof "4.0.0-alpha.22" !== 'undefined' ? "4.0.0-alpha.22" : 'latest';
//# sourceMappingURL=version.js.map

@@ -0,4 +1,4 @@

import type { LoaderContext } from '@loaders.gl/loader-utils';
import type { GLTF } from '../types/gltf-json-schema';
import type { GLTFLoaderOptions } from '../../gltf-loader';
import type { LoaderContext } from '@loaders.gl/loader-utils';
/** Extension name */

@@ -5,0 +5,0 @@ export declare const name = "KHR_draco_mesh_compression";

@@ -7,4 +7,4 @@ "use strict";

exports.encode = exports.decode = exports.preprocess = exports.name = void 0;
const loader_utils_1 = require("@loaders.gl/loader-utils");
const draco_1 = require("@loaders.gl/draco");
const loader_utils_1 = require("@loaders.gl/loader-utils");
const gltf_scenegraph_1 = require("../api/gltf-scenegraph");

@@ -66,7 +66,6 @@ const gltf_attribute_utils_1 = require("../gltf-utils/gltf-attribute-utils");

const bufferCopy = (0, loader_utils_1.sliceArrayBuffer)(buffer.buffer, buffer.byteOffset); // , buffer.byteLength);
const { parse } = context;
const dracoOptions = { ...options };
// TODO - remove hack: The entire tileset might be included, too expensive to serialize
delete dracoOptions['3d-tiles'];
const decodedData = (await parse(bufferCopy, draco_1.DracoLoader, dracoOptions, context));
const decodedData = await (0, loader_utils_1.parseFromContext)(bufferCopy, draco_1.DracoLoader, dracoOptions, context);
const decodedAttributes = (0, gltf_attribute_utils_1.getGLTFAccessors)(decodedData.attributes);

@@ -73,0 +72,0 @@ // Restore min/max values

@@ -148,6 +148,6 @@ "use strict";

async function loadImage(gltf, image, index, options, context) {
const { fetch, parse } = context;
let arrayBuffer;
if (image.uri && !image.hasOwnProperty('bufferView')) {
const uri = (0, resolve_url_1.resolveUrl)(image.uri, options);
const { fetch } = context;
const response = await fetch(uri);

@@ -165,10 +165,11 @@ arrayBuffer = await response.arrayBuffer();

// Call `parse`
let parsedImage = await parse(arrayBuffer, [images_1.ImageLoader, textures_1.BasisLoader], {
let parsedImage = (await (0, loader_utils_1.parseFromContext)(arrayBuffer, [images_1.ImageLoader, textures_1.BasisLoader], {
...options,
mimeType: image.mimeType,
basis: options.basis || { format: (0, textures_1.selectSupportedBasisFormat)() }
}, context);
}, context));
if (parsedImage && parsedImage[0]) {
parsedImage = {
compressed: true,
// @ts-expect-error
mipmaps: false,

@@ -184,3 +185,4 @@ width: parsedImage[0].width,

gltf.images = gltf.images || [];
// @ts-expect-error TODO - sort out image typing asap
gltf.images[index] = parsedImage;
}
{
"name": "@loaders.gl/gltf",
"version": "4.0.0-alpha.21",
"version": "4.0.0-alpha.22",
"description": "Framework-independent loader for the glTF format",

@@ -37,9 +37,9 @@ "license": "MIT",

"dependencies": {
"@loaders.gl/draco": "4.0.0-alpha.21",
"@loaders.gl/images": "4.0.0-alpha.21",
"@loaders.gl/loader-utils": "4.0.0-alpha.21",
"@loaders.gl/textures": "4.0.0-alpha.21",
"@loaders.gl/draco": "4.0.0-alpha.22",
"@loaders.gl/images": "4.0.0-alpha.22",
"@loaders.gl/loader-utils": "4.0.0-alpha.22",
"@loaders.gl/textures": "4.0.0-alpha.22",
"@math.gl/core": "^3.5.1"
},
"gitHead": "df5d670b136192b26941396e944f9c46be788e83"
"gitHead": "0da838c506d1275383f2fd3d244d9c72b25397d2"
}

@@ -5,3 +5,8 @@ // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression

/* eslint-disable camelcase */
import type {LoaderContext} from '@loaders.gl/loader-utils';
import {sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';
import {DracoLoader} from '@loaders.gl/draco';
import {DracoLoaderOptions} from '@loaders.gl/draco';
import type {

@@ -15,6 +20,2 @@ GLTF,

import type {LoaderContext} from '@loaders.gl/loader-utils';
import {DracoLoader} from '@loaders.gl/draco';
import {DracoLoaderOptions, DracoMesh} from '@loaders.gl/draco';
import {sliceArrayBuffer} from '@loaders.gl/loader-utils';
import {GLTFScenegraph} from '../api/gltf-scenegraph';

@@ -104,3 +105,2 @@ import {getGLTFAccessors, getGLTFAccessor} from '../gltf-utils/gltf-attribute-utils';

const {parse} = context;
const dracoOptions: DracoLoaderOptions = {...options};

@@ -110,3 +110,3 @@

delete dracoOptions['3d-tiles'];
const decodedData = (await parse(bufferCopy, DracoLoader, dracoOptions, context)) as DracoMesh;
const decodedData = await parseFromContext(bufferCopy, DracoLoader, dracoOptions, context);

@@ -113,0 +113,0 @@ const decodedAttributes: {[key: string]: GLTFAccessor} = getGLTFAccessors(decodedData.attributes);

@@ -8,3 +8,4 @@ /* eslint-disable camelcase, max-statements, no-restricted-globals */

import {parseJSON, sliceArrayBuffer} from '@loaders.gl/loader-utils';
import type {ImageType, TextureLevel} from '@loaders.gl/schema';
import {parseJSON, sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';
import {ImageLoader} from '@loaders.gl/images';

@@ -202,4 +203,2 @@ import {BasisLoader, selectSupportedBasisFormat} from '@loaders.gl/textures';

) {
const {fetch, parse} = context;
let arrayBuffer;

@@ -209,3 +208,6 @@

const uri = resolveUrl(image.uri, options);
const {fetch} = context;
const response = await fetch(uri);
arrayBuffer = await response.arrayBuffer();

@@ -225,3 +227,3 @@ image.bufferView = {

// Call `parse`
let parsedImage = await parse(
let parsedImage = (await parseFromContext(
arrayBuffer,

@@ -235,3 +237,3 @@ [ImageLoader, BasisLoader],

context
);
)) as ImageType | TextureLevel[][];

@@ -241,2 +243,3 @@ if (parsedImage && parsedImage[0]) {

compressed: true,
// @ts-expect-error
mipmaps: false,

@@ -253,3 +256,4 @@ width: parsedImage[0].width,

gltf.images = gltf.images || [];
// @ts-expect-error TODO - sort out image typing asap
gltf.images[index] = parsedImage;
}

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 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc