@loaders.gl/draco 4.2.0-alpha.3 → 4.2.0-alpha.5
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 +260 -79
- package/dist/dist.min.js +11 -0
- package/dist/draco-loader.d.ts +2 -2
- package/dist/draco-loader.d.ts.map +1 -1
- package/dist/draco-loader.js +23 -17
- package/dist/draco-worker-node.js +2 -2
- package/dist/draco-worker.js +2 -2
- package/dist/draco-writer-worker-node.js +2 -2
- package/dist/draco-writer-worker.js +2 -2
- package/dist/draco-writer.d.ts +2 -2
- package/dist/draco-writer.d.ts.map +1 -1
- package/dist/draco-writer.js +30 -23
- package/dist/draco3d/draco3d-types.js +48 -41
- package/dist/index.cjs +26 -71
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -21
- package/dist/lib/draco-builder.d.ts +2 -2
- package/dist/lib/draco-builder.d.ts.map +1 -1
- package/dist/lib/draco-builder.js +309 -243
- package/dist/lib/draco-module-loader.js +78 -62
- package/dist/lib/draco-parser.d.ts +2 -2
- package/dist/lib/draco-parser.d.ts.map +1 -1
- package/dist/lib/draco-parser.js +434 -323
- package/dist/lib/draco-types.js +1 -1
- package/dist/lib/utils/get-draco-schema.d.ts +1 -1
- package/dist/lib/utils/get-draco-schema.d.ts.map +1 -1
- package/dist/lib/utils/get-draco-schema.js +29 -32
- package/dist/lib/utils/version.js +4 -2
- package/dist/workers/draco-worker-node.js +1 -1
- package/dist/workers/draco-worker.js +0 -1
- package/dist/workers/draco-writer-worker-node.js +20 -25
- package/dist/workers/draco-writer-worker.js +19 -25
- package/package.json +12 -9
- package/dist/draco-loader.js.map +0 -1
- package/dist/draco-writer.js.map +0 -1
- package/dist/draco3d/draco3d-types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/draco-builder.js.map +0 -1
- package/dist/lib/draco-module-loader.js.map +0 -1
- package/dist/lib/draco-parser.js.map +0 -1
- package/dist/lib/draco-types.js.map +0 -1
- package/dist/lib/utils/get-draco-schema.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/libs/libs/draco_decoder.wasm +0 -0
- package/dist/libs/libs/draco_encoder.js +0 -52
- package/dist/libs/libs/draco_wasm_wrapper.js +0 -117
- package/dist/workers/draco-worker-node.js.map +0 -1
- package/dist/workers/draco-worker.js.map +0 -1
- package/dist/workers/draco-writer-worker-node.js.map +0 -1
- package/dist/workers/draco-writer-worker.js.map +0 -1
package/dist/dist.min.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
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.4";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{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.4"),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{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);})();
|
|
10
|
+
return __exports__;
|
|
11
|
+
});
|
package/dist/draco-loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import type { DracoMesh } from
|
|
3
|
-
import type { DracoParseOptions } from
|
|
2
|
+
import type { DracoMesh } from "./lib/draco-types.js";
|
|
3
|
+
import type { DracoParseOptions } from "./lib/draco-parser.js";
|
|
4
4
|
export type DracoLoaderOptions = LoaderOptions & {
|
|
5
5
|
draco?: DracoParseOptions & {
|
|
6
6
|
decoderType?: 'wasm' | 'js';
|
|
@@ -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,
|
|
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"}
|
package/dist/draco-loader.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { VERSION } from "./lib/utils/version.js";
|
|
5
|
+
/**
|
|
6
|
+
* Worker loader for Draco3D compressed geometries
|
|
7
|
+
*/
|
|
2
8
|
export const DracoLoader = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
name: 'Draco',
|
|
10
|
+
id: 'draco',
|
|
11
|
+
module: 'draco',
|
|
12
|
+
// shapes: ['mesh'],
|
|
13
|
+
version: VERSION,
|
|
14
|
+
worker: true,
|
|
15
|
+
extensions: ['drc'],
|
|
16
|
+
mimeTypes: ['application/octet-stream'],
|
|
17
|
+
binary: true,
|
|
18
|
+
tests: ['DRACO'],
|
|
19
|
+
options: {
|
|
20
|
+
draco: {
|
|
21
|
+
decoderType: typeof WebAssembly === 'object' ? 'wasm' : 'js', // 'js' for IE11
|
|
22
|
+
libraryPath: 'libs/',
|
|
23
|
+
extraAttributes: {},
|
|
24
|
+
attributeNameEntry: undefined
|
|
25
|
+
}
|
|
18
26
|
}
|
|
19
|
-
}
|
|
20
27
|
};
|
|
21
|
-
//# sourceMappingURL=draco-loader.js.map
|
|
@@ -63711,7 +63711,7 @@ function getVersion() {
|
|
|
63711
63711
|
);
|
|
63712
63712
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
63713
63713
|
} else {
|
|
63714
|
-
globalThis._loadersgl_.version = "4.2.0-alpha.
|
|
63714
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.4";
|
|
63715
63715
|
}
|
|
63716
63716
|
}
|
|
63717
63717
|
return globalThis._loadersgl_.version;
|
|
@@ -65245,7 +65245,7 @@ if (nodeVersion2 < 18) {
|
|
|
65245
65245
|
}
|
|
65246
65246
|
|
|
65247
65247
|
// src/lib/utils/version.ts
|
|
65248
|
-
var VERSION2 = true ? "4.2.0-alpha.
|
|
65248
|
+
var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
|
|
65249
65249
|
|
|
65250
65250
|
// src/draco-loader.ts
|
|
65251
65251
|
var DracoLoader = {
|
package/dist/draco-worker.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
);
|
|
44
44
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
45
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.2.0-alpha.
|
|
46
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.4";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return globalThis._loadersgl_.version;
|
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// src/lib/utils/version.ts
|
|
361
|
-
var VERSION2 = true ? "4.2.0-alpha.
|
|
361
|
+
var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
|
|
362
362
|
|
|
363
363
|
// src/draco-loader.ts
|
|
364
364
|
var DracoLoader = {
|
|
@@ -63711,7 +63711,7 @@ function getVersion() {
|
|
|
63711
63711
|
);
|
|
63712
63712
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
63713
63713
|
} else {
|
|
63714
|
-
globalThis._loadersgl_.version = "4.2.0-alpha.
|
|
63714
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.4";
|
|
63715
63715
|
}
|
|
63716
63716
|
}
|
|
63717
63717
|
return globalThis._loadersgl_.version;
|
|
@@ -65533,7 +65533,7 @@ async function loadDracoEncoder(options) {
|
|
|
65533
65533
|
}
|
|
65534
65534
|
|
|
65535
65535
|
// src/lib/utils/version.ts
|
|
65536
|
-
var VERSION2 = true ? "4.2.0-alpha.
|
|
65536
|
+
var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
|
|
65537
65537
|
|
|
65538
65538
|
// src/draco-writer.ts
|
|
65539
65539
|
var DEFAULT_DRACO_WRITER_OPTIONS = {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
);
|
|
44
44
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
45
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.2.0-alpha.
|
|
46
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.4";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return globalThis._loadersgl_.version;
|
|
@@ -651,7 +651,7 @@
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
// src/lib/utils/version.ts
|
|
654
|
-
var VERSION2 = true ? "4.2.0-alpha.
|
|
654
|
+
var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
|
|
655
655
|
|
|
656
656
|
// src/draco-writer.ts
|
|
657
657
|
var DEFAULT_DRACO_WRITER_OPTIONS = {
|
package/dist/draco-writer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import type { DracoMesh } from
|
|
3
|
-
import type { DracoBuildOptions } from
|
|
2
|
+
import type { DracoMesh } from "./lib/draco-types.js";
|
|
3
|
+
import type { DracoBuildOptions } from "./lib/draco-builder.js";
|
|
4
4
|
/** Writer Options for draco */
|
|
5
5
|
export type DracoWriterOptions = WriterOptions & {
|
|
6
6
|
draco?: DracoBuildOptions & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draco-writer.d.ts","sourceRoot":"","sources":["../src/draco-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"draco-writer.d.ts","sourceRoot":"","sources":["../src/draco-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,SAAS,EAAC,6BAA0B;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,+BAA4B;AAK3D,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE,iBAAiB,GAAG;QAC1B,MAAM,CAAC,EAAE,2BAA2B,GAAG,0BAA0B,CAAC;QAClE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH,CAAC;AAaF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAUjF,CAAC"}
|
package/dist/draco-writer.js
CHANGED
|
@@ -2,30 +2,37 @@ import DRACOBuilder from "./lib/draco-builder.js";
|
|
|
2
2
|
import { loadDracoEncoderModule } from "./lib/draco-module-loader.js";
|
|
3
3
|
import { VERSION } from "./lib/utils/version.js";
|
|
4
4
|
const DEFAULT_DRACO_WRITER_OPTIONS = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
pointcloud: false, // Set to true if pointcloud (mode: 0, no indices)
|
|
6
|
+
attributeNameEntry: 'name'
|
|
7
|
+
// Draco Compression Parameters
|
|
8
|
+
// method: 'MESH_EDGEBREAKER_ENCODING', // Use draco defaults
|
|
9
|
+
// speed: [5, 5], // Use draco defaults
|
|
10
|
+
// quantization: { // Use draco defaults
|
|
11
|
+
// POSITION: 10
|
|
12
|
+
// }
|
|
7
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Exporter for Draco3D compressed geometries
|
|
16
|
+
*/
|
|
8
17
|
export const DracoWriter = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
name: 'DRACO',
|
|
19
|
+
id: 'draco',
|
|
20
|
+
module: 'draco',
|
|
21
|
+
version: VERSION,
|
|
22
|
+
extensions: ['drc'],
|
|
23
|
+
options: {
|
|
24
|
+
draco: DEFAULT_DRACO_WRITER_OPTIONS
|
|
25
|
+
},
|
|
26
|
+
encode
|
|
18
27
|
};
|
|
19
|
-
async function encode(data) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
draco
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
28
|
+
async function encode(data, options = {}) {
|
|
29
|
+
// Dynamically load draco
|
|
30
|
+
const { draco } = await loadDracoEncoderModule(options);
|
|
31
|
+
const dracoBuilder = new DRACOBuilder(draco);
|
|
32
|
+
try {
|
|
33
|
+
return dracoBuilder.encodeSync(data, options.draco);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
dracoBuilder.destroy();
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
|
-
//# sourceMappingURL=draco-writer.js.map
|
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
// A set of typescript types manually adapted from the Draco web IDL
|
|
2
|
+
// Draco JS is a bit tricky to work with due to the C++ emscripten code base
|
|
3
|
+
// sparse documentation, so these types provide an extra safety net.
|
|
4
|
+
// DRACO WEB DECODER IDL
|
|
5
|
+
/** Draco3D geometry attribute type */
|
|
6
|
+
export var draco_GeometryAttribute_Type;
|
|
7
|
+
(function (draco_GeometryAttribute_Type) {
|
|
8
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::INVALID"] = 0] = "draco_GeometryAttribute::INVALID";
|
|
9
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::POSITION"] = 1] = "draco_GeometryAttribute::POSITION";
|
|
10
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::NORMAL"] = 2] = "draco_GeometryAttribute::NORMAL";
|
|
11
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::COLOR"] = 3] = "draco_GeometryAttribute::COLOR";
|
|
12
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::TEX_COORD"] = 4] = "draco_GeometryAttribute::TEX_COORD";
|
|
13
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::GENERIC"] = 5] = "draco_GeometryAttribute::GENERIC";
|
|
14
|
+
})(draco_GeometryAttribute_Type || (draco_GeometryAttribute_Type = {}));
|
|
15
|
+
/** Draco3D encoded geometry type */
|
|
16
|
+
export var draco_EncodedGeometryType;
|
|
17
|
+
(function (draco_EncodedGeometryType) {
|
|
18
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::INVALID_GEOMETRY_TYPE"] = 0] = "draco::INVALID_GEOMETRY_TYPE";
|
|
19
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::POINT_CLOUD"] = 1] = "draco::POINT_CLOUD";
|
|
20
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::TRIANGULAR_MESH"] = 2] = "draco::TRIANGULAR_MESH";
|
|
21
|
+
})(draco_EncodedGeometryType || (draco_EncodedGeometryType = {}));
|
|
22
|
+
/** Draco3D data type */
|
|
23
|
+
export var draco_DataType;
|
|
24
|
+
(function (draco_DataType) {
|
|
25
|
+
draco_DataType[draco_DataType["draco::DT_INVALID"] = 0] = "draco::DT_INVALID";
|
|
26
|
+
draco_DataType[draco_DataType["draco::DT_INT8"] = 1] = "draco::DT_INT8";
|
|
27
|
+
draco_DataType[draco_DataType["draco::DT_UINT8"] = 2] = "draco::DT_UINT8";
|
|
28
|
+
draco_DataType[draco_DataType["draco::DT_INT16"] = 3] = "draco::DT_INT16";
|
|
29
|
+
draco_DataType[draco_DataType["draco::DT_UINT16"] = 4] = "draco::DT_UINT16";
|
|
30
|
+
draco_DataType[draco_DataType["draco::DT_INT32"] = 5] = "draco::DT_INT32";
|
|
31
|
+
draco_DataType[draco_DataType["draco::DT_UINT32"] = 6] = "draco::DT_UINT32";
|
|
32
|
+
draco_DataType[draco_DataType["draco::DT_INT64"] = 7] = "draco::DT_INT64";
|
|
33
|
+
draco_DataType[draco_DataType["draco::DT_UINT64"] = 8] = "draco::DT_UINT64";
|
|
34
|
+
draco_DataType[draco_DataType["draco::DT_FLOAT32"] = 9] = "draco::DT_FLOAT32";
|
|
35
|
+
draco_DataType[draco_DataType["draco::DT_FLOAT64"] = 10] = "draco::DT_FLOAT64";
|
|
36
|
+
draco_DataType[draco_DataType["draco::DT_BOOL"] = 11] = "draco::DT_BOOL";
|
|
37
|
+
draco_DataType[draco_DataType["draco::DT_TYPES_COUNT"] = 12] = "draco::DT_TYPES_COUNT";
|
|
38
|
+
})(draco_DataType || (draco_DataType = {}));
|
|
39
|
+
/** Draco3D status code */
|
|
40
|
+
export var draco_StatusCode;
|
|
41
|
+
(function (draco_StatusCode) {
|
|
42
|
+
draco_StatusCode[draco_StatusCode["draco_Status::OK"] = 0] = "draco_Status::OK";
|
|
43
|
+
draco_StatusCode[draco_StatusCode["draco_Status::DRACO_ERROR"] = 1] = "draco_Status::DRACO_ERROR";
|
|
44
|
+
draco_StatusCode[draco_StatusCode["draco_Status::IO_ERROR"] = 2] = "draco_Status::IO_ERROR";
|
|
45
|
+
draco_StatusCode[draco_StatusCode["draco_Status::INVALID_PARAMETER"] = 3] = "draco_Status::INVALID_PARAMETER";
|
|
46
|
+
draco_StatusCode[draco_StatusCode["draco_Status::UNSUPPORTED_VERSION"] = 4] = "draco_Status::UNSUPPORTED_VERSION";
|
|
47
|
+
draco_StatusCode[draco_StatusCode["draco_Status::UNKNOWN_VERSION"] = 5] = "draco_Status::UNKNOWN_VERSION";
|
|
48
|
+
})(draco_StatusCode || (draco_StatusCode = {}));
|
package/dist/index.cjs
CHANGED
|
@@ -17,9 +17,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
//
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
20
|
+
// dist/index.js
|
|
21
|
+
var dist_exports = {};
|
|
22
|
+
__export(dist_exports, {
|
|
23
23
|
DRACO_EXTERNAL_LIBRARIES: () => DRACO_EXTERNAL_LIBRARIES,
|
|
24
24
|
DRACO_EXTERNAL_LIBRARY_URLS: () => DRACO_EXTERNAL_LIBRARY_URLS,
|
|
25
25
|
DracoLoader: () => DracoLoader2,
|
|
@@ -27,12 +27,12 @@ __export(src_exports, {
|
|
|
27
27
|
DracoWriter: () => DracoWriter,
|
|
28
28
|
DracoWriterWorker: () => DracoWriterWorker
|
|
29
29
|
});
|
|
30
|
-
module.exports = __toCommonJS(
|
|
30
|
+
module.exports = __toCommonJS(dist_exports);
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
var VERSION =
|
|
32
|
+
// dist/lib/utils/version.js
|
|
33
|
+
var VERSION = true ? "4.2.0-alpha.4" : "latest";
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// dist/draco-loader.js
|
|
36
36
|
var DracoLoader = {
|
|
37
37
|
name: "Draco",
|
|
38
38
|
id: "draco",
|
|
@@ -55,10 +55,10 @@ var DracoLoader = {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// dist/lib/draco-parser.js
|
|
59
59
|
var import_schema2 = require("@loaders.gl/schema");
|
|
60
60
|
|
|
61
|
-
//
|
|
61
|
+
// dist/lib/utils/get-draco-schema.js
|
|
62
62
|
var import_schema = require("@loaders.gl/schema");
|
|
63
63
|
function getDracoSchema(attributes, loaderData, indices) {
|
|
64
64
|
const metadata = makeMetadata(loaderData.metadata);
|
|
@@ -66,11 +66,7 @@ function getDracoSchema(attributes, loaderData, indices) {
|
|
|
66
66
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
67
67
|
for (const attributeName in attributes) {
|
|
68
68
|
const attribute = attributes[attributeName];
|
|
69
|
-
const field = getArrowFieldFromAttribute(
|
|
70
|
-
attributeName,
|
|
71
|
-
attribute,
|
|
72
|
-
namedLoaderDataAttributes[attributeName]
|
|
73
|
-
);
|
|
69
|
+
const field = getArrowFieldFromAttribute(attributeName, attribute, namedLoaderDataAttributes[attributeName]);
|
|
74
70
|
fields.push(field);
|
|
75
71
|
}
|
|
76
72
|
if (indices) {
|
|
@@ -101,7 +97,7 @@ function makeMetadata(metadata) {
|
|
|
101
97
|
return serializedMetadata;
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
//
|
|
100
|
+
// dist/lib/draco-parser.js
|
|
105
101
|
var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = {
|
|
106
102
|
POSITION: "POSITION",
|
|
107
103
|
NORMAL: "NORMAL",
|
|
@@ -343,13 +339,7 @@ var DracoParser = class {
|
|
|
343
339
|
const ptr = this.draco._malloc(byteLength);
|
|
344
340
|
try {
|
|
345
341
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
|
|
346
|
-
this.decoder.GetAttributeDataArrayForAllPoints(
|
|
347
|
-
dracoGeometry,
|
|
348
|
-
dracoAttribute,
|
|
349
|
-
dataType,
|
|
350
|
-
byteLength,
|
|
351
|
-
ptr
|
|
352
|
-
);
|
|
342
|
+
this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, dracoAttribute, dataType, byteLength, ptr);
|
|
353
343
|
value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
|
|
354
344
|
} finally {
|
|
355
345
|
this.draco._free(ptr);
|
|
@@ -357,7 +347,7 @@ var DracoParser = class {
|
|
|
357
347
|
return { value, size: numComponents };
|
|
358
348
|
}
|
|
359
349
|
// Attribute names
|
|
360
|
-
/**
|
|
350
|
+
/**
|
|
361
351
|
* DRACO does not store attribute names - We need to deduce an attribute name
|
|
362
352
|
* for each attribute
|
|
363
353
|
_getAttributeNames(
|
|
@@ -382,9 +372,7 @@ var DracoParser = class {
|
|
|
382
372
|
*/
|
|
383
373
|
_deduceAttributeName(attribute, options) {
|
|
384
374
|
const uniqueId = attribute.unique_id;
|
|
385
|
-
for (const [attributeName, attributeUniqueId] of Object.entries(
|
|
386
|
-
options.extraAttributes || {}
|
|
387
|
-
)) {
|
|
375
|
+
for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
|
|
388
376
|
if (attributeUniqueId === uniqueId) {
|
|
389
377
|
return attributeName;
|
|
390
378
|
}
|
|
@@ -501,7 +489,6 @@ var DracoParser = class {
|
|
|
501
489
|
}
|
|
502
490
|
return null;
|
|
503
491
|
}
|
|
504
|
-
// HELPERS
|
|
505
492
|
};
|
|
506
493
|
function getDracoDataType(draco, attributeType) {
|
|
507
494
|
switch (attributeType) {
|
|
@@ -540,7 +527,7 @@ function getUint32Array(dracoArray) {
|
|
|
540
527
|
return intArray;
|
|
541
528
|
}
|
|
542
529
|
|
|
543
|
-
//
|
|
530
|
+
// dist/lib/draco-module-loader.js
|
|
544
531
|
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
545
532
|
var DRACO_DECODER_VERSION = "1.5.6";
|
|
546
533
|
var DRACO_ENCODER_VERSION = "1.4.1";
|
|
@@ -590,28 +577,13 @@ async function loadDracoDecoder(options) {
|
|
|
590
577
|
let wasmBinary;
|
|
591
578
|
switch (options.draco && options.draco.decoderType) {
|
|
592
579
|
case "js":
|
|
593
|
-
DracoDecoderModule = await (0, import_worker_utils.loadLibrary)(
|
|
594
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
|
|
595
|
-
"draco",
|
|
596
|
-
options,
|
|
597
|
-
DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
|
|
598
|
-
);
|
|
580
|
+
DracoDecoderModule = await (0, import_worker_utils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER);
|
|
599
581
|
break;
|
|
600
582
|
case "wasm":
|
|
601
583
|
default:
|
|
602
584
|
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
603
|
-
await (0, import_worker_utils.loadLibrary)(
|
|
604
|
-
|
|
605
|
-
"draco",
|
|
606
|
-
options,
|
|
607
|
-
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
608
|
-
),
|
|
609
|
-
await (0, import_worker_utils.loadLibrary)(
|
|
610
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
611
|
-
"draco",
|
|
612
|
-
options,
|
|
613
|
-
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
614
|
-
)
|
|
585
|
+
await (0, import_worker_utils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER),
|
|
586
|
+
await (0, import_worker_utils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM)
|
|
615
587
|
]);
|
|
616
588
|
}
|
|
617
589
|
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
@@ -631,12 +603,7 @@ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
|
|
|
631
603
|
});
|
|
632
604
|
}
|
|
633
605
|
async function loadDracoEncoder(options) {
|
|
634
|
-
let DracoEncoderModule = await (0, import_worker_utils.loadLibrary)(
|
|
635
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],
|
|
636
|
-
"draco",
|
|
637
|
-
options,
|
|
638
|
-
DRACO_EXTERNAL_LIBRARIES.ENCODER
|
|
639
|
-
);
|
|
606
|
+
let DracoEncoderModule = await (0, import_worker_utils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.ENCODER);
|
|
640
607
|
DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;
|
|
641
608
|
return new Promise((resolve) => {
|
|
642
609
|
DracoEncoderModule({
|
|
@@ -646,7 +613,7 @@ async function loadDracoEncoder(options) {
|
|
|
646
613
|
});
|
|
647
614
|
}
|
|
648
615
|
|
|
649
|
-
//
|
|
616
|
+
// dist/lib/draco-builder.js
|
|
650
617
|
var GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {
|
|
651
618
|
POSITION: "POSITION",
|
|
652
619
|
NORMAL: "NORMAL",
|
|
@@ -704,11 +671,7 @@ var DracoBuilder = class {
|
|
|
704
671
|
this._createDracoPointCloud(dracoPointCloud, attributes, options);
|
|
705
672
|
const dracoData = new this.draco.DracoInt8Array();
|
|
706
673
|
try {
|
|
707
|
-
const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(
|
|
708
|
-
dracoPointCloud,
|
|
709
|
-
false,
|
|
710
|
-
dracoData
|
|
711
|
-
);
|
|
674
|
+
const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData);
|
|
712
675
|
if (!(encodedLen > 0)) {
|
|
713
676
|
throw new Error("Draco encoding failed.");
|
|
714
677
|
}
|
|
@@ -806,12 +769,7 @@ var DracoBuilder = class {
|
|
|
806
769
|
for (let attributeName in attributes) {
|
|
807
770
|
const attribute = attributes[attributeName];
|
|
808
771
|
attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;
|
|
809
|
-
const uniqueId = this._addAttributeToMesh(
|
|
810
|
-
dracoPointCloud,
|
|
811
|
-
attributeName,
|
|
812
|
-
attribute,
|
|
813
|
-
vertexCount
|
|
814
|
-
);
|
|
772
|
+
const uniqueId = this._addAttributeToMesh(dracoPointCloud, attributeName, attribute, vertexCount);
|
|
815
773
|
if (uniqueId !== -1) {
|
|
816
774
|
this._addAttributeMetadata(dracoPointCloud, uniqueId, {
|
|
817
775
|
name: attributeName,
|
|
@@ -920,11 +878,7 @@ var DracoBuilder = class {
|
|
|
920
878
|
_addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata) {
|
|
921
879
|
const dracoAttributeMetadata = new this.draco.Metadata();
|
|
922
880
|
this._populateDracoMetadata(dracoAttributeMetadata, metadata);
|
|
923
|
-
this.dracoMeshBuilder.SetMetadataForAttribute(
|
|
924
|
-
dracoGeometry,
|
|
925
|
-
uniqueAttributeId,
|
|
926
|
-
dracoAttributeMetadata
|
|
927
|
-
);
|
|
881
|
+
this.dracoMeshBuilder.SetMetadataForAttribute(dracoGeometry, uniqueAttributeId, dracoAttributeMetadata);
|
|
928
882
|
}
|
|
929
883
|
/**
|
|
930
884
|
* Add contents of object or map to a WASM Draco Metadata Object
|
|
@@ -967,7 +921,7 @@ function getEntries(container) {
|
|
|
967
921
|
return hasEntriesFunc ? container.entries() : Object.entries(container);
|
|
968
922
|
}
|
|
969
923
|
|
|
970
|
-
//
|
|
924
|
+
// dist/draco-writer.js
|
|
971
925
|
var DEFAULT_DRACO_WRITER_OPTIONS = {
|
|
972
926
|
pointcloud: false,
|
|
973
927
|
// Set to true if pointcloud (mode: 0, no indices)
|
|
@@ -1000,7 +954,7 @@ async function encode(data, options = {}) {
|
|
|
1000
954
|
}
|
|
1001
955
|
}
|
|
1002
956
|
|
|
1003
|
-
//
|
|
957
|
+
// dist/index.js
|
|
1004
958
|
var DracoWriterWorker = {
|
|
1005
959
|
id: "draco-writer",
|
|
1006
960
|
name: "Draco compressed geometry writer",
|
|
@@ -1025,3 +979,4 @@ async function parse(arrayBuffer, options) {
|
|
|
1025
979
|
dracoParser.destroy();
|
|
1026
980
|
}
|
|
1027
981
|
}
|
|
982
|
+
//# sourceMappingURL=index.cjs.map
|