@loaders.gl/ply 3.1.0-alpha.5 → 3.1.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.
- package/dist/bundle.d.ts +1 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +1249 -0
- package/dist/es5/ply-loader.js +1 -1
- package/dist/es5/ply-loader.js.map +1 -1
- package/dist/esm/ply-loader.js +1 -1
- package/dist/esm/ply-loader.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/lib/get-ply-schema.d.ts +1 -0
- package/dist/lib/get-ply-schema.d.ts.map +1 -0
- package/dist/lib/get-ply-schema.js +36 -0
- package/dist/lib/normalize-ply.d.ts +1 -0
- package/dist/lib/normalize-ply.d.ts.map +1 -0
- package/dist/lib/normalize-ply.js +58 -0
- package/dist/lib/parse-ply-in-batches.d.ts +1 -0
- package/dist/lib/parse-ply-in-batches.d.ts.map +1 -0
- package/dist/lib/parse-ply-in-batches.js +253 -0
- package/dist/lib/parse-ply.d.ts +1 -0
- package/dist/lib/parse-ply.d.ts.map +1 -0
- package/dist/lib/parse-ply.js +350 -0
- package/dist/lib/ply-types.d.ts +1 -0
- package/dist/lib/ply-types.d.ts.map +1 -0
- package/dist/lib/ply-types.js +2 -0
- package/dist/ply-loader.d.ts +1 -0
- package/dist/ply-loader.d.ts.map +1 -0
- package/dist/ply-loader.js +28 -0
- package/dist/ply-worker.js +1257 -2
- package/dist/workers/ply-worker.d.ts +1 -0
- package/dist/workers/ply-worker.d.ts.map +1 -0
- package/dist/workers/ply-worker.js +5 -0
- package/package.json +7 -8
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/ply-worker.js.map +0 -1
package/dist/ply-worker.js
CHANGED
|
@@ -1,2 +1,1257 @@
|
|
|
1
|
-
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(24);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){e.exports=n(19)},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(15);e.exports=function(e){return new r(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,u,"next",e)}function u(e){n(a,o,i,s,u,"throw",e)}s(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){var t;if("undefined"!=typeof Symbol&&(Symbol.asyncIterator&&(t=e[Symbol.asyncIterator]),null==t&&Symbol.iterator&&(t=e[Symbol.iterator])),null==t&&(t=e["@@asyncIterator"]),null==t&&(t=e["@@iterator"]),null==t)throw new TypeError("Object is not async iterable");return t.call(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=n=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),n(t)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(25);e.exports=function(e){return function(){return new r(e.apply(this,arguments))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(20),o=n(21),i=n(22),a=n(23);e.exports=function(e){return r(e)||o(e)||i(e)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.default=e.exports,e.exports.__esModule=!0,n(t)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){this.wrapped=e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(9).default,o=n(6);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t},e.exports.default=e.exports,e.exports.__esModule=!0},,,function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof f?t:f,i=Object.create(o.prototype),a=new S(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return O()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=b(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,a),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function p(){}function d(){}var h={};h[o]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(_([])));v&&v!==t&&n.call(v,o)&&(h=v);var m=d.prototype=f.prototype=Object.create(h);function x(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(o,i){function a(){return new t((function(r,a){!function r(o,i,a,s){var u=c(e[o],e,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function _(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return p.prototype=m.constructor=d,d.constructor=p,p.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},x(g.prototype),g.prototype[i]=function(){return this},e.AsyncIterator=g,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new g(u(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(m),s(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=_,S.prototype={constructor:S,reset:function(e){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(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){var r=n(14);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(14);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.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.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.default=e.exports,e.exports.__esModule=!0,n(t,r)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(15);function o(e){var t,n;function o(t,n){try{var a=e[t](n),s=a.value,u=s instanceof r;Promise.resolve(u?s.wrapped:s).then((function(e){u?o("return"===t?"return":"next",e):i(a.done?"return":"normal",e)}),(function(e){o("throw",e)}))}catch(e){i("throw",e)}}function i(e,r){switch(e){case"return":t.resolve({value:r,done:!0});break;case"throw":t.reject(r);break;default:t.resolve({value:r,done:!1})}(t=t.next)?o(t.key,t.arg):n=null}this._invoke=function(e,r){return new Promise((function(i,a){var s={key:e,arg:r,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,o(e,r))}))},"function"!=typeof e.return&&(this.return=void 0)}o.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},o.prototype.next=function(e){return this._invoke("next",e)},o.prototype.throw=function(e){return this._invoke("throw",e)},o.prototype.return=function(e){return this._invoke("return",e)},e.exports=o,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";n.r(t);var r=n(3),o=n.n(r),i=n(7),a=n.n(i),s=n(2),u=n.n(s),c=n(0),l=n.n(c),f=n(4),p=n.n(f),d=n(9),h=n.n(d);function y(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,m=function(){function e(){l()(this,e)}return p()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(x(t)){var n=t.data,r=n.type,o=n.payload;e(r,o)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(x(t)){var n=t.data,r=n.type,o=n.payload;e(r,o)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var n={source:"loaders.gl",type:e,payload:t},r=function e(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0,o=r||new Set;if(t){if(y(t))o.add(t);else if(y(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(n&&"object"===h()(t))for(var i in t)e(t[i],n,o)}else;return void 0===r?Array.from(o):[]}(t);self.postMessage(n,r)}}}]),e}();function x(e){var t=e.type,n=e.data;return"message"===t&&n&&"string"==typeof n.source&&n.source.startsWith("loaders.gl")}function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?g(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var w=0;function k(e,t){return new Promise((function(n,r){var o=w++;m.addEventListener((function e(t,i){if(i.id===o)switch(t){case"done":m.removeEventListener(e),n(i.result);break;case"error":m.removeEventListener(e),r(i.error)}}));var i={id:o,input:e,options:t};m.postMessage("process",i)}))}function S(e){return _.apply(this,arguments)}function _(){return(_=a()(u.a.mark((function e(t){var n,r,o,i,a,s,c;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.loader,r=t.arrayBuffer,o=t.options,i=t.context,!n.parseSync&&!n.parse){e.next=6;break}a=r,s=n.parseSync||n.parse,e.next=13;break;case 6:if(!n.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(r),s=n.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(n.name," loader"));case 13:return o=b(b({},o),{},{modules:n&&n.options&&n.options.modules||{},worker:!1}),e.next=16,s(a,b({},o),i,n);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var O={name:"PLY",id:"ply",module:"ply",shapes:["mesh","gltf","columnar-table"],version:"3.1.0-alpha.5",worker:!0,extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"],options:{ply:{}}};var I=n(11),T=n.n(I);function M(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},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,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var L=function(){function e(t,n){l()(this,e),o()(this,"fields",void 0),o()(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(t)),function(e){var t,n={},r=M(e);try{for(r.s();!(t=r.n()).done;){var o=t.value;n[o.name]&&console.warn("Schema: duplicated field name",o.name,o),n[o.name]=!0}}catch(e){r.e(e)}finally{r.f()}}(t),this.fields=t,this.metadata=n||new Map}return p()(e,[{key:"compareTo",value:function(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(var t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}},{key:"select",value:function(){for(var t=Object.create(null),n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];for(var i=0,a=r;i<a.length;i++){var s=a[i];t[s]=!0}var u=this.fields.filter((function(e){return t[e.name]}));return new e(u,this.metadata)}},{key:"selectAt",value:function(){for(var t=this,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];var i=r.map((function(e){return t.fields[e]})).filter(Boolean);return new e(i,this.metadata)}},{key:"assign",value:function(t){var n,r=this.metadata;if(t instanceof e){var o=t;n=o.fields,r=E(E(new Map,this.metadata),o.metadata)}else n=t;var i,a=Object.create(null),s=M(this.fields);try{for(s.s();!(i=s.n()).done;){var u=i.value;a[u.name]=u}}catch(e){s.e(e)}finally{s.f()}var c,l=M(n);try{for(l.s();!(c=l.n()).done;){var f=c.value;a[f.name]=f}}catch(e){l.e(e)}finally{l.f()}return new e(Object.values(a),r)}}]),e}();function E(e,t){return new Map([].concat(T()(e||new Map),T()(t||new Map)))}var P,F,A,D,U=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;l()(this,e),o()(this,"name",void 0),o()(this,"type",void 0),o()(this,"nullable",void 0),o()(this,"metadata",void 0),this.name=t,this.type=n,this.nullable=r,this.metadata=i}return p()(e,[{key:"typeId",get:function(){return this.type&&this.type.typeId}},{key:"clone",value:function(){return new e(this.name,this.type,this.nullable,this.metadata)}},{key:"compareTo",value:function(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}},{key:"toString",value:function(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}]),e}(),z=n(6),N=n.n(z),B=n(1),R=n.n(B),C=n(16),G=n.n(C),Y=n(12),W=n.n(Y);function $(e){var t=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(e){return!1}}();return function(){var n,r=W()(e);if(t){var o=W()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return G()(this,n)}}!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(P||(P={}));var J=function(){function e(){l()(this,e)}return p()(e,[{key:"typeId",get:function(){return P.NONE}},{key:"compareTo",value:function(e){return this===e}}],[{key:"isNull",value:function(e){return e&&e.typeId===P.Null}},{key:"isInt",value:function(e){return e&&e.typeId===P.Int}},{key:"isFloat",value:function(e){return e&&e.typeId===P.Float}},{key:"isBinary",value:function(e){return e&&e.typeId===P.Binary}},{key:"isUtf8",value:function(e){return e&&e.typeId===P.Utf8}},{key:"isBool",value:function(e){return e&&e.typeId===P.Bool}},{key:"isDecimal",value:function(e){return e&&e.typeId===P.Decimal}},{key:"isDate",value:function(e){return e&&e.typeId===P.Date}},{key:"isTime",value:function(e){return e&&e.typeId===P.Time}},{key:"isTimestamp",value:function(e){return e&&e.typeId===P.Timestamp}},{key:"isInterval",value:function(e){return e&&e.typeId===P.Interval}},{key:"isList",value:function(e){return e&&e.typeId===P.List}},{key:"isStruct",value:function(e){return e&&e.typeId===P.Struct}},{key:"isUnion",value:function(e){return e&&e.typeId===P.Union}},{key:"isFixedSizeBinary",value:function(e){return e&&e.typeId===P.FixedSizeBinary}},{key:"isFixedSizeList",value:function(e){return e&&e.typeId===P.FixedSizeList}},{key:"isMap",value:function(e){return e&&e.typeId===P.Map}},{key:"isDictionary",value:function(e){return e&&e.typeId===P.Dictionary}}]),e}();F=Symbol.toStringTag;var V=function(e){R()(n,e);var t=$(n);function n(e,r){var i;return l()(this,n),i=t.call(this),o()(N()(i),"isSigned",void 0),o()(N()(i),"bitWidth",void 0),i.isSigned=e,i.bitWidth=r,i}return p()(n,[{key:"typeId",get:function(){return P.Int}},{key:F,get:function(){return"Int"}},{key:"toString",value:function(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}]),n}(J),X=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!0,8)}return n}(V),q=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!0,16)}return n}(V),H=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!0,32)}return n}(V),K=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!1,8)}return n}(V),Q=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!1,16)}return n}(V),Z=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,!1,32)}return n}(V),ee=32,te=64;A=Symbol.toStringTag;var ne=function(e){R()(n,e);var t=$(n);function n(e){var r;return l()(this,n),r=t.call(this),o()(N()(r),"precision",void 0),r.precision=e,r}return p()(n,[{key:"typeId",get:function(){return P.Float}},{key:A,get:function(){return"Float"}},{key:"toString",value:function(){return"Float".concat(this.precision)}}]),n}(J),re=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,ee)}return n}(ne),oe=function(e){R()(n,e);var t=$(n);function n(){return l()(this,n),t.call(this,te)}return n}(ne);Symbol.toStringTag;Symbol.toStringTag;Symbol.toStringTag;Symbol.toStringTag;D=Symbol.toStringTag;var ie=function(e){R()(n,e);var t=$(n);function n(e,r){var i;return l()(this,n),i=t.call(this),o()(N()(i),"listSize",void 0),o()(N()(i),"children",void 0),i.listSize=e,i.children=[r],i}return p()(n,[{key:"typeId",get:function(){return P.FixedSizeList}},{key:"valueType",get:function(){return this.children[0].type}},{key:"valueField",get:function(){return this.children[0]}},{key:D,get:function(){return"FixedSizeList"}},{key:"toString",value:function(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}]),n}(J);Symbol.toStringTag;function ae(e,t){var n=function(e){var t=[];for(var n in e){var r=e[n];t.push(se(n,r))}return t}(e);return new L(n,t)}function se(e,t,n){var r=function(e){switch(e.constructor){case Int8Array:return new X;case Uint8Array:return new K;case Int16Array:return new q;case Uint16Array:return new Q;case Int32Array:return new H;case Uint32Array:return new Z;case Float32Array:return new re;case Float64Array:return new oe;default:throw new Error("array type not supported")}}(t.value),o=n||function(e){var t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new U(e,new ie(t.size,new U("value",r)),!1,o)}function ue(e,t){return ae(t,function(e){var t=new Map;t.set("ply_comments",JSON.stringify(e.comments)),t.set("ply_elements",JSON.stringify(e.elements)),void 0!==e.format&&t.set("ply_format",e.format);void 0!==e.version&&t.set("ply_version",e.version);void 0!==e.headerLength&&t.set("ply_headerLength",e.headerLength.toString(10));return t}(e))}function ce(e,t,n){var r=function(e){var t={};t.POSITION={value:new Float32Array(e.vertices),size:3},e.normals.length>0&&(t.NORMAL={value:new Float32Array(e.normals),size:3});e.uvs.length>0&&(t.TEXCOORD_0={value:new Float32Array(e.uvs),size:2});e.colors.length>0&&(t.COLOR_0={value:new Uint8Array(e.colors),size:3,normalized:!0});return t}(t),o=function(e){for(var t=1/0,n=1/0,r=1/0,o=-1/0,i=-1/0,a=-1/0,s=e.POSITION?e.POSITION.value:[],u=s&&s.length,c=0;c<u;c+=3){var l=s[c],f=s[c+1],p=s[c+2];t=l<t?l:t,n=f<n?f:n,r=p<r?p:r,o=l>o?l:o,i=f>i?f:i,a=p>a?p:a}return[[t,n,r],[o,i,a]]}(r),i=t.indices.length||t.vertices.length/3,a=t.indices&&t.indices.length>0,s=a?4:0,u=a?"triangle-list":"point-list",c={loader:"ply",loaderData:e,header:{vertexCount:i,boundingBox:o},schema:ue(e,r),attributes:r,indices:{value:new Uint32Array(0),size:0},mode:s,topology:u};return t.indices.length>0&&(c.indices={value:new Uint32Array(t.indices),size:1}),c}function le(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e instanceof ArrayBuffer){var o=(new TextDecoder).decode(e);n="ascii"===(t=fe(o,r)).format?ye(o,t):ge(e,t)}else n=ye(e,t=fe(e,r));return ce(t,n)}function fe(e,t){var n="",r=0,o=/ply([\s\S]*)end_header\s/.exec(e);return null!==o&&(n=o[1],r=o[0].length),function(e,t,n){for(var r,o,i={comments:[],elements:[],headerLength:t},a=null,s=0;s<e.length;s++){var u=e[s];if(""!==(u=u.trim()))switch(o=u.split(/\s+/),r=o.shift(),u=o.join(" "),r){case"format":i.format=o[0],i.version=o[1];break;case"comment":i.comments.push(u);break;case"element":a&&i.elements.push(a),a={name:o[0],count:parseInt(o[1],10),properties:[]};break;case"property":if(!a)break;a.properties.push(pe(o,n.propertyNameMapping));break;default:console.log("unhandled",r,o)}}void 0!==a&&i.elements.push(a);return i}(n.split("\n"),r,t)}function pe(e,t){var n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],t&&n.name in t&&(n.name=t[n.name]),n}function de(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e,10);case"float":case"double":case"float32":case"float64":return parseFloat(e);default:throw new Error(t)}}function he(e,t){for(var n=t.split(/\s+/),r={},o=0;o<e.length;o++)if("list"===e[o].type){for(var i=[],a=de(n.shift(),e[o].countType),s=0;s<a;s++)i.push(de(n.shift(),e[o].itemType));r[e[o].name]=i}else r[e[o].name]=de(n.shift(),e[o].type);return r}function ye(e,t){var n,r={indices:[],vertices:[],normals:[],uvs:[],colors:[]},o="";null!==(n=/end_header\s([\s\S]*)$/.exec(e))&&(o=n[1]);for(var i=o.split("\n"),a=0,s=0,u=0;u<i.length;u++){var c=i[u];if(""!==(c=c.trim())){s>=t.elements[a].count&&(a++,s=0);var l=he(t.elements[a].properties,c);ve(r,t.elements[a].name,l),s++}}return r}function ve(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("vertex"===t)e.vertices.push(n.x,n.y,n.z),"nx"in n&&"ny"in n&&"nz"in n&&e.normals.push(n.nx,n.ny,n.nz),"s"in n&&"t"in n&&e.uvs.push(n.s,n.t),"red"in n&&"green"in n&&"blue"in n&&e.colors.push(n.red,n.green,n.blue);else if("face"===t){var r=n.vertex_indices||n.vertex_index;3===r.length?e.indices.push(r[0],r[1],r[2]):4===r.length&&(e.indices.push(r[0],r[1],r[3]),e.indices.push(r[1],r[2],r[3]))}}function me(e,t,n,r){switch(n){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,r),2];case"uint16":case"ushort":return[e.getUint16(t,r),2];case"int32":case"int":return[e.getInt32(t,r),4];case"uint32":case"uint":return[e.getUint32(t,r),4];case"float32":case"float":return[e.getFloat32(t,r),4];case"float64":case"double":return[e.getFloat64(t,r),8];default:throw new Error(n)}}function xe(e,t,n,r){for(var o,i={},a=0,s=0;s<n.length;s++)if("list"===n[s].type){var u=[],c=(o=me(e,t+a,n[s].countType,r))[0];a+=o[1];for(var l=0;l<c;l++)o=me(e,t+a,n[s].itemType,r),u.push(o[0]),a+=o[1];i[n[s].name]=u}else o=me(e,t+a,n[s].type,r),i[n[s].name]=o[0],a+=o[1];return[i,a]}function ge(e,t){for(var n,r={indices:[],vertices:[],normals:[],uvs:[],colors:[]},o="binary_little_endian"===t.format,i=new DataView(e,t.headerLength),a=0,s=0;s<t.elements.length;s++)for(var u=t.elements[s].count,c=0;c<u;c++){a+=(n=xe(i,a,t.elements[s].properties,o))[1];var l=n[0];ve(r,t.elements[s].name,l)}return r}var be=n(8),we=n.n(be),ke=n(5),Se=n.n(ke),_e=n(10),Oe=n.n(_e);function Ie(e){return Te.apply(this,arguments)}function Te(){return(Te=Oe()(u.a.mark((function e(t){var n,r,o,i,a,s,c,l,f,p=arguments;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=p.length>1&&void 0!==p[1]?p[1]:{},r=new TextDecoder(void 0,n),o=!0,i=!1,e.prev=4,s=we()(t);case 6:return e.next=8,Se()(s.next());case 8:return c=e.sent,o=c.done,e.next=12,Se()(c.value);case 12:if(l=e.sent,o){e.next=20;break}return f=l,e.next=17,"string"==typeof f?f:r.decode(f,{stream:!0});case 17:o=!0,e.next=6;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(4),i=!0,a=e.t0;case 26:if(e.prev=26,e.prev=27,o||null==s.return){e.next=31;break}return e.next=31,Se()(s.return());case 31:if(e.prev=31,!i){e.next=34;break}throw a;case 34:return e.finish(31);case 35:return e.finish(26);case 36:case"end":return e.stop()}}),e,null,[[4,22,26,36],[27,,31,35]])})))).apply(this,arguments)}function Me(e){return je.apply(this,arguments)}function je(){return(je=Oe()(u.a.mark((function e(t){var n,r,o,i,a,s,c,l,f;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n="",r=!0,o=!1,e.prev=3,a=we()(t);case 5:return e.next=7,Se()(a.next());case 7:return s=e.sent,r=s.done,e.next=11,Se()(s.value);case 11:if(c=e.sent,r){e.next=26;break}n+=c,l=void 0;case 16:if(!((l=n.indexOf("\n"))>=0)){e.next=23;break}return f=n.slice(0,l+1),n=n.slice(l+1),e.next=21,f;case 21:e.next=16;break;case 23:r=!0,e.next=5;break;case 26:e.next=32;break;case 28:e.prev=28,e.t0=e.catch(3),o=!0,i=e.t0;case 32:if(e.prev=32,e.prev=33,r||null==a.return){e.next=37;break}return e.next=37,Se()(a.return());case 37:if(e.prev=37,!o){e.next=40;break}throw i;case 40:return e.finish(37);case 41:return e.finish(32);case 42:if(!(n.length>0)){e.next=45;break}return e.next=45,n;case 45:case"end":return e.stop()}}),e,null,[[3,28,32,42],[33,,37,41]])})))).apply(this,arguments)}var Le;n(13);function Ee(e,t){return Pe.apply(this,arguments)}function Pe(){return(Pe=a()(u.a.mark((function e(t,n){var r,o,i;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,t.next();case 3:if(r=e.sent,o=r.done,i=r.value,!o){e.next=9;break}return t.return(),e.abrupt("return");case 9:if(!n(i)){e.next=12;break}return e.abrupt("return");case 12:e.next=0;break;case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fe(){return(Fe=Oe()(u.a.mark((function e(t,n){var r,o,i;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Me(Ie(t)),e.next=3,Se()(Ae(r,n));case 3:o=e.sent,e.t0=o.format,e.next="ascii"===e.t0?7:11;break;case 7:return e.next=9,Se()(ze(r,o));case 9:return i=e.sent,e.abrupt("break",12);case 11:throw new Error("Binary PLY can not yet be parsed in streaming mode");case 12:return e.next=14,ce(o,i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ae(e,t){return De.apply(this,arguments)}function De(){return(De=a()(u.a.mark((function e(t,n){var r;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={comments:[],elements:[]},e.next=3,Ee(t,(function(e){if("end_header"===(e=e.trim()))return!0;if(""===e)return!1;var t=e.split(/\s+/),o=t.shift();switch(e=t.join(" "),o){case"ply":break;case"format":r.format=t[0],r.version=t[1];break;case"comment":r.comments.push(e);break;case"element":Le&&r.elements.push(Le),Le={name:t[0],count:parseInt(t[1],10),properties:[]};break;case"property":var i=Ue(t,n.propertyNameMapping);Le.properties.push(i);break;default:console.log("unhandled",o,t)}return!1}));case 3:return Le&&r.elements.push(Le),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ue(e,t){var n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],t&&n.name in t&&(n.name=t[n.name]),n}function ze(e,t){var n,r,o,i,a,s,c,l,f,p,d;return u.a.async((function(h){for(;;)switch(h.prev=h.next){case 0:n={indices:[],vertices:[],normals:[],uvs:[],colors:[]},r=0,o=0,i=!0,a=!1,h.prev=5,c=we()(e);case 7:return h.next=9,u.a.awrap(c.next());case 9:return l=h.sent,i=l.done,h.next=13,u.a.awrap(l.value);case 13:if(f=h.sent,i){h.next=21;break}""!==(p=(p=f).trim())&&(o>=t.elements[r].count&&(r++,o=0),d=Be(t.elements[r].properties,p),Re(n,t.elements[r].name,d),o++);case 18:i=!0,h.next=7;break;case 21:h.next=27;break;case 23:h.prev=23,h.t0=h.catch(5),a=!0,s=h.t0;case 27:if(h.prev=27,h.prev=28,i||null==c.return){h.next=32;break}return h.next=32,u.a.awrap(c.return());case 32:if(h.prev=32,!a){h.next=35;break}throw s;case 35:return h.finish(32);case 36:return h.finish(27);case 37:return h.abrupt("return",n);case 38:case"end":return h.stop()}}),null,null,[[5,23,27,37],[28,,32,36]],Promise)}function Ne(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e,10);case"float":case"double":case"float32":case"float64":return parseFloat(e);default:throw new Error(t)}}function Be(e,t){for(var n=t.split(/\s+/),r={},o=0;o<e.length;o++)if("list"===e[o].type){for(var i=[],a=Ne(n.shift(),e[o].countType),s=0;s<a;s++)i.push(Ne(n.shift(),e[o].itemType));r[e[o].name]=i}else r[e[o].name]=Ne(n.shift(),e[o].type);return r}function Re(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};switch(t){case"vertex":e.vertices.push(n.x,n.y,n.z),"nx"in n&&"ny"in n&&"nz"in n&&e.normals.push(n.nx,n.ny,n.nz),"s"in n&&"t"in n&&e.uvs.push(n.s,n.t),"red"in n&&"green"in n&&"blue"in n&&e.colors.push(n.red/255,n.green/255,n.blue/255);break;case"face":var r=n.vertex_indices||n.vertex_index;3===r.length?e.indices.push(r[0],r[1],r[2]):4===r.length&&(e.indices.push(r[0],r[1],r[3]),e.indices.push(r[1],r[2],r[3]))}}function Ce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ce(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ce(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ye,We,$e=Ge(Ge({},O),{},{parse:(Ye=a()(u.a.mark((function e(t,n){return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",le(t,n));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return Ye.apply(this,arguments)}),parseTextSync:le,parseSync:le,parseInBatches:function(e,t){return Fe.apply(this,arguments)}});We=$e,"undefined"!=typeof self&&(m.onmessage=function(){var e=a()(u.a.mark((function e(t,n){var r,o,i,a,s;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:16;break;case 3:return e.prev=3,r=n.input,o=n.options,i=void 0===o?{}:o,e.next=7,S({loader:We,arrayBuffer:r,options:i,context:{parse:k}});case 7:a=e.sent,m.postMessage("done",{result:a}),e.next=15;break;case 11:e.prev=11,e.t1=e.catch(3),s=e.t1 instanceof Error?e.t1.message:"",m.postMessage("error",{error:s});case 15:return e.abrupt("break",16);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,n){return e.apply(this,arguments)}}())}]);
|
|
2
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
3
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
4
|
+
const transfersSet = transfers || new Set();
|
|
5
|
+
if (!object) {
|
|
6
|
+
} else if (isTransferable(object)) {
|
|
7
|
+
transfersSet.add(object);
|
|
8
|
+
} else if (isTransferable(object.buffer)) {
|
|
9
|
+
transfersSet.add(object.buffer);
|
|
10
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
11
|
+
} else if (recursive && typeof object === "object") {
|
|
12
|
+
for (const key in object) {
|
|
13
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
17
|
+
}
|
|
18
|
+
function isTransferable(object) {
|
|
19
|
+
if (!object) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (object instanceof ArrayBuffer) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
var onMessageWrapperMap = new Map();
|
|
39
|
+
var WorkerBody = class {
|
|
40
|
+
static set onmessage(onMessage) {
|
|
41
|
+
self.onmessage = (message) => {
|
|
42
|
+
if (!isKnownMessage(message)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { type, payload } = message.data;
|
|
46
|
+
onMessage(type, payload);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
static addEventListener(onMessage) {
|
|
50
|
+
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
51
|
+
if (!onMessageWrapper) {
|
|
52
|
+
onMessageWrapper = (message) => {
|
|
53
|
+
if (!isKnownMessage(message)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { type, payload } = message.data;
|
|
57
|
+
onMessage(type, payload);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
self.addEventListener("message", onMessageWrapper);
|
|
61
|
+
}
|
|
62
|
+
static removeEventListener(onMessage) {
|
|
63
|
+
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
|
+
onMessageWrapperMap.delete(onMessage);
|
|
65
|
+
self.removeEventListener("message", onMessageWrapper);
|
|
66
|
+
}
|
|
67
|
+
static postMessage(type, payload) {
|
|
68
|
+
if (self) {
|
|
69
|
+
const data = { source: "loaders.gl", type, payload };
|
|
70
|
+
const transferList = getTransferList(payload);
|
|
71
|
+
self.postMessage(data, transferList);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function isKnownMessage(message) {
|
|
76
|
+
const { type, data } = message;
|
|
77
|
+
return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
|
+
var requestId = 0;
|
|
82
|
+
function createLoaderWorker(loader) {
|
|
83
|
+
if (typeof self === "undefined") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case "process":
|
|
89
|
+
try {
|
|
90
|
+
const { input, options = {} } = payload;
|
|
91
|
+
const result = await parseData({
|
|
92
|
+
loader,
|
|
93
|
+
arrayBuffer: input,
|
|
94
|
+
options,
|
|
95
|
+
context: {
|
|
96
|
+
parse: parseOnMainThread
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
WorkerBody.postMessage("done", { result });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : "";
|
|
102
|
+
WorkerBody.postMessage("error", { error: message });
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function parseOnMainThread(arrayBuffer, options) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
const id = requestId++;
|
|
112
|
+
const onMessage = (type, payload2) => {
|
|
113
|
+
if (payload2.id !== id) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
switch (type) {
|
|
117
|
+
case "done":
|
|
118
|
+
WorkerBody.removeEventListener(onMessage);
|
|
119
|
+
resolve(payload2.result);
|
|
120
|
+
break;
|
|
121
|
+
case "error":
|
|
122
|
+
WorkerBody.removeEventListener(onMessage);
|
|
123
|
+
reject(payload2.error);
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
WorkerBody.addEventListener(onMessage);
|
|
129
|
+
const payload = { id, input: arrayBuffer, options };
|
|
130
|
+
WorkerBody.postMessage("process", payload);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function parseData({ loader, arrayBuffer, options, context }) {
|
|
134
|
+
let data;
|
|
135
|
+
let parser;
|
|
136
|
+
if (loader.parseSync || loader.parse) {
|
|
137
|
+
data = arrayBuffer;
|
|
138
|
+
parser = loader.parseSync || loader.parse;
|
|
139
|
+
} else if (loader.parseTextSync) {
|
|
140
|
+
const textDecoder = new TextDecoder();
|
|
141
|
+
data = textDecoder.decode(arrayBuffer);
|
|
142
|
+
parser = loader.parseTextSync;
|
|
143
|
+
} else {
|
|
144
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
145
|
+
}
|
|
146
|
+
options = {
|
|
147
|
+
...options,
|
|
148
|
+
modules: loader && loader.options && loader.options.modules || {},
|
|
149
|
+
worker: false
|
|
150
|
+
};
|
|
151
|
+
return await parser(data, { ...options }, context, loader);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ../loader-utils/src/lib/iterators/text-iterators.ts
|
|
155
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
156
|
+
const textDecoder = new TextDecoder(void 0, options);
|
|
157
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
158
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function* makeLineIterator(textIterator) {
|
|
162
|
+
let previous = "";
|
|
163
|
+
for await (const textChunk of textIterator) {
|
|
164
|
+
previous += textChunk;
|
|
165
|
+
let eolIndex;
|
|
166
|
+
while ((eolIndex = previous.indexOf("\n")) >= 0) {
|
|
167
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
168
|
+
previous = previous.slice(eolIndex + 1);
|
|
169
|
+
yield line;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (previous.length > 0) {
|
|
173
|
+
yield previous;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
178
|
+
async function forEach(iterator, visitor) {
|
|
179
|
+
while (true) {
|
|
180
|
+
const { done, value } = await iterator.next();
|
|
181
|
+
if (done) {
|
|
182
|
+
iterator.return();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const cancel = visitor(value);
|
|
186
|
+
if (cancel) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/ply-loader.ts
|
|
193
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
194
|
+
var PLYLoader = {
|
|
195
|
+
name: "PLY",
|
|
196
|
+
id: "ply",
|
|
197
|
+
module: "ply",
|
|
198
|
+
shapes: ["mesh", "gltf", "columnar-table"],
|
|
199
|
+
version: VERSION,
|
|
200
|
+
worker: true,
|
|
201
|
+
extensions: ["ply"],
|
|
202
|
+
mimeTypes: ["text/plain", "application/octet-stream"],
|
|
203
|
+
text: true,
|
|
204
|
+
binary: true,
|
|
205
|
+
tests: ["ply"],
|
|
206
|
+
options: {
|
|
207
|
+
ply: {}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// ../schema/src/category/mesh/mesh-utils.ts
|
|
212
|
+
function getMeshBoundingBox(attributes) {
|
|
213
|
+
let minX = Infinity;
|
|
214
|
+
let minY = Infinity;
|
|
215
|
+
let minZ = Infinity;
|
|
216
|
+
let maxX = -Infinity;
|
|
217
|
+
let maxY = -Infinity;
|
|
218
|
+
let maxZ = -Infinity;
|
|
219
|
+
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
220
|
+
const len = positions && positions.length;
|
|
221
|
+
for (let i = 0; i < len; i += 3) {
|
|
222
|
+
const x = positions[i];
|
|
223
|
+
const y = positions[i + 1];
|
|
224
|
+
const z = positions[i + 2];
|
|
225
|
+
minX = x < minX ? x : minX;
|
|
226
|
+
minY = y < minY ? y : minY;
|
|
227
|
+
minZ = z < minZ ? z : minZ;
|
|
228
|
+
maxX = x > maxX ? x : maxX;
|
|
229
|
+
maxY = y > maxY ? y : maxY;
|
|
230
|
+
maxZ = z > maxZ ? z : maxZ;
|
|
231
|
+
}
|
|
232
|
+
return [
|
|
233
|
+
[minX, minY, minZ],
|
|
234
|
+
[maxX, maxY, maxZ]
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ../schema/src/lib/utils/assert.ts
|
|
239
|
+
function assert(condition, message) {
|
|
240
|
+
if (!condition) {
|
|
241
|
+
throw new Error(message || "loader assertion failed.");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ../schema/src/lib/schema/impl/schema.ts
|
|
246
|
+
var Schema = class {
|
|
247
|
+
constructor(fields, metadata) {
|
|
248
|
+
assert(Array.isArray(fields));
|
|
249
|
+
checkNames(fields);
|
|
250
|
+
this.fields = fields;
|
|
251
|
+
this.metadata = metadata || new Map();
|
|
252
|
+
}
|
|
253
|
+
compareTo(other) {
|
|
254
|
+
if (this.metadata !== other.metadata) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (this.fields.length !== other.fields.length) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
for (let i = 0; i < this.fields.length; ++i) {
|
|
261
|
+
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
select(...columnNames) {
|
|
268
|
+
const nameMap = Object.create(null);
|
|
269
|
+
for (const name of columnNames) {
|
|
270
|
+
nameMap[name] = true;
|
|
271
|
+
}
|
|
272
|
+
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
273
|
+
return new Schema(selectedFields, this.metadata);
|
|
274
|
+
}
|
|
275
|
+
selectAt(...columnIndices) {
|
|
276
|
+
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
277
|
+
return new Schema(selectedFields, this.metadata);
|
|
278
|
+
}
|
|
279
|
+
assign(schemaOrFields) {
|
|
280
|
+
let fields;
|
|
281
|
+
let metadata = this.metadata;
|
|
282
|
+
if (schemaOrFields instanceof Schema) {
|
|
283
|
+
const otherSchema = schemaOrFields;
|
|
284
|
+
fields = otherSchema.fields;
|
|
285
|
+
metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
|
|
286
|
+
} else {
|
|
287
|
+
fields = schemaOrFields;
|
|
288
|
+
}
|
|
289
|
+
const fieldMap = Object.create(null);
|
|
290
|
+
for (const field of this.fields) {
|
|
291
|
+
fieldMap[field.name] = field;
|
|
292
|
+
}
|
|
293
|
+
for (const field of fields) {
|
|
294
|
+
fieldMap[field.name] = field;
|
|
295
|
+
}
|
|
296
|
+
const mergedFields = Object.values(fieldMap);
|
|
297
|
+
return new Schema(mergedFields, metadata);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
function checkNames(fields) {
|
|
301
|
+
const usedNames = {};
|
|
302
|
+
for (const field of fields) {
|
|
303
|
+
if (usedNames[field.name]) {
|
|
304
|
+
console.warn("Schema: duplicated field name", field.name, field);
|
|
305
|
+
}
|
|
306
|
+
usedNames[field.name] = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function mergeMaps(m1, m2) {
|
|
310
|
+
return new Map([...m1 || new Map(), ...m2 || new Map()]);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// ../schema/src/lib/schema/impl/field.ts
|
|
314
|
+
var Field = class {
|
|
315
|
+
constructor(name, type, nullable = false, metadata = new Map()) {
|
|
316
|
+
this.name = name;
|
|
317
|
+
this.type = type;
|
|
318
|
+
this.nullable = nullable;
|
|
319
|
+
this.metadata = metadata;
|
|
320
|
+
}
|
|
321
|
+
get typeId() {
|
|
322
|
+
return this.type && this.type.typeId;
|
|
323
|
+
}
|
|
324
|
+
clone() {
|
|
325
|
+
return new Field(this.name, this.type, this.nullable, this.metadata);
|
|
326
|
+
}
|
|
327
|
+
compareTo(other) {
|
|
328
|
+
return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
|
|
329
|
+
}
|
|
330
|
+
toString() {
|
|
331
|
+
return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// ../schema/src/lib/schema/impl/enum.ts
|
|
336
|
+
var Type;
|
|
337
|
+
(function(Type2) {
|
|
338
|
+
Type2[Type2["NONE"] = 0] = "NONE";
|
|
339
|
+
Type2[Type2["Null"] = 1] = "Null";
|
|
340
|
+
Type2[Type2["Int"] = 2] = "Int";
|
|
341
|
+
Type2[Type2["Float"] = 3] = "Float";
|
|
342
|
+
Type2[Type2["Binary"] = 4] = "Binary";
|
|
343
|
+
Type2[Type2["Utf8"] = 5] = "Utf8";
|
|
344
|
+
Type2[Type2["Bool"] = 6] = "Bool";
|
|
345
|
+
Type2[Type2["Decimal"] = 7] = "Decimal";
|
|
346
|
+
Type2[Type2["Date"] = 8] = "Date";
|
|
347
|
+
Type2[Type2["Time"] = 9] = "Time";
|
|
348
|
+
Type2[Type2["Timestamp"] = 10] = "Timestamp";
|
|
349
|
+
Type2[Type2["Interval"] = 11] = "Interval";
|
|
350
|
+
Type2[Type2["List"] = 12] = "List";
|
|
351
|
+
Type2[Type2["Struct"] = 13] = "Struct";
|
|
352
|
+
Type2[Type2["Union"] = 14] = "Union";
|
|
353
|
+
Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
|
|
354
|
+
Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
|
|
355
|
+
Type2[Type2["Map"] = 17] = "Map";
|
|
356
|
+
Type2[Type2["Dictionary"] = -1] = "Dictionary";
|
|
357
|
+
Type2[Type2["Int8"] = -2] = "Int8";
|
|
358
|
+
Type2[Type2["Int16"] = -3] = "Int16";
|
|
359
|
+
Type2[Type2["Int32"] = -4] = "Int32";
|
|
360
|
+
Type2[Type2["Int64"] = -5] = "Int64";
|
|
361
|
+
Type2[Type2["Uint8"] = -6] = "Uint8";
|
|
362
|
+
Type2[Type2["Uint16"] = -7] = "Uint16";
|
|
363
|
+
Type2[Type2["Uint32"] = -8] = "Uint32";
|
|
364
|
+
Type2[Type2["Uint64"] = -9] = "Uint64";
|
|
365
|
+
Type2[Type2["Float16"] = -10] = "Float16";
|
|
366
|
+
Type2[Type2["Float32"] = -11] = "Float32";
|
|
367
|
+
Type2[Type2["Float64"] = -12] = "Float64";
|
|
368
|
+
Type2[Type2["DateDay"] = -13] = "DateDay";
|
|
369
|
+
Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
|
|
370
|
+
Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
|
|
371
|
+
Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
|
|
372
|
+
Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
|
|
373
|
+
Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
|
|
374
|
+
Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
|
|
375
|
+
Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
|
|
376
|
+
Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
|
|
377
|
+
Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
|
|
378
|
+
Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
|
|
379
|
+
Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
|
|
380
|
+
Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
|
|
381
|
+
Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
|
|
382
|
+
})(Type || (Type = {}));
|
|
383
|
+
|
|
384
|
+
// ../schema/src/lib/schema/impl/type.ts
|
|
385
|
+
var DataType = class {
|
|
386
|
+
static isNull(x) {
|
|
387
|
+
return x && x.typeId === Type.Null;
|
|
388
|
+
}
|
|
389
|
+
static isInt(x) {
|
|
390
|
+
return x && x.typeId === Type.Int;
|
|
391
|
+
}
|
|
392
|
+
static isFloat(x) {
|
|
393
|
+
return x && x.typeId === Type.Float;
|
|
394
|
+
}
|
|
395
|
+
static isBinary(x) {
|
|
396
|
+
return x && x.typeId === Type.Binary;
|
|
397
|
+
}
|
|
398
|
+
static isUtf8(x) {
|
|
399
|
+
return x && x.typeId === Type.Utf8;
|
|
400
|
+
}
|
|
401
|
+
static isBool(x) {
|
|
402
|
+
return x && x.typeId === Type.Bool;
|
|
403
|
+
}
|
|
404
|
+
static isDecimal(x) {
|
|
405
|
+
return x && x.typeId === Type.Decimal;
|
|
406
|
+
}
|
|
407
|
+
static isDate(x) {
|
|
408
|
+
return x && x.typeId === Type.Date;
|
|
409
|
+
}
|
|
410
|
+
static isTime(x) {
|
|
411
|
+
return x && x.typeId === Type.Time;
|
|
412
|
+
}
|
|
413
|
+
static isTimestamp(x) {
|
|
414
|
+
return x && x.typeId === Type.Timestamp;
|
|
415
|
+
}
|
|
416
|
+
static isInterval(x) {
|
|
417
|
+
return x && x.typeId === Type.Interval;
|
|
418
|
+
}
|
|
419
|
+
static isList(x) {
|
|
420
|
+
return x && x.typeId === Type.List;
|
|
421
|
+
}
|
|
422
|
+
static isStruct(x) {
|
|
423
|
+
return x && x.typeId === Type.Struct;
|
|
424
|
+
}
|
|
425
|
+
static isUnion(x) {
|
|
426
|
+
return x && x.typeId === Type.Union;
|
|
427
|
+
}
|
|
428
|
+
static isFixedSizeBinary(x) {
|
|
429
|
+
return x && x.typeId === Type.FixedSizeBinary;
|
|
430
|
+
}
|
|
431
|
+
static isFixedSizeList(x) {
|
|
432
|
+
return x && x.typeId === Type.FixedSizeList;
|
|
433
|
+
}
|
|
434
|
+
static isMap(x) {
|
|
435
|
+
return x && x.typeId === Type.Map;
|
|
436
|
+
}
|
|
437
|
+
static isDictionary(x) {
|
|
438
|
+
return x && x.typeId === Type.Dictionary;
|
|
439
|
+
}
|
|
440
|
+
get typeId() {
|
|
441
|
+
return Type.NONE;
|
|
442
|
+
}
|
|
443
|
+
compareTo(other) {
|
|
444
|
+
return this === other;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
var Null = class extends DataType {
|
|
448
|
+
get typeId() {
|
|
449
|
+
return Type.Null;
|
|
450
|
+
}
|
|
451
|
+
get [Symbol.toStringTag]() {
|
|
452
|
+
return "Null";
|
|
453
|
+
}
|
|
454
|
+
toString() {
|
|
455
|
+
return "Null";
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
var Bool = class extends DataType {
|
|
459
|
+
get typeId() {
|
|
460
|
+
return Type.Bool;
|
|
461
|
+
}
|
|
462
|
+
get [Symbol.toStringTag]() {
|
|
463
|
+
return "Bool";
|
|
464
|
+
}
|
|
465
|
+
toString() {
|
|
466
|
+
return "Bool";
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
var Int = class extends DataType {
|
|
470
|
+
constructor(isSigned, bitWidth) {
|
|
471
|
+
super();
|
|
472
|
+
this.isSigned = isSigned;
|
|
473
|
+
this.bitWidth = bitWidth;
|
|
474
|
+
}
|
|
475
|
+
get typeId() {
|
|
476
|
+
return Type.Int;
|
|
477
|
+
}
|
|
478
|
+
get [Symbol.toStringTag]() {
|
|
479
|
+
return "Int";
|
|
480
|
+
}
|
|
481
|
+
toString() {
|
|
482
|
+
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
var Int8 = class extends Int {
|
|
486
|
+
constructor() {
|
|
487
|
+
super(true, 8);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
var Int16 = class extends Int {
|
|
491
|
+
constructor() {
|
|
492
|
+
super(true, 16);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
var Int32 = class extends Int {
|
|
496
|
+
constructor() {
|
|
497
|
+
super(true, 32);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
var Uint8 = class extends Int {
|
|
501
|
+
constructor() {
|
|
502
|
+
super(false, 8);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
var Uint16 = class extends Int {
|
|
506
|
+
constructor() {
|
|
507
|
+
super(false, 16);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var Uint32 = class extends Int {
|
|
511
|
+
constructor() {
|
|
512
|
+
super(false, 32);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
var Precision = {
|
|
516
|
+
HALF: 16,
|
|
517
|
+
SINGLE: 32,
|
|
518
|
+
DOUBLE: 64
|
|
519
|
+
};
|
|
520
|
+
var Float = class extends DataType {
|
|
521
|
+
constructor(precision) {
|
|
522
|
+
super();
|
|
523
|
+
this.precision = precision;
|
|
524
|
+
}
|
|
525
|
+
get typeId() {
|
|
526
|
+
return Type.Float;
|
|
527
|
+
}
|
|
528
|
+
get [Symbol.toStringTag]() {
|
|
529
|
+
return "Float";
|
|
530
|
+
}
|
|
531
|
+
toString() {
|
|
532
|
+
return `Float${this.precision}`;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
var Float32 = class extends Float {
|
|
536
|
+
constructor() {
|
|
537
|
+
super(Precision.SINGLE);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
var Float64 = class extends Float {
|
|
541
|
+
constructor() {
|
|
542
|
+
super(Precision.DOUBLE);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
var Binary = class extends DataType {
|
|
546
|
+
constructor() {
|
|
547
|
+
super();
|
|
548
|
+
}
|
|
549
|
+
get typeId() {
|
|
550
|
+
return Type.Binary;
|
|
551
|
+
}
|
|
552
|
+
toString() {
|
|
553
|
+
return "Binary";
|
|
554
|
+
}
|
|
555
|
+
get [Symbol.toStringTag]() {
|
|
556
|
+
return "Binary";
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
var Utf8 = class extends DataType {
|
|
560
|
+
get typeId() {
|
|
561
|
+
return Type.Utf8;
|
|
562
|
+
}
|
|
563
|
+
get [Symbol.toStringTag]() {
|
|
564
|
+
return "Utf8";
|
|
565
|
+
}
|
|
566
|
+
toString() {
|
|
567
|
+
return "Utf8";
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
var DateUnit = {
|
|
571
|
+
DAY: 0,
|
|
572
|
+
MILLISECOND: 1
|
|
573
|
+
};
|
|
574
|
+
var Date = class extends DataType {
|
|
575
|
+
constructor(unit) {
|
|
576
|
+
super();
|
|
577
|
+
this.unit = unit;
|
|
578
|
+
}
|
|
579
|
+
get typeId() {
|
|
580
|
+
return Type.Date;
|
|
581
|
+
}
|
|
582
|
+
get [Symbol.toStringTag]() {
|
|
583
|
+
return "Date";
|
|
584
|
+
}
|
|
585
|
+
toString() {
|
|
586
|
+
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
var TimeUnit = {
|
|
590
|
+
SECOND: 1,
|
|
591
|
+
MILLISECOND: 1e3,
|
|
592
|
+
MICROSECOND: 1e6,
|
|
593
|
+
NANOSECOND: 1e9
|
|
594
|
+
};
|
|
595
|
+
var Time = class extends DataType {
|
|
596
|
+
constructor(unit, bitWidth) {
|
|
597
|
+
super();
|
|
598
|
+
this.unit = unit;
|
|
599
|
+
this.bitWidth = bitWidth;
|
|
600
|
+
}
|
|
601
|
+
get typeId() {
|
|
602
|
+
return Type.Time;
|
|
603
|
+
}
|
|
604
|
+
toString() {
|
|
605
|
+
return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
|
|
606
|
+
}
|
|
607
|
+
get [Symbol.toStringTag]() {
|
|
608
|
+
return "Time";
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
var Timestamp = class extends DataType {
|
|
612
|
+
constructor(unit, timezone = null) {
|
|
613
|
+
super();
|
|
614
|
+
this.unit = unit;
|
|
615
|
+
this.timezone = timezone;
|
|
616
|
+
}
|
|
617
|
+
get typeId() {
|
|
618
|
+
return Type.Timestamp;
|
|
619
|
+
}
|
|
620
|
+
get [Symbol.toStringTag]() {
|
|
621
|
+
return "Timestamp";
|
|
622
|
+
}
|
|
623
|
+
toString() {
|
|
624
|
+
return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
var IntervalUnit = {
|
|
628
|
+
DAY_TIME: 0,
|
|
629
|
+
YEAR_MONTH: 1
|
|
630
|
+
};
|
|
631
|
+
var Interval = class extends DataType {
|
|
632
|
+
constructor(unit) {
|
|
633
|
+
super();
|
|
634
|
+
this.unit = unit;
|
|
635
|
+
}
|
|
636
|
+
get typeId() {
|
|
637
|
+
return Type.Interval;
|
|
638
|
+
}
|
|
639
|
+
get [Symbol.toStringTag]() {
|
|
640
|
+
return "Interval";
|
|
641
|
+
}
|
|
642
|
+
toString() {
|
|
643
|
+
return `Interval<${IntervalUnit[this.unit]}>`;
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
var FixedSizeList = class extends DataType {
|
|
647
|
+
constructor(listSize, child) {
|
|
648
|
+
super();
|
|
649
|
+
this.listSize = listSize;
|
|
650
|
+
this.children = [child];
|
|
651
|
+
}
|
|
652
|
+
get typeId() {
|
|
653
|
+
return Type.FixedSizeList;
|
|
654
|
+
}
|
|
655
|
+
get valueType() {
|
|
656
|
+
return this.children[0].type;
|
|
657
|
+
}
|
|
658
|
+
get valueField() {
|
|
659
|
+
return this.children[0];
|
|
660
|
+
}
|
|
661
|
+
get [Symbol.toStringTag]() {
|
|
662
|
+
return "FixedSizeList";
|
|
663
|
+
}
|
|
664
|
+
toString() {
|
|
665
|
+
return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
var Struct = class extends DataType {
|
|
669
|
+
constructor(children) {
|
|
670
|
+
super();
|
|
671
|
+
this.children = children;
|
|
672
|
+
}
|
|
673
|
+
get typeId() {
|
|
674
|
+
return Type.Struct;
|
|
675
|
+
}
|
|
676
|
+
toString() {
|
|
677
|
+
return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
|
|
678
|
+
}
|
|
679
|
+
get [Symbol.toStringTag]() {
|
|
680
|
+
return "Struct";
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
// ../schema/src/lib/arrow/arrow-like-type-utils.ts
|
|
685
|
+
function getArrowTypeFromTypedArray(array) {
|
|
686
|
+
switch (array.constructor) {
|
|
687
|
+
case Int8Array:
|
|
688
|
+
return new Int8();
|
|
689
|
+
case Uint8Array:
|
|
690
|
+
return new Uint8();
|
|
691
|
+
case Int16Array:
|
|
692
|
+
return new Int16();
|
|
693
|
+
case Uint16Array:
|
|
694
|
+
return new Uint16();
|
|
695
|
+
case Int32Array:
|
|
696
|
+
return new Int32();
|
|
697
|
+
case Uint32Array:
|
|
698
|
+
return new Uint32();
|
|
699
|
+
case Float32Array:
|
|
700
|
+
return new Float32();
|
|
701
|
+
case Float64Array:
|
|
702
|
+
return new Float64();
|
|
703
|
+
default:
|
|
704
|
+
throw new Error("array type not supported");
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// ../schema/src/category/mesh/deduce-mesh-schema.ts
|
|
709
|
+
function deduceMeshSchema(attributes, metadata) {
|
|
710
|
+
const fields = deduceMeshFields(attributes);
|
|
711
|
+
return new Schema(fields, metadata);
|
|
712
|
+
}
|
|
713
|
+
function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
714
|
+
const type = getArrowTypeFromTypedArray(attribute.value);
|
|
715
|
+
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
716
|
+
const field = new Field(attributeName, new FixedSizeList(attribute.size, new Field("value", type)), false, metadata);
|
|
717
|
+
return field;
|
|
718
|
+
}
|
|
719
|
+
function deduceMeshFields(attributes) {
|
|
720
|
+
const fields = [];
|
|
721
|
+
for (const attributeName in attributes) {
|
|
722
|
+
const attribute = attributes[attributeName];
|
|
723
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
724
|
+
}
|
|
725
|
+
return fields;
|
|
726
|
+
}
|
|
727
|
+
function makeMeshAttributeMetadata(attribute) {
|
|
728
|
+
const result = new Map();
|
|
729
|
+
if ("byteOffset" in attribute) {
|
|
730
|
+
result.set("byteOffset", attribute.byteOffset.toString(10));
|
|
731
|
+
}
|
|
732
|
+
if ("byteStride" in attribute) {
|
|
733
|
+
result.set("byteStride", attribute.byteStride.toString(10));
|
|
734
|
+
}
|
|
735
|
+
if ("normalized" in attribute) {
|
|
736
|
+
result.set("normalized", attribute.normalized.toString());
|
|
737
|
+
}
|
|
738
|
+
return result;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// src/lib/get-ply-schema.ts
|
|
742
|
+
function getPLYSchema(plyHeader, attributes) {
|
|
743
|
+
const metadataMap = makeMetadataFromPlyHeader(plyHeader);
|
|
744
|
+
const schema = deduceMeshSchema(attributes, metadataMap);
|
|
745
|
+
return schema;
|
|
746
|
+
}
|
|
747
|
+
function makeMetadataFromPlyHeader(plyHeader) {
|
|
748
|
+
const metadataMap = new Map();
|
|
749
|
+
metadataMap.set("ply_comments", JSON.stringify(plyHeader.comments));
|
|
750
|
+
metadataMap.set("ply_elements", JSON.stringify(plyHeader.elements));
|
|
751
|
+
if (plyHeader.format !== void 0) {
|
|
752
|
+
metadataMap.set("ply_format", plyHeader.format);
|
|
753
|
+
}
|
|
754
|
+
if (plyHeader.version !== void 0) {
|
|
755
|
+
metadataMap.set("ply_version", plyHeader.version);
|
|
756
|
+
}
|
|
757
|
+
if (plyHeader.headerLength !== void 0) {
|
|
758
|
+
metadataMap.set("ply_headerLength", plyHeader.headerLength.toString(10));
|
|
759
|
+
}
|
|
760
|
+
return metadataMap;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/lib/normalize-ply.ts
|
|
764
|
+
function normalizePLY(plyHeader, plyAttributes, options) {
|
|
765
|
+
const attributes = getMeshAttributes(plyAttributes);
|
|
766
|
+
const boundingBox = getMeshBoundingBox(attributes);
|
|
767
|
+
const vertexCount = plyAttributes.indices.length || plyAttributes.vertices.length / 3;
|
|
768
|
+
const isTriangles = plyAttributes.indices && plyAttributes.indices.length > 0;
|
|
769
|
+
const mode = isTriangles ? 4 : 0;
|
|
770
|
+
const topology = isTriangles ? "triangle-list" : "point-list";
|
|
771
|
+
const schema = getPLYSchema(plyHeader, attributes);
|
|
772
|
+
const plyMesh = {
|
|
773
|
+
loader: "ply",
|
|
774
|
+
loaderData: plyHeader,
|
|
775
|
+
header: {
|
|
776
|
+
vertexCount,
|
|
777
|
+
boundingBox
|
|
778
|
+
},
|
|
779
|
+
schema,
|
|
780
|
+
attributes,
|
|
781
|
+
indices: { value: new Uint32Array(0), size: 0 },
|
|
782
|
+
mode,
|
|
783
|
+
topology
|
|
784
|
+
};
|
|
785
|
+
if (plyAttributes.indices.length > 0) {
|
|
786
|
+
plyMesh.indices = { value: new Uint32Array(plyAttributes.indices), size: 1 };
|
|
787
|
+
}
|
|
788
|
+
return plyMesh;
|
|
789
|
+
}
|
|
790
|
+
function getMeshAttributes(attributes) {
|
|
791
|
+
const accessors = {};
|
|
792
|
+
accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };
|
|
793
|
+
if (attributes.normals.length > 0) {
|
|
794
|
+
accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };
|
|
795
|
+
}
|
|
796
|
+
if (attributes.uvs.length > 0) {
|
|
797
|
+
accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };
|
|
798
|
+
}
|
|
799
|
+
if (attributes.colors.length > 0) {
|
|
800
|
+
accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };
|
|
801
|
+
}
|
|
802
|
+
return accessors;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/lib/parse-ply.ts
|
|
806
|
+
function parsePLY(data, options = {}) {
|
|
807
|
+
let header;
|
|
808
|
+
let attributes;
|
|
809
|
+
if (data instanceof ArrayBuffer) {
|
|
810
|
+
const text = new TextDecoder().decode(data);
|
|
811
|
+
header = parseHeader(text, options);
|
|
812
|
+
attributes = header.format === "ascii" ? parseASCII(text, header) : parseBinary(data, header);
|
|
813
|
+
} else {
|
|
814
|
+
header = parseHeader(data, options);
|
|
815
|
+
attributes = parseASCII(data, header);
|
|
816
|
+
}
|
|
817
|
+
return normalizePLY(header, attributes);
|
|
818
|
+
}
|
|
819
|
+
function parseHeader(data, options) {
|
|
820
|
+
const PLY_HEADER_PATTERN = /ply([\s\S]*)end_header\s/;
|
|
821
|
+
let headerText = "";
|
|
822
|
+
let headerLength = 0;
|
|
823
|
+
const result = PLY_HEADER_PATTERN.exec(data);
|
|
824
|
+
if (result !== null) {
|
|
825
|
+
headerText = result[1];
|
|
826
|
+
headerLength = result[0].length;
|
|
827
|
+
}
|
|
828
|
+
const lines = headerText.split("\n");
|
|
829
|
+
const header = parseHeaderLines(lines, headerLength, options);
|
|
830
|
+
return header;
|
|
831
|
+
}
|
|
832
|
+
function parseHeaderLines(lines, headerLength, options) {
|
|
833
|
+
const header = {
|
|
834
|
+
comments: [],
|
|
835
|
+
elements: [],
|
|
836
|
+
headerLength
|
|
837
|
+
};
|
|
838
|
+
let lineType;
|
|
839
|
+
let lineValues;
|
|
840
|
+
let currentElement2 = null;
|
|
841
|
+
for (let i = 0; i < lines.length; i++) {
|
|
842
|
+
let line = lines[i];
|
|
843
|
+
line = line.trim();
|
|
844
|
+
if (line === "") {
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
lineValues = line.split(/\s+/);
|
|
848
|
+
lineType = lineValues.shift();
|
|
849
|
+
line = lineValues.join(" ");
|
|
850
|
+
switch (lineType) {
|
|
851
|
+
case "format":
|
|
852
|
+
header.format = lineValues[0];
|
|
853
|
+
header.version = lineValues[1];
|
|
854
|
+
break;
|
|
855
|
+
case "comment":
|
|
856
|
+
header.comments.push(line);
|
|
857
|
+
break;
|
|
858
|
+
case "element":
|
|
859
|
+
if (currentElement2) {
|
|
860
|
+
header.elements.push(currentElement2);
|
|
861
|
+
}
|
|
862
|
+
currentElement2 = {
|
|
863
|
+
name: lineValues[0],
|
|
864
|
+
count: parseInt(lineValues[1], 10),
|
|
865
|
+
properties: []
|
|
866
|
+
};
|
|
867
|
+
break;
|
|
868
|
+
case "property":
|
|
869
|
+
if (!currentElement2) {
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
currentElement2.properties.push(makePLYElementProperty(lineValues, options.propertyNameMapping));
|
|
873
|
+
break;
|
|
874
|
+
default:
|
|
875
|
+
console.log("unhandled", lineType, lineValues);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (currentElement2 !== void 0) {
|
|
879
|
+
header.elements.push(currentElement2);
|
|
880
|
+
}
|
|
881
|
+
return header;
|
|
882
|
+
}
|
|
883
|
+
function makePLYElementProperty(propertValues, propertyNameMapping) {
|
|
884
|
+
const property = {
|
|
885
|
+
type: propertValues[0]
|
|
886
|
+
};
|
|
887
|
+
if (property.type === "list") {
|
|
888
|
+
property.name = propertValues[3];
|
|
889
|
+
property.countType = propertValues[1];
|
|
890
|
+
property.itemType = propertValues[2];
|
|
891
|
+
} else {
|
|
892
|
+
property.name = propertValues[1];
|
|
893
|
+
}
|
|
894
|
+
if (propertyNameMapping && property.name in propertyNameMapping) {
|
|
895
|
+
property.name = propertyNameMapping[property.name];
|
|
896
|
+
}
|
|
897
|
+
return property;
|
|
898
|
+
}
|
|
899
|
+
function parseASCIINumber(n, type) {
|
|
900
|
+
switch (type) {
|
|
901
|
+
case "char":
|
|
902
|
+
case "uchar":
|
|
903
|
+
case "short":
|
|
904
|
+
case "ushort":
|
|
905
|
+
case "int":
|
|
906
|
+
case "uint":
|
|
907
|
+
case "int8":
|
|
908
|
+
case "uint8":
|
|
909
|
+
case "int16":
|
|
910
|
+
case "uint16":
|
|
911
|
+
case "int32":
|
|
912
|
+
case "uint32":
|
|
913
|
+
return parseInt(n, 10);
|
|
914
|
+
case "float":
|
|
915
|
+
case "double":
|
|
916
|
+
case "float32":
|
|
917
|
+
case "float64":
|
|
918
|
+
return parseFloat(n);
|
|
919
|
+
default:
|
|
920
|
+
throw new Error(type);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function parseASCIIElement(properties, line) {
|
|
924
|
+
const values = line.split(/\s+/);
|
|
925
|
+
const element = {};
|
|
926
|
+
for (let i = 0; i < properties.length; i++) {
|
|
927
|
+
if (properties[i].type === "list") {
|
|
928
|
+
const list = [];
|
|
929
|
+
const n = parseASCIINumber(values.shift(), properties[i].countType);
|
|
930
|
+
for (let j = 0; j < n; j++) {
|
|
931
|
+
list.push(parseASCIINumber(values.shift(), properties[i].itemType));
|
|
932
|
+
}
|
|
933
|
+
element[properties[i].name] = list;
|
|
934
|
+
} else {
|
|
935
|
+
element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return element;
|
|
939
|
+
}
|
|
940
|
+
function parseASCII(data, header) {
|
|
941
|
+
const attributes = {
|
|
942
|
+
indices: [],
|
|
943
|
+
vertices: [],
|
|
944
|
+
normals: [],
|
|
945
|
+
uvs: [],
|
|
946
|
+
colors: []
|
|
947
|
+
};
|
|
948
|
+
let result;
|
|
949
|
+
const patternBody = /end_header\s([\s\S]*)$/;
|
|
950
|
+
let body = "";
|
|
951
|
+
if ((result = patternBody.exec(data)) !== null) {
|
|
952
|
+
body = result[1];
|
|
953
|
+
}
|
|
954
|
+
const lines = body.split("\n");
|
|
955
|
+
let currentElement2 = 0;
|
|
956
|
+
let currentElementCount = 0;
|
|
957
|
+
for (let i = 0; i < lines.length; i++) {
|
|
958
|
+
let line = lines[i];
|
|
959
|
+
line = line.trim();
|
|
960
|
+
if (line !== "") {
|
|
961
|
+
if (currentElementCount >= header.elements[currentElement2].count) {
|
|
962
|
+
currentElement2++;
|
|
963
|
+
currentElementCount = 0;
|
|
964
|
+
}
|
|
965
|
+
const element = parseASCIIElement(header.elements[currentElement2].properties, line);
|
|
966
|
+
handleElement(attributes, header.elements[currentElement2].name, element);
|
|
967
|
+
currentElementCount++;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return attributes;
|
|
971
|
+
}
|
|
972
|
+
function handleElement(buffer, elementName, element = {}) {
|
|
973
|
+
if (elementName === "vertex") {
|
|
974
|
+
buffer.vertices.push(element.x, element.y, element.z);
|
|
975
|
+
if ("nx" in element && "ny" in element && "nz" in element) {
|
|
976
|
+
buffer.normals.push(element.nx, element.ny, element.nz);
|
|
977
|
+
}
|
|
978
|
+
if ("s" in element && "t" in element) {
|
|
979
|
+
buffer.uvs.push(element.s, element.t);
|
|
980
|
+
}
|
|
981
|
+
if ("red" in element && "green" in element && "blue" in element) {
|
|
982
|
+
buffer.colors.push(element.red, element.green, element.blue);
|
|
983
|
+
}
|
|
984
|
+
} else if (elementName === "face") {
|
|
985
|
+
const vertexIndices = element.vertex_indices || element.vertex_index;
|
|
986
|
+
if (vertexIndices.length === 3) {
|
|
987
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);
|
|
988
|
+
} else if (vertexIndices.length === 4) {
|
|
989
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);
|
|
990
|
+
buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function binaryRead(dataview, at, type, littleEndian) {
|
|
995
|
+
switch (type) {
|
|
996
|
+
case "int8":
|
|
997
|
+
case "char":
|
|
998
|
+
return [dataview.getInt8(at), 1];
|
|
999
|
+
case "uint8":
|
|
1000
|
+
case "uchar":
|
|
1001
|
+
return [dataview.getUint8(at), 1];
|
|
1002
|
+
case "int16":
|
|
1003
|
+
case "short":
|
|
1004
|
+
return [dataview.getInt16(at, littleEndian), 2];
|
|
1005
|
+
case "uint16":
|
|
1006
|
+
case "ushort":
|
|
1007
|
+
return [dataview.getUint16(at, littleEndian), 2];
|
|
1008
|
+
case "int32":
|
|
1009
|
+
case "int":
|
|
1010
|
+
return [dataview.getInt32(at, littleEndian), 4];
|
|
1011
|
+
case "uint32":
|
|
1012
|
+
case "uint":
|
|
1013
|
+
return [dataview.getUint32(at, littleEndian), 4];
|
|
1014
|
+
case "float32":
|
|
1015
|
+
case "float":
|
|
1016
|
+
return [dataview.getFloat32(at, littleEndian), 4];
|
|
1017
|
+
case "float64":
|
|
1018
|
+
case "double":
|
|
1019
|
+
return [dataview.getFloat64(at, littleEndian), 8];
|
|
1020
|
+
default:
|
|
1021
|
+
throw new Error(type);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
function binaryReadElement(dataview, at, properties, littleEndian) {
|
|
1025
|
+
const element = {};
|
|
1026
|
+
let result;
|
|
1027
|
+
let read = 0;
|
|
1028
|
+
for (let i = 0; i < properties.length; i++) {
|
|
1029
|
+
if (properties[i].type === "list") {
|
|
1030
|
+
const list = [];
|
|
1031
|
+
result = binaryRead(dataview, at + read, properties[i].countType, littleEndian);
|
|
1032
|
+
const n = result[0];
|
|
1033
|
+
read += result[1];
|
|
1034
|
+
for (let j = 0; j < n; j++) {
|
|
1035
|
+
result = binaryRead(dataview, at + read, properties[i].itemType, littleEndian);
|
|
1036
|
+
list.push(result[0]);
|
|
1037
|
+
read += result[1];
|
|
1038
|
+
}
|
|
1039
|
+
element[properties[i].name] = list;
|
|
1040
|
+
} else {
|
|
1041
|
+
result = binaryRead(dataview, at + read, properties[i].type, littleEndian);
|
|
1042
|
+
element[properties[i].name] = result[0];
|
|
1043
|
+
read += result[1];
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return [element, read];
|
|
1047
|
+
}
|
|
1048
|
+
function parseBinary(data, header) {
|
|
1049
|
+
const attributes = {
|
|
1050
|
+
indices: [],
|
|
1051
|
+
vertices: [],
|
|
1052
|
+
normals: [],
|
|
1053
|
+
uvs: [],
|
|
1054
|
+
colors: []
|
|
1055
|
+
};
|
|
1056
|
+
const littleEndian = header.format === "binary_little_endian";
|
|
1057
|
+
const body = new DataView(data, header.headerLength);
|
|
1058
|
+
let result;
|
|
1059
|
+
let loc = 0;
|
|
1060
|
+
for (let currentElement2 = 0; currentElement2 < header.elements.length; currentElement2++) {
|
|
1061
|
+
const count = header.elements[currentElement2].count;
|
|
1062
|
+
for (let currentElementCount = 0; currentElementCount < count; currentElementCount++) {
|
|
1063
|
+
result = binaryReadElement(body, loc, header.elements[currentElement2].properties, littleEndian);
|
|
1064
|
+
loc += result[1];
|
|
1065
|
+
const element = result[0];
|
|
1066
|
+
handleElement(attributes, header.elements[currentElement2].name, element);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return attributes;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// src/lib/parse-ply-in-batches.ts
|
|
1073
|
+
var currentElement;
|
|
1074
|
+
async function* parsePLYInBatches(iterator, options) {
|
|
1075
|
+
const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));
|
|
1076
|
+
const header = await parsePLYHeader(lineIterator, options);
|
|
1077
|
+
let attributes;
|
|
1078
|
+
switch (header.format) {
|
|
1079
|
+
case "ascii":
|
|
1080
|
+
attributes = await parseASCII2(lineIterator, header);
|
|
1081
|
+
break;
|
|
1082
|
+
default:
|
|
1083
|
+
throw new Error("Binary PLY can not yet be parsed in streaming mode");
|
|
1084
|
+
}
|
|
1085
|
+
yield normalizePLY(header, attributes, options);
|
|
1086
|
+
}
|
|
1087
|
+
async function parsePLYHeader(lineIterator, options) {
|
|
1088
|
+
const header = {
|
|
1089
|
+
comments: [],
|
|
1090
|
+
elements: []
|
|
1091
|
+
};
|
|
1092
|
+
await forEach(lineIterator, (line) => {
|
|
1093
|
+
line = line.trim();
|
|
1094
|
+
if (line === "end_header") {
|
|
1095
|
+
return true;
|
|
1096
|
+
}
|
|
1097
|
+
if (line === "") {
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
const lineValues = line.split(/\s+/);
|
|
1101
|
+
const lineType = lineValues.shift();
|
|
1102
|
+
line = lineValues.join(" ");
|
|
1103
|
+
switch (lineType) {
|
|
1104
|
+
case "ply":
|
|
1105
|
+
break;
|
|
1106
|
+
case "format":
|
|
1107
|
+
header.format = lineValues[0];
|
|
1108
|
+
header.version = lineValues[1];
|
|
1109
|
+
break;
|
|
1110
|
+
case "comment":
|
|
1111
|
+
header.comments.push(line);
|
|
1112
|
+
break;
|
|
1113
|
+
case "element":
|
|
1114
|
+
if (currentElement) {
|
|
1115
|
+
header.elements.push(currentElement);
|
|
1116
|
+
}
|
|
1117
|
+
currentElement = {
|
|
1118
|
+
name: lineValues[0],
|
|
1119
|
+
count: parseInt(lineValues[1], 10),
|
|
1120
|
+
properties: []
|
|
1121
|
+
};
|
|
1122
|
+
break;
|
|
1123
|
+
case "property":
|
|
1124
|
+
const property = makePLYElementProperty2(lineValues, options.propertyNameMapping);
|
|
1125
|
+
currentElement.properties.push(property);
|
|
1126
|
+
break;
|
|
1127
|
+
default:
|
|
1128
|
+
console.log("unhandled", lineType, lineValues);
|
|
1129
|
+
}
|
|
1130
|
+
return false;
|
|
1131
|
+
});
|
|
1132
|
+
if (currentElement) {
|
|
1133
|
+
header.elements.push(currentElement);
|
|
1134
|
+
}
|
|
1135
|
+
return header;
|
|
1136
|
+
}
|
|
1137
|
+
function makePLYElementProperty2(propertValues, propertyNameMapping) {
|
|
1138
|
+
const property = {
|
|
1139
|
+
type: propertValues[0]
|
|
1140
|
+
};
|
|
1141
|
+
if (property.type === "list") {
|
|
1142
|
+
property.name = propertValues[3];
|
|
1143
|
+
property.countType = propertValues[1];
|
|
1144
|
+
property.itemType = propertValues[2];
|
|
1145
|
+
} else {
|
|
1146
|
+
property.name = propertValues[1];
|
|
1147
|
+
}
|
|
1148
|
+
if (propertyNameMapping && property.name in propertyNameMapping) {
|
|
1149
|
+
property.name = propertyNameMapping[property.name];
|
|
1150
|
+
}
|
|
1151
|
+
return property;
|
|
1152
|
+
}
|
|
1153
|
+
async function parseASCII2(lineIterator, header) {
|
|
1154
|
+
const attributes = {
|
|
1155
|
+
indices: [],
|
|
1156
|
+
vertices: [],
|
|
1157
|
+
normals: [],
|
|
1158
|
+
uvs: [],
|
|
1159
|
+
colors: []
|
|
1160
|
+
};
|
|
1161
|
+
let currentElement2 = 0;
|
|
1162
|
+
let currentElementCount = 0;
|
|
1163
|
+
for await (let line of lineIterator) {
|
|
1164
|
+
line = line.trim();
|
|
1165
|
+
if (line !== "") {
|
|
1166
|
+
if (currentElementCount >= header.elements[currentElement2].count) {
|
|
1167
|
+
currentElement2++;
|
|
1168
|
+
currentElementCount = 0;
|
|
1169
|
+
}
|
|
1170
|
+
const element = parseASCIIElement2(header.elements[currentElement2].properties, line);
|
|
1171
|
+
handleElement2(attributes, header.elements[currentElement2].name, element);
|
|
1172
|
+
currentElementCount++;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return attributes;
|
|
1176
|
+
}
|
|
1177
|
+
function parseASCIINumber2(n, type) {
|
|
1178
|
+
switch (type) {
|
|
1179
|
+
case "char":
|
|
1180
|
+
case "uchar":
|
|
1181
|
+
case "short":
|
|
1182
|
+
case "ushort":
|
|
1183
|
+
case "int":
|
|
1184
|
+
case "uint":
|
|
1185
|
+
case "int8":
|
|
1186
|
+
case "uint8":
|
|
1187
|
+
case "int16":
|
|
1188
|
+
case "uint16":
|
|
1189
|
+
case "int32":
|
|
1190
|
+
case "uint32":
|
|
1191
|
+
return parseInt(n, 10);
|
|
1192
|
+
case "float":
|
|
1193
|
+
case "double":
|
|
1194
|
+
case "float32":
|
|
1195
|
+
case "float64":
|
|
1196
|
+
return parseFloat(n);
|
|
1197
|
+
default:
|
|
1198
|
+
throw new Error(type);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
function parseASCIIElement2(properties, line) {
|
|
1202
|
+
const values = line.split(/\s+/);
|
|
1203
|
+
const element = {};
|
|
1204
|
+
for (let i = 0; i < properties.length; i++) {
|
|
1205
|
+
if (properties[i].type === "list") {
|
|
1206
|
+
const list = [];
|
|
1207
|
+
const n = parseASCIINumber2(values.shift(), properties[i].countType);
|
|
1208
|
+
for (let j = 0; j < n; j++) {
|
|
1209
|
+
list.push(parseASCIINumber2(values.shift(), properties[i].itemType));
|
|
1210
|
+
}
|
|
1211
|
+
element[properties[i].name] = list;
|
|
1212
|
+
} else {
|
|
1213
|
+
element[properties[i].name] = parseASCIINumber2(values.shift(), properties[i].type);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return element;
|
|
1217
|
+
}
|
|
1218
|
+
function handleElement2(buffer, elementName, element = {}) {
|
|
1219
|
+
switch (elementName) {
|
|
1220
|
+
case "vertex":
|
|
1221
|
+
buffer.vertices.push(element.x, element.y, element.z);
|
|
1222
|
+
if ("nx" in element && "ny" in element && "nz" in element) {
|
|
1223
|
+
buffer.normals.push(element.nx, element.ny, element.nz);
|
|
1224
|
+
}
|
|
1225
|
+
if ("s" in element && "t" in element) {
|
|
1226
|
+
buffer.uvs.push(element.s, element.t);
|
|
1227
|
+
}
|
|
1228
|
+
if ("red" in element && "green" in element && "blue" in element) {
|
|
1229
|
+
buffer.colors.push(element.red / 255, element.green / 255, element.blue / 255);
|
|
1230
|
+
}
|
|
1231
|
+
break;
|
|
1232
|
+
case "face":
|
|
1233
|
+
const vertexIndices = element.vertex_indices || element.vertex_index;
|
|
1234
|
+
if (vertexIndices.length === 3) {
|
|
1235
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);
|
|
1236
|
+
} else if (vertexIndices.length === 4) {
|
|
1237
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);
|
|
1238
|
+
buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);
|
|
1239
|
+
}
|
|
1240
|
+
break;
|
|
1241
|
+
default:
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// src/index.ts
|
|
1247
|
+
var PLYLoader2 = {
|
|
1248
|
+
...PLYLoader,
|
|
1249
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options),
|
|
1250
|
+
parseTextSync: parsePLY,
|
|
1251
|
+
parseSync: parsePLY,
|
|
1252
|
+
parseInBatches: parsePLYInBatches
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
// src/workers/ply-worker.ts
|
|
1256
|
+
createLoaderWorker(PLYLoader2);
|
|
1257
|
+
})();
|