@loaders.gl/draco 4.0.0-beta.4 → 4.0.0-beta.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var S=Object.create;var w=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var V=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var G=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!v.call(r,a)&&a!==t&&w(r,a,{get:()=>e[a],enumerable:!(o=N(e,a))||o.enumerable});return r};var j=(r,e,t)=>(t=r!=null?S($(r)):{},G(e||!r||!r.__esModule?w(t,"default",{value:r,enumerable:!0}):t,r));var C=V(()=>{"use strict"});function q(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.
|
|
1
|
+
"use strict";(()=>{var S=Object.create;var w=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var V=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var G=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!v.call(r,a)&&a!==t&&w(r,a,{get:()=>e[a],enumerable:!(o=N(e,a))||o.enumerable});return r};var j=(r,e,t)=>(t=r!=null?S($(r)):{},G(e||!r||!r.__esModule?w(t,"default",{value:r,enumerable:!0}):t,r));var C=V(()=>{"use strict"});function q(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.5"),globalThis._loadersgl_.version}var b=q();function T(r,e){if(!r)throw new Error(e||"loaders.gl assertion failed.")}var u={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ie=u.self||u.window||u.global||{},de=u.window||u.self||u.global||{},ce=u.global||u.self||u.window||{},ue=u.document||{};var m=typeof process!="object"||String(process)!=="[object process]"||process.browser,E=typeof importScripts=="function",le=typeof window<"u"&&typeof window.orientation<"u",R=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),fe=R&&parseFloat(R[1])||0;function A(r,e=!0,t){let o=t||new Set;if(r){if(B(r))o.add(r);else if(B(r.buffer))o.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(e&&typeof r=="object")for(let a in r)A(r[a],e,o)}}return t===void 0?Array.from(o):[]}function B(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function y(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var D=new Map,f=class{static inWorkerThread(){return typeof self<"u"||Boolean(y())}static set onmessage(e){function t(a){let n=y(),{type:i,payload:s}=n?a:a.data;e(i,s)}let o=y();o?(o.on("message",t),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=t}static addEventListener(e){let t=D.get(e);t||(t=a=>{if(!z(a))return;let n=y(),{type:i,payload:s}=n?a:a.data;e(i,s)}),y()?console.error("not implemented"):globalThis.addEventListener("message",t)}static removeEventListener(e){let t=D.get(e);D.delete(e),y()?console.error("not implemented"):globalThis.removeEventListener("message",t)}static postMessage(e,t){let o={source:"loaders.gl",type:e,payload:t},a=A(t),n=y();n?n.postMessage(o,a):globalThis.postMessage(o,a)}};function z(r){let{type:e,data:t}=r;return e==="message"&&t&&typeof t.source=="string"&&t.source.startsWith("loaders.gl")}var d=j(C(),1);var M={};async function _(r,e=null,t={},o=null){return e&&(r=P(r,e,t,o)),M[r]=M[r]||U(r),await M[r]}function P(r,e,t={},o=null){if(!t.useLocalLibraries&&r.startsWith("http"))return r;o=o||r;let a=t.modules||{};return a[o]?a[o]:m?t.CDN?(T(t.CDN.startsWith("http")),`${t.CDN}/${e}@${b}/dist/libs/${o}`):E?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function U(r){if(r.endsWith("wasm"))return await X(r);if(!m)try{return d&&void 0&&await(void 0)(r)}catch(t){return console.error(t),null}if(E)return importScripts(r);let e=await Q(r);return K(e,r)}function K(r,e){if(!m)return void 0&&(void 0)(r,e);if(E)return eval.call(globalThis,r),null;let t=document.createElement("script");t.id=e;try{t.appendChild(document.createTextNode(r))}catch{t.text=r}return document.body.appendChild(t),null}async function X(r){return!void 0||r.startsWith("http")?await(await fetch(r)).arrayBuffer():await(void 0)(r)}async function Q(r){return!void 0||r.startsWith("http")?await(await fetch(r)).text():await(void 0)(r)}var W={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},H=()=>{},h=class{draco;dracoEncoder;dracoMeshBuilder;dracoMetadataBuilder;log;constructor(e){this.draco=e,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(e){e&&this.draco.destroy(e)}encodeSync(e,t={}){return this.log=H,this._setOptions(t),t.pointcloud?this._encodePointCloud(e,t):this._encodeMesh(e,t)}_getAttributesFromMesh(e){let t={...e,...e.attributes};return e.indices&&(t.indices=e.indices),t}_encodePointCloud(e,t){let o=new this.draco.PointCloud;t.metadata&&this._addGeometryMetadata(o,t.metadata);let a=this._getAttributesFromMesh(e);this._createDracoPointCloud(o,a,t);let n=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,n);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
|
|
2
2
|
with ${o.num_attributes()} attributes into ${i} bytes`),I(n)}finally{this.destroyEncodedObject(n),this.destroyEncodedObject(o)}}_encodeMesh(e,t){let o=new this.draco.Mesh;t.metadata&&this._addGeometryMetadata(o,t.metadata);let a=this._getAttributesFromMesh(e);this._createDracoMesh(o,a,t);let n=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(o,n);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
|
|
3
|
-
with ${o.num_attributes()} attributes into ${i} bytes`),I(n)}finally{this.destroyEncodedObject(n),this.destroyEncodedObject(o)}}_setOptions(e){if("speed"in e&&this.dracoEncoder.SetSpeedOptions(...e.speed),"method"in e){let t=this.draco[e.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(t)}if("quantization"in e)for(let t in e.quantization){let o=e.quantization[t],a=this.draco[t];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=W[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_createDracoPointCloud(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=W[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_addAttributeToMesh(e,t,o,a){if(!ArrayBuffer.isView(o))return-1;let n=this._getDracoAttributeType(t),i=o.length/a;if(n==="indices"){let p=o.length/3;return this.log(`Adding attribute ${t}, size ${p}`),this.dracoMeshBuilder.AddFacesToMesh(e,p,o),-1}this.log(`Adding attribute ${t}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=o;switch(o.constructor){case Int8Array:return s.AddInt8Attribute(e,n,a,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(e,n,a,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(e,n,a,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(e,n,a,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(e,n,a,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(e,n,a,i,new Uint32Array(c));case Float32Array:default:return s.AddFloatAttribute(e,n,a,i,new Float32Array(c))}}_getDracoAttributeType(e){switch(e.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(e){for(let t in e){let o=e[t];if(this._getDracoAttributeType(t)===this.draco.POSITION)return o}return null}_addGeometryMetadata(e,t){let o=new this.draco.Metadata;this._populateDracoMetadata(o,t),this.dracoMeshBuilder.AddMetadata(e,o)}_addAttributeMetadata(e,t,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(e,t,a)}_populateDracoMetadata(e,t){for(let[o,a]of J(t))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(e,o,a):this.dracoMetadataBuilder.AddDoubleEntry(e,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(e,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(e,o,a)}}};function I(r){let e=r.size(),t=new ArrayBuffer(e),o=new Int8Array(t);for(let a=0;a<e;++a)o[a]=r.GetValue(a);return t}function J(r){return r.entries&&!r.hasOwnProperty("entries")?r.entries():Object.entries(r)}var Y="1.5.6",Z="1.4.1",O=`https://www.gstatic.com/draco/versioned/decoders/${Y}`,l={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},ee={[l.DECODER]:`${O}/${l.DECODER}`,[l.DECODER_WASM]:`${O}/${l.DECODER_WASM}`,[l.FALLBACK_DECODER]:`${O}/${l.FALLBACK_DECODER}`,[l.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Z}/javascript/${l.ENCODER}`};var g;async function L(r){let e=r.modules||{};return e.draco3d?g=g||e.draco3d.createEncoderModule({}).then(t=>({draco:t})):g=g||te(r),await g}async function te(r){let e=await _(ee[l.ENCODER],"draco",r,l.ENCODER);return e=e||globalThis.DracoEncoderModule,new Promise(t=>{e({onModuleLoaded:o=>t({draco:o})})})}var k="4.0.0-beta.
|
|
3
|
+
with ${o.num_attributes()} attributes into ${i} bytes`),I(n)}finally{this.destroyEncodedObject(n),this.destroyEncodedObject(o)}}_setOptions(e){if("speed"in e&&this.dracoEncoder.SetSpeedOptions(...e.speed),"method"in e){let t=this.draco[e.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(t)}if("quantization"in e)for(let t in e.quantization){let o=e.quantization[t],a=this.draco[t];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=W[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_createDracoPointCloud(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=W[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_addAttributeToMesh(e,t,o,a){if(!ArrayBuffer.isView(o))return-1;let n=this._getDracoAttributeType(t),i=o.length/a;if(n==="indices"){let p=o.length/3;return this.log(`Adding attribute ${t}, size ${p}`),this.dracoMeshBuilder.AddFacesToMesh(e,p,o),-1}this.log(`Adding attribute ${t}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=o;switch(o.constructor){case Int8Array:return s.AddInt8Attribute(e,n,a,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(e,n,a,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(e,n,a,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(e,n,a,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(e,n,a,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(e,n,a,i,new Uint32Array(c));case Float32Array:default:return s.AddFloatAttribute(e,n,a,i,new Float32Array(c))}}_getDracoAttributeType(e){switch(e.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(e){for(let t in e){let o=e[t];if(this._getDracoAttributeType(t)===this.draco.POSITION)return o}return null}_addGeometryMetadata(e,t){let o=new this.draco.Metadata;this._populateDracoMetadata(o,t),this.dracoMeshBuilder.AddMetadata(e,o)}_addAttributeMetadata(e,t,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(e,t,a)}_populateDracoMetadata(e,t){for(let[o,a]of J(t))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(e,o,a):this.dracoMetadataBuilder.AddDoubleEntry(e,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(e,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(e,o,a)}}};function I(r){let e=r.size(),t=new ArrayBuffer(e),o=new Int8Array(t);for(let a=0;a<e;++a)o[a]=r.GetValue(a);return t}function J(r){return r.entries&&!r.hasOwnProperty("entries")?r.entries():Object.entries(r)}var Y="1.5.6",Z="1.4.1",O=`https://www.gstatic.com/draco/versioned/decoders/${Y}`,l={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},ee={[l.DECODER]:`${O}/${l.DECODER}`,[l.DECODER_WASM]:`${O}/${l.DECODER_WASM}`,[l.FALLBACK_DECODER]:`${O}/${l.FALLBACK_DECODER}`,[l.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Z}/javascript/${l.ENCODER}`};var g;async function L(r){let e=r.modules||{};return e.draco3d?g=g||e.draco3d.createEncoderModule({}).then(t=>({draco:t})):g=g||te(r),await g}async function te(r){let e=await _(ee[l.ENCODER],"draco",r,l.ENCODER);return e=e||globalThis.DracoEncoderModule,new Promise(t=>{e({onModuleLoaded:o=>t({draco:o})})})}var k="4.0.0-beta.5";var re={pointcloud:!1,attributeNameEntry:"name"},x={name:"DRACO",id:"draco",module:"draco",version:k,extensions:["drc"],encode:oe,options:{draco:re}};async function oe(r,e={}){let{draco:t}=await L(e),o=new h(t);try{return o.encodeSync(r,e.draco)}finally{o.destroy()}}f.inWorkerThread()&&(f.onmessage=async(r,e)=>{switch(r){case"process":try{let{input:t,options:o}=e,a=await x.encode(t,o);f.postMessage("done",{result:a})}catch(t){let o=t instanceof Error?t.message:"";f.postMessage("error",{error:o})}break;default:}});})();
|
|
4
4
|
//# sourceMappingURL=draco-writer-worker.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/draco",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"description": "Framework-independent loader and writer for Draco compressed meshes and point clouds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/runtime": "^7.3.1",
|
|
54
|
-
"@loaders.gl/loader-utils": "4.0.0-beta.
|
|
55
|
-
"@loaders.gl/schema": "4.0.0-beta.
|
|
56
|
-
"@loaders.gl/worker-utils": "4.0.0-beta.
|
|
54
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.5",
|
|
55
|
+
"@loaders.gl/schema": "4.0.0-beta.5",
|
|
56
|
+
"@loaders.gl/worker-utils": "4.0.0-beta.5",
|
|
57
57
|
"draco3d": "1.5.5"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@loaders.gl/polyfills": "4.0.0-beta.
|
|
60
|
+
"@loaders.gl/polyfills": "4.0.0-beta.5"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
|
|
63
63
|
}
|