@loaders.gl/draco 4.2.0-alpha.6 → 4.2.0-beta.1

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.dev.js CHANGED
@@ -45,13 +45,6 @@ var __exports__ = (() => {
45
45
  }
46
46
  });
47
47
 
48
- // (disabled):../worker-utils/src/lib/node/require-utils.node
49
- var require_require_utils = __commonJS({
50
- "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
51
- "use strict";
52
- }
53
- });
54
-
55
48
  // bundle.ts
56
49
  var bundle_exports = {};
57
50
  __export(bundle_exports, {
@@ -69,6 +62,8 @@ var __exports__ = (() => {
69
62
 
70
63
  // src/draco-loader.ts
71
64
  var DracoLoader = {
65
+ dataType: null,
66
+ batchType: null,
72
67
  name: "Draco",
73
68
  id: "draco",
74
69
  module: "draco",
@@ -223,7 +218,11 @@ var __exports__ = (() => {
223
218
  4: Uint16Array,
224
219
  5: Int32Array,
225
220
  6: Uint32Array,
221
+ // 7: BigInt64Array,
222
+ // 8: BigUint64Array,
226
223
  9: Float32Array
224
+ // 10: Float64Array
225
+ // 11: BOOL - What array type do we use for this?
227
226
  };
228
227
  var INDEX_ITEM_SIZE = 4;
229
228
  var DracoParser = class {
@@ -396,14 +395,17 @@ var __exports__ = (() => {
396
395
  for (const loaderAttribute of Object.values(loaderData.attributes)) {
397
396
  const attributeName = this._deduceAttributeName(loaderAttribute, options);
398
397
  loaderAttribute.name = attributeName;
399
- const { value, size } = this._getAttributeValues(dracoGeometry, loaderAttribute);
400
- attributes[attributeName] = {
401
- value,
402
- size,
403
- byteOffset: loaderAttribute.byte_offset,
404
- byteStride: loaderAttribute.byte_stride,
405
- normalized: loaderAttribute.normalized
406
- };
398
+ const values = this._getAttributeValues(dracoGeometry, loaderAttribute);
399
+ if (values) {
400
+ const { value, size } = values;
401
+ attributes[attributeName] = {
402
+ value,
403
+ size,
404
+ byteOffset: loaderAttribute.byte_offset,
405
+ byteStride: loaderAttribute.byte_stride,
406
+ normalized: loaderAttribute.normalized
407
+ };
408
+ }
407
409
  }
408
410
  return attributes;
409
411
  }
@@ -445,6 +447,10 @@ var __exports__ = (() => {
445
447
  */
446
448
  _getAttributeValues(dracoGeometry, attribute) {
447
449
  const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
450
+ if (!TypedArrayCtor) {
451
+ console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`);
452
+ return null;
453
+ }
448
454
  const numComponents = attribute.num_components;
449
455
  const numPoints = dracoGeometry.num_points();
450
456
  const numValues = numPoints * numComponents;
@@ -697,7 +703,6 @@ var __exports__ = (() => {
697
703
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
698
704
 
699
705
  // ../worker-utils/src/lib/library-utils/library-utils.ts
700
- var node = __toESM(require_require_utils(), 1);
701
706
  var loadLibraryPromises = {};
702
707
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
703
708
  if (moduleName) {
@@ -734,7 +739,8 @@ var __exports__ = (() => {
734
739
  }
735
740
  if (!isBrowser) {
736
741
  try {
737
- return node && void 0 && await (void 0)(libraryUrl);
742
+ const { requireFromFile } = globalThis.loaders || {};
743
+ return await requireFromFile?.(libraryUrl);
738
744
  } catch (error) {
739
745
  console.error(error);
740
746
  return null;
@@ -748,7 +754,8 @@ var __exports__ = (() => {
748
754
  }
749
755
  function loadLibraryFromString(scriptSource, id) {
750
756
  if (!isBrowser) {
751
- return void 0 && (void 0)(scriptSource, id);
757
+ const { requireFromString } = globalThis.loaders || {};
758
+ return requireFromString?.(scriptSource, id);
752
759
  }
753
760
  if (isWorker) {
754
761
  eval.call(globalThis, scriptSource);
@@ -765,18 +772,20 @@ var __exports__ = (() => {
765
772
  return null;
766
773
  }
767
774
  async function loadAsArrayBuffer(url) {
768
- if (isBrowser || !void 0 || url.startsWith("http")) {
775
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
776
+ if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
769
777
  const response = await fetch(url);
770
778
  return await response.arrayBuffer();
771
779
  }
772
- return await (void 0)(url);
780
+ return await readFileAsArrayBuffer(url);
773
781
  }
774
782
  async function loadAsText(url) {
775
- if (isBrowser || !void 0 || url.startsWith("http")) {
783
+ const { readFileAsText } = globalThis.loaders || {};
784
+ if (isBrowser || !readFileAsText || url.startsWith("http")) {
776
785
  const response = await fetch(url);
777
786
  return await response.text();
778
787
  }
779
- return await (void 0)(url);
788
+ return await readFileAsText(url);
780
789
  }
781
790
 
782
791
  // src/lib/draco-module-loader.ts
@@ -804,22 +813,22 @@ var __exports__ = (() => {
804
813
  async function loadDracoDecoderModule(options) {
805
814
  const modules = options.modules || {};
806
815
  if (modules.draco3d) {
807
- loadDecoderPromise = loadDecoderPromise || modules.draco3d.createDecoderModule({}).then((draco) => {
816
+ loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
808
817
  return { draco };
809
818
  });
810
819
  } else {
811
- loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
820
+ loadDecoderPromise ||= loadDracoDecoder(options);
812
821
  }
813
822
  return await loadDecoderPromise;
814
823
  }
815
824
  async function loadDracoEncoderModule(options) {
816
825
  const modules = options.modules || {};
817
826
  if (modules.draco3d) {
818
- loadEncoderPromise = loadEncoderPromise || modules.draco3d.createEncoderModule({}).then((draco) => {
827
+ loadEncoderPromise ||= modules.draco3d.createEncoderModule({}).then((draco) => {
819
828
  return { draco };
820
829
  });
821
830
  } else {
822
- loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);
831
+ loadEncoderPromise ||= loadDracoEncoder(options);
823
832
  }
824
833
  return await loadEncoderPromise;
825
834
  }
@@ -1104,8 +1113,10 @@ var __exports__ = (() => {
1104
1113
  case Uint32Array:
1105
1114
  return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));
1106
1115
  case Float32Array:
1107
- default:
1108
1116
  return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));
1117
+ default:
1118
+ console.warn("Unsupported attribute type", attribute);
1119
+ return -1;
1109
1120
  }
1110
1121
  }
1111
1122
  /**
package/dist/dist.min.js CHANGED
@@ -4,8 +4,8 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var K=Object.create;var I=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var rt=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),ot=(o,t)=>{for(var e in t)I(o,e,{get:t[e],enumerable:!0})},O=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!et.call(o,n)&&n!==e&&I(o,n,{get:()=>t[n],enumerable:!(r=Z(t,n))||r.enumerable});return o},M=(o,t,e)=>(O(o,t,"default"),e&&O(e,t,"default")),nt=(o,t,e)=>(e=o!=null?K(tt(o)):{},O(t||!o||!o.__esModule?I(e,"default",{value:o,enumerable:!0}):e,o)),at=o=>O(I({},"__esModule",{value:!0}),o);var B=rt((Lt,N)=>{N.exports=globalThis.loaders});var w={};ot(w,{DRACO_EXTERNAL_LIBRARIES:()=>u,DRACO_EXTERNAL_LIBRARY_URLS:()=>b,DracoLoader:()=>Mt,DracoWorkerLoader:()=>x,DracoWriter:()=>H,DracoWriterWorker:()=>It});M(w,nt(B(),1));var y="4.2.0-alpha.5";var x={name:"Draco",id:"draco",module:"draco",version:y,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function P(o){switch(o.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function L(o){let t=1/0,e=1/0,r=1/0,n=-1/0,a=-1/0,i=-1/0,s=o.POSITION?o.POSITION.value:[],c=s&&s.length;for(let d=0;d<c;d+=3){let f=s[d],m=s[d+1],A=s[d+2];t=f<t?f:t,e=m<e?m:e,r=A<r?A:r,n=f>n?f:n,a=m>a?m:a,i=A>i?A:i}return[[t,e,r],[n,a,i]]}function C(o,t,e){let r=P(t.value),n=e||k(t);return{name:o,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:n}}function k(o){let t={};return"byteOffset"in o&&(t.byteOffset=o.byteOffset.toString(10)),"byteStride"in o&&(t.byteStride=o.byteStride.toString(10)),"normalized"in o&&(t.normalized=o.normalized.toString()),t}function U(o,t,e){let r=W(t.metadata),n=[],a=it(t.attributes);for(let i in o){let s=o[i],c=z(i,s,a[i]);n.push(c)}if(e){let i=z("indices",e);n.push(i)}return{fields:n,metadata:r}}function it(o){let t={};for(let e in o){let r=o[e];t[r.name||"undefined"]=r}return t}function z(o,t,e){let r=e?W(e.metadata):void 0;return C(o,t,r)}function W(o){Object.entries(o);let t={};for(let e in o)t[`${e}.string`]=JSON.stringify(o[e]);return t}var $={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},st={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},ct=4,g=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){let r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);let n=this.decoder.GetEncodedGeometryType(r),a=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(n){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(r,a);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(r,a);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!a.ptr){let A=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(A)}let s=this._getDracoLoaderData(a,n,e),c=this._getMeshData(a,s,e),d=L(c.attributes),f=U(c.attributes,s,c.indices);return{loader:"draco",loaderData:s,header:{vertexCount:a.num_points(),boundingBox:d},...c,schema:f}}finally{this.draco.destroy(r),a&&this.draco.destroy(a)}}_getDracoLoaderData(t,e,r){let n=this._getTopLevelMetadata(t),a=this._getDracoAttributes(t,r);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:n,attributes:a}}_getDracoAttributes(t,e){let r={};for(let n=0;n<t.num_attributes();n++){let a=this.decoder.GetAttribute(t,n),i=this._getAttributeMetadata(t,n);r[a.unique_id()]={unique_id:a.unique_id(),attribute_type:a.attribute_type(),data_type:a.data_type(),num_components:a.num_components(),byte_offset:a.byte_offset(),byte_stride:a.byte_stride(),normalized:a.normalized(),attribute_index:n,metadata:i};let s=this._getQuantizationTransform(a,e);s&&(r[a.unique_id()].quantization_transform=s);let c=this._getOctahedronTransform(a,e);c&&(r[a.unique_id()].octahedron_transform=c)}return r}_getMeshData(t,e,r){let n=this._getMeshAttributes(e,t,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(t,e,r){let n={};for(let a of Object.values(t.attributes)){let i=this._deduceAttributeName(a,r);a.name=i;let{value:s,size:c}=this._getAttributeValues(e,a);n[i]={value:s,size:c,byteOffset:a.byte_offset,byteStride:a.byte_stride,normalized:a.normalized}}return n}_getTriangleListIndices(t){let r=t.num_faces()*3,n=r*ct,a=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(t,n,a),new Uint32Array(this.draco.HEAPF32.buffer,a,r).slice()}finally{this.draco._free(a)}}_getTriangleStripIndices(t){let e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),lt(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){let r=st[e.data_type],n=e.num_components,i=t.num_points()*n,s=i*r.BYTES_PER_ELEMENT,c=dt(this.draco,r),d,f=this.draco._malloc(s);try{let m=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,m,c,s,f),d=new r(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:d,size:n}}_deduceAttributeName(t,e){let r=t.unique_id;for(let[i,s]of Object.entries(e.extraAttributes||{}))if(s===r)return i;let n=t.attribute_type;for(let i in $)if(this.draco[i]===n)return $[i];let a=e.attributeNameEntry||"name";return t.metadata[a]?t.metadata[a].string:`CUSTOM_ATTRIBUTE_${r}`}_getTopLevelMetadata(t){let e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){let r=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(r)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let e={},r=this.metadataQuerier.NumEntries(t);for(let n=0;n<r;n++){let a=this.metadataQuerier.GetEntryName(t,n);e[a]=this._getDracoMetadataField(t,a)}return e}_getDracoMetadataField(t,e){let r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,r);let n=ut(r);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(t){let{quantizedAttributes:e=[],octahedronAttributes:r=[]}=t,n=[...e,...r];for(let a of n)this.decoder.SkipAttributeTransform(this.draco[a])}_getQuantizationTransform(t,e){let{quantizedAttributes:r=[]}=e,n=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(s=>i.min_value(s))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(t,e){let{octahedronAttributes:r=[]}=e,n=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function dt(o,t){switch(t){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32;default:return o.DT_INVALID}}function ut(o){let t=o.size(),e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=o.GetValue(r);return e}function lt(o){let t=o.size(),e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=o.GetValue(r);return e}function ft(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-alpha.5"),globalThis._loadersgl_.version}var v=ft();function j(o,t){if(!o)throw new Error(t||"loaders.gl assertion failed.")}var h={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Ht=h.self||h.window||h.global||{},Kt=h.window||h.self||h.global||{},Zt=h.global||h.self||h.window||{},Jt=h.document||{};var p=typeof process!="object"||String(process)!=="[object process]"||process.browser,R=typeof importScripts=="function",te=typeof window<"u"&&typeof window.orientation<"u",q=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),ee=q&&parseFloat(q[1])||0;var l={};var S={};async function _(o,t=null,e={},r=null){return t&&(o=V(o,t,e,r)),S[o]=S[o]||ht(o),await S[o]}function V(o,t,e={},r=null){if(!e.useLocalLibraries&&o.startsWith("http"))return o;r=r||o;let n=e.modules||{};return n[r]?n[r]:p?e.CDN?(j(e.CDN.startsWith("http")),`${e.CDN}/${t}@${v}/dist/libs/${r}`):R?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function ht(o){if(o.endsWith("wasm"))return await At(o);if(!p)try{return l&&void 0&&await(void 0)(o)}catch(e){return console.error(e),null}if(R)return importScripts(o);let t=await yt(o);return mt(t,o)}function mt(o,t){if(!p)return void 0&&(void 0)(o,t);if(R)return eval.call(globalThis,o),null;let e=document.createElement("script");e.id=t;try{e.appendChild(document.createTextNode(o))}catch{e.text=o}return document.body.appendChild(e),null}async function At(o){return p||!void 0||o.startsWith("http")?await(await fetch(o)).arrayBuffer():await(void 0)(o)}async function yt(o){return p||!void 0||o.startsWith("http")?await(await fetch(o)).text():await(void 0)(o)}var pt="1.5.6",_t="1.4.1",F=`https://www.gstatic.com/draco/versioned/decoders/${pt}`,u={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},b={[u.DECODER]:`${F}/${u.DECODER}`,[u.DECODER_WASM]:`${F}/${u.DECODER_WASM}`,[u.FALLBACK_DECODER]:`${F}/${u.FALLBACK_DECODER}`,[u.ENCODER]:`https://raw.githubusercontent.com/google/draco/${_t}/javascript/${u.ENCODER}`},T,D;async function G(o){let t=o.modules||{};return t.draco3d?T=T||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):T=T||bt(o),await T}async function Q(o){let t=o.modules||{};return t.draco3d?D=D||t.draco3d.createEncoderModule({}).then(e=>({draco:e})):D=D||Tt(o),await D}async function bt(o){let t,e;switch(o.draco&&o.draco.decoderType){case"js":t=await _(b[u.FALLBACK_DECODER],"draco",o,u.FALLBACK_DECODER);break;case"wasm":default:[t,e]=await Promise.all([await _(b[u.DECODER],"draco",o,u.DECODER),await _(b[u.DECODER_WASM],"draco",o,u.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await gt(t,e)}function gt(o,t){let e={};return t&&(e.wasmBinary=t),new Promise(r=>{o({...e,onModuleLoaded:n=>r({draco:n})})})}async function Tt(o){let t=await _(b[u.ENCODER],"draco",o,u.ENCODER);return t=t||globalThis.DracoEncoderModule,new Promise(e=>{t({onModuleLoaded:r=>e({draco:r})})})}var X={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},Dt=()=>{},E=class{draco;dracoEncoder;dracoMeshBuilder;dracoMetadataBuilder;log;constructor(t){this.draco=t,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.dracoMetadataBuilder=new this.draco.MetadataBuilder}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.destroyEncodedObject(this.dracoMetadataBuilder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(t){t&&this.draco.destroy(t)}encodeSync(t,e={}){return this.log=Dt,this._setOptions(e),e.pointcloud?this._encodePointCloud(t,e):this._encodeMesh(t,e)}_getAttributesFromMesh(t){let e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t,e){let r=new this.draco.PointCloud;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoPointCloud(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(r,!1,a);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points
8
- with ${r.num_attributes()} attributes into ${i} bytes`),Y(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_encodeMesh(t,e){let r=new this.draco.Mesh;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoMesh(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(r,a);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points
9
- with ${r.num_attributes()} attributes into ${i} bytes`),Y(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_setOptions(t){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){let e=this.draco[t.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(let e in t.quantization){let r=t.quantization[e],n=this.draco[e];this.dracoEncoder.SetAttributeQuantization(n,r)}}_createDracoMesh(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=X[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_createDracoPointCloud(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=X[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_addAttributeToMesh(t,e,r,n){if(!ArrayBuffer.isView(r))return-1;let a=this._getDracoAttributeType(e),i=r.length/n;if(a==="indices"){let d=r.length/3;return this.log(`Adding attribute ${e}, size ${d}`),this.dracoMeshBuilder.AddFacesToMesh(t,d,r),-1}this.log(`Adding attribute ${e}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=r;switch(r.constructor){case Int8Array:return s.AddInt8Attribute(t,a,n,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(t,a,n,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(t,a,n,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(t,a,n,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(t,a,n,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(t,a,n,i,new Uint32Array(c));case Float32Array:default:return s.AddFloatAttribute(t,a,n,i,new Float32Array(c))}}_getDracoAttributeType(t){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texcoord":case"texcoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(let e in t){let r=t[e];if(this._getDracoAttributeType(e)===this.draco.POSITION)return r}return null}_addGeometryMetadata(t,e){let r=new this.draco.Metadata;this._populateDracoMetadata(r,e),this.dracoMeshBuilder.AddMetadata(t,r)}_addAttributeMetadata(t,e,r){let n=new this.draco.Metadata;this._populateDracoMetadata(n,r),this.dracoMeshBuilder.SetMetadataForAttribute(t,e,n)}_populateDracoMetadata(t,e){for(let[r,n]of Et(e))switch(typeof n){case"number":Math.trunc(n)===n?this.dracoMetadataBuilder.AddIntEntry(t,r,n):this.dracoMetadataBuilder.AddDoubleEntry(t,r,n);break;case"object":n instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(t,r,n,n.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(t,r,n)}}};function Y(o){let t=o.size(),e=new ArrayBuffer(t),r=new Int8Array(e);for(let n=0;n<t;++n)r[n]=o.GetValue(n);return e}function Et(o){return o.entries&&!o.hasOwnProperty("entries")?o.entries():Object.entries(o)}var wt={pointcloud:!1,attributeNameEntry:"name"},H={name:"DRACO",id:"draco",module:"draco",version:y,extensions:["drc"],options:{draco:wt},encode:Ot};async function Ot(o,t={}){let{draco:e}=await Q(t),r=new E(e);try{return r.encodeSync(o,t.draco)}finally{r.destroy()}}var It={id:"draco-writer",name:"Draco compressed geometry writer",module:"draco",version:y,worker:!0,options:{draco:{},source:null}};var Mt={...x,parse:Rt};async function Rt(o,t){let{draco:e}=await G(t),r=new g(e);try{return r.parseSync(o,t?.draco)}finally{r.destroy()}}return at(w);})();
7
+ "use strict";var __exports__=(()=>{var H=Object.create;var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var et=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),rt=(o,t)=>{for(var e in t)E(o,e,{get:t[e],enumerable:!0})},D=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!tt.call(o,n)&&n!==e&&E(o,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return o},w=(o,t,e)=>(D(o,t,"default"),e&&D(e,t,"default")),ot=(o,t,e)=>(e=o!=null?H(J(o)):{},D(t||!o||!o.__esModule?E(e,"default",{value:o,enumerable:!0}):e,o)),nt=o=>D(E({},"__esModule",{value:!0}),o);var F=et((xt,N)=>{N.exports=globalThis.loaders});var T={};rt(T,{DRACO_EXTERNAL_LIBRARIES:()=>u,DRACO_EXTERNAL_LIBRARY_URLS:()=>_,DracoLoader:()=>It,DracoWorkerLoader:()=>I,DracoWriter:()=>Y,DracoWriterWorker:()=>Ot});w(T,ot(F(),1));var A="4.2.0-alpha.6";var I={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:A,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function B(o){switch(o.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function M(o){let t=1/0,e=1/0,r=1/0,n=-1/0,a=-1/0,i=-1/0,s=o.POSITION?o.POSITION.value:[],c=s&&s.length;for(let d=0;d<c;d+=3){let l=s[d],h=s[d+1],m=s[d+2];t=l<t?l:t,e=h<e?h:e,r=m<r?m:r,n=l>n?l:n,a=h>a?h:a,i=m>i?m:i}return[[t,e,r],[n,a,i]]}function R(o,t,e){let r=B(t.value),n=e||P(t);return{name:o,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:n}}function P(o){let t={};return"byteOffset"in o&&(t.byteOffset=o.byteOffset.toString(10)),"byteStride"in o&&(t.byteStride=o.byteStride.toString(10)),"normalized"in o&&(t.normalized=o.normalized.toString()),t}function U(o,t,e){let r=z(t.metadata),n=[],a=at(t.attributes);for(let i in o){let s=o[i],c=k(i,s,a[i]);n.push(c)}if(e){let i=k("indices",e);n.push(i)}return{fields:n,metadata:r}}function at(o){let t={};for(let e in o){let r=o[e];t[r.name||"undefined"]=r}return t}function k(o,t,e){let r=e?z(e.metadata):void 0;return R(o,t,r)}function z(o){Object.entries(o);let t={};for(let e in o)t[`${e}.string`]=JSON.stringify(o[e]);return t}var W={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},it={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},st=4,b=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){let r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);let n=this.decoder.GetEncodedGeometryType(r),a=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(n){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(r,a);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(r,a);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!a.ptr){let m=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(m)}let s=this._getDracoLoaderData(a,n,e),c=this._getMeshData(a,s,e),d=M(c.attributes),l=U(c.attributes,s,c.indices);return{loader:"draco",loaderData:s,header:{vertexCount:a.num_points(),boundingBox:d},...c,schema:l}}finally{this.draco.destroy(r),a&&this.draco.destroy(a)}}_getDracoLoaderData(t,e,r){let n=this._getTopLevelMetadata(t),a=this._getDracoAttributes(t,r);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:n,attributes:a}}_getDracoAttributes(t,e){let r={};for(let n=0;n<t.num_attributes();n++){let a=this.decoder.GetAttribute(t,n),i=this._getAttributeMetadata(t,n);r[a.unique_id()]={unique_id:a.unique_id(),attribute_type:a.attribute_type(),data_type:a.data_type(),num_components:a.num_components(),byte_offset:a.byte_offset(),byte_stride:a.byte_stride(),normalized:a.normalized(),attribute_index:n,metadata:i};let s=this._getQuantizationTransform(a,e);s&&(r[a.unique_id()].quantization_transform=s);let c=this._getOctahedronTransform(a,e);c&&(r[a.unique_id()].octahedron_transform=c)}return r}_getMeshData(t,e,r){let n=this._getMeshAttributes(e,t,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(t,e,r){let n={};for(let a of Object.values(t.attributes)){let i=this._deduceAttributeName(a,r);a.name=i;let s=this._getAttributeValues(e,a);if(s){let{value:c,size:d}=s;n[i]={value:c,size:d,byteOffset:a.byte_offset,byteStride:a.byte_stride,normalized:a.normalized}}}return n}_getTriangleListIndices(t){let r=t.num_faces()*3,n=r*st,a=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(t,n,a),new Uint32Array(this.draco.HEAPF32.buffer,a,r).slice()}finally{this.draco._free(a)}}_getTriangleStripIndices(t){let e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),ut(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){let r=it[e.data_type];if(!r)return console.warn(`DRACO: Unsupported attribute type ${e.data_type}`),null;let n=e.num_components,i=t.num_points()*n,s=i*r.BYTES_PER_ELEMENT,c=ct(this.draco,r),d,l=this.draco._malloc(s);try{let h=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,h,c,s,l),d=new r(this.draco.HEAPF32.buffer,l,i).slice()}finally{this.draco._free(l)}return{value:d,size:n}}_deduceAttributeName(t,e){let r=t.unique_id;for(let[i,s]of Object.entries(e.extraAttributes||{}))if(s===r)return i;let n=t.attribute_type;for(let i in W)if(this.draco[i]===n)return W[i];let a=e.attributeNameEntry||"name";return t.metadata[a]?t.metadata[a].string:`CUSTOM_ATTRIBUTE_${r}`}_getTopLevelMetadata(t){let e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){let r=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(r)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let e={},r=this.metadataQuerier.NumEntries(t);for(let n=0;n<r;n++){let a=this.metadataQuerier.GetEntryName(t,n);e[a]=this._getDracoMetadataField(t,a)}return e}_getDracoMetadataField(t,e){let r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,r);let n=dt(r);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(t){let{quantizedAttributes:e=[],octahedronAttributes:r=[]}=t,n=[...e,...r];for(let a of n)this.decoder.SkipAttributeTransform(this.draco[a])}_getQuantizationTransform(t,e){let{quantizedAttributes:r=[]}=e,n=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(s=>i.min_value(s))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(t,e){let{octahedronAttributes:r=[]}=e,n=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function ct(o,t){switch(t){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32;default:return o.DT_INVALID}}function dt(o){let t=o.size(),e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=o.GetValue(r);return e}function ut(o){let t=o.size(),e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=o.GetValue(r);return e}function lt(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-alpha.6"),globalThis._loadersgl_.version}var $=lt();function v(o,t){if(!o)throw new Error(t||"loaders.gl assertion failed.")}var f={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Yt=f.self||f.window||f.global||{},Ht=f.window||f.self||f.global||{},Kt=f.global||f.self||f.window||{},Zt=f.document||{};var y=typeof process!="object"||String(process)!=="[object process]"||process.browser,O=typeof importScripts=="function",Jt=typeof window<"u"&&typeof window.orientation<"u",j=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),te=j&&parseFloat(j[1])||0;var x={};async function p(o,t=null,e={},r=null){return t&&(o=V(o,t,e,r)),x[o]=x[o]||ft(o),await x[o]}function V(o,t,e={},r=null){if(!e.useLocalLibraries&&o.startsWith("http"))return o;r=r||o;let n=e.modules||{};return n[r]?n[r]:y?e.CDN?(v(e.CDN.startsWith("http")),`${e.CDN}/${t}@${$}/dist/libs/${r}`):O?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function ft(o){if(o.endsWith("wasm"))return await mt(o);if(!y)try{let{requireFromFile:e}=globalThis.loaders||{};return await e?.(o)}catch(e){return console.error(e),null}if(O)return importScripts(o);let t=await At(o);return ht(t,o)}function ht(o,t){if(!y){let{requireFromString:r}=globalThis.loaders||{};return r?.(o,t)}if(O)return eval.call(globalThis,o),null;let e=document.createElement("script");e.id=t;try{e.appendChild(document.createTextNode(o))}catch{e.text=o}return document.body.appendChild(e),null}async function mt(o){let{readFileAsArrayBuffer:t}=globalThis.loaders||{};return y||!t||o.startsWith("http")?await(await fetch(o)).arrayBuffer():await t(o)}async function At(o){let{readFileAsText:t}=globalThis.loaders||{};return y||!t||o.startsWith("http")?await(await fetch(o)).text():await t(o)}var yt="1.5.6",pt="1.4.1",L=`https://www.gstatic.com/draco/versioned/decoders/${yt}`,u={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},_={[u.DECODER]:`${L}/${u.DECODER}`,[u.DECODER_WASM]:`${L}/${u.DECODER_WASM}`,[u.FALLBACK_DECODER]:`${L}/${u.FALLBACK_DECODER}`,[u.ENCODER]:`https://raw.githubusercontent.com/google/draco/${pt}/javascript/${u.ENCODER}`},C,S;async function q(o){let t=o.modules||{};return t.draco3d?C||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):C||=_t(o),await C}async function G(o){let t=o.modules||{};return t.draco3d?S||=t.draco3d.createEncoderModule({}).then(e=>({draco:e})):S||=gt(o),await S}async function _t(o){let t,e;switch(o.draco&&o.draco.decoderType){case"js":t=await p(_[u.FALLBACK_DECODER],"draco",o,u.FALLBACK_DECODER);break;case"wasm":default:[t,e]=await Promise.all([await p(_[u.DECODER],"draco",o,u.DECODER),await p(_[u.DECODER_WASM],"draco",o,u.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await bt(t,e)}function bt(o,t){let e={};return t&&(e.wasmBinary=t),new Promise(r=>{o({...e,onModuleLoaded:n=>r({draco:n})})})}async function gt(o){let t=await p(_[u.ENCODER],"draco",o,u.ENCODER);return t=t||globalThis.DracoEncoderModule,new Promise(e=>{t({onModuleLoaded:r=>e({draco:r})})})}var Q={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},Tt=()=>{},g=class{draco;dracoEncoder;dracoMeshBuilder;dracoMetadataBuilder;log;constructor(t){this.draco=t,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.dracoMetadataBuilder=new this.draco.MetadataBuilder}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.destroyEncodedObject(this.dracoMetadataBuilder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(t){t&&this.draco.destroy(t)}encodeSync(t,e={}){return this.log=Tt,this._setOptions(e),e.pointcloud?this._encodePointCloud(t,e):this._encodeMesh(t,e)}_getAttributesFromMesh(t){let e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t,e){let r=new this.draco.PointCloud;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoPointCloud(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(r,!1,a);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points
8
+ with ${r.num_attributes()} attributes into ${i} bytes`),X(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_encodeMesh(t,e){let r=new this.draco.Mesh;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoMesh(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(r,a);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points
9
+ with ${r.num_attributes()} attributes into ${i} bytes`),X(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_setOptions(t){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){let e=this.draco[t.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(let e in t.quantization){let r=t.quantization[e],n=this.draco[e];this.dracoEncoder.SetAttributeQuantization(n,r)}}_createDracoMesh(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=Q[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_createDracoPointCloud(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=Q[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_addAttributeToMesh(t,e,r,n){if(!ArrayBuffer.isView(r))return-1;let a=this._getDracoAttributeType(e),i=r.length/n;if(a==="indices"){let d=r.length/3;return this.log(`Adding attribute ${e}, size ${d}`),this.dracoMeshBuilder.AddFacesToMesh(t,d,r),-1}this.log(`Adding attribute ${e}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=r;switch(r.constructor){case Int8Array:return s.AddInt8Attribute(t,a,n,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(t,a,n,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(t,a,n,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(t,a,n,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(t,a,n,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(t,a,n,i,new Uint32Array(c));case Float32Array:return s.AddFloatAttribute(t,a,n,i,new Float32Array(c));default:return console.warn("Unsupported attribute type",r),-1}}_getDracoAttributeType(t){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texcoord":case"texcoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(let e in t){let r=t[e];if(this._getDracoAttributeType(e)===this.draco.POSITION)return r}return null}_addGeometryMetadata(t,e){let r=new this.draco.Metadata;this._populateDracoMetadata(r,e),this.dracoMeshBuilder.AddMetadata(t,r)}_addAttributeMetadata(t,e,r){let n=new this.draco.Metadata;this._populateDracoMetadata(n,r),this.dracoMeshBuilder.SetMetadataForAttribute(t,e,n)}_populateDracoMetadata(t,e){for(let[r,n]of Dt(e))switch(typeof n){case"number":Math.trunc(n)===n?this.dracoMetadataBuilder.AddIntEntry(t,r,n):this.dracoMetadataBuilder.AddDoubleEntry(t,r,n);break;case"object":n instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(t,r,n,n.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(t,r,n)}}};function X(o){let t=o.size(),e=new ArrayBuffer(t),r=new Int8Array(e);for(let n=0;n<t;++n)r[n]=o.GetValue(n);return e}function Dt(o){return o.entries&&!o.hasOwnProperty("entries")?o.entries():Object.entries(o)}var Et={pointcloud:!1,attributeNameEntry:"name"},Y={name:"DRACO",id:"draco",module:"draco",version:A,extensions:["drc"],options:{draco:Et},encode:wt};async function wt(o,t={}){let{draco:e}=await G(t),r=new g(e);try{return r.encodeSync(o,t.draco)}finally{r.destroy()}}var Ot={id:"draco-writer",name:"Draco compressed geometry writer",module:"draco",version:A,worker:!0,options:{draco:{},source:null}};var It={...I,parse:Mt};async function Mt(o,t){let{draco:e}=await q(t),r=new b(e);try{return r.parseSync(o,t?.draco)}finally{r.destroy()}}return nt(T);})();
10
10
  return __exports__;
11
11
  });
@@ -1,17 +1,38 @@
1
- import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  import type { DracoMesh } from "./lib/draco-types.js";
3
3
  import type { DracoParseOptions } from "./lib/draco-parser.js";
4
4
  export type DracoLoaderOptions = LoaderOptions & {
5
5
  draco?: DracoParseOptions & {
6
+ /** @deprecated WASM decoding is faster but JS is more backwards compatible */
6
7
  decoderType?: 'wasm' | 'js';
8
+ /** @deprecated Specify where to load the Draco decoder library */
7
9
  libraryPath?: string;
8
- extraAttributes?: any;
9
- attributeNameEntry?: string;
10
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
10
11
  workerUrl?: string;
11
12
  };
12
13
  };
13
14
  /**
14
15
  * Worker loader for Draco3D compressed geometries
15
16
  */
16
- export declare const DracoLoader: Loader<DracoMesh, never, DracoLoaderOptions>;
17
+ export declare const DracoLoader: {
18
+ readonly dataType: DracoMesh;
19
+ readonly batchType: never;
20
+ readonly name: "Draco";
21
+ readonly id: "draco";
22
+ readonly module: "draco";
23
+ readonly version: any;
24
+ readonly worker: true;
25
+ readonly extensions: ["drc"];
26
+ readonly mimeTypes: ["application/octet-stream"];
27
+ readonly binary: true;
28
+ readonly tests: ["DRACO"];
29
+ readonly options: {
30
+ readonly draco: {
31
+ readonly decoderType: "wasm" | "js";
32
+ readonly libraryPath: "libs/";
33
+ readonly extraAttributes: {};
34
+ readonly attributeNameEntry: undefined;
35
+ };
36
+ };
37
+ };
17
38
  //# sourceMappingURL=draco-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draco-loader.d.ts","sourceRoot":"","sources":["../src/draco-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,SAAS,EAAC,6BAA0B;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,8BAA2B;AAG1D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE,iBAAiB,GAAG;QAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,MAAC;QACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,kBAAkB,CAmBpE,CAAC"}
1
+ {"version":3,"file":"draco-loader.d.ts","sourceRoot":"","sources":["../src/draco-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,SAAS,EAAC,6BAA0B;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,8BAA2B;AAG1D,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE,iBAAiB,GAAG;QAC1B,8EAA8E;QAC9E,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,kEAAkE;QAClE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;CAqByC,CAAC"}
@@ -6,6 +6,8 @@ import { VERSION } from "./lib/utils/version.js";
6
6
  * Worker loader for Draco3D compressed geometries
7
7
  */
8
8
  export const DracoLoader = {
9
+ dataType: null,
10
+ batchType: null,
9
11
  name: 'Draco',
10
12
  id: 'draco',
11
13
  module: 'draco',