@loaders.gl/draco 3.1.0-alpha.3 → 4.0.0-alpha.4
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/draco-worker.js +1236 -2
- package/dist/lib/draco-builder.js +4 -6
- package/dist/lib/draco-builder.js.map +1 -1
- package/dist/lib/draco-module-loader.js +4 -4
- package/dist/lib/draco-module-loader.js.map +1 -1
- package/dist/lib/draco-parser.js +2 -2
- package/dist/lib/draco-parser.js.map +1 -1
- package/dist/lib/utils/get-draco-schema.js +1 -1
- package/dist/lib/utils/get-draco-schema.js.map +1 -1
- package/dist/lib/utils/version.js +1 -1
- package/package.json +7 -7
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/draco-worker.js.map +0 -1
package/dist/draco-worker.js
CHANGED
|
@@ -1,2 +1,1236 @@
|
|
|
1
|
-
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=30)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){var n=r(29);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){t.exports=r(20)},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,c,"next",t)}function c(t){r(a,o,i,u,c,"throw",t)}u(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){"use strict";(function(t,n){r.d(e,"a",(function(){return a})),r.d(e,"b",(function(){return u})),r.d(e,"c",(function(){return c}));var o=r(8),i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},a=i.global||i.self||i.window||{},u="object"!==(void 0===n?"undefined":r.n(o)()(n))||"[object process]"!==String(n)||n.browser,c="function"==typeof importScripts,s=("undefined"!=typeof window&&window.orientation,void 0!==n&&n.version&&/v([0-9]*)/.exec(n.version));s&&parseFloat(s[1])}).call(this,r(24),r(25))},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=r=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){var n=r(26),o=r(27),i=r(14),a=r(28);t.exports=function(t){return n(t)||o(t)||i(t)||a()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){},function(t,e,r){var n=r(21),o=r(22),i=r(14),a=r(23);t.exports=function(t,e){return n(t)||o(t,e)||i(t,e)||a()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(e){return t.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.default=t.exports,t.exports.__esModule=!0,r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},,function(t,e,r){var n=r(15);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){var n=r(8).default,o=r(5);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?o(t):e},t.exports.default=t.exports,t.exports.__esModule=!0},,,,function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function l(){}function d(){}function p(){}var y={};y[o]=function(){return this};var h=Object.getPrototypeOf,v=h&&h(h(T([])));v&&v!==e&&r.call(v,o)&&(y=v);var m=p.prototype=l.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function T(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return d.prototype=m.constructor=p,p.constructor=d,d.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),u(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=T,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:T(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){var r=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null!=r){var n,o,i=[],a=!0,u=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var c,s=[],f=!1,l=-1;function d(){f&&c&&(f=!1,c.length?s=c.concat(s):l=-1,s.length&&p())}function p(){if(!f){var t=u(d);f=!0;for(var e=s.length;e;){for(c=s,s=[];++l<e;)c&&c[l].run();l=-1,e=s.length}c=null,f=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function h(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];s.push(new y(t,e)),1!==s.length||f||u(p)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){var n=r(15);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(e,n){return t.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports.default=t.exports,t.exports.__esModule=!0,r(e,n)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){"use strict";r.r(e);var n=r(2),o=r.n(n),i=r(6),a=r.n(i),u=r(4),c=r.n(u),s=r(0),f=r.n(s),l=r(3),d=r.n(l),p=r(8),y=r.n(p);function h(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}var v=new Map,m=function(){function t(){f()(this,t)}return d()(t,null,[{key:"onmessage",set:function(t){self.onmessage=function(e){if(b(e)){var r=e.data,n=r.type,o=r.payload;t(n,o)}}}},{key:"addEventListener",value:function(t){var e=v.get(t);e||(e=function(e){if(b(e)){var r=e.data,n=r.type,o=r.payload;t(n,o)}}),self.addEventListener("message",e)}},{key:"removeEventListener",value:function(t){var e=v.get(t);v.delete(t),self.removeEventListener("message",e)}},{key:"postMessage",value:function(t,e){if(self){var r={source:"loaders.gl",type:t,payload:e},n=function t(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=n||new Set;if(e){if(h(e))o.add(e);else if(h(e.buffer))o.add(e.buffer);else if(ArrayBuffer.isView(e));else if(r&&"object"===y()(e))for(var i in e)t(e[i],r,o)}else;return void 0===n?Array.from(o):[]}(e);self.postMessage(r,n)}}}]),t}();function b(t){var e=t.type,r=t.data;return"message"===e&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function w(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var x=0;function _(t,e){return new Promise((function(r,n){var o=x++;m.addEventListener((function t(e,i){if(i.id===o)switch(e){case"done":m.removeEventListener(t),r(i.result);break;case"error":m.removeEventListener(t),n(i.error)}}));var i={id:o,input:t,options:e};m.postMessage("process",i)}))}function O(t){return T.apply(this,arguments)}function T(){return(T=a()(c.a.mark((function t(e){var r,n,o,i,a,u,s;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.loader,n=e.arrayBuffer,o=e.options,i=e.context,!r.parseSync&&!r.parse){t.next=6;break}a=n,u=r.parseSync||r.parse,t.next=13;break;case 6:if(!r.parseTextSync){t.next=12;break}s=new TextDecoder,a=s.decode(n),u=r.parseTextSync,t.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=w(w({},o),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),t.next=16,u(a,w({},o),i,r);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var S={name:"Draco",id:"draco",module:"draco",shapes:["mesh"],version:"3.1.0-alpha.3",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"===("undefined"==typeof WebAssembly?"undefined":y()(WebAssembly))?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}},A=r(9),I=r.n(A),k=r(11),j=r.n(k);function M(t){for(var e=1/0,r=1/0,n=1/0,o=-1/0,i=-1/0,a=-1/0,u=t.POSITION?t.POSITION.value:[],c=u&&u.length,s=0;s<c;s+=3){var f=u[s],l=u[s+1],d=u[s+2];e=f<e?f:e,r=l<r?l:r,n=d<n?d:n,o=f>o?f:o,i=l>i?l:i,a=d>a?d:a}return[[e,r,n],[o,i,a]]}function D(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return E(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var P=function(){function t(e,r){f()(this,t),o()(this,"fields",void 0),o()(this,"metadata",void 0),function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(Array.isArray(e)),function(t){var e,r={},n=D(t);try{for(n.s();!(e=n.n()).done;){var o=e.value;r[o.name]&&console.warn("Schema: duplicated field name",o.name,o),r[o.name]=!0}}catch(t){n.e(t)}finally{n.f()}}(e),this.fields=e,this.metadata=r||new Map}return d()(t,[{key:"compareTo",value:function(t){if(this.metadata!==t.metadata)return!1;if(this.fields.length!==t.fields.length)return!1;for(var e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}},{key:"select",value:function(){for(var e=Object.create(null),r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];for(var i=0,a=n;i<a.length;i++){var u=a[i];e[u]=!0}var c=this.fields.filter((function(t){return e[t.name]}));return new t(c,this.metadata)}},{key:"selectAt",value:function(){for(var e=this,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var i=n.map((function(t){return e.fields[t]})).filter(Boolean);return new t(i,this.metadata)}},{key:"assign",value:function(e){var r,n=this.metadata;if(e instanceof t){var o=e;r=o.fields,n=L(L(new Map,this.metadata),o.metadata)}else r=e;var i,a=Object.create(null),u=D(this.fields);try{for(u.s();!(i=u.n()).done;){var c=i.value;a[c.name]=c}}catch(t){u.e(t)}finally{u.f()}var s,f=D(r);try{for(f.s();!(s=f.n()).done;){var l=s.value;a[l.name]=l}}catch(t){f.e(t)}finally{f.f()}return new t(Object.values(a),n)}}]),t}();function L(t,e){return new Map([].concat(I()(t||new Map),I()(e||new Map)))}var F,N,U,z,B=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;f()(this,t),o()(this,"name",void 0),o()(this,"type",void 0),o()(this,"nullable",void 0),o()(this,"metadata",void 0),this.name=e,this.type=r,this.nullable=n,this.metadata=i}return d()(t,[{key:"typeId",get:function(){return this.type&&this.type.typeId}},{key:"clone",value:function(){return new t(this.name,this.type,this.nullable,this.metadata)}},{key:"compareTo",value:function(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}},{key:"toString",value:function(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}]),t}(),G=r(5),C=r.n(G),R=r(1),q=r.n(R),Q=r(16),W=r.n(Q),V=r(12),Y=r.n(V);function H(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=Y()(t);if(e){var o=Y()(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return W()(this,r)}}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(F||(F={}));var $=function(){function t(){f()(this,t)}return d()(t,[{key:"typeId",get:function(){return F.NONE}},{key:"compareTo",value:function(t){return this===t}}],[{key:"isNull",value:function(t){return t&&t.typeId===F.Null}},{key:"isInt",value:function(t){return t&&t.typeId===F.Int}},{key:"isFloat",value:function(t){return t&&t.typeId===F.Float}},{key:"isBinary",value:function(t){return t&&t.typeId===F.Binary}},{key:"isUtf8",value:function(t){return t&&t.typeId===F.Utf8}},{key:"isBool",value:function(t){return t&&t.typeId===F.Bool}},{key:"isDecimal",value:function(t){return t&&t.typeId===F.Decimal}},{key:"isDate",value:function(t){return t&&t.typeId===F.Date}},{key:"isTime",value:function(t){return t&&t.typeId===F.Time}},{key:"isTimestamp",value:function(t){return t&&t.typeId===F.Timestamp}},{key:"isInterval",value:function(t){return t&&t.typeId===F.Interval}},{key:"isList",value:function(t){return t&&t.typeId===F.List}},{key:"isStruct",value:function(t){return t&&t.typeId===F.Struct}},{key:"isUnion",value:function(t){return t&&t.typeId===F.Union}},{key:"isFixedSizeBinary",value:function(t){return t&&t.typeId===F.FixedSizeBinary}},{key:"isFixedSizeList",value:function(t){return t&&t.typeId===F.FixedSizeList}},{key:"isMap",value:function(t){return t&&t.typeId===F.Map}},{key:"isDictionary",value:function(t){return t&&t.typeId===F.Dictionary}}]),t}();N=Symbol.toStringTag;var X=function(t){q()(r,t);var e=H(r);function r(t,n){var i;return f()(this,r),i=e.call(this),o()(C()(i),"isSigned",void 0),o()(C()(i),"bitWidth",void 0),i.isSigned=t,i.bitWidth=n,i}return d()(r,[{key:"typeId",get:function(){return F.Int}},{key:N,get:function(){return"Int"}},{key:"toString",value:function(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}]),r}($),J=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!0,8)}return r}(X),K=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!0,16)}return r}(X),Z=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!0,32)}return r}(X),tt=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!1,8)}return r}(X),et=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!1,16)}return r}(X),rt=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,!1,32)}return r}(X),nt=32,ot=64;U=Symbol.toStringTag;var it=function(t){q()(r,t);var e=H(r);function r(t){var n;return f()(this,r),n=e.call(this),o()(C()(n),"precision",void 0),n.precision=t,n}return d()(r,[{key:"typeId",get:function(){return F.Float}},{key:U,get:function(){return"Float"}},{key:"toString",value:function(){return"Float".concat(this.precision)}}]),r}($),at=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,nt)}return r}(it),ut=function(t){q()(r,t);var e=H(r);function r(){return f()(this,r),e.call(this,ot)}return r}(it);Symbol.toStringTag;Symbol.toStringTag;Symbol.toStringTag;Symbol.toStringTag;z=Symbol.toStringTag;var ct=function(t){q()(r,t);var e=H(r);function r(t,n){var i;return f()(this,r),i=e.call(this),o()(C()(i),"listSize",void 0),o()(C()(i),"children",void 0),i.listSize=t,i.children=[n],i}return d()(r,[{key:"typeId",get:function(){return F.FixedSizeList}},{key:"valueType",get:function(){return this.children[0].type}},{key:"valueField",get:function(){return this.children[0]}},{key:z,get:function(){return"FixedSizeList"}},{key:"toString",value:function(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}]),r}($);Symbol.toStringTag;function st(t,e,r){var n=function(t){switch(t.constructor){case Int8Array:return new J;case Uint8Array:return new tt;case Int16Array:return new K;case Uint16Array:return new et;case Int32Array:return new Z;case Uint32Array:return new rt;case Float32Array:return new at;case Float64Array:return new ut;default:throw new Error("array type not supported")}}(e.value),o=r||function(t){var e=new Map;"byteOffset"in t&&e.set("byteOffset",t.byteOffset.toString(10));"byteStride"in t&&e.set("byteStride",t.byteStride.toString(10));"normalized"in t&&e.set("normalized",t.normalized.toString());return e}(e);return new B(t,new ct(e.size,new B("value",n)),!1,o)}function ft(t,e,r){var n=dt(e.metadata),o=[],i=function(t){var e={};for(var r in t){var n=t[r];e[n.name||"undefined"]=n}return e}(e.attributes);for(var a in t){var u=lt(a,t[a],i[a]);o.push(u)}if(r){var c=lt("indices",r);o.push(c)}return new P(o,n)}function lt(t,e,r){return st(t,e,r?dt(r.metadata):void 0)}function dt(t){var e=new Map;for(var r in t)e.set("".concat(r,".string"),JSON.stringify(t[r]));return e}function pt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return yt(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function vt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ht(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ht(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var mt={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},bt={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},gt=function(){function t(e){f()(this,t),o()(this,"draco",void 0),o()(this,"decoder",void 0),o()(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}return d()(t,[{key:"destroy",value:function(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}},{key:"parseSync",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);var n=this.decoder.GetEncodedGeometryType(r),o=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{var i;switch(n){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(r,o);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(r,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!o.ptr){var a="DRACO decompression failed: ".concat(i.error_msg());throw new Error(a)}var u=this._getDracoLoaderData(o,n,e),c=this._getMeshData(o,u,e),s=M(c.attributes),f=ft(c.attributes,u,c.indices),l=vt(vt({loader:"draco",loaderData:u,header:{vertexCount:o.num_points(),boundingBox:s}},c),{},{schema:f});return l}finally{this.draco.destroy(r),o&&this.draco.destroy(o)}}},{key:"_getDracoLoaderData",value:function(t,e,r){var n=this._getTopLevelMetadata(t),o=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:o}}},{key:"_getDracoAttributes",value:function(t,e){for(var r={},n=0;n<t.num_attributes();n++){var o=this.decoder.GetAttribute(t,n),i=this._getAttributeMetadata(t,n);r[o.unique_id()]={unique_id:o.unique_id(),attribute_type:o.attribute_type(),data_type:o.data_type(),num_components:o.num_components(),byte_offset:o.byte_offset(),byte_stride:o.byte_stride(),normalized:o.normalized(),attribute_index:n,metadata:i};var a=this._getQuantizationTransform(o,e);a&&(r[o.unique_id()].quantization_transform=a);var u=this._getOctahedronTransform(o,e);u&&(r[o.unique_id()].octahedron_transform=u)}return r}},{key:"_getMeshData",value:function(t,e,r){var 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}}},{key:"_getMeshAttributes",value:function(t,e,r){for(var n={},o=0,i=Object.values(t.attributes);o<i.length;o++){var a=i[o],u=this._deduceAttributeName(a,r);a.name=u;var c=this._getAttributeValues(e,a),s=c.value,f=c.size;n[u]={value:s,size:f,byteOffset:a.byte_offset,byteStride:a.byte_stride,normalized:a.normalized}}return n}},{key:"_getTriangleListIndices",value:function(t){var e=3*t.num_faces(),r=4*e,n=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(t,r,n),new Uint32Array(this.draco.HEAPF32.buffer,n,e).slice()}finally{this.draco._free(n)}}},{key:"_getTriangleStripIndices",value:function(t){var e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),function(t){for(var e=t.size(),r=new Int32Array(e),n=0;n<e;n++)r[n]=t.GetValue(n);return r}(e)}finally{this.draco.destroy(e)}}},{key:"_getAttributeValues",value:function(t,e){var r,n=bt[e.data_type],o=e.num_components,i=t.num_points()*o,a=i*n.BYTES_PER_ELEMENT,u=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}(this.draco,n),c=this.draco._malloc(a);try{var s=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,s,u,a,c),r=new n(this.draco.HEAPF32.buffer,c,i).slice()}finally{this.draco._free(c)}return{value:r,size:o}}},{key:"_deduceAttributeName",value:function(t,e){for(var r=t.unique_id,n=0,o=Object.entries(e.extraAttributes||{});n<o.length;n++){var i=j()(o[n],2),a=i[0];if(i[1]===r)return a}var u=t.attribute_type;for(var c in mt){if(this.draco[c]===u)return mt[c]}var s=e.attributeNameEntry||"name";return t.metadata[s]?t.metadata[s].string:"CUSTOM_ATTRIBUTE_".concat(r)}},{key:"_getTopLevelMetadata",value:function(t){var e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}},{key:"_getAttributeMetadata",value:function(t,e){var r=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(r)}},{key:"_getDracoMetadata",value:function(t){if(!t||!t.ptr)return{};for(var e={},r=this.metadataQuerier.NumEntries(t),n=0;n<r;n++){var o=this.metadataQuerier.GetEntryName(t,n);e[o]=this._getDracoMetadataField(t,o)}return e}},{key:"_getDracoMetadataField",value:function(t,e){var r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,r);var n=function(t){for(var e=t.size(),r=new Int32Array(e),n=0;n<e;n++)r[n]=t.GetValue(n);return r}(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)}}},{key:"_disableAttributeTransforms",value:function(t){var e,r=t.quantizedAttributes,n=void 0===r?[]:r,o=t.octahedronAttributes,i=void 0===o?[]:o,a=pt([].concat(I()(n),I()(i)));try{for(a.s();!(e=a.n()).done;){var u=e.value;this.decoder.SkipAttributeTransform(this.draco[u])}}catch(t){a.e(t)}finally{a.f()}}},{key:"_getQuantizationTransform",value:function(t,e){var r=this,n=e.quantizedAttributes,o=void 0===n?[]:n,i=t.attribute_type();if(o.map((function(t){return r.decoder[t]})).includes(i)){var a=new this.draco.AttributeQuantizationTransform;try{if(a.InitFromAttribute(t))return{quantization_bits:a.quantization_bits(),range:a.range(),min_values:new Float32Array([1,2,3]).map((function(t){return a.min_value(t)}))}}finally{this.draco.destroy(a)}}return null}},{key:"_getOctahedronTransform",value:function(t,e){var r=this,n=e.octahedronAttributes,o=void 0===n?[]:n,i=t.attribute_type();if(o.map((function(t){return r.decoder[t]})).includes(i)){var a=new this.draco.AttributeQuantizationTransform;try{if(a.InitFromAttribute(t))return{quantization_bits:a.quantization_bits()}}finally{this.draco.destroy(a)}}return null}}]),t}();var wt=r(7),xt=r(10);var _t={};function Ot(t){return Tt.apply(this,arguments)}function Tt(){return(Tt=a()(c.a.mark((function t(e){var r,n,o=arguments;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:null,n=o.length>2&&void 0!==o[2]?o[2]:{},r&&(e=St(e,r,n)),_t[e]=_t[e]||At(e),t.next=6,_t[e];case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function St(t,e,r){if(t.startsWith("http"))return t;var n=r.modules||{};return n[t]?n[t]:wt.b?r.CDN?(function(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}(r.CDN.startsWith("http")),"".concat(r.CDN,"/").concat(e,"@").concat("3.1.0-alpha.3","/dist/libs/").concat(t)):wt.c?"../src/libs/".concat(t):"modules/".concat(e,"/src/libs/").concat(t):"modules/".concat(e,"/dist/libs/").concat(t)}function At(t){return It.apply(this,arguments)}function It(){return(It=a()(c.a.mark((function t(e){var r,n,o;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.endsWith("wasm")){t.next=7;break}return t.next=3,fetch(e);case 3:return r=t.sent,t.next=6,r.arrayBuffer();case 6:return t.abrupt("return",t.sent);case 7:if(wt.b){t.next=14;break}if(t.t0=xt.requireFromFile,!t.t0){t.next=13;break}return t.next=12,xt.requireFromFile(e);case 12:t.t0=t.sent;case 13:return t.abrupt("return",t.t0);case 14:if(!wt.c){t.next=16;break}return t.abrupt("return",importScripts(e));case 16:return t.next=18,fetch(e);case 18:return n=t.sent,t.next=21,n.text();case 21:return o=t.sent,t.abrupt("return",kt(o,e));case 23:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function kt(t,e){if(!wt.b)return xt.requireFromString&&xt.requireFromString(t,e);if(wt.c)return eval.call(wt.a,t),null;var r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch(e){r.text=t}return document.body.appendChild(r),null}function jt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Mt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?jt(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):jt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var Dt,Et="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.js"),Pt="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_wasm_wrapper.js"),Lt="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.wasm");"https://raw.githubusercontent.com/google/draco/".concat("1.4.1","/javascript/draco_encoder.js");function Ft(t){return Nt.apply(this,arguments)}function Nt(){return(Nt=a()(c.a.mark((function t(e){var r;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.modules||{},Dt=r.draco3d?Dt||r.draco3d.createDecoderModule({}).then((function(t){return{draco:t}})):Dt||Ut(e),t.next=4,Dt;case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ut(t){return zt.apply(this,arguments)}function zt(){return(zt=a()(c.a.mark((function t(e){var r,n,o,i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.draco&&e.draco.decoderType,t.next="js"===t.t0?3:(t.t0,7);break;case 3:return t.next=5,Ot(Et,"draco",e);case 5:return r=t.sent,t.abrupt("break",21);case 7:return t.t1=Promise,t.next=10,Ot(Pt,"draco",e);case 10:return t.t2=t.sent,t.next=13,Ot(Lt,"draco",e);case 13:return t.t3=t.sent,t.t4=[t.t2,t.t3],t.next=17,t.t1.all.call(t.t1,t.t4);case 17:o=t.sent,i=j()(o,2),r=i[0],n=i[1];case 21:return r=r||globalThis.DracoDecoderModule,t.next=24,Bt(r,n);case 24:return t.abrupt("return",t.sent);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e){var r={};return e&&(r.wasmBinary=e),new Promise((function(e){t(Mt(Mt({},r),{},{onModuleLoaded:function(t){return e({draco:t})}}))}))}function Gt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Gt(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Gt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var Rt=Ct(Ct({},S),{},{parse:function(t,e){return qt.apply(this,arguments)}});function qt(){return(qt=a()(c.a.mark((function t(e,r){var n,o,i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Ft(r);case 2:return n=t.sent,o=n.draco,i=new gt(o),t.prev=5,t.abrupt("return",i.parseSync(e,null==r?void 0:r.draco));case 7:return t.prev=7,i.destroy(),t.finish(7);case 10:case"end":return t.stop()}}),t,null,[[5,,7,10]])})))).apply(this,arguments)}var Qt;Qt=Rt,"undefined"!=typeof self&&(m.onmessage=function(){var t=a()(c.a.mark((function t(e,r){var n,o,i,a,u;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="process"===t.t0?3:16;break;case 3:return t.prev=3,n=r.input,o=r.options,i=void 0===o?{}:o,t.next=7,O({loader:Qt,arrayBuffer:n,options:i,context:{parse:_}});case 7:a=t.sent,m.postMessage("done",{result:a}),t.next=15;break;case 11:t.prev=11,t.t1=t.catch(3),u=t.t1 instanceof Error?t.t1.message:"",m.postMessage("error",{error:u});case 15:return t.abrupt("break",16);case 16:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}())}]);
|
|
2
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// ../worker-utils/src/lib/env-utils/version.ts
|
|
3
|
+
var DEFAULT_VERSION = "beta";
|
|
4
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
|
|
5
|
+
if (typeof __VERSION__ === "undefined") {
|
|
6
|
+
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
10
|
+
function assert(condition, message) {
|
|
11
|
+
if (!condition) {
|
|
12
|
+
throw new Error(message || "loaders.gl assertion failed.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ../worker-utils/src/lib/env-utils/globals.ts
|
|
17
|
+
var globals = {
|
|
18
|
+
self: typeof self !== "undefined" && self,
|
|
19
|
+
window: typeof window !== "undefined" && window,
|
|
20
|
+
global: typeof global !== "undefined" && global,
|
|
21
|
+
document: typeof document !== "undefined" && document
|
|
22
|
+
};
|
|
23
|
+
var self_ = globals.self || globals.window || globals.global || {};
|
|
24
|
+
var window_ = globals.window || globals.self || globals.global || {};
|
|
25
|
+
var global_ = globals.global || globals.self || globals.window || {};
|
|
26
|
+
var document_ = globals.document || {};
|
|
27
|
+
var isBrowser = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
|
|
28
|
+
var isWorker = typeof importScripts === "function";
|
|
29
|
+
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
30
|
+
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
31
|
+
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
32
|
+
|
|
33
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
34
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
35
|
+
const transfersSet = transfers || new Set();
|
|
36
|
+
if (!object) {
|
|
37
|
+
} else if (isTransferable(object)) {
|
|
38
|
+
transfersSet.add(object);
|
|
39
|
+
} else if (isTransferable(object.buffer)) {
|
|
40
|
+
transfersSet.add(object.buffer);
|
|
41
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
42
|
+
} else if (recursive && typeof object === "object") {
|
|
43
|
+
for (const key in object) {
|
|
44
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
48
|
+
}
|
|
49
|
+
function isTransferable(object) {
|
|
50
|
+
if (!object) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (object instanceof ArrayBuffer) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
69
|
+
var onMessageWrapperMap = new Map();
|
|
70
|
+
var WorkerBody = class {
|
|
71
|
+
static set onmessage(onMessage) {
|
|
72
|
+
self.onmessage = (message) => {
|
|
73
|
+
if (!isKnownMessage(message)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const { type, payload } = message.data;
|
|
77
|
+
onMessage(type, payload);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
static addEventListener(onMessage) {
|
|
81
|
+
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
82
|
+
if (!onMessageWrapper) {
|
|
83
|
+
onMessageWrapper = (message) => {
|
|
84
|
+
if (!isKnownMessage(message)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { type, payload } = message.data;
|
|
88
|
+
onMessage(type, payload);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
self.addEventListener("message", onMessageWrapper);
|
|
92
|
+
}
|
|
93
|
+
static removeEventListener(onMessage) {
|
|
94
|
+
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
95
|
+
onMessageWrapperMap.delete(onMessage);
|
|
96
|
+
self.removeEventListener("message", onMessageWrapper);
|
|
97
|
+
}
|
|
98
|
+
static postMessage(type, payload) {
|
|
99
|
+
if (self) {
|
|
100
|
+
const data = { source: "loaders.gl", type, payload };
|
|
101
|
+
const transferList = getTransferList(payload);
|
|
102
|
+
self.postMessage(data, transferList);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function isKnownMessage(message) {
|
|
107
|
+
const { type, data } = message;
|
|
108
|
+
return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
112
|
+
var LATEST = "beta";
|
|
113
|
+
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
114
|
+
var loadLibraryPromises = {};
|
|
115
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
116
|
+
if (moduleName) {
|
|
117
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
118
|
+
}
|
|
119
|
+
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
120
|
+
return await loadLibraryPromises[libraryUrl];
|
|
121
|
+
}
|
|
122
|
+
function getLibraryUrl(library, moduleName, options) {
|
|
123
|
+
if (library.startsWith("http")) {
|
|
124
|
+
return library;
|
|
125
|
+
}
|
|
126
|
+
const modules = options.modules || {};
|
|
127
|
+
if (modules[library]) {
|
|
128
|
+
return modules[library];
|
|
129
|
+
}
|
|
130
|
+
if (!isBrowser) {
|
|
131
|
+
return `modules/${moduleName}/dist/libs/${library}`;
|
|
132
|
+
}
|
|
133
|
+
if (options.CDN) {
|
|
134
|
+
assert(options.CDN.startsWith("http"));
|
|
135
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${library}`;
|
|
136
|
+
}
|
|
137
|
+
if (isWorker) {
|
|
138
|
+
return `../src/libs/${library}`;
|
|
139
|
+
}
|
|
140
|
+
return `modules/${moduleName}/src/libs/${library}`;
|
|
141
|
+
}
|
|
142
|
+
async function loadLibraryFromFile(libraryUrl) {
|
|
143
|
+
if (libraryUrl.endsWith("wasm")) {
|
|
144
|
+
const response2 = await fetch(libraryUrl);
|
|
145
|
+
return await response2.arrayBuffer();
|
|
146
|
+
}
|
|
147
|
+
if (!isBrowser) {
|
|
148
|
+
return node.requireFromFile && await node.requireFromFile(libraryUrl);
|
|
149
|
+
}
|
|
150
|
+
if (isWorker) {
|
|
151
|
+
return importScripts(libraryUrl);
|
|
152
|
+
}
|
|
153
|
+
const response = await fetch(libraryUrl);
|
|
154
|
+
const scriptSource = await response.text();
|
|
155
|
+
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
156
|
+
}
|
|
157
|
+
function loadLibraryFromString(scriptSource, id) {
|
|
158
|
+
if (!isBrowser) {
|
|
159
|
+
return node.requireFromString && node.requireFromString(scriptSource, id);
|
|
160
|
+
}
|
|
161
|
+
if (isWorker) {
|
|
162
|
+
eval.call(global_, scriptSource);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const script = document.createElement("script");
|
|
166
|
+
script.id = id;
|
|
167
|
+
try {
|
|
168
|
+
script.appendChild(document.createTextNode(scriptSource));
|
|
169
|
+
} catch (e) {
|
|
170
|
+
script.text = scriptSource;
|
|
171
|
+
}
|
|
172
|
+
document.body.appendChild(script);
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
177
|
+
var requestId = 0;
|
|
178
|
+
function createLoaderWorker(loader) {
|
|
179
|
+
if (typeof self === "undefined") {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
183
|
+
switch (type) {
|
|
184
|
+
case "process":
|
|
185
|
+
try {
|
|
186
|
+
const { input, options = {} } = payload;
|
|
187
|
+
const result = await parseData({
|
|
188
|
+
loader,
|
|
189
|
+
arrayBuffer: input,
|
|
190
|
+
options,
|
|
191
|
+
context: {
|
|
192
|
+
parse: parseOnMainThread
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
WorkerBody.postMessage("done", { result });
|
|
196
|
+
} catch (error) {
|
|
197
|
+
const message = error instanceof Error ? error.message : "";
|
|
198
|
+
WorkerBody.postMessage("error", { error: message });
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function parseOnMainThread(arrayBuffer, options) {
|
|
206
|
+
return new Promise((resolve, reject) => {
|
|
207
|
+
const id = requestId++;
|
|
208
|
+
const onMessage = (type, payload2) => {
|
|
209
|
+
if (payload2.id !== id) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
switch (type) {
|
|
213
|
+
case "done":
|
|
214
|
+
WorkerBody.removeEventListener(onMessage);
|
|
215
|
+
resolve(payload2.result);
|
|
216
|
+
break;
|
|
217
|
+
case "error":
|
|
218
|
+
WorkerBody.removeEventListener(onMessage);
|
|
219
|
+
reject(payload2.error);
|
|
220
|
+
break;
|
|
221
|
+
default:
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
WorkerBody.addEventListener(onMessage);
|
|
225
|
+
const payload = { id, input: arrayBuffer, options };
|
|
226
|
+
WorkerBody.postMessage("process", payload);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async function parseData({ loader, arrayBuffer, options, context }) {
|
|
230
|
+
let data;
|
|
231
|
+
let parser;
|
|
232
|
+
if (loader.parseSync || loader.parse) {
|
|
233
|
+
data = arrayBuffer;
|
|
234
|
+
parser = loader.parseSync || loader.parse;
|
|
235
|
+
} else if (loader.parseTextSync) {
|
|
236
|
+
const textDecoder = new TextDecoder();
|
|
237
|
+
data = textDecoder.decode(arrayBuffer);
|
|
238
|
+
parser = loader.parseTextSync;
|
|
239
|
+
} else {
|
|
240
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
241
|
+
}
|
|
242
|
+
options = {
|
|
243
|
+
...options,
|
|
244
|
+
modules: loader && loader.options && loader.options.modules || {},
|
|
245
|
+
worker: false
|
|
246
|
+
};
|
|
247
|
+
return await parser(data, { ...options }, context, loader);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/lib/utils/version.ts
|
|
251
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
252
|
+
|
|
253
|
+
// src/draco-loader.ts
|
|
254
|
+
var DEFAULT_DRACO_OPTIONS = {
|
|
255
|
+
draco: {
|
|
256
|
+
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
257
|
+
libraryPath: "libs/",
|
|
258
|
+
extraAttributes: {},
|
|
259
|
+
attributeNameEntry: void 0
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var DracoLoader = {
|
|
263
|
+
name: "Draco",
|
|
264
|
+
id: "draco",
|
|
265
|
+
module: "draco",
|
|
266
|
+
shapes: ["mesh"],
|
|
267
|
+
version: VERSION3,
|
|
268
|
+
worker: true,
|
|
269
|
+
extensions: ["drc"],
|
|
270
|
+
mimeTypes: ["application/octet-stream"],
|
|
271
|
+
binary: true,
|
|
272
|
+
tests: ["DRACO"],
|
|
273
|
+
options: DEFAULT_DRACO_OPTIONS
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// ../schema/src/category/mesh/mesh-utils.ts
|
|
277
|
+
function getMeshBoundingBox(attributes) {
|
|
278
|
+
let minX = Infinity;
|
|
279
|
+
let minY = Infinity;
|
|
280
|
+
let minZ = Infinity;
|
|
281
|
+
let maxX = -Infinity;
|
|
282
|
+
let maxY = -Infinity;
|
|
283
|
+
let maxZ = -Infinity;
|
|
284
|
+
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
285
|
+
const len = positions && positions.length;
|
|
286
|
+
for (let i = 0; i < len; i += 3) {
|
|
287
|
+
const x = positions[i];
|
|
288
|
+
const y = positions[i + 1];
|
|
289
|
+
const z = positions[i + 2];
|
|
290
|
+
minX = x < minX ? x : minX;
|
|
291
|
+
minY = y < minY ? y : minY;
|
|
292
|
+
minZ = z < minZ ? z : minZ;
|
|
293
|
+
maxX = x > maxX ? x : maxX;
|
|
294
|
+
maxY = y > maxY ? y : maxY;
|
|
295
|
+
maxZ = z > maxZ ? z : maxZ;
|
|
296
|
+
}
|
|
297
|
+
return [
|
|
298
|
+
[minX, minY, minZ],
|
|
299
|
+
[maxX, maxY, maxZ]
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ../schema/src/lib/utils/assert.ts
|
|
304
|
+
function assert2(condition, message) {
|
|
305
|
+
if (!condition) {
|
|
306
|
+
throw new Error(message || "loader assertion failed.");
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ../schema/src/lib/schema/impl/schema.ts
|
|
311
|
+
var Schema = class {
|
|
312
|
+
constructor(fields, metadata) {
|
|
313
|
+
assert2(Array.isArray(fields));
|
|
314
|
+
checkNames(fields);
|
|
315
|
+
this.fields = fields;
|
|
316
|
+
this.metadata = metadata || new Map();
|
|
317
|
+
}
|
|
318
|
+
compareTo(other) {
|
|
319
|
+
if (this.metadata !== other.metadata) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if (this.fields.length !== other.fields.length) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
for (let i = 0; i < this.fields.length; ++i) {
|
|
326
|
+
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
select(...columnNames) {
|
|
333
|
+
const nameMap = Object.create(null);
|
|
334
|
+
for (const name of columnNames) {
|
|
335
|
+
nameMap[name] = true;
|
|
336
|
+
}
|
|
337
|
+
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
338
|
+
return new Schema(selectedFields, this.metadata);
|
|
339
|
+
}
|
|
340
|
+
selectAt(...columnIndices) {
|
|
341
|
+
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
342
|
+
return new Schema(selectedFields, this.metadata);
|
|
343
|
+
}
|
|
344
|
+
assign(schemaOrFields) {
|
|
345
|
+
let fields;
|
|
346
|
+
let metadata = this.metadata;
|
|
347
|
+
if (schemaOrFields instanceof Schema) {
|
|
348
|
+
const otherSchema = schemaOrFields;
|
|
349
|
+
fields = otherSchema.fields;
|
|
350
|
+
metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
|
|
351
|
+
} else {
|
|
352
|
+
fields = schemaOrFields;
|
|
353
|
+
}
|
|
354
|
+
const fieldMap = Object.create(null);
|
|
355
|
+
for (const field of this.fields) {
|
|
356
|
+
fieldMap[field.name] = field;
|
|
357
|
+
}
|
|
358
|
+
for (const field of fields) {
|
|
359
|
+
fieldMap[field.name] = field;
|
|
360
|
+
}
|
|
361
|
+
const mergedFields = Object.values(fieldMap);
|
|
362
|
+
return new Schema(mergedFields, metadata);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
function checkNames(fields) {
|
|
366
|
+
const usedNames = {};
|
|
367
|
+
for (const field of fields) {
|
|
368
|
+
if (usedNames[field.name]) {
|
|
369
|
+
console.warn("Schema: duplicated field name", field.name, field);
|
|
370
|
+
}
|
|
371
|
+
usedNames[field.name] = true;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function mergeMaps(m1, m2) {
|
|
375
|
+
return new Map([...m1 || new Map(), ...m2 || new Map()]);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ../schema/src/lib/schema/impl/field.ts
|
|
379
|
+
var Field = class {
|
|
380
|
+
constructor(name, type, nullable = false, metadata = new Map()) {
|
|
381
|
+
this.name = name;
|
|
382
|
+
this.type = type;
|
|
383
|
+
this.nullable = nullable;
|
|
384
|
+
this.metadata = metadata;
|
|
385
|
+
}
|
|
386
|
+
get typeId() {
|
|
387
|
+
return this.type && this.type.typeId;
|
|
388
|
+
}
|
|
389
|
+
clone() {
|
|
390
|
+
return new Field(this.name, this.type, this.nullable, this.metadata);
|
|
391
|
+
}
|
|
392
|
+
compareTo(other) {
|
|
393
|
+
return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
|
|
394
|
+
}
|
|
395
|
+
toString() {
|
|
396
|
+
return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// ../schema/src/lib/schema/impl/enum.ts
|
|
401
|
+
var Type;
|
|
402
|
+
(function(Type2) {
|
|
403
|
+
Type2[Type2["NONE"] = 0] = "NONE";
|
|
404
|
+
Type2[Type2["Null"] = 1] = "Null";
|
|
405
|
+
Type2[Type2["Int"] = 2] = "Int";
|
|
406
|
+
Type2[Type2["Float"] = 3] = "Float";
|
|
407
|
+
Type2[Type2["Binary"] = 4] = "Binary";
|
|
408
|
+
Type2[Type2["Utf8"] = 5] = "Utf8";
|
|
409
|
+
Type2[Type2["Bool"] = 6] = "Bool";
|
|
410
|
+
Type2[Type2["Decimal"] = 7] = "Decimal";
|
|
411
|
+
Type2[Type2["Date"] = 8] = "Date";
|
|
412
|
+
Type2[Type2["Time"] = 9] = "Time";
|
|
413
|
+
Type2[Type2["Timestamp"] = 10] = "Timestamp";
|
|
414
|
+
Type2[Type2["Interval"] = 11] = "Interval";
|
|
415
|
+
Type2[Type2["List"] = 12] = "List";
|
|
416
|
+
Type2[Type2["Struct"] = 13] = "Struct";
|
|
417
|
+
Type2[Type2["Union"] = 14] = "Union";
|
|
418
|
+
Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
|
|
419
|
+
Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
|
|
420
|
+
Type2[Type2["Map"] = 17] = "Map";
|
|
421
|
+
Type2[Type2["Dictionary"] = -1] = "Dictionary";
|
|
422
|
+
Type2[Type2["Int8"] = -2] = "Int8";
|
|
423
|
+
Type2[Type2["Int16"] = -3] = "Int16";
|
|
424
|
+
Type2[Type2["Int32"] = -4] = "Int32";
|
|
425
|
+
Type2[Type2["Int64"] = -5] = "Int64";
|
|
426
|
+
Type2[Type2["Uint8"] = -6] = "Uint8";
|
|
427
|
+
Type2[Type2["Uint16"] = -7] = "Uint16";
|
|
428
|
+
Type2[Type2["Uint32"] = -8] = "Uint32";
|
|
429
|
+
Type2[Type2["Uint64"] = -9] = "Uint64";
|
|
430
|
+
Type2[Type2["Float16"] = -10] = "Float16";
|
|
431
|
+
Type2[Type2["Float32"] = -11] = "Float32";
|
|
432
|
+
Type2[Type2["Float64"] = -12] = "Float64";
|
|
433
|
+
Type2[Type2["DateDay"] = -13] = "DateDay";
|
|
434
|
+
Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
|
|
435
|
+
Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
|
|
436
|
+
Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
|
|
437
|
+
Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
|
|
438
|
+
Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
|
|
439
|
+
Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
|
|
440
|
+
Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
|
|
441
|
+
Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
|
|
442
|
+
Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
|
|
443
|
+
Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
|
|
444
|
+
Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
|
|
445
|
+
Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
|
|
446
|
+
Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
|
|
447
|
+
})(Type || (Type = {}));
|
|
448
|
+
|
|
449
|
+
// ../schema/src/lib/schema/impl/type.ts
|
|
450
|
+
var DataType = class {
|
|
451
|
+
static isNull(x) {
|
|
452
|
+
return x && x.typeId === Type.Null;
|
|
453
|
+
}
|
|
454
|
+
static isInt(x) {
|
|
455
|
+
return x && x.typeId === Type.Int;
|
|
456
|
+
}
|
|
457
|
+
static isFloat(x) {
|
|
458
|
+
return x && x.typeId === Type.Float;
|
|
459
|
+
}
|
|
460
|
+
static isBinary(x) {
|
|
461
|
+
return x && x.typeId === Type.Binary;
|
|
462
|
+
}
|
|
463
|
+
static isUtf8(x) {
|
|
464
|
+
return x && x.typeId === Type.Utf8;
|
|
465
|
+
}
|
|
466
|
+
static isBool(x) {
|
|
467
|
+
return x && x.typeId === Type.Bool;
|
|
468
|
+
}
|
|
469
|
+
static isDecimal(x) {
|
|
470
|
+
return x && x.typeId === Type.Decimal;
|
|
471
|
+
}
|
|
472
|
+
static isDate(x) {
|
|
473
|
+
return x && x.typeId === Type.Date;
|
|
474
|
+
}
|
|
475
|
+
static isTime(x) {
|
|
476
|
+
return x && x.typeId === Type.Time;
|
|
477
|
+
}
|
|
478
|
+
static isTimestamp(x) {
|
|
479
|
+
return x && x.typeId === Type.Timestamp;
|
|
480
|
+
}
|
|
481
|
+
static isInterval(x) {
|
|
482
|
+
return x && x.typeId === Type.Interval;
|
|
483
|
+
}
|
|
484
|
+
static isList(x) {
|
|
485
|
+
return x && x.typeId === Type.List;
|
|
486
|
+
}
|
|
487
|
+
static isStruct(x) {
|
|
488
|
+
return x && x.typeId === Type.Struct;
|
|
489
|
+
}
|
|
490
|
+
static isUnion(x) {
|
|
491
|
+
return x && x.typeId === Type.Union;
|
|
492
|
+
}
|
|
493
|
+
static isFixedSizeBinary(x) {
|
|
494
|
+
return x && x.typeId === Type.FixedSizeBinary;
|
|
495
|
+
}
|
|
496
|
+
static isFixedSizeList(x) {
|
|
497
|
+
return x && x.typeId === Type.FixedSizeList;
|
|
498
|
+
}
|
|
499
|
+
static isMap(x) {
|
|
500
|
+
return x && x.typeId === Type.Map;
|
|
501
|
+
}
|
|
502
|
+
static isDictionary(x) {
|
|
503
|
+
return x && x.typeId === Type.Dictionary;
|
|
504
|
+
}
|
|
505
|
+
get typeId() {
|
|
506
|
+
return Type.NONE;
|
|
507
|
+
}
|
|
508
|
+
compareTo(other) {
|
|
509
|
+
return this === other;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
var Null = class extends DataType {
|
|
513
|
+
get typeId() {
|
|
514
|
+
return Type.Null;
|
|
515
|
+
}
|
|
516
|
+
get [Symbol.toStringTag]() {
|
|
517
|
+
return "Null";
|
|
518
|
+
}
|
|
519
|
+
toString() {
|
|
520
|
+
return "Null";
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
var Bool = class extends DataType {
|
|
524
|
+
get typeId() {
|
|
525
|
+
return Type.Bool;
|
|
526
|
+
}
|
|
527
|
+
get [Symbol.toStringTag]() {
|
|
528
|
+
return "Bool";
|
|
529
|
+
}
|
|
530
|
+
toString() {
|
|
531
|
+
return "Bool";
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var Int = class extends DataType {
|
|
535
|
+
constructor(isSigned, bitWidth) {
|
|
536
|
+
super();
|
|
537
|
+
this.isSigned = isSigned;
|
|
538
|
+
this.bitWidth = bitWidth;
|
|
539
|
+
}
|
|
540
|
+
get typeId() {
|
|
541
|
+
return Type.Int;
|
|
542
|
+
}
|
|
543
|
+
get [Symbol.toStringTag]() {
|
|
544
|
+
return "Int";
|
|
545
|
+
}
|
|
546
|
+
toString() {
|
|
547
|
+
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
var Int8 = class extends Int {
|
|
551
|
+
constructor() {
|
|
552
|
+
super(true, 8);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var Int16 = class extends Int {
|
|
556
|
+
constructor() {
|
|
557
|
+
super(true, 16);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
var Int32 = class extends Int {
|
|
561
|
+
constructor() {
|
|
562
|
+
super(true, 32);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
var Uint8 = class extends Int {
|
|
566
|
+
constructor() {
|
|
567
|
+
super(false, 8);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
var Uint16 = class extends Int {
|
|
571
|
+
constructor() {
|
|
572
|
+
super(false, 16);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
var Uint32 = class extends Int {
|
|
576
|
+
constructor() {
|
|
577
|
+
super(false, 32);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
var Precision = {
|
|
581
|
+
HALF: 16,
|
|
582
|
+
SINGLE: 32,
|
|
583
|
+
DOUBLE: 64
|
|
584
|
+
};
|
|
585
|
+
var Float = class extends DataType {
|
|
586
|
+
constructor(precision) {
|
|
587
|
+
super();
|
|
588
|
+
this.precision = precision;
|
|
589
|
+
}
|
|
590
|
+
get typeId() {
|
|
591
|
+
return Type.Float;
|
|
592
|
+
}
|
|
593
|
+
get [Symbol.toStringTag]() {
|
|
594
|
+
return "Float";
|
|
595
|
+
}
|
|
596
|
+
toString() {
|
|
597
|
+
return `Float${this.precision}`;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
var Float32 = class extends Float {
|
|
601
|
+
constructor() {
|
|
602
|
+
super(Precision.SINGLE);
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
var Float64 = class extends Float {
|
|
606
|
+
constructor() {
|
|
607
|
+
super(Precision.DOUBLE);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var Binary = class extends DataType {
|
|
611
|
+
constructor() {
|
|
612
|
+
super();
|
|
613
|
+
}
|
|
614
|
+
get typeId() {
|
|
615
|
+
return Type.Binary;
|
|
616
|
+
}
|
|
617
|
+
toString() {
|
|
618
|
+
return "Binary";
|
|
619
|
+
}
|
|
620
|
+
get [Symbol.toStringTag]() {
|
|
621
|
+
return "Binary";
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
var Utf8 = class extends DataType {
|
|
625
|
+
get typeId() {
|
|
626
|
+
return Type.Utf8;
|
|
627
|
+
}
|
|
628
|
+
get [Symbol.toStringTag]() {
|
|
629
|
+
return "Utf8";
|
|
630
|
+
}
|
|
631
|
+
toString() {
|
|
632
|
+
return "Utf8";
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
var DateUnit = {
|
|
636
|
+
DAY: 0,
|
|
637
|
+
MILLISECOND: 1
|
|
638
|
+
};
|
|
639
|
+
var Date = class extends DataType {
|
|
640
|
+
constructor(unit) {
|
|
641
|
+
super();
|
|
642
|
+
this.unit = unit;
|
|
643
|
+
}
|
|
644
|
+
get typeId() {
|
|
645
|
+
return Type.Date;
|
|
646
|
+
}
|
|
647
|
+
get [Symbol.toStringTag]() {
|
|
648
|
+
return "Date";
|
|
649
|
+
}
|
|
650
|
+
toString() {
|
|
651
|
+
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
var TimeUnit = {
|
|
655
|
+
SECOND: 1,
|
|
656
|
+
MILLISECOND: 1e3,
|
|
657
|
+
MICROSECOND: 1e6,
|
|
658
|
+
NANOSECOND: 1e9
|
|
659
|
+
};
|
|
660
|
+
var Time = class extends DataType {
|
|
661
|
+
constructor(unit, bitWidth) {
|
|
662
|
+
super();
|
|
663
|
+
this.unit = unit;
|
|
664
|
+
this.bitWidth = bitWidth;
|
|
665
|
+
}
|
|
666
|
+
get typeId() {
|
|
667
|
+
return Type.Time;
|
|
668
|
+
}
|
|
669
|
+
toString() {
|
|
670
|
+
return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
|
|
671
|
+
}
|
|
672
|
+
get [Symbol.toStringTag]() {
|
|
673
|
+
return "Time";
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
var Timestamp = class extends DataType {
|
|
677
|
+
constructor(unit, timezone = null) {
|
|
678
|
+
super();
|
|
679
|
+
this.unit = unit;
|
|
680
|
+
this.timezone = timezone;
|
|
681
|
+
}
|
|
682
|
+
get typeId() {
|
|
683
|
+
return Type.Timestamp;
|
|
684
|
+
}
|
|
685
|
+
get [Symbol.toStringTag]() {
|
|
686
|
+
return "Timestamp";
|
|
687
|
+
}
|
|
688
|
+
toString() {
|
|
689
|
+
return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
var IntervalUnit = {
|
|
693
|
+
DAY_TIME: 0,
|
|
694
|
+
YEAR_MONTH: 1
|
|
695
|
+
};
|
|
696
|
+
var Interval = class extends DataType {
|
|
697
|
+
constructor(unit) {
|
|
698
|
+
super();
|
|
699
|
+
this.unit = unit;
|
|
700
|
+
}
|
|
701
|
+
get typeId() {
|
|
702
|
+
return Type.Interval;
|
|
703
|
+
}
|
|
704
|
+
get [Symbol.toStringTag]() {
|
|
705
|
+
return "Interval";
|
|
706
|
+
}
|
|
707
|
+
toString() {
|
|
708
|
+
return `Interval<${IntervalUnit[this.unit]}>`;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
var FixedSizeList = class extends DataType {
|
|
712
|
+
constructor(listSize, child) {
|
|
713
|
+
super();
|
|
714
|
+
this.listSize = listSize;
|
|
715
|
+
this.children = [child];
|
|
716
|
+
}
|
|
717
|
+
get typeId() {
|
|
718
|
+
return Type.FixedSizeList;
|
|
719
|
+
}
|
|
720
|
+
get valueType() {
|
|
721
|
+
return this.children[0].type;
|
|
722
|
+
}
|
|
723
|
+
get valueField() {
|
|
724
|
+
return this.children[0];
|
|
725
|
+
}
|
|
726
|
+
get [Symbol.toStringTag]() {
|
|
727
|
+
return "FixedSizeList";
|
|
728
|
+
}
|
|
729
|
+
toString() {
|
|
730
|
+
return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
var Struct = class extends DataType {
|
|
734
|
+
constructor(children) {
|
|
735
|
+
super();
|
|
736
|
+
this.children = children;
|
|
737
|
+
}
|
|
738
|
+
get typeId() {
|
|
739
|
+
return Type.Struct;
|
|
740
|
+
}
|
|
741
|
+
toString() {
|
|
742
|
+
return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
|
|
743
|
+
}
|
|
744
|
+
get [Symbol.toStringTag]() {
|
|
745
|
+
return "Struct";
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// ../schema/src/lib/arrow/arrow-like-type-utils.ts
|
|
750
|
+
function getArrowTypeFromTypedArray(array) {
|
|
751
|
+
switch (array.constructor) {
|
|
752
|
+
case Int8Array:
|
|
753
|
+
return new Int8();
|
|
754
|
+
case Uint8Array:
|
|
755
|
+
return new Uint8();
|
|
756
|
+
case Int16Array:
|
|
757
|
+
return new Int16();
|
|
758
|
+
case Uint16Array:
|
|
759
|
+
return new Uint16();
|
|
760
|
+
case Int32Array:
|
|
761
|
+
return new Int32();
|
|
762
|
+
case Uint32Array:
|
|
763
|
+
return new Uint32();
|
|
764
|
+
case Float32Array:
|
|
765
|
+
return new Float32();
|
|
766
|
+
case Float64Array:
|
|
767
|
+
return new Float64();
|
|
768
|
+
default:
|
|
769
|
+
throw new Error("array type not supported");
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// ../schema/src/category/mesh/deduce-mesh-schema.ts
|
|
774
|
+
function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
775
|
+
const type = getArrowTypeFromTypedArray(attribute.value);
|
|
776
|
+
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
777
|
+
const field = new Field(attributeName, new FixedSizeList(attribute.size, new Field("value", type)), false, metadata);
|
|
778
|
+
return field;
|
|
779
|
+
}
|
|
780
|
+
function makeMeshAttributeMetadata(attribute) {
|
|
781
|
+
const result = new Map();
|
|
782
|
+
if ("byteOffset" in attribute) {
|
|
783
|
+
result.set("byteOffset", attribute.byteOffset.toString(10));
|
|
784
|
+
}
|
|
785
|
+
if ("byteStride" in attribute) {
|
|
786
|
+
result.set("byteStride", attribute.byteStride.toString(10));
|
|
787
|
+
}
|
|
788
|
+
if ("normalized" in attribute) {
|
|
789
|
+
result.set("normalized", attribute.normalized.toString());
|
|
790
|
+
}
|
|
791
|
+
return result;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// src/lib/utils/get-draco-schema.ts
|
|
795
|
+
function getDracoSchema(attributes, loaderData, indices) {
|
|
796
|
+
const metadataMap = makeMetadata(loaderData.metadata);
|
|
797
|
+
const fields = [];
|
|
798
|
+
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
799
|
+
for (const attributeName in attributes) {
|
|
800
|
+
const attribute = attributes[attributeName];
|
|
801
|
+
const field = getArrowFieldFromAttribute(attributeName, attribute, namedLoaderDataAttributes[attributeName]);
|
|
802
|
+
fields.push(field);
|
|
803
|
+
}
|
|
804
|
+
if (indices) {
|
|
805
|
+
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
806
|
+
fields.push(indicesField);
|
|
807
|
+
}
|
|
808
|
+
return new Schema(fields, metadataMap);
|
|
809
|
+
}
|
|
810
|
+
function transformAttributesLoaderData(loaderData) {
|
|
811
|
+
const result = {};
|
|
812
|
+
for (const key in loaderData) {
|
|
813
|
+
const dracoAttribute = loaderData[key];
|
|
814
|
+
result[dracoAttribute.name || "undefined"] = dracoAttribute;
|
|
815
|
+
}
|
|
816
|
+
return result;
|
|
817
|
+
}
|
|
818
|
+
function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
|
|
819
|
+
const metadataMap = loaderData ? makeMetadata(loaderData.metadata) : void 0;
|
|
820
|
+
const field = deduceMeshField(attributeName, attribute, metadataMap);
|
|
821
|
+
return field;
|
|
822
|
+
}
|
|
823
|
+
function makeMetadata(metadata) {
|
|
824
|
+
const metadataMap = new Map();
|
|
825
|
+
for (const key in metadata) {
|
|
826
|
+
metadataMap.set(`${key}.string`, JSON.stringify(metadata[key]));
|
|
827
|
+
}
|
|
828
|
+
return metadataMap;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// src/lib/draco-parser.ts
|
|
832
|
+
var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = {
|
|
833
|
+
POSITION: "POSITION",
|
|
834
|
+
NORMAL: "NORMAL",
|
|
835
|
+
COLOR: "COLOR_0",
|
|
836
|
+
TEX_COORD: "TEXCOORD_0"
|
|
837
|
+
};
|
|
838
|
+
var DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = {
|
|
839
|
+
1: Int8Array,
|
|
840
|
+
2: Uint8Array,
|
|
841
|
+
3: Int16Array,
|
|
842
|
+
4: Uint16Array,
|
|
843
|
+
5: Int32Array,
|
|
844
|
+
6: Uint32Array,
|
|
845
|
+
9: Float32Array
|
|
846
|
+
};
|
|
847
|
+
var INDEX_ITEM_SIZE = 4;
|
|
848
|
+
var DracoParser = class {
|
|
849
|
+
constructor(draco) {
|
|
850
|
+
this.draco = draco;
|
|
851
|
+
this.decoder = new this.draco.Decoder();
|
|
852
|
+
this.metadataQuerier = new this.draco.MetadataQuerier();
|
|
853
|
+
}
|
|
854
|
+
destroy() {
|
|
855
|
+
this.draco.destroy(this.decoder);
|
|
856
|
+
this.draco.destroy(this.metadataQuerier);
|
|
857
|
+
}
|
|
858
|
+
parseSync(arrayBuffer, options = {}) {
|
|
859
|
+
const buffer = new this.draco.DecoderBuffer();
|
|
860
|
+
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
|
|
861
|
+
this._disableAttributeTransforms(options);
|
|
862
|
+
const geometry_type = this.decoder.GetEncodedGeometryType(buffer);
|
|
863
|
+
const dracoGeometry = geometry_type === this.draco.TRIANGULAR_MESH ? new this.draco.Mesh() : new this.draco.PointCloud();
|
|
864
|
+
try {
|
|
865
|
+
let dracoStatus;
|
|
866
|
+
switch (geometry_type) {
|
|
867
|
+
case this.draco.TRIANGULAR_MESH:
|
|
868
|
+
dracoStatus = this.decoder.DecodeBufferToMesh(buffer, dracoGeometry);
|
|
869
|
+
break;
|
|
870
|
+
case this.draco.POINT_CLOUD:
|
|
871
|
+
dracoStatus = this.decoder.DecodeBufferToPointCloud(buffer, dracoGeometry);
|
|
872
|
+
break;
|
|
873
|
+
default:
|
|
874
|
+
throw new Error("DRACO: Unknown geometry type.");
|
|
875
|
+
}
|
|
876
|
+
if (!dracoStatus.ok() || !dracoGeometry.ptr) {
|
|
877
|
+
const message = `DRACO decompression failed: ${dracoStatus.error_msg()}`;
|
|
878
|
+
throw new Error(message);
|
|
879
|
+
}
|
|
880
|
+
const loaderData = this._getDracoLoaderData(dracoGeometry, geometry_type, options);
|
|
881
|
+
const geometry = this._getMeshData(dracoGeometry, loaderData, options);
|
|
882
|
+
const boundingBox = getMeshBoundingBox(geometry.attributes);
|
|
883
|
+
const schema = getDracoSchema(geometry.attributes, loaderData, geometry.indices);
|
|
884
|
+
const data = {
|
|
885
|
+
loader: "draco",
|
|
886
|
+
loaderData,
|
|
887
|
+
header: {
|
|
888
|
+
vertexCount: dracoGeometry.num_points(),
|
|
889
|
+
boundingBox
|
|
890
|
+
},
|
|
891
|
+
...geometry,
|
|
892
|
+
schema
|
|
893
|
+
};
|
|
894
|
+
return data;
|
|
895
|
+
} finally {
|
|
896
|
+
this.draco.destroy(buffer);
|
|
897
|
+
if (dracoGeometry) {
|
|
898
|
+
this.draco.destroy(dracoGeometry);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
903
|
+
const metadata = this._getTopLevelMetadata(dracoGeometry);
|
|
904
|
+
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
905
|
+
return {
|
|
906
|
+
geometry_type,
|
|
907
|
+
num_attributes: dracoGeometry.num_attributes(),
|
|
908
|
+
num_points: dracoGeometry.num_points(),
|
|
909
|
+
num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
|
|
910
|
+
metadata,
|
|
911
|
+
attributes
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
_getDracoAttributes(dracoGeometry, options) {
|
|
915
|
+
const dracoAttributes = {};
|
|
916
|
+
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
917
|
+
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
918
|
+
const metadata = this._getAttributeMetadata(dracoGeometry, attributeId);
|
|
919
|
+
dracoAttributes[dracoAttribute.unique_id()] = {
|
|
920
|
+
unique_id: dracoAttribute.unique_id(),
|
|
921
|
+
attribute_type: dracoAttribute.attribute_type(),
|
|
922
|
+
data_type: dracoAttribute.data_type(),
|
|
923
|
+
num_components: dracoAttribute.num_components(),
|
|
924
|
+
byte_offset: dracoAttribute.byte_offset(),
|
|
925
|
+
byte_stride: dracoAttribute.byte_stride(),
|
|
926
|
+
normalized: dracoAttribute.normalized(),
|
|
927
|
+
attribute_index: attributeId,
|
|
928
|
+
metadata
|
|
929
|
+
};
|
|
930
|
+
const quantization = this._getQuantizationTransform(dracoAttribute, options);
|
|
931
|
+
if (quantization) {
|
|
932
|
+
dracoAttributes[dracoAttribute.unique_id()].quantization_transform = quantization;
|
|
933
|
+
}
|
|
934
|
+
const octahedron = this._getOctahedronTransform(dracoAttribute, options);
|
|
935
|
+
if (octahedron) {
|
|
936
|
+
dracoAttributes[dracoAttribute.unique_id()].octahedron_transform = octahedron;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return dracoAttributes;
|
|
940
|
+
}
|
|
941
|
+
_getMeshData(dracoGeometry, loaderData, options) {
|
|
942
|
+
const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
|
|
943
|
+
const positionAttribute = attributes.POSITION;
|
|
944
|
+
if (!positionAttribute) {
|
|
945
|
+
throw new Error("DRACO: No position attribute found.");
|
|
946
|
+
}
|
|
947
|
+
if (dracoGeometry instanceof this.draco.Mesh) {
|
|
948
|
+
switch (options.topology) {
|
|
949
|
+
case "triangle-strip":
|
|
950
|
+
return {
|
|
951
|
+
topology: "triangle-strip",
|
|
952
|
+
mode: 4,
|
|
953
|
+
attributes,
|
|
954
|
+
indices: {
|
|
955
|
+
value: this._getTriangleStripIndices(dracoGeometry),
|
|
956
|
+
size: 1
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
case "triangle-list":
|
|
960
|
+
default:
|
|
961
|
+
return {
|
|
962
|
+
topology: "triangle-list",
|
|
963
|
+
mode: 5,
|
|
964
|
+
attributes,
|
|
965
|
+
indices: {
|
|
966
|
+
value: this._getTriangleListIndices(dracoGeometry),
|
|
967
|
+
size: 1
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return {
|
|
973
|
+
topology: "point-list",
|
|
974
|
+
mode: 0,
|
|
975
|
+
attributes
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
_getMeshAttributes(loaderData, dracoGeometry, options) {
|
|
979
|
+
const attributes = {};
|
|
980
|
+
for (const loaderAttribute of Object.values(loaderData.attributes)) {
|
|
981
|
+
const attributeName = this._deduceAttributeName(loaderAttribute, options);
|
|
982
|
+
loaderAttribute.name = attributeName;
|
|
983
|
+
const { value, size } = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
984
|
+
attributes[attributeName] = {
|
|
985
|
+
value,
|
|
986
|
+
size,
|
|
987
|
+
byteOffset: loaderAttribute.byte_offset,
|
|
988
|
+
byteStride: loaderAttribute.byte_stride,
|
|
989
|
+
normalized: loaderAttribute.normalized
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
return attributes;
|
|
993
|
+
}
|
|
994
|
+
_getTriangleListIndices(dracoGeometry) {
|
|
995
|
+
const numFaces = dracoGeometry.num_faces();
|
|
996
|
+
const numIndices = numFaces * 3;
|
|
997
|
+
const byteLength = numIndices * INDEX_ITEM_SIZE;
|
|
998
|
+
const ptr = this.draco._malloc(byteLength);
|
|
999
|
+
try {
|
|
1000
|
+
this.decoder.GetTrianglesUInt32Array(dracoGeometry, byteLength, ptr);
|
|
1001
|
+
return new Uint32Array(this.draco.HEAPF32.buffer, ptr, numIndices).slice();
|
|
1002
|
+
} finally {
|
|
1003
|
+
this.draco._free(ptr);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
_getTriangleStripIndices(dracoGeometry) {
|
|
1007
|
+
const dracoArray = new this.draco.DracoInt32Array();
|
|
1008
|
+
try {
|
|
1009
|
+
this.decoder.GetTriangleStripsFromMesh(dracoGeometry, dracoArray);
|
|
1010
|
+
return getUint32Array(dracoArray);
|
|
1011
|
+
} finally {
|
|
1012
|
+
this.draco.destroy(dracoArray);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
_getAttributeValues(dracoGeometry, attribute) {
|
|
1016
|
+
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
1017
|
+
const numComponents = attribute.num_components;
|
|
1018
|
+
const numPoints = dracoGeometry.num_points();
|
|
1019
|
+
const numValues = numPoints * numComponents;
|
|
1020
|
+
const byteLength = numValues * TypedArrayCtor.BYTES_PER_ELEMENT;
|
|
1021
|
+
const dataType = getDracoDataType(this.draco, TypedArrayCtor);
|
|
1022
|
+
let value;
|
|
1023
|
+
const ptr = this.draco._malloc(byteLength);
|
|
1024
|
+
try {
|
|
1025
|
+
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
|
|
1026
|
+
this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, dracoAttribute, dataType, byteLength, ptr);
|
|
1027
|
+
value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
|
|
1028
|
+
} finally {
|
|
1029
|
+
this.draco._free(ptr);
|
|
1030
|
+
}
|
|
1031
|
+
return { value, size: numComponents };
|
|
1032
|
+
}
|
|
1033
|
+
_deduceAttributeName(attribute, options) {
|
|
1034
|
+
const uniqueId = attribute.unique_id;
|
|
1035
|
+
for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
|
|
1036
|
+
if (attributeUniqueId === uniqueId) {
|
|
1037
|
+
return attributeName;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
const thisAttributeType = attribute.attribute_type;
|
|
1041
|
+
for (const dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) {
|
|
1042
|
+
const attributeType = this.draco[dracoAttributeConstant];
|
|
1043
|
+
if (attributeType === thisAttributeType) {
|
|
1044
|
+
return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant];
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
const entryName = options.attributeNameEntry || "name";
|
|
1048
|
+
if (attribute.metadata[entryName]) {
|
|
1049
|
+
return attribute.metadata[entryName].string;
|
|
1050
|
+
}
|
|
1051
|
+
return `CUSTOM_ATTRIBUTE_${uniqueId}`;
|
|
1052
|
+
}
|
|
1053
|
+
_getTopLevelMetadata(dracoGeometry) {
|
|
1054
|
+
const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
|
|
1055
|
+
return this._getDracoMetadata(dracoMetadata);
|
|
1056
|
+
}
|
|
1057
|
+
_getAttributeMetadata(dracoGeometry, attributeId) {
|
|
1058
|
+
const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
|
|
1059
|
+
return this._getDracoMetadata(dracoMetadata);
|
|
1060
|
+
}
|
|
1061
|
+
_getDracoMetadata(dracoMetadata) {
|
|
1062
|
+
if (!dracoMetadata || !dracoMetadata.ptr) {
|
|
1063
|
+
return {};
|
|
1064
|
+
}
|
|
1065
|
+
const result = {};
|
|
1066
|
+
const numEntries = this.metadataQuerier.NumEntries(dracoMetadata);
|
|
1067
|
+
for (let entryIndex = 0; entryIndex < numEntries; entryIndex++) {
|
|
1068
|
+
const entryName = this.metadataQuerier.GetEntryName(dracoMetadata, entryIndex);
|
|
1069
|
+
result[entryName] = this._getDracoMetadataField(dracoMetadata, entryName);
|
|
1070
|
+
}
|
|
1071
|
+
return result;
|
|
1072
|
+
}
|
|
1073
|
+
_getDracoMetadataField(dracoMetadata, entryName) {
|
|
1074
|
+
const dracoArray = new this.draco.DracoInt32Array();
|
|
1075
|
+
try {
|
|
1076
|
+
this.metadataQuerier.GetIntEntryArray(dracoMetadata, entryName, dracoArray);
|
|
1077
|
+
const intArray = getInt32Array(dracoArray);
|
|
1078
|
+
return {
|
|
1079
|
+
int: this.metadataQuerier.GetIntEntry(dracoMetadata, entryName),
|
|
1080
|
+
string: this.metadataQuerier.GetStringEntry(dracoMetadata, entryName),
|
|
1081
|
+
double: this.metadataQuerier.GetDoubleEntry(dracoMetadata, entryName),
|
|
1082
|
+
intArray
|
|
1083
|
+
};
|
|
1084
|
+
} finally {
|
|
1085
|
+
this.draco.destroy(dracoArray);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
_disableAttributeTransforms(options) {
|
|
1089
|
+
const { quantizedAttributes = [], octahedronAttributes = [] } = options;
|
|
1090
|
+
const skipAttributes = [...quantizedAttributes, ...octahedronAttributes];
|
|
1091
|
+
for (const dracoAttributeName of skipAttributes) {
|
|
1092
|
+
this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
_getQuantizationTransform(dracoAttribute, options) {
|
|
1096
|
+
const { quantizedAttributes = [] } = options;
|
|
1097
|
+
const attribute_type = dracoAttribute.attribute_type();
|
|
1098
|
+
const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
1099
|
+
if (skip) {
|
|
1100
|
+
const transform = new this.draco.AttributeQuantizationTransform();
|
|
1101
|
+
try {
|
|
1102
|
+
if (transform.InitFromAttribute(dracoAttribute)) {
|
|
1103
|
+
return {
|
|
1104
|
+
quantization_bits: transform.quantization_bits(),
|
|
1105
|
+
range: transform.range(),
|
|
1106
|
+
min_values: new Float32Array([1, 2, 3]).map((i) => transform.min_value(i))
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
} finally {
|
|
1110
|
+
this.draco.destroy(transform);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
_getOctahedronTransform(dracoAttribute, options) {
|
|
1116
|
+
const { octahedronAttributes = [] } = options;
|
|
1117
|
+
const attribute_type = dracoAttribute.attribute_type();
|
|
1118
|
+
const octahedron = octahedronAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
1119
|
+
if (octahedron) {
|
|
1120
|
+
const transform = new this.draco.AttributeQuantizationTransform();
|
|
1121
|
+
try {
|
|
1122
|
+
if (transform.InitFromAttribute(dracoAttribute)) {
|
|
1123
|
+
return {
|
|
1124
|
+
quantization_bits: transform.quantization_bits()
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
} finally {
|
|
1128
|
+
this.draco.destroy(transform);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return null;
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
function getDracoDataType(draco, attributeType) {
|
|
1135
|
+
switch (attributeType) {
|
|
1136
|
+
case Float32Array:
|
|
1137
|
+
return draco.DT_FLOAT32;
|
|
1138
|
+
case Int8Array:
|
|
1139
|
+
return draco.DT_INT8;
|
|
1140
|
+
case Int16Array:
|
|
1141
|
+
return draco.DT_INT16;
|
|
1142
|
+
case Int32Array:
|
|
1143
|
+
return draco.DT_INT32;
|
|
1144
|
+
case Uint8Array:
|
|
1145
|
+
return draco.DT_UINT8;
|
|
1146
|
+
case Uint16Array:
|
|
1147
|
+
return draco.DT_UINT16;
|
|
1148
|
+
case Uint32Array:
|
|
1149
|
+
return draco.DT_UINT32;
|
|
1150
|
+
default:
|
|
1151
|
+
return draco.DT_INVALID;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
function getInt32Array(dracoArray) {
|
|
1155
|
+
const numValues = dracoArray.size();
|
|
1156
|
+
const intArray = new Int32Array(numValues);
|
|
1157
|
+
for (let i = 0; i < numValues; i++) {
|
|
1158
|
+
intArray[i] = dracoArray.GetValue(i);
|
|
1159
|
+
}
|
|
1160
|
+
return intArray;
|
|
1161
|
+
}
|
|
1162
|
+
function getUint32Array(dracoArray) {
|
|
1163
|
+
const numValues = dracoArray.size();
|
|
1164
|
+
const intArray = new Int32Array(numValues);
|
|
1165
|
+
for (let i = 0; i < numValues; i++) {
|
|
1166
|
+
intArray[i] = dracoArray.GetValue(i);
|
|
1167
|
+
}
|
|
1168
|
+
return intArray;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// src/lib/draco-module-loader.ts
|
|
1172
|
+
var DRACO_VERSION = "1.4.1";
|
|
1173
|
+
var DRACO_JS_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_VERSION}/draco_decoder.js`;
|
|
1174
|
+
var DRACO_WASM_WRAPPER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_VERSION}/draco_wasm_wrapper.js`;
|
|
1175
|
+
var DRACO_WASM_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_VERSION}/draco_decoder.wasm`;
|
|
1176
|
+
var DRACO_ENCODER_URL = `https://raw.githubusercontent.com/google/draco/${DRACO_VERSION}/javascript/draco_encoder.js`;
|
|
1177
|
+
var loadDecoderPromise;
|
|
1178
|
+
async function loadDracoDecoderModule(options) {
|
|
1179
|
+
const modules = options.modules || {};
|
|
1180
|
+
if (modules.draco3d) {
|
|
1181
|
+
loadDecoderPromise = loadDecoderPromise || modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
1182
|
+
return { draco };
|
|
1183
|
+
});
|
|
1184
|
+
} else {
|
|
1185
|
+
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
|
|
1186
|
+
}
|
|
1187
|
+
return await loadDecoderPromise;
|
|
1188
|
+
}
|
|
1189
|
+
async function loadDracoDecoder(options) {
|
|
1190
|
+
let DracoDecoderModule;
|
|
1191
|
+
let wasmBinary;
|
|
1192
|
+
switch (options.draco && options.draco.decoderType) {
|
|
1193
|
+
case "js":
|
|
1194
|
+
DracoDecoderModule = await loadLibrary(DRACO_JS_DECODER_URL, "draco", options);
|
|
1195
|
+
break;
|
|
1196
|
+
case "wasm":
|
|
1197
|
+
default:
|
|
1198
|
+
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
1199
|
+
await loadLibrary(DRACO_WASM_WRAPPER_URL, "draco", options),
|
|
1200
|
+
await loadLibrary(DRACO_WASM_DECODER_URL, "draco", options)
|
|
1201
|
+
]);
|
|
1202
|
+
}
|
|
1203
|
+
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
1204
|
+
return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
|
|
1205
|
+
}
|
|
1206
|
+
function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
|
|
1207
|
+
const options = {};
|
|
1208
|
+
if (wasmBinary) {
|
|
1209
|
+
options.wasmBinary = wasmBinary;
|
|
1210
|
+
}
|
|
1211
|
+
return new Promise((resolve) => {
|
|
1212
|
+
DracoDecoderModule({
|
|
1213
|
+
...options,
|
|
1214
|
+
onModuleLoaded: (draco) => resolve({ draco })
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// src/index.ts
|
|
1220
|
+
var DracoLoader2 = {
|
|
1221
|
+
...DracoLoader,
|
|
1222
|
+
parse
|
|
1223
|
+
};
|
|
1224
|
+
async function parse(arrayBuffer, options) {
|
|
1225
|
+
const { draco } = await loadDracoDecoderModule(options);
|
|
1226
|
+
const dracoParser = new DracoParser(draco);
|
|
1227
|
+
try {
|
|
1228
|
+
return dracoParser.parseSync(arrayBuffer, options?.draco);
|
|
1229
|
+
} finally {
|
|
1230
|
+
dracoParser.destroy();
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// src/workers/draco-worker.ts
|
|
1235
|
+
createLoaderWorker(DracoLoader2);
|
|
1236
|
+
})();
|