@loaders.gl/scene 5.0.0-alpha.5 → 5.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -9,6 +9,6 @@
9
9
  `;)this.offset++;else if(e==="/"&&this.source[this.offset+1]==="*"){for(this.offset+=2;this.offset<this.source.length&&!this.source.startsWith("*/",this.offset);)this.source[this.offset]===`
10
10
  `&&this.line++,this.offset++;this.offset+=2}else if(this.source.startsWith('"""',this.offset)){for(this.offset+=3;this.offset<this.source.length&&!this.source.startsWith('"""',this.offset);)this.source[this.offset]===`
11
11
  `&&this.line++,this.offset++;this.offset+=3}else break}}readQuotedString(e){this.offset++;let t="";for(;this.offset<this.source.length;){let n=this.source[this.offset++];if(n===e)break;if(n==="\\"&&this.offset<this.source.length){let r=this.source[this.offset++];t+=r==="n"?`
12
- `:r}else t+=n}return t}readDelimitedValue(e){this.offset++;let t=this.offset;for(;this.offset<this.source.length&&this.source[this.offset]!==e;)this.offset++;let n=this.source.slice(t,this.offset);return this.offset++,n}}});function V(s){let e=new DataView(s),t=ne(e),n=e.getUint16(t+10,!0),r=e.getUint32(t+16,!0),i=new Map,a=new TextDecoder;for(let c=0;c<n;c++){if(e.getUint32(r,!0)!==33639248)throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");let f=e.getUint16(r+10,!0),h=e.getUint32(r+20,!0),o=e.getUint16(r+28,!0),p=e.getUint16(r+30,!0),m=e.getUint16(r+32,!0),u=e.getUint32(r+42,!0),d=a.decode(new Uint8Array(s,r+46,o));if(f!==0)throw new Error(`USDZ entry "${d}" is compressed; USDZ requires stored ZIP entries.`);if(e.getUint32(u,!0)!==67324752)throw new Error(`USDZ entry "${d}" has an invalid local ZIP header.`);let l=e.getUint16(u+26,!0),D=e.getUint16(u+28,!0),g=u+30+l+D;i.set(d,s.slice(g,g+h)),r+=46+o+p+m}return i}function ne(s){let e=Math.max(0,s.byteLength-65557);for(let t=s.byteLength-22;t>=e;t--)if(s.getUint32(t,!0)===101010256)return t;throw new Error("USDZ archive does not contain a ZIP end-of-central-directory record.")}var $=k(()=>{"use strict"});async function R(s,e={},t){let n=oe(e.core?.baseUrl,t?.url),r={fetch:async a=>{let c=await(t?.fetch||fetch)(a);if(!(c instanceof Response))throw new Error(`OpenUSD reference "${a}" did not return an HTTP response.`);if(!c.ok)throw new Error(`Unable to load OpenUSD reference "${a}": ${c.status}.`);return c},cache:new Map,archiveFiles:new Map,layers:new Set,options:{...e,usd:{...he,...e.usd}}},i;if(de(s)){let a=V(s),c=Array.from(a.keys()).find(o=>/\.usda?$/i.test(o));if(!c)throw new Error("USDZ archives with binary USDC root layers are not implemented yet.");let f="https://usd.archive/";for(let[o,p]of a)r.archiveFiles.set(new URL(o,f).href,p);let h=new URL(c,f).href;i=P(a.get(c),h),i.format="usdz"}else i=P(s,n);return i.url&&r.layers.add(i.url),r.options.usd?.compose!==!1&&(i.rootPrims=await A(i.rootPrims,i.url,{},r,0)),i.layers=Array.from(r.layers),n&&(i.url=n),i}function oe(s,e){let t=Z(s);return t||Z(e)||s||e}function Z(s){try{return s?new URL(s).href:void 0}catch{return}}function ce(s,e){try{return new URL(s,e).href}catch{let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>=0?`${e.slice(0,t+1)}${s}`:s}}function P(s,e){if(M.decode(s.slice(0,8))===ie)throw new Error("Binary USDC crate layers are not implemented yet; use ASCII USDA layers.");return _(M.decode(s),e)}async function A(s,e,t,n,r){if(r>(n.options.usd?.maxReferenceDepth??12))throw new Error("OpenUSD reference composition exceeded the configured depth limit.");let i=[];for(let a of s){if(a.specifier==="class")continue;let f={...le(a.metadata.variants),...t,...n.options.usd?.variantSelections},h=a.sourceUrl||e,o=v(a);for(let[m,u]of Object.entries(o.variants)){let d=f[m]||Object.keys(u)[0],l=u[d];l&&(o=T(o,{...o,attributes:l.attributes,metadata:l.metadata,children:l.children,variants:{}}))}let p=W(o);if(n.options.usd?.loadReferences!==!1&&p.length>0)for(let m of p){if(!h)throw new Error("OpenUSD references require a source URL or options.core.baseUrl.");let u=ce(m.assetPath,h),d=await fe(u,n),l=ue(d,m.primPath),D=await A(l,u,f,n,r+1);for(let g of D)o=T(j(g,o.path),o)}o.children=await A(o.children,h,f,n,r),i.push(o)}return i}async function fe(s,e){let t=e.cache.get(s);return t||(t=(async()=>{let r=e.archiveFiles.get(s);if(!r){let a;try{a=await e.fetch(s)}catch(c){throw new Error(`Unable to fetch USD layer "${s}": ${String(c)}`)}r=a.arrayBuffer()}let i=P(await r,s);return e.layers.add(s),i})(),e.cache.set(s,t)),t}function ue(s,e){let t=e||s.metadata.defaultPrim;if(typeof t!="string")return s.rootPrims;let n=t.startsWith("/")?t:`/${t}`,r=F(s.rootPrims,n);return r?[r]:[]}function F(s,e){for(let t of s){if(t.path===e)return t;let n=F(t.children,e);if(n)return n}}function W(s){let e=[];for(let t of[s.metadata.references,s.metadata.payload,s.metadata.payloads])Array.isArray(t)?e.push(...t.filter(x)):x(t)&&e.push(t);return e}function le(s){return!s||typeof s!="object"||Array.isArray(s)||x(s)?{}:Object.fromEntries(Object.entries(s).filter(e=>typeof e[1]=="string"))}function x(s){return!!(s&&typeof s=="object"&&!Array.isArray(s)&&"assetPath"in s)}function v(s){return{...s,attributes:{...s.attributes},metadata:{...s.metadata},variants:{...s.variants},children:s.children.map(v)}}function j(s,e){let t=v(s);return t.path=e,t.children=t.children.map(n=>j(n,`${e}/${n.name}`)),t}function T(s,e){let t=s.children.map(v);for(let n of e.children){let r=t.findIndex(i=>i.name===n.name);r>=0?t[r]=T(t[r],n):t.push(v(n))}return{...s,...e,sourceUrl:W(e).length>0?e.sourceUrl:s.sourceUrl||e.sourceUrl,type:e.type||s.type,attributes:{...s.attributes,...e.attributes},metadata:{...s.metadata,...e.metadata},variants:{...s.variants,...e.variants},children:t}}function de(s){return s.byteLength>=4&&new DataView(s).getUint32(0,!0)===ae}var M,ie,ae,he,Y=k(()=>{"use strict";N();$();M=new TextDecoder,ie="PXR-USDC",ae=67324752;he={compose:!0,loadReferences:!0,maxReferenceDepth:12,variantSelections:{}}});var H={};O(H,{USDLoaderWithParser:()=>me});async function ke(s,e,t){return R(new TextEncoder().encode(s).buffer,e,t)}var Ae,pe,me,Q=k(()=>{"use strict";Y();L();({preload:Ae,...pe}=z),me={...pe,parse:R,parseText:ke}});async function Ue(){let{USDLoaderWithParser:s}=await Promise.resolve().then(()=>(Q(),H));return s}var ve,z,L=k(()=>{"use strict";ve="5.0.0-alpha.5";z={dataType:null,batchType:null,name:"Universal Scene Description",id:"usd",module:"scene",version:ve,extensions:["usd","usda","usdz"],mimeTypes:["model/vnd.usd","model/vnd.usda","model/vnd.usdz+zip"],text:!0,binary:!0,tests:["#usda","PK"],options:{usd:{compose:!0,loadReferences:!0,maxReferenceDepth:12,variantSelections:{}}},preload:Ue}});var U={};O(U,{USDLoader:()=>z});S(U,ee(C(),1));L();return te(U);})();
12
+ `:r}else t+=n}return t}readDelimitedValue(e){this.offset++;let t=this.offset;for(;this.offset<this.source.length&&this.source[this.offset]!==e;)this.offset++;let n=this.source.slice(t,this.offset);return this.offset++,n}}});function V(s){let e=new DataView(s),t=ne(e),n=e.getUint16(t+10,!0),r=e.getUint32(t+16,!0),i=new Map,a=new TextDecoder;for(let c=0;c<n;c++){if(e.getUint32(r,!0)!==33639248)throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");let f=e.getUint16(r+10,!0),h=e.getUint32(r+20,!0),o=e.getUint16(r+28,!0),p=e.getUint16(r+30,!0),m=e.getUint16(r+32,!0),u=e.getUint32(r+42,!0),d=a.decode(new Uint8Array(s,r+46,o));if(f!==0)throw new Error(`USDZ entry "${d}" is compressed; USDZ requires stored ZIP entries.`);if(e.getUint32(u,!0)!==67324752)throw new Error(`USDZ entry "${d}" has an invalid local ZIP header.`);let l=e.getUint16(u+26,!0),D=e.getUint16(u+28,!0),g=u+30+l+D;i.set(d,s.slice(g,g+h)),r+=46+o+p+m}return i}function ne(s){let e=Math.max(0,s.byteLength-65557);for(let t=s.byteLength-22;t>=e;t--)if(s.getUint32(t,!0)===101010256)return t;throw new Error("USDZ archive does not contain a ZIP end-of-central-directory record.")}var $=k(()=>{"use strict"});async function R(s,e={},t){let n=oe(e.core?.baseUrl,t?.url),r={fetch:async a=>{let c=await(t?.fetch||fetch)(a);if(!(c instanceof Response))throw new Error(`OpenUSD reference "${a}" did not return an HTTP response.`);if(!c.ok)throw new Error(`Unable to load OpenUSD reference "${a}": ${c.status}.`);return c},cache:new Map,archiveFiles:new Map,layers:new Set,options:{...e,usd:{...he,...e.usd}}},i;if(de(s)){let a=V(s),c=Array.from(a.keys()).find(o=>/\.usda?$/i.test(o));if(!c)throw new Error("USDZ archives with binary USDC root layers are not implemented yet.");let f="https://usd.archive/";for(let[o,p]of a)r.archiveFiles.set(new URL(o,f).href,p);let h=new URL(c,f).href;i=P(a.get(c),h),i.format="usdz"}else i=P(s,n);return i.url&&r.layers.add(i.url),r.options.usd?.compose!==!1&&(i.rootPrims=await A(i.rootPrims,i.url,{},r,0)),i.layers=Array.from(r.layers),n&&(i.url=n),i}function oe(s,e){let t=Z(s);return t||Z(e)||s||e}function Z(s){try{return s?new URL(s).href:void 0}catch{return}}function ce(s,e){try{return new URL(s,e).href}catch{let t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t>=0?`${e.slice(0,t+1)}${s}`:s}}function P(s,e){if(M.decode(s.slice(0,8))===ie)throw new Error("Binary USDC crate layers are not implemented yet; use ASCII USDA layers.");return _(M.decode(s),e)}async function A(s,e,t,n,r){if(r>(n.options.usd?.maxReferenceDepth??12))throw new Error("OpenUSD reference composition exceeded the configured depth limit.");let i=[];for(let a of s){if(a.specifier==="class")continue;let f={...le(a.metadata.variants),...t,...n.options.usd?.variantSelections},h=a.sourceUrl||e,o=v(a);for(let[m,u]of Object.entries(o.variants)){let d=f[m]||Object.keys(u)[0],l=u[d];l&&(o=T(o,{...o,attributes:l.attributes,metadata:l.metadata,children:l.children,variants:{}}))}let p=W(o);if(n.options.usd?.loadReferences!==!1&&p.length>0)for(let m of p){if(!h)throw new Error("OpenUSD references require a source URL or options.core.baseUrl.");let u=ce(m.assetPath,h),d=await fe(u,n),l=ue(d,m.primPath),D=await A(l,u,f,n,r+1);for(let g of D)o=T(j(g,o.path),o)}o.children=await A(o.children,h,f,n,r),i.push(o)}return i}async function fe(s,e){let t=e.cache.get(s);return t||(t=(async()=>{let r=e.archiveFiles.get(s);if(!r){let a;try{a=await e.fetch(s)}catch(c){throw new Error(`Unable to fetch USD layer "${s}": ${String(c)}`)}r=a.arrayBuffer()}let i=P(await r,s);return e.layers.add(s),i})(),e.cache.set(s,t)),t}function ue(s,e){let t=e||s.metadata.defaultPrim;if(typeof t!="string")return s.rootPrims;let n=t.startsWith("/")?t:`/${t}`,r=F(s.rootPrims,n);return r?[r]:[]}function F(s,e){for(let t of s){if(t.path===e)return t;let n=F(t.children,e);if(n)return n}}function W(s){let e=[];for(let t of[s.metadata.references,s.metadata.payload,s.metadata.payloads])Array.isArray(t)?e.push(...t.filter(x)):x(t)&&e.push(t);return e}function le(s){return!s||typeof s!="object"||Array.isArray(s)||x(s)?{}:Object.fromEntries(Object.entries(s).filter(e=>typeof e[1]=="string"))}function x(s){return!!(s&&typeof s=="object"&&!Array.isArray(s)&&"assetPath"in s)}function v(s){return{...s,attributes:{...s.attributes},metadata:{...s.metadata},variants:{...s.variants},children:s.children.map(v)}}function j(s,e){let t=v(s);return t.path=e,t.children=t.children.map(n=>j(n,`${e}/${n.name}`)),t}function T(s,e){let t=s.children.map(v);for(let n of e.children){let r=t.findIndex(i=>i.name===n.name);r>=0?t[r]=T(t[r],n):t.push(v(n))}return{...s,...e,sourceUrl:W(e).length>0?e.sourceUrl:s.sourceUrl||e.sourceUrl,type:e.type||s.type,attributes:{...s.attributes,...e.attributes},metadata:{...s.metadata,...e.metadata},variants:{...s.variants,...e.variants},children:t}}function de(s){return s.byteLength>=4&&new DataView(s).getUint32(0,!0)===ae}var M,ie,ae,he,Y=k(()=>{"use strict";N();$();M=new TextDecoder,ie="PXR-USDC",ae=67324752;he={compose:!0,loadReferences:!0,maxReferenceDepth:12,variantSelections:{}}});var H={};O(H,{USDLoaderWithParser:()=>me});async function ke(s,e,t){return R(new TextEncoder().encode(s).buffer,e,t)}var Ae,pe,me,Q=k(()=>{"use strict";Y();L();({preload:Ae,...pe}=z),me={...pe,parse:R,parseText:ke}});async function Ue(){let{USDLoaderWithParser:s}=await Promise.resolve().then(()=>(Q(),H));return s}var ve,z,L=k(()=>{"use strict";ve="5.0.0-alpha.6";z={dataType:null,batchType:null,name:"Universal Scene Description",id:"usd",module:"scene",version:ve,extensions:["usd","usda","usdz"],mimeTypes:["model/vnd.usd","model/vnd.usda","model/vnd.usdz+zip"],text:!0,binary:!0,tests:["#usda","PK"],options:{usd:{compose:!0,loadReferences:!0,maxReferenceDepth:12,variantSelections:{}}},preload:Ue}});var U={};O(U,{USDLoader:()=>z});S(U,ee(C(),1));L();return te(U);})();
13
13
  return __exports__;
14
14
  });
package/dist/index.cjs CHANGED
@@ -803,7 +803,7 @@ __export(index_exports, {
803
803
  module.exports = __toCommonJS(index_exports);
804
804
 
805
805
  // dist/usd-loader-types.js
806
- var VERSION2 = true ? "5.0.0-alpha.5" : "latest";
806
+ var VERSION2 = true ? "5.0.0-alpha.6" : "latest";
807
807
  async function preload2() {
808
808
  const { USDLoaderWithParser: USDLoaderWithParser2 } = await Promise.resolve().then(() => (init_usd_loader(), usd_loader_exports));
809
809
  return USDLoaderWithParser2;
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  // __VERSION__ is injected by babel-plugin-version-inline
5
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
- const VERSION = typeof "5.0.0-alpha.5" !== 'undefined' ? "5.0.0-alpha.5" : 'latest';
6
+ const VERSION = typeof "5.0.0-alpha.6" !== 'undefined' ? "5.0.0-alpha.6" : 'latest';
7
7
  /** Loads the parser-bearing USD loader implementation. */
8
8
  async function preload() {
9
9
  const { USDLoaderWithParser } = await import('@loaders.gl/scene/usd-loader');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/scene",
3
- "version": "5.0.0-alpha.5",
3
+ "version": "5.0.0-alpha.6",
4
4
  "description": "Framework-independent loaders for scene description formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,10 +46,10 @@
46
46
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
47
47
  },
48
48
  "dependencies": {
49
- "@loaders.gl/loader-utils": "5.0.0-alpha.5"
49
+ "@loaders.gl/loader-utils": "5.0.0-alpha.6"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@loaders.gl/core": "~5.0.0-alpha.0"
53
53
  },
54
- "gitHead": "0f6abae409f8d987337f5d7b7e6ba47bf72123b0"
54
+ "gitHead": "9b9ea7738e0fe63e55c19c136283705f99e0b9bf"
55
55
  }