@loaders.gl/ply 4.2.3 → 4.2.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/dist.min.js CHANGED
@@ -4,7 +4,7 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var R=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),X=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},h=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of j(t))!J.call(e,o)&&o!==r&&x(e,o,{get:()=>t[o],enumerable:!(n=U(t,o))||n.enumerable});return e},g=(e,t,r)=>(h(e,t,"default"),r&&h(r,t,"default")),Z=(e,t,r)=>(r=e!=null?R(W(e)):{},h(t||!e||!e.__esModule?x(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>h(x({},"__esModule",{value:!0}),e);var P=V((fe,v)=>{v.exports=globalThis.loaders});var d={};X(d,{PLYLoader:()=>le,PLYWorkerLoader:()=>k});g(d,Z(P(),1));var Q="4.2.2",k={dataType:null,batchType:null,name:"PLY",id:"ply",module:"ply",version:Q,worker:!0,extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"],options:{ply:{}}};function M(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function A(e){let t=1/0,r=1/0,n=1/0,o=-1/0,a=-1/0,s=-1/0,i=e.POSITION?e.POSITION.value:[],l=i&&i.length;for(let c=0;c<l;c+=3){let u=i[c],f=i[c+1],y=i[c+2];t=u<t?u:t,r=f<r?f:r,n=y<n?y:n,o=u>o?u:o,a=f>a?f:a,s=y>s?y:s}return[[t,r,n],[o,a,s]]}function b(e,t={}){return{fields:$(e),metadata:t}}function N(e,t,r){let n=M(t.value),o=r||z(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:o}}function $(e){let t=[];for(let r in e){let n=e[r];t.push(N(r,n))}return t}function z(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}function D(e,t){let r=G(e);return b(t,r)}function G(e){let t={};return t.ply_comments=JSON.stringify(e.comments),t.ply_elements=JSON.stringify(e.elements),e.format!==void 0&&(t.ply_format=e.format),e.version!==void 0&&(t.ply_version=e.version),e.headerLength!==void 0&&(t.ply_headerLength=e.headerLength.toString(10)),t}function p(e,t,r){let n=K(t),o=A(n),a=t.indices.length||t.vertices.length/3,s=t.indices&&t.indices.length>0,i=s?4:0,l=s?"triangle-list":"point-list",c=D(e,n),u={loader:"ply",loaderData:e,header:{vertexCount:a,boundingBox:o},schema:c,attributes:n,indices:{value:new Uint32Array(0),size:0},mode:i,topology:l};return t.indices.length>0&&(u.indices={value:new Uint32Array(t.indices),size:1}),u}function K(e){let t={};for(let r of Object.keys(e))switch(r){case"vertices":e.vertices.length>0&&(t.POSITION={value:new Float32Array(e.vertices),size:3});break;case"normals":e.normals.length>0&&(t.NORMAL={value:new Float32Array(e.normals),size:3});break;case"uvs":e.uvs.length>0&&(t.TEXCOORD_0={value:new Float32Array(e.uvs),size:2});break;case"colors":e.colors.length>0&&(t.COLOR_0={value:new Uint8Array(e.colors),size:3,normalized:!0});break;case"indices":break;default:e[r].length>0&&(t[r]={value:new Float32Array(e[r]),size:1});break}return t}function T(e,t={}){let r,n;if(e instanceof ArrayBuffer){let o=new TextDecoder().decode(e);r=E(o,t),n=r.format==="ascii"?O(o,r):ne(e,r)}else r=E(e,t),n=O(e,r);return p(r,n)}function E(e,t){let r=/ply([\s\S]*)end_header\s/,n="",o=0,a=r.exec(e);a!==null&&(n=a[1],o=a[0].length);let s=n.split(`
7
+ "use strict";var __exports__=(()=>{var R=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),X=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},h=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of j(t))!J.call(e,o)&&o!==r&&x(e,o,{get:()=>t[o],enumerable:!(n=U(t,o))||n.enumerable});return e},g=(e,t,r)=>(h(e,t,"default"),r&&h(r,t,"default")),Z=(e,t,r)=>(r=e!=null?R(W(e)):{},h(t||!e||!e.__esModule?x(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>h(x({},"__esModule",{value:!0}),e);var P=V((fe,v)=>{v.exports=globalThis.loaders});var d={};X(d,{PLYLoader:()=>le,PLYWorkerLoader:()=>k});g(d,Z(P(),1));var Q="4.2.3",k={dataType:null,batchType:null,name:"PLY",id:"ply",module:"ply",version:Q,worker:!0,extensions:["ply"],mimeTypes:["text/plain","application/octet-stream"],text:!0,binary:!0,tests:["ply"],options:{ply:{}}};function M(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function A(e){let t=1/0,r=1/0,n=1/0,o=-1/0,a=-1/0,s=-1/0,i=e.POSITION?e.POSITION.value:[],l=i&&i.length;for(let c=0;c<l;c+=3){let u=i[c],f=i[c+1],y=i[c+2];t=u<t?u:t,r=f<r?f:r,n=y<n?y:n,o=u>o?u:o,a=f>a?f:a,s=y>s?y:s}return[[t,r,n],[o,a,s]]}function b(e,t={}){return{fields:$(e),metadata:t}}function N(e,t,r){let n=M(t.value),o=r||z(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:o}}function $(e){let t=[];for(let r in e){let n=e[r];t.push(N(r,n))}return t}function z(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}function D(e,t){let r=G(e);return b(t,r)}function G(e){let t={};return t.ply_comments=JSON.stringify(e.comments),t.ply_elements=JSON.stringify(e.elements),e.format!==void 0&&(t.ply_format=e.format),e.version!==void 0&&(t.ply_version=e.version),e.headerLength!==void 0&&(t.ply_headerLength=e.headerLength.toString(10)),t}function p(e,t,r){let n=K(t),o=A(n),a=t.indices.length||t.vertices.length/3,s=t.indices&&t.indices.length>0,i=s?4:0,l=s?"triangle-list":"point-list",c=D(e,n),u={loader:"ply",loaderData:e,header:{vertexCount:a,boundingBox:o},schema:c,attributes:n,indices:{value:new Uint32Array(0),size:0},mode:i,topology:l};return t.indices.length>0&&(u.indices={value:new Uint32Array(t.indices),size:1}),u}function K(e){let t={};for(let r of Object.keys(e))switch(r){case"vertices":e.vertices.length>0&&(t.POSITION={value:new Float32Array(e.vertices),size:3});break;case"normals":e.normals.length>0&&(t.NORMAL={value:new Float32Array(e.normals),size:3});break;case"uvs":e.uvs.length>0&&(t.TEXCOORD_0={value:new Float32Array(e.uvs),size:2});break;case"colors":e.colors.length>0&&(t.COLOR_0={value:new Uint8Array(e.colors),size:3,normalized:!0});break;case"indices":break;default:e[r].length>0&&(t[r]={value:new Float32Array(e[r]),size:1});break}return t}function T(e,t={}){let r,n;if(e instanceof ArrayBuffer){let o=new TextDecoder().decode(e);r=E(o,t),n=r.format==="ascii"?O(o,r):ne(e,r)}else r=E(e,t),n=O(e,r);return p(r,n)}function E(e,t){let r=/ply([\s\S]*)end_header\s/,n="",o=0,a=r.exec(e);a!==null&&(n=a[1],o=a[0].length);let s=n.split(`
8
8
  `);return H(s,o,t)}function H(e,t,r){let n={comments:[],elements:[],headerLength:t},o,a,s=null;for(let i=0;i<e.length;i++){let l=e[i];if(l=l.trim(),l!=="")switch(a=l.split(/\s+/),o=a.shift(),l=a.join(" "),o){case"format":n.format=a[0],n.version=a[1];break;case"comment":n.comments.push(l);break;case"element":s&&n.elements.push(s),s={name:a[0],count:parseInt(a[1],10),properties:[]};break;case"property":if(s){let c=ee(a);r?.propertyNameMapping&&c.name in r?.propertyNameMapping&&(c.name=r?.propertyNameMapping[c.name]),s.properties.push(c)}break;default:console.log("unhandled",o,a)}}return s&&n.elements.push(s),n}function Y(e){let t={indices:[],vertices:[],normals:[],uvs:[],colors:[]};for(let r of e.elements)if(r.name==="vertex")for(let n of r.properties)switch(n.name){case"x":case"y":case"z":case"nx":case"ny":case"nz":case"s":case"t":case"red":case"green":case"blue":break;default:t[n.name]=[];break}return t}function ee(e){let t=e[0];switch(t){case"list":return{type:t,name:e[3],countType:e[1],itemType:e[2]};default:return{type:t,name:e[1]}}}function I(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 te(e,t){let r=t.split(/\s+/),n={};for(let o=0;o<e.length;o++)if(e[o].type==="list"){let a=[],s=I(r.shift(),e[o].countType);for(let i=0;i<s;i++)a.push(I(r.shift(),e[o].itemType));n[e[o].name]=a}else n[e[o].name]=I(r.shift(),e[o].type);return n}function O(e,t){let r=Y(t),n,o=/end_header\s([\s\S]*)$/,a="";(n=o.exec(e))!==null&&(a=n[1]);let s=a.split(`
9
9
  `),i=0,l=0;for(let c=0;c<s.length;c++){let u=s[c];if(u=u.trim(),u!==""){l>=t.elements[i].count&&(i++,l=0);let f=te(t.elements[i].properties,u);C(r,t.elements[i].name,f),l++}}return r}function C(e,t,r={}){if(t==="vertex")for(let n of Object.keys(r))switch(n){case"x":e.vertices.push(r.x,r.y,r.z);break;case"y":case"z":break;case"nx":"nx"in r&&"ny"in r&&"nz"in r&&e.normals.push(r.nx,r.ny,r.nz);break;case"ny":case"nz":break;case"s":"s"in r&&"t"in r&&e.uvs.push(r.s,r.t);break;case"t":break;case"red":"red"in r&&"green"in r&&"blue"in r&&e.colors.push(r.red,r.green,r.blue);break;case"green":case"blue":break;default:e[n].push(r[n])}else if(t==="face"){let n=r.vertex_indices||r.vertex_index;n.length===3?e.indices.push(n[0],n[1],n[2]):n.length===4&&(e.indices.push(n[0],n[1],n[3]),e.indices.push(n[1],n[2],n[3]))}}function w(e,t,r,n){switch(r){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,n),2];case"uint16":case"ushort":return[e.getUint16(t,n),2];case"int32":case"int":return[e.getInt32(t,n),4];case"uint32":case"uint":return[e.getUint32(t,n),4];case"float32":case"float":return[e.getFloat32(t,n),4];case"float64":case"double":return[e.getFloat64(t,n),8];default:throw new Error(r)}}function re(e,t,r,n){let o={},a,s=0;for(let i=0;i<r.length;i++)if(r[i].type==="list"){let l=[];a=w(e,t+s,r[i].countType,n);let c=a[0];s+=a[1];for(let u=0;u<c;u++)a=w(e,t+s,r[i].itemType,n),l.push(a[0]),s+=a[1];o[r[i].name]=l}else a=w(e,t+s,r[i].type,n),o[r[i].name]=a[0],s+=a[1];return[o,s]}function ne(e,t){let r=Y(t),n=t.format==="binary_little_endian",o=new DataView(e,t.headerLength),a,s=0;for(let i=0;i<t.elements.length;i++){let l=t.elements[i].count;for(let c=0;c<l;c++){a=re(o,s,t.elements[i].properties,n),s+=a[1];let u=a[0];C(r,t.elements[i].name,u)}}return r}async function*S(e,t={}){let r=new TextDecoder(void 0,t);for await(let n of e)yield typeof n=="string"?n:r.decode(n,{stream:!0})}async function*L(e){let t="";for await(let r of e){t+=r;let n;for(;(n=t.indexOf(`
10
10
  `))>=0;){let o=t.slice(0,n+1);t=t.slice(n+1),yield o}}t.length>0&&(yield t)}async function F(e,t){for(;;){let{done:r,value:n}=await e.next();if(r){e.return();return}if(t(n))return}}var m;async function*_(e,t){let r=L(S(e)),n=await oe(r,t),o;switch(n.format){case"ascii":o=await se(r,n);break;default:throw new Error("Binary PLY can not yet be parsed in streaming mode")}yield p(n,o,t)}async function oe(e,t){let r={comments:[],elements:[]};return await F(e,n=>{if(n=n.trim(),n==="end_header")return!0;if(n==="")return!1;let o=n.split(/\s+/),a=o.shift();switch(n=o.join(" "),a){case"ply":break;case"format":r.format=o[0],r.version=o[1];break;case"comment":r.comments.push(n);break;case"element":m&&r.elements.push(m),m={name:o[0],count:parseInt(o[1],10),properties:[]};break;case"property":let s=ae(o,t.propertyNameMapping);m.properties.push(s);break;default:console.log("unhandled",a,o)}return!1}),m&&r.elements.push(m),r}function ae(e,t){let r=e[0];switch(r){case"list":return{type:r,name:e[3],countType:e[1],itemType:e[2]};default:return{type:r,name:e[1]}}}async function se(e,t){let r={indices:[],vertices:[],normals:[],uvs:[],colors:[]},n=0,o=0;for await(let a of e)if(a=a.trim(),a!==""){o>=t.elements[n].count&&(n++,o=0);let s=ie(t.elements[n].properties,a);ce(r,t.elements[n].name,s),o++}return r}function B(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 ie(e,t){let r=t.split(/\s+/),n={};for(let o=0;o<e.length;o++)if(e[o].type==="list"){let a=[],s=B(r.shift(),e[o].countType);for(let i=0;i<s;i++)a.push(B(r.shift(),e[o].itemType));n[e[o].name]=a}else n[e[o].name]=B(r.shift(),e[o].type);return n}function ce(e,t,r={}){switch(t){case"vertex":e.vertices.push(r.x,r.y,r.z),"nx"in r&&"ny"in r&&"nz"in r&&e.normals.push(r.nx,r.ny,r.nz),"s"in r&&"t"in r&&e.uvs.push(r.s,r.t),"red"in r&&"green"in r&&"blue"in r&&e.colors.push(r.red/255,r.green/255,r.blue/255);break;case"face":let n=r.vertex_indices||r.vertex_index;n.length===3?e.indices.push(n[0],n[1],n[2]):n.length===4&&(e.indices.push(n[0],n[1],n[3]),e.indices.push(n[1],n[2],n[3]));break;default:break}}var le={...k,parse:async(e,t)=>T(e,t?.ply),parseTextSync:(e,t)=>T(e,t?.ply),parseSync:(e,t)=>T(e,t?.ply),parseInBatches:(e,t)=>_(e,t?.ply)};return q(d);})();
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ __export(dist_exports, {
26
26
  module.exports = __toCommonJS(dist_exports);
27
27
 
28
28
  // dist/ply-loader.js
29
- var VERSION = true ? "4.2.2" : "latest";
29
+ var VERSION = true ? "4.2.3" : "latest";
30
30
  var PLYLoader = {
31
31
  dataType: null,
32
32
  batchType: null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "ply-loader.js", "lib/normalize-ply.js", "lib/get-ply-schema.js", "lib/parse-ply.js", "lib/parse-ply-in-batches.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { PLYLoader as PLYWorkerLoader } from \"./ply-loader.js\";\nimport { parsePLY } from \"./lib/parse-ply.js\";\nimport { parsePLYInBatches } from \"./lib/parse-ply-in-batches.js\";\nexport { PLYWorkerLoader };\n/**\n * Loader for PLY - Polygon File Format\n */\nexport const PLYLoader = {\n ...PLYWorkerLoader,\n // Note: parsePLY supports both text and binary\n parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?\n parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),\n parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),\n parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)\n};\n", "// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.2\" !== 'undefined' ? \"4.2.2\" : 'latest';\n/**\n * Worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'\n * links: ['http://paulbourke.net/dataformats/ply/',\n * 'https://en.wikipedia.org/wiki/PLY_(file_format)']\n */\nexport const PLYLoader = {\n dataType: null,\n batchType: null,\n name: 'PLY',\n id: 'ply',\n module: 'ply',\n // shapes: ['mesh', 'gltf', 'columnar-table'],\n version: VERSION,\n worker: true,\n extensions: ['ply'],\n mimeTypes: ['text/plain', 'application/octet-stream'],\n text: true,\n binary: true,\n tests: ['ply'],\n options: {\n ply: {}\n }\n};\n", "import { getMeshBoundingBox } from '@loaders.gl/schema';\nimport { getPLYSchema } from \"./get-ply-schema.js\";\n/**\n * @param header\n * @param attributes\n * @returns data and header\n */\nexport default function normalizePLY(plyHeader, plyAttributes, options) {\n const attributes = getMeshAttributes(plyAttributes);\n const boundingBox = getMeshBoundingBox(attributes);\n const vertexCount = plyAttributes.indices.length || plyAttributes.vertices.length / 3;\n // TODO - how to detect POINT CLOUDS vs MESHES?\n // TODO - For Meshes, PLY quadrangles must be split?\n const isTriangles = plyAttributes.indices && plyAttributes.indices.length > 0;\n const mode = isTriangles ? 4 : 0; // TRIANGLES vs POINTS\n const topology = isTriangles ? 'triangle-list' : 'point-list';\n const schema = getPLYSchema(plyHeader, attributes);\n const plyMesh = {\n loader: 'ply',\n loaderData: plyHeader,\n header: {\n vertexCount,\n boundingBox\n },\n schema,\n attributes,\n indices: { value: new Uint32Array(0), size: 0 },\n mode,\n topology\n };\n if (plyAttributes.indices.length > 0) {\n plyMesh.indices = { value: new Uint32Array(plyAttributes.indices), size: 1 };\n }\n return plyMesh;\n}\n/**\n * @param attributes\n * @returns accessors []\n */\n// eslint-disable-next-line complexity\nfunction getMeshAttributes(attributes) {\n const accessors = {};\n for (const attributeName of Object.keys(attributes)) {\n switch (attributeName) {\n case 'vertices':\n if (attributes.vertices.length > 0) {\n accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };\n }\n break;\n // optional attributes data\n case 'normals':\n if (attributes.normals.length > 0) {\n accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };\n }\n break;\n case 'uvs':\n if (attributes.uvs.length > 0) {\n accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };\n }\n break;\n case 'colors':\n if (attributes.colors.length > 0) {\n // TODO - normalized shoud be based on `uchar` flag in source data?\n accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };\n }\n break;\n case 'indices':\n break;\n default:\n if (attributes[attributeName].length > 0) {\n accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };\n }\n break;\n }\n }\n return accessors;\n}\n", "import { deduceMeshSchema } from '@loaders.gl/schema';\n/**\n * Gets schema from PLY header\n * @param plyHeader\n * @param metadata\n * @returns Schema\n */\nexport function getPLYSchema(plyHeader, attributes) {\n const metadata = makeMetadataFromPlyHeader(plyHeader);\n const schema = deduceMeshSchema(attributes, metadata);\n return schema;\n}\n/**\n * Make arrow like schema metadata by PlyHeader properties\n * @param plyHeader\n * @returns\n */\nfunction makeMetadataFromPlyHeader(plyHeader) {\n /* eslint-disable camelcase */\n const metadata = {};\n metadata.ply_comments = JSON.stringify(plyHeader.comments);\n metadata.ply_elements = JSON.stringify(plyHeader.elements);\n if (plyHeader.format !== undefined) {\n metadata.ply_format = plyHeader.format;\n }\n if (plyHeader.version !== undefined) {\n metadata.ply_version = plyHeader.version;\n }\n if (plyHeader.headerLength !== undefined) {\n metadata.ply_headerLength = plyHeader.headerLength.toString(10);\n }\n return metadata;\n}\n", "import normalizePLY from \"./normalize-ply.js\";\n/**\n * @param data\n * @param options\n * @returns\n */\nexport function parsePLY(data, options = {}) {\n let header;\n let attributes;\n if (data instanceof ArrayBuffer) {\n const text = new TextDecoder().decode(data);\n header = parseHeader(text, options);\n attributes = header.format === 'ascii' ? parseASCII(text, header) : parseBinary(data, header);\n }\n else {\n header = parseHeader(data, options);\n attributes = parseASCII(data, header);\n }\n return normalizePLY(header, attributes);\n}\n/**\n * @param data\n * @param options\n * @returns header\n */\nfunction parseHeader(data, options) {\n const PLY_HEADER_PATTERN = /ply([\\s\\S]*)end_header\\s/;\n let headerText = '';\n let headerLength = 0;\n const result = PLY_HEADER_PATTERN.exec(data);\n if (result !== null) {\n headerText = result[1];\n headerLength = result[0].length;\n }\n const lines = headerText.split('\\n');\n const header = parseHeaderLines(lines, headerLength, options);\n return header;\n}\n/**\n * @param lines\n * @param headerLength\n * @param options\n * @returns header\n */\n// eslint-disable-next-line complexity\nfunction parseHeaderLines(lines, headerLength, options) {\n const header = {\n comments: [],\n elements: [],\n headerLength\n };\n let lineType;\n let lineValues;\n let currentElement = null;\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i];\n line = line.trim();\n if (line === '') {\n // eslint-disable-next-line\n continue;\n }\n lineValues = line.split(/\\s+/);\n lineType = lineValues.shift();\n line = lineValues.join(' ');\n switch (lineType) {\n case 'format':\n header.format = lineValues[0];\n header.version = lineValues[1];\n break;\n case 'comment':\n header.comments.push(line);\n break;\n case 'element':\n // Start new element, store previous element\n if (currentElement) {\n header.elements.push(currentElement);\n }\n currentElement = {\n name: lineValues[0],\n count: parseInt(lineValues[1], 10),\n properties: []\n };\n break;\n case 'property':\n if (currentElement) {\n const property = makePLYElementProperty(lineValues);\n if (options?.propertyNameMapping && property.name in options?.propertyNameMapping) {\n property.name = options?.propertyNameMapping[property.name];\n }\n currentElement.properties.push(property);\n }\n break;\n default:\n // eslint-disable-next-line\n console.log('unhandled', lineType, lineValues);\n }\n }\n // Store in-progress element\n if (currentElement) {\n header.elements.push(currentElement);\n }\n return header;\n}\n/** Generate attributes arrays from the header */\n// eslint-disable-next-line complexity\nfunction getPLYAttributes(header) {\n // TODO Generate only the attribute arrays actually in the header\n const attributes = {\n indices: [],\n vertices: [],\n normals: [],\n uvs: [],\n colors: []\n };\n for (const element of header.elements) {\n if (element.name === 'vertex') {\n for (const property of element.properties) {\n switch (property.name) {\n case 'x':\n case 'y':\n case 'z':\n case 'nx':\n case 'ny':\n case 'nz':\n case 's':\n case 't':\n case 'red':\n case 'green':\n case 'blue':\n break;\n default:\n // Add any non-geometry attributes\n attributes[property.name] = [];\n break;\n }\n }\n }\n }\n return attributes;\n}\n/**\n * @param propertyValues\n * @returns property of ply element\n */\nfunction makePLYElementProperty(propertyValues) {\n const type = propertyValues[0];\n switch (type) {\n case 'list':\n return {\n type,\n name: propertyValues[3],\n countType: propertyValues[1],\n itemType: propertyValues[2]\n };\n default:\n return {\n type,\n name: propertyValues[1]\n };\n }\n}\n/**\n * Parses ASCII number\n * @param n\n * @param type\n * @returns\n */\n// eslint-disable-next-line complexity\nfunction parseASCIINumber(n, type) {\n switch (type) {\n case 'char':\n case 'uchar':\n case 'short':\n case 'ushort':\n case 'int':\n case 'uint':\n case 'int8':\n case 'uint8':\n case 'int16':\n case 'uint16':\n case 'int32':\n case 'uint32':\n return parseInt(n, 10);\n case 'float':\n case 'double':\n case 'float32':\n case 'float64':\n return parseFloat(n);\n default:\n throw new Error(type);\n }\n}\n/**\n * @param properties\n * @param line\n * @returns ASCII element\n */\nfunction parsePLYElement(properties, line) {\n const values = line.split(/\\s+/);\n const element = {};\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n const n = parseASCIINumber(values.shift(), properties[i].countType);\n for (let j = 0; j < n; j++) {\n list.push(parseASCIINumber(values.shift(), properties[i].itemType));\n }\n element[properties[i].name] = list;\n }\n else {\n element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);\n }\n }\n return element;\n}\n/**\n * @param data\n * @param header\n * @returns [attributes]\n */\nfunction parseASCII(data, header) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n const attributes = getPLYAttributes(header);\n let result;\n const patternBody = /end_header\\s([\\s\\S]*)$/;\n let body = '';\n if ((result = patternBody.exec(data)) !== null) {\n body = result[1];\n }\n const lines = body.split('\\n');\n let currentElement = 0;\n let currentElementCount = 0;\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i];\n line = line.trim();\n if (line !== '') {\n if (currentElementCount >= header.elements[currentElement].count) {\n currentElement++;\n currentElementCount = 0;\n }\n const element = parsePLYElement(header.elements[currentElement].properties, line);\n handleElement(attributes, header.elements[currentElement].name, element);\n currentElementCount++;\n }\n }\n return attributes;\n}\n/**\n * @param buffer\n * @param elementName\n * @param element\n */\n// eslint-disable-next-line complexity\nfunction handleElement(buffer, elementName, element = {}) {\n if (elementName === 'vertex') {\n for (const propertyName of Object.keys(element)) {\n switch (propertyName) {\n case 'x':\n buffer.vertices.push(element.x, element.y, element.z);\n break;\n case 'y':\n case 'z':\n break;\n case 'nx':\n if ('nx' in element && 'ny' in element && 'nz' in element) {\n buffer.normals.push(element.nx, element.ny, element.nz);\n }\n break;\n case 'ny':\n case 'nz':\n break;\n case 's':\n if ('s' in element && 't' in element) {\n buffer.uvs.push(element.s, element.t);\n }\n break;\n case 't':\n break;\n case 'red':\n if ('red' in element && 'green' in element && 'blue' in element) {\n buffer.colors.push(element.red, element.green, element.blue);\n }\n break;\n case 'green':\n case 'blue':\n break;\n default:\n buffer[propertyName].push(element[propertyName]);\n }\n }\n }\n else if (elementName === 'face') {\n const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338\n if (vertexIndices.length === 3) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);\n }\n else if (vertexIndices.length === 4) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);\n buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);\n }\n }\n}\n/**\n * Reads binary data\n * @param dataview\n * @param at\n * @param type\n * @param littleEndian\n * @returns [number, number]\n */\n// eslint-disable-next-line complexity\nfunction binaryRead(dataview, at, type, littleEndian) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8':\n case 'char':\n return [dataview.getInt8(at), 1];\n case 'uint8':\n case 'uchar':\n return [dataview.getUint8(at), 1];\n case 'int16':\n case 'short':\n return [dataview.getInt16(at, littleEndian), 2];\n case 'uint16':\n case 'ushort':\n return [dataview.getUint16(at, littleEndian), 2];\n case 'int32':\n case 'int':\n return [dataview.getInt32(at, littleEndian), 4];\n case 'uint32':\n case 'uint':\n return [dataview.getUint32(at, littleEndian), 4];\n case 'float32':\n case 'float':\n return [dataview.getFloat32(at, littleEndian), 4];\n case 'float64':\n case 'double':\n return [dataview.getFloat64(at, littleEndian), 8];\n default:\n throw new Error(type);\n }\n}\n/**\n * Reads binary data\n * @param dataview\n * @param at\n * @param properties\n * @param littleEndian\n * @returns [object, number]\n */\nfunction binaryReadElement(dataview, at, properties, littleEndian) {\n const element = {};\n let result;\n let read = 0;\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n result = binaryRead(dataview, at + read, properties[i].countType, littleEndian);\n const n = result[0];\n read += result[1];\n for (let j = 0; j < n; j++) {\n result = binaryRead(dataview, at + read, properties[i].itemType, littleEndian);\n // @ts-ignore\n list.push(result[0]);\n read += result[1];\n }\n element[properties[i].name] = list;\n }\n else {\n result = binaryRead(dataview, at + read, properties[i].type, littleEndian);\n element[properties[i].name] = result[0];\n read += result[1];\n }\n }\n return [element, read];\n}\n/**\n * Parses binary data\n * @param data\n * @param header\n * @returns [attributes] of data\n */\nfunction parseBinary(data, header) {\n const attributes = getPLYAttributes(header);\n const littleEndian = header.format === 'binary_little_endian';\n const body = new DataView(data, header.headerLength);\n let result;\n let loc = 0;\n for (let currentElement = 0; currentElement < header.elements.length; currentElement++) {\n const count = header.elements[currentElement].count;\n for (let currentElementCount = 0; currentElementCount < count; currentElementCount++) {\n result = binaryReadElement(body, loc, header.elements[currentElement].properties, littleEndian);\n loc += result[1];\n const element = result[0];\n handleElement(attributes, header.elements[currentElement].name, element);\n }\n }\n return attributes;\n}\n", "// PLY Loader, adapted from THREE.js (MIT license)\n//\n// Attributions per original THREE.js source file:\n//\n// @author Wei Meng / http://about.me/menway\n//\n// Description: A loader for PLY ASCII files (known as the Polygon File Format\n// or the Stanford Triangle Format).\n//\n// Limitations: ASCII decoding assumes file is UTF-8.\n//\n// If the PLY file uses non standard property names, they can be mapped while\n// loading. For example, the following maps the properties\n// \u201Cdiffuse_(red|green|blue)\u201D in the file to standard color names.\n//\n// parsePLY(data, {\n// propertyNameMapping: {\n// diffuse_red: 'red',\n// diffuse_green: 'green',\n// diffuse_blue: 'blue'\n// }\n// });\nimport { makeLineIterator, makeTextDecoderIterator, forEach } from '@loaders.gl/loader-utils';\nimport normalizePLY from \"./normalize-ply.js\";\nlet currentElement;\n/**\n * PARSER\n * @param iterator\n * @param options\n */\nexport async function* parsePLYInBatches(iterator, options) {\n const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));\n const header = await parsePLYHeader(lineIterator, options);\n let attributes;\n switch (header.format) {\n case 'ascii':\n attributes = await parseASCII(lineIterator, header);\n break;\n default:\n throw new Error('Binary PLY can not yet be parsed in streaming mode');\n // attributes = await parseBinary(lineIterator, header);\n }\n yield normalizePLY(header, attributes, options);\n}\n/**\n * Parses header\n * @param lineIterator\n * @param options\n * @returns\n */\nasync function parsePLYHeader(lineIterator, options) {\n const header = {\n comments: [],\n elements: []\n // headerLength\n };\n // Note: forEach does not reset iterator if exiting loop prematurely\n // so that iteration can continue in a second loop\n await forEach(lineIterator, (line) => {\n line = line.trim();\n // End of header\n if (line === 'end_header') {\n return true; // Returning true cancels `forEach`\n }\n // Ignore empty lines\n if (line === '') {\n // eslint-disable-next-line\n return false; // Returning false does not cancel `forEach`\n }\n const lineValues = line.split(/\\s+/);\n const lineType = lineValues.shift();\n line = lineValues.join(' ');\n switch (lineType) {\n case 'ply':\n // First line magic characters, ignore\n break;\n case 'format':\n header.format = lineValues[0];\n header.version = lineValues[1];\n break;\n case 'comment':\n header.comments.push(line);\n break;\n case 'element':\n if (currentElement) {\n header.elements.push(currentElement);\n }\n currentElement = {\n name: lineValues[0],\n count: parseInt(lineValues[1], 10),\n properties: []\n };\n break;\n case 'property':\n const property = makePLYElementProperty(lineValues, options.propertyNameMapping);\n currentElement.properties.push(property);\n break;\n default:\n // eslint-disable-next-line\n console.log('unhandled', lineType, lineValues);\n }\n return false;\n });\n if (currentElement) {\n header.elements.push(currentElement);\n }\n return header;\n}\nfunction makePLYElementProperty(propertyValues, propertyNameMapping) {\n const type = propertyValues[0];\n switch (type) {\n case 'list':\n return {\n type,\n name: propertyValues[3],\n countType: propertyValues[1],\n itemType: propertyValues[2]\n };\n default:\n return {\n type,\n name: propertyValues[1]\n };\n }\n}\n// ASCII PARSING\n/**\n * @param lineIterator\n * @param header\n * @returns\n */\nasync function parseASCII(lineIterator, header) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n const attributes = {\n indices: [],\n vertices: [],\n normals: [],\n uvs: [],\n colors: []\n };\n let currentElement = 0;\n let currentElementCount = 0;\n for await (let line of lineIterator) {\n line = line.trim();\n if (line !== '') {\n if (currentElementCount >= header.elements[currentElement].count) {\n currentElement++;\n currentElementCount = 0;\n }\n const element = parsePLYElement(header.elements[currentElement].properties, line);\n handleElement(attributes, header.elements[currentElement].name, element);\n currentElementCount++;\n }\n }\n return attributes;\n}\n/**\n * Parses ASCII number\n * @param n\n * @param type\n * @returns ASCII number\n */\n// eslint-disable-next-line complexity\nfunction parseASCIINumber(n, type) {\n switch (type) {\n case 'char':\n case 'uchar':\n case 'short':\n case 'ushort':\n case 'int':\n case 'uint':\n case 'int8':\n case 'uint8':\n case 'int16':\n case 'uint16':\n case 'int32':\n case 'uint32':\n return parseInt(n, 10);\n case 'float':\n case 'double':\n case 'float32':\n case 'float64':\n return parseFloat(n);\n default:\n throw new Error(type);\n }\n}\n/**\n * Parses ASCII element\n * @param properties\n * @param line\n * @returns element\n */\nfunction parsePLYElement(properties, line) {\n const values = line.split(/\\s+/);\n const element = {};\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n const n = parseASCIINumber(values.shift(), properties[i].countType);\n for (let j = 0; j < n; j++) {\n list.push(parseASCIINumber(values.shift(), properties[i].itemType));\n }\n element[properties[i].name] = list;\n }\n else {\n element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);\n }\n }\n return element;\n}\n/**\n * @param buffer\n * @param elementName\n * @param element\n */\n// HELPER FUNCTIONS\n// eslint-disable-next-line complexity\nfunction handleElement(buffer, elementName, element = {}) {\n switch (elementName) {\n case 'vertex':\n buffer.vertices.push(element.x, element.y, element.z);\n if ('nx' in element && 'ny' in element && 'nz' in element) {\n buffer.normals.push(element.nx, element.ny, element.nz);\n }\n if ('s' in element && 't' in element) {\n buffer.uvs.push(element.s, element.t);\n }\n if ('red' in element && 'green' in element && 'blue' in element) {\n buffer.colors.push(element.red / 255.0, element.green / 255.0, element.blue / 255.0);\n }\n break;\n case 'face':\n const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338\n if (vertexIndices.length === 3) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);\n }\n else if (vertexIndices.length === 4) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);\n buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);\n }\n break;\n default:\n break;\n }\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { PLYLoader as PLYWorkerLoader } from \"./ply-loader.js\";\nimport { parsePLY } from \"./lib/parse-ply.js\";\nimport { parsePLYInBatches } from \"./lib/parse-ply-in-batches.js\";\nexport { PLYWorkerLoader };\n/**\n * Loader for PLY - Polygon File Format\n */\nexport const PLYLoader = {\n ...PLYWorkerLoader,\n // Note: parsePLY supports both text and binary\n parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?\n parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),\n parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),\n parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)\n};\n", "// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.3\" !== 'undefined' ? \"4.2.3\" : 'latest';\n/**\n * Worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'\n * links: ['http://paulbourke.net/dataformats/ply/',\n * 'https://en.wikipedia.org/wiki/PLY_(file_format)']\n */\nexport const PLYLoader = {\n dataType: null,\n batchType: null,\n name: 'PLY',\n id: 'ply',\n module: 'ply',\n // shapes: ['mesh', 'gltf', 'columnar-table'],\n version: VERSION,\n worker: true,\n extensions: ['ply'],\n mimeTypes: ['text/plain', 'application/octet-stream'],\n text: true,\n binary: true,\n tests: ['ply'],\n options: {\n ply: {}\n }\n};\n", "import { getMeshBoundingBox } from '@loaders.gl/schema';\nimport { getPLYSchema } from \"./get-ply-schema.js\";\n/**\n * @param header\n * @param attributes\n * @returns data and header\n */\nexport default function normalizePLY(plyHeader, plyAttributes, options) {\n const attributes = getMeshAttributes(plyAttributes);\n const boundingBox = getMeshBoundingBox(attributes);\n const vertexCount = plyAttributes.indices.length || plyAttributes.vertices.length / 3;\n // TODO - how to detect POINT CLOUDS vs MESHES?\n // TODO - For Meshes, PLY quadrangles must be split?\n const isTriangles = plyAttributes.indices && plyAttributes.indices.length > 0;\n const mode = isTriangles ? 4 : 0; // TRIANGLES vs POINTS\n const topology = isTriangles ? 'triangle-list' : 'point-list';\n const schema = getPLYSchema(plyHeader, attributes);\n const plyMesh = {\n loader: 'ply',\n loaderData: plyHeader,\n header: {\n vertexCount,\n boundingBox\n },\n schema,\n attributes,\n indices: { value: new Uint32Array(0), size: 0 },\n mode,\n topology\n };\n if (plyAttributes.indices.length > 0) {\n plyMesh.indices = { value: new Uint32Array(plyAttributes.indices), size: 1 };\n }\n return plyMesh;\n}\n/**\n * @param attributes\n * @returns accessors []\n */\n// eslint-disable-next-line complexity\nfunction getMeshAttributes(attributes) {\n const accessors = {};\n for (const attributeName of Object.keys(attributes)) {\n switch (attributeName) {\n case 'vertices':\n if (attributes.vertices.length > 0) {\n accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };\n }\n break;\n // optional attributes data\n case 'normals':\n if (attributes.normals.length > 0) {\n accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };\n }\n break;\n case 'uvs':\n if (attributes.uvs.length > 0) {\n accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };\n }\n break;\n case 'colors':\n if (attributes.colors.length > 0) {\n // TODO - normalized shoud be based on `uchar` flag in source data?\n accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };\n }\n break;\n case 'indices':\n break;\n default:\n if (attributes[attributeName].length > 0) {\n accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };\n }\n break;\n }\n }\n return accessors;\n}\n", "import { deduceMeshSchema } from '@loaders.gl/schema';\n/**\n * Gets schema from PLY header\n * @param plyHeader\n * @param metadata\n * @returns Schema\n */\nexport function getPLYSchema(plyHeader, attributes) {\n const metadata = makeMetadataFromPlyHeader(plyHeader);\n const schema = deduceMeshSchema(attributes, metadata);\n return schema;\n}\n/**\n * Make arrow like schema metadata by PlyHeader properties\n * @param plyHeader\n * @returns\n */\nfunction makeMetadataFromPlyHeader(plyHeader) {\n /* eslint-disable camelcase */\n const metadata = {};\n metadata.ply_comments = JSON.stringify(plyHeader.comments);\n metadata.ply_elements = JSON.stringify(plyHeader.elements);\n if (plyHeader.format !== undefined) {\n metadata.ply_format = plyHeader.format;\n }\n if (plyHeader.version !== undefined) {\n metadata.ply_version = plyHeader.version;\n }\n if (plyHeader.headerLength !== undefined) {\n metadata.ply_headerLength = plyHeader.headerLength.toString(10);\n }\n return metadata;\n}\n", "import normalizePLY from \"./normalize-ply.js\";\n/**\n * @param data\n * @param options\n * @returns\n */\nexport function parsePLY(data, options = {}) {\n let header;\n let attributes;\n if (data instanceof ArrayBuffer) {\n const text = new TextDecoder().decode(data);\n header = parseHeader(text, options);\n attributes = header.format === 'ascii' ? parseASCII(text, header) : parseBinary(data, header);\n }\n else {\n header = parseHeader(data, options);\n attributes = parseASCII(data, header);\n }\n return normalizePLY(header, attributes);\n}\n/**\n * @param data\n * @param options\n * @returns header\n */\nfunction parseHeader(data, options) {\n const PLY_HEADER_PATTERN = /ply([\\s\\S]*)end_header\\s/;\n let headerText = '';\n let headerLength = 0;\n const result = PLY_HEADER_PATTERN.exec(data);\n if (result !== null) {\n headerText = result[1];\n headerLength = result[0].length;\n }\n const lines = headerText.split('\\n');\n const header = parseHeaderLines(lines, headerLength, options);\n return header;\n}\n/**\n * @param lines\n * @param headerLength\n * @param options\n * @returns header\n */\n// eslint-disable-next-line complexity\nfunction parseHeaderLines(lines, headerLength, options) {\n const header = {\n comments: [],\n elements: [],\n headerLength\n };\n let lineType;\n let lineValues;\n let currentElement = null;\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i];\n line = line.trim();\n if (line === '') {\n // eslint-disable-next-line\n continue;\n }\n lineValues = line.split(/\\s+/);\n lineType = lineValues.shift();\n line = lineValues.join(' ');\n switch (lineType) {\n case 'format':\n header.format = lineValues[0];\n header.version = lineValues[1];\n break;\n case 'comment':\n header.comments.push(line);\n break;\n case 'element':\n // Start new element, store previous element\n if (currentElement) {\n header.elements.push(currentElement);\n }\n currentElement = {\n name: lineValues[0],\n count: parseInt(lineValues[1], 10),\n properties: []\n };\n break;\n case 'property':\n if (currentElement) {\n const property = makePLYElementProperty(lineValues);\n if (options?.propertyNameMapping && property.name in options?.propertyNameMapping) {\n property.name = options?.propertyNameMapping[property.name];\n }\n currentElement.properties.push(property);\n }\n break;\n default:\n // eslint-disable-next-line\n console.log('unhandled', lineType, lineValues);\n }\n }\n // Store in-progress element\n if (currentElement) {\n header.elements.push(currentElement);\n }\n return header;\n}\n/** Generate attributes arrays from the header */\n// eslint-disable-next-line complexity\nfunction getPLYAttributes(header) {\n // TODO Generate only the attribute arrays actually in the header\n const attributes = {\n indices: [],\n vertices: [],\n normals: [],\n uvs: [],\n colors: []\n };\n for (const element of header.elements) {\n if (element.name === 'vertex') {\n for (const property of element.properties) {\n switch (property.name) {\n case 'x':\n case 'y':\n case 'z':\n case 'nx':\n case 'ny':\n case 'nz':\n case 's':\n case 't':\n case 'red':\n case 'green':\n case 'blue':\n break;\n default:\n // Add any non-geometry attributes\n attributes[property.name] = [];\n break;\n }\n }\n }\n }\n return attributes;\n}\n/**\n * @param propertyValues\n * @returns property of ply element\n */\nfunction makePLYElementProperty(propertyValues) {\n const type = propertyValues[0];\n switch (type) {\n case 'list':\n return {\n type,\n name: propertyValues[3],\n countType: propertyValues[1],\n itemType: propertyValues[2]\n };\n default:\n return {\n type,\n name: propertyValues[1]\n };\n }\n}\n/**\n * Parses ASCII number\n * @param n\n * @param type\n * @returns\n */\n// eslint-disable-next-line complexity\nfunction parseASCIINumber(n, type) {\n switch (type) {\n case 'char':\n case 'uchar':\n case 'short':\n case 'ushort':\n case 'int':\n case 'uint':\n case 'int8':\n case 'uint8':\n case 'int16':\n case 'uint16':\n case 'int32':\n case 'uint32':\n return parseInt(n, 10);\n case 'float':\n case 'double':\n case 'float32':\n case 'float64':\n return parseFloat(n);\n default:\n throw new Error(type);\n }\n}\n/**\n * @param properties\n * @param line\n * @returns ASCII element\n */\nfunction parsePLYElement(properties, line) {\n const values = line.split(/\\s+/);\n const element = {};\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n const n = parseASCIINumber(values.shift(), properties[i].countType);\n for (let j = 0; j < n; j++) {\n list.push(parseASCIINumber(values.shift(), properties[i].itemType));\n }\n element[properties[i].name] = list;\n }\n else {\n element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);\n }\n }\n return element;\n}\n/**\n * @param data\n * @param header\n * @returns [attributes]\n */\nfunction parseASCII(data, header) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n const attributes = getPLYAttributes(header);\n let result;\n const patternBody = /end_header\\s([\\s\\S]*)$/;\n let body = '';\n if ((result = patternBody.exec(data)) !== null) {\n body = result[1];\n }\n const lines = body.split('\\n');\n let currentElement = 0;\n let currentElementCount = 0;\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i];\n line = line.trim();\n if (line !== '') {\n if (currentElementCount >= header.elements[currentElement].count) {\n currentElement++;\n currentElementCount = 0;\n }\n const element = parsePLYElement(header.elements[currentElement].properties, line);\n handleElement(attributes, header.elements[currentElement].name, element);\n currentElementCount++;\n }\n }\n return attributes;\n}\n/**\n * @param buffer\n * @param elementName\n * @param element\n */\n// eslint-disable-next-line complexity\nfunction handleElement(buffer, elementName, element = {}) {\n if (elementName === 'vertex') {\n for (const propertyName of Object.keys(element)) {\n switch (propertyName) {\n case 'x':\n buffer.vertices.push(element.x, element.y, element.z);\n break;\n case 'y':\n case 'z':\n break;\n case 'nx':\n if ('nx' in element && 'ny' in element && 'nz' in element) {\n buffer.normals.push(element.nx, element.ny, element.nz);\n }\n break;\n case 'ny':\n case 'nz':\n break;\n case 's':\n if ('s' in element && 't' in element) {\n buffer.uvs.push(element.s, element.t);\n }\n break;\n case 't':\n break;\n case 'red':\n if ('red' in element && 'green' in element && 'blue' in element) {\n buffer.colors.push(element.red, element.green, element.blue);\n }\n break;\n case 'green':\n case 'blue':\n break;\n default:\n buffer[propertyName].push(element[propertyName]);\n }\n }\n }\n else if (elementName === 'face') {\n const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338\n if (vertexIndices.length === 3) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);\n }\n else if (vertexIndices.length === 4) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);\n buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);\n }\n }\n}\n/**\n * Reads binary data\n * @param dataview\n * @param at\n * @param type\n * @param littleEndian\n * @returns [number, number]\n */\n// eslint-disable-next-line complexity\nfunction binaryRead(dataview, at, type, littleEndian) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8':\n case 'char':\n return [dataview.getInt8(at), 1];\n case 'uint8':\n case 'uchar':\n return [dataview.getUint8(at), 1];\n case 'int16':\n case 'short':\n return [dataview.getInt16(at, littleEndian), 2];\n case 'uint16':\n case 'ushort':\n return [dataview.getUint16(at, littleEndian), 2];\n case 'int32':\n case 'int':\n return [dataview.getInt32(at, littleEndian), 4];\n case 'uint32':\n case 'uint':\n return [dataview.getUint32(at, littleEndian), 4];\n case 'float32':\n case 'float':\n return [dataview.getFloat32(at, littleEndian), 4];\n case 'float64':\n case 'double':\n return [dataview.getFloat64(at, littleEndian), 8];\n default:\n throw new Error(type);\n }\n}\n/**\n * Reads binary data\n * @param dataview\n * @param at\n * @param properties\n * @param littleEndian\n * @returns [object, number]\n */\nfunction binaryReadElement(dataview, at, properties, littleEndian) {\n const element = {};\n let result;\n let read = 0;\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n result = binaryRead(dataview, at + read, properties[i].countType, littleEndian);\n const n = result[0];\n read += result[1];\n for (let j = 0; j < n; j++) {\n result = binaryRead(dataview, at + read, properties[i].itemType, littleEndian);\n // @ts-ignore\n list.push(result[0]);\n read += result[1];\n }\n element[properties[i].name] = list;\n }\n else {\n result = binaryRead(dataview, at + read, properties[i].type, littleEndian);\n element[properties[i].name] = result[0];\n read += result[1];\n }\n }\n return [element, read];\n}\n/**\n * Parses binary data\n * @param data\n * @param header\n * @returns [attributes] of data\n */\nfunction parseBinary(data, header) {\n const attributes = getPLYAttributes(header);\n const littleEndian = header.format === 'binary_little_endian';\n const body = new DataView(data, header.headerLength);\n let result;\n let loc = 0;\n for (let currentElement = 0; currentElement < header.elements.length; currentElement++) {\n const count = header.elements[currentElement].count;\n for (let currentElementCount = 0; currentElementCount < count; currentElementCount++) {\n result = binaryReadElement(body, loc, header.elements[currentElement].properties, littleEndian);\n loc += result[1];\n const element = result[0];\n handleElement(attributes, header.elements[currentElement].name, element);\n }\n }\n return attributes;\n}\n", "// PLY Loader, adapted from THREE.js (MIT license)\n//\n// Attributions per original THREE.js source file:\n//\n// @author Wei Meng / http://about.me/menway\n//\n// Description: A loader for PLY ASCII files (known as the Polygon File Format\n// or the Stanford Triangle Format).\n//\n// Limitations: ASCII decoding assumes file is UTF-8.\n//\n// If the PLY file uses non standard property names, they can be mapped while\n// loading. For example, the following maps the properties\n// \u201Cdiffuse_(red|green|blue)\u201D in the file to standard color names.\n//\n// parsePLY(data, {\n// propertyNameMapping: {\n// diffuse_red: 'red',\n// diffuse_green: 'green',\n// diffuse_blue: 'blue'\n// }\n// });\nimport { makeLineIterator, makeTextDecoderIterator, forEach } from '@loaders.gl/loader-utils';\nimport normalizePLY from \"./normalize-ply.js\";\nlet currentElement;\n/**\n * PARSER\n * @param iterator\n * @param options\n */\nexport async function* parsePLYInBatches(iterator, options) {\n const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));\n const header = await parsePLYHeader(lineIterator, options);\n let attributes;\n switch (header.format) {\n case 'ascii':\n attributes = await parseASCII(lineIterator, header);\n break;\n default:\n throw new Error('Binary PLY can not yet be parsed in streaming mode');\n // attributes = await parseBinary(lineIterator, header);\n }\n yield normalizePLY(header, attributes, options);\n}\n/**\n * Parses header\n * @param lineIterator\n * @param options\n * @returns\n */\nasync function parsePLYHeader(lineIterator, options) {\n const header = {\n comments: [],\n elements: []\n // headerLength\n };\n // Note: forEach does not reset iterator if exiting loop prematurely\n // so that iteration can continue in a second loop\n await forEach(lineIterator, (line) => {\n line = line.trim();\n // End of header\n if (line === 'end_header') {\n return true; // Returning true cancels `forEach`\n }\n // Ignore empty lines\n if (line === '') {\n // eslint-disable-next-line\n return false; // Returning false does not cancel `forEach`\n }\n const lineValues = line.split(/\\s+/);\n const lineType = lineValues.shift();\n line = lineValues.join(' ');\n switch (lineType) {\n case 'ply':\n // First line magic characters, ignore\n break;\n case 'format':\n header.format = lineValues[0];\n header.version = lineValues[1];\n break;\n case 'comment':\n header.comments.push(line);\n break;\n case 'element':\n if (currentElement) {\n header.elements.push(currentElement);\n }\n currentElement = {\n name: lineValues[0],\n count: parseInt(lineValues[1], 10),\n properties: []\n };\n break;\n case 'property':\n const property = makePLYElementProperty(lineValues, options.propertyNameMapping);\n currentElement.properties.push(property);\n break;\n default:\n // eslint-disable-next-line\n console.log('unhandled', lineType, lineValues);\n }\n return false;\n });\n if (currentElement) {\n header.elements.push(currentElement);\n }\n return header;\n}\nfunction makePLYElementProperty(propertyValues, propertyNameMapping) {\n const type = propertyValues[0];\n switch (type) {\n case 'list':\n return {\n type,\n name: propertyValues[3],\n countType: propertyValues[1],\n itemType: propertyValues[2]\n };\n default:\n return {\n type,\n name: propertyValues[1]\n };\n }\n}\n// ASCII PARSING\n/**\n * @param lineIterator\n * @param header\n * @returns\n */\nasync function parseASCII(lineIterator, header) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n const attributes = {\n indices: [],\n vertices: [],\n normals: [],\n uvs: [],\n colors: []\n };\n let currentElement = 0;\n let currentElementCount = 0;\n for await (let line of lineIterator) {\n line = line.trim();\n if (line !== '') {\n if (currentElementCount >= header.elements[currentElement].count) {\n currentElement++;\n currentElementCount = 0;\n }\n const element = parsePLYElement(header.elements[currentElement].properties, line);\n handleElement(attributes, header.elements[currentElement].name, element);\n currentElementCount++;\n }\n }\n return attributes;\n}\n/**\n * Parses ASCII number\n * @param n\n * @param type\n * @returns ASCII number\n */\n// eslint-disable-next-line complexity\nfunction parseASCIINumber(n, type) {\n switch (type) {\n case 'char':\n case 'uchar':\n case 'short':\n case 'ushort':\n case 'int':\n case 'uint':\n case 'int8':\n case 'uint8':\n case 'int16':\n case 'uint16':\n case 'int32':\n case 'uint32':\n return parseInt(n, 10);\n case 'float':\n case 'double':\n case 'float32':\n case 'float64':\n return parseFloat(n);\n default:\n throw new Error(type);\n }\n}\n/**\n * Parses ASCII element\n * @param properties\n * @param line\n * @returns element\n */\nfunction parsePLYElement(properties, line) {\n const values = line.split(/\\s+/);\n const element = {};\n for (let i = 0; i < properties.length; i++) {\n if (properties[i].type === 'list') {\n const list = [];\n const n = parseASCIINumber(values.shift(), properties[i].countType);\n for (let j = 0; j < n; j++) {\n list.push(parseASCIINumber(values.shift(), properties[i].itemType));\n }\n element[properties[i].name] = list;\n }\n else {\n element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);\n }\n }\n return element;\n}\n/**\n * @param buffer\n * @param elementName\n * @param element\n */\n// HELPER FUNCTIONS\n// eslint-disable-next-line complexity\nfunction handleElement(buffer, elementName, element = {}) {\n switch (elementName) {\n case 'vertex':\n buffer.vertices.push(element.x, element.y, element.z);\n if ('nx' in element && 'ny' in element && 'nz' in element) {\n buffer.normals.push(element.nx, element.ny, element.nz);\n }\n if ('s' in element && 't' in element) {\n buffer.uvs.push(element.s, element.t);\n }\n if ('red' in element && 'green' in element && 'blue' in element) {\n buffer.colors.push(element.red / 255.0, element.green / 255.0, element.blue / 255.0);\n }\n break;\n case 'face':\n const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338\n if (vertexIndices.length === 3) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);\n }\n else if (vertexIndices.length === 4) {\n buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);\n buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);\n }\n break;\n default:\n break;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACEA,IAAM,UAAU,OAAiC,UAAU;AAMpD,IAAM,YAAY;AAAA,EACrB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,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AAW,CAAC,aAAa,YAAY,SAAS,aAAa,mCAAS,GAAG;AAAA,EACvE,gBAAgB,CAAC,aAAa,YAAY,kBAAkB,aAAa,mCAAS,GAAG;AACzF;",
6
6
  "names": ["PLYLoader", "import_schema", "currentElement", "parseASCII", "makePLYElementProperty", "currentElement", "parsePLYElement", "handleElement", "parseASCIINumber", "PLYLoader"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  // __VERSION__ is injected by babel-plugin-version-inline
2
2
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
3
- const VERSION = typeof "4.2.2" !== 'undefined' ? "4.2.2" : 'latest';
3
+ const VERSION = typeof "4.2.3" !== 'undefined' ? "4.2.3" : 'latest';
4
4
  /**
5
5
  * Worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'
6
6
  * links: ['http://paulbourke.net/dataformats/ply/',
@@ -238,7 +238,7 @@
238
238
  }
239
239
 
240
240
  // src/ply-loader.ts
241
- var VERSION = true ? "4.2.2" : "latest";
241
+ var VERSION = true ? "4.2.3" : "latest";
242
242
  var PLYLoader = {
243
243
  dataType: null,
244
244
  batchType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/ply",
3
- "version": "4.2.3",
3
+ "version": "4.2.4",
4
4
  "description": "Framework-independent loader for the PLY format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,11 +42,11 @@
42
42
  "build-worker": "esbuild src/workers/ply-worker.ts --bundle --outfile=dist/ply-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
43
43
  },
44
44
  "dependencies": {
45
- "@loaders.gl/loader-utils": "4.2.3",
46
- "@loaders.gl/schema": "4.2.3"
45
+ "@loaders.gl/loader-utils": "4.2.4",
46
+ "@loaders.gl/schema": "4.2.4"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@loaders.gl/core": "^4.0.0"
50
50
  },
51
- "gitHead": "b81621afebc699faf74a4987d7859a587fe73a78"
51
+ "gitHead": "68ce51cb8ef8ca55a9cc66801e0aff504e925bb9"
52
52
  }