@loaders.gl/las 4.2.0-alpha.5 → 4.2.0-beta.1

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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
1
  import type { LASLoaderOptions } from "./las-loader.js";
3
2
  import type { LASMesh } from "./lib/las-types.js";
4
3
  import { LASLoader as LASWorkerLoader } from "./las-loader.js";
@@ -8,5 +7,28 @@ export { LASWorkerLoader };
8
7
  * Loader for the LAS (LASer) point cloud format
9
8
  * @note Does not support LAS v1.4
10
9
  */
11
- export declare const LASLoader: LoaderWithParser<LASMesh, never, LASLoaderOptions>;
10
+ export declare const LASLoader: {
11
+ readonly parse: (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) => Promise<LASMesh>;
12
+ readonly parseSync: (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) => LASMesh;
13
+ readonly dataType: LASMesh;
14
+ readonly batchType: never;
15
+ readonly name: "LAS";
16
+ readonly id: "las";
17
+ readonly module: "las";
18
+ readonly version: any;
19
+ readonly worker: true;
20
+ readonly extensions: ["las", "laz"];
21
+ readonly mimeTypes: ["application/octet-stream"];
22
+ readonly text: true;
23
+ readonly binary: true;
24
+ readonly tests: ["LAS"];
25
+ readonly options: {
26
+ readonly las: {
27
+ readonly shape: "mesh";
28
+ readonly fp64: false;
29
+ readonly skip: 1;
30
+ readonly colorDepth: 8;
31
+ };
32
+ };
33
+ };
12
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAC,gBAAgB,EAAC,wBAAqB;AACnD,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAC7C,OAAO,EAAC,SAAS,IAAI,eAAe,EAAC,wBAAqB;AAK1D,YAAY,EAAC,gBAAgB,EAAC,CAAC;AAC/B,OAAO,EAAC,eAAe,EAAC,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAMxE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAAC,wBAAqB;AACnD,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAC7C,OAAO,EAAC,SAAS,IAAI,eAAe,EAAC,wBAAqB;AAK1D,YAAY,EAAC,gBAAgB,EAAC,CAAC;AAC/B,OAAO,EAAC,eAAe,EAAC,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,SAAS;kCAEO,WAAW,YAAY,gBAAgB;sCAEzC,WAAW,YAAY,gBAAgB;;;;;;;;;;;;;;;;;;;;;CAEK,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  import type { LASMesh } from "./lib/las-types.js";
3
3
  export type LASLoaderOptions = LoaderOptions & {
4
4
  las?: {
@@ -6,6 +6,8 @@ export type LASLoaderOptions = LoaderOptions & {
6
6
  fp64?: boolean;
7
7
  skip?: number;
8
8
  colorDepth?: number | string;
9
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
10
+ workerUrl?: string;
9
11
  };
10
12
  onProgress?: Function;
11
13
  };
@@ -13,5 +15,26 @@ export type LASLoaderOptions = LoaderOptions & {
13
15
  * Loader for the LAS (LASer) point cloud format
14
16
  * @note Does not support LAS v1.4
15
17
  */
16
- export declare const LASLoader: Loader<LASMesh, never, LASLoaderOptions>;
18
+ export declare const LASLoader: {
19
+ readonly dataType: LASMesh;
20
+ readonly batchType: never;
21
+ readonly name: "LAS";
22
+ readonly id: "las";
23
+ readonly module: "las";
24
+ readonly version: any;
25
+ readonly worker: true;
26
+ readonly extensions: ["las", "laz"];
27
+ readonly mimeTypes: ["application/octet-stream"];
28
+ readonly text: true;
29
+ readonly binary: true;
30
+ readonly tests: ["LAS"];
31
+ readonly options: {
32
+ readonly las: {
33
+ readonly shape: "mesh";
34
+ readonly fp64: false;
35
+ readonly skip: 1;
36
+ readonly colorDepth: 8;
37
+ };
38
+ };
39
+ };
17
40
  //# sourceMappingURL=las-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"las-loader.d.ts","sourceRoot":"","sources":["../src/las-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAM7C,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,aAAa,CAAC;QAClD,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9B,CAAC;IACF,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAmB9D,CAAC"}
1
+ {"version":3,"file":"las-loader.d.ts","sourceRoot":"","sources":["../src/las-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAM7C,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,aAAa,CAAC;QAClD,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC7B,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;CAsBuC,CAAC"}
@@ -1,11 +1,13 @@
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.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
3
+ const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
4
4
  /**
5
5
  * Loader for the LAS (LASer) point cloud format
6
6
  * @note Does not support LAS v1.4
7
7
  */
8
8
  export const LASLoader = {
9
+ dataType: null,
10
+ batchType: null,
9
11
  name: 'LAS',
10
12
  id: 'las',
11
13
  module: 'las',
@@ -76,7 +76,9 @@
76
76
  }
77
77
  getParentPort().then((parentPort2) => {
78
78
  if (parentPort2) {
79
- parentPort2.on("message", handleMessage);
79
+ parentPort2.on("message", (message) => {
80
+ handleMessage(message);
81
+ });
80
82
  parentPort2.on("exit", () => console.debug("Node worker closing"));
81
83
  } else {
82
84
  globalThis.onmessage = handleMessage;
@@ -215,8 +217,10 @@
215
217
  }
216
218
 
217
219
  // src/las-loader.ts
218
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
220
+ var VERSION = true ? "4.2.0-alpha.6" : "latest";
219
221
  var LASLoader = {
222
+ dataType: null,
223
+ batchType: null,
220
224
  name: "LAS",
221
225
  id: "las",
222
226
  module: "las",
@@ -19012,22 +19016,23 @@
19012
19016
  return o;
19013
19017
  }
19014
19018
  var LASLoader2 = class {
19019
+ arraybuffer;
19020
+ readOffset = 0;
19021
+ header = {
19022
+ pointsOffset: 0,
19023
+ pointsFormatId: 0,
19024
+ pointsStructSize: 0,
19025
+ pointsCount: 0,
19026
+ scale: [0, 0, 0],
19027
+ offset: [0, 0, 0],
19028
+ maxs: [0],
19029
+ mins: [0],
19030
+ totalToRead: 0,
19031
+ totalRead: 0,
19032
+ versionAsString: "",
19033
+ isCompressed: true
19034
+ };
19015
19035
  constructor(arraybuffer) {
19016
- this.readOffset = 0;
19017
- this.header = {
19018
- pointsOffset: 0,
19019
- pointsFormatId: 0,
19020
- pointsStructSize: 0,
19021
- pointsCount: 0,
19022
- scale: [0, 0, 0],
19023
- offset: [0, 0, 0],
19024
- maxs: [0],
19025
- mins: [0],
19026
- totalToRead: 0,
19027
- totalRead: 0,
19028
- versionAsString: "",
19029
- isCompressed: true
19030
- };
19031
19036
  this.arraybuffer = arraybuffer;
19032
19037
  }
19033
19038
  /**
@@ -19099,10 +19104,11 @@
19099
19104
  }
19100
19105
  };
19101
19106
  var LAZLoader = class {
19107
+ arraybuffer;
19108
+ instance = null;
19109
+ // LASZip instance
19110
+ header = null;
19102
19111
  constructor(arraybuffer) {
19103
- this.instance = null;
19104
- // LASZip instance
19105
- this.header = null;
19106
19112
  this.arraybuffer = arraybuffer;
19107
19113
  if (!Module) {
19108
19114
  Module = getModule();
@@ -19172,6 +19178,7 @@
19172
19178
  }
19173
19179
  instance.readOffset++;
19174
19180
  }
19181
+ Module._free(bufRead);
19175
19182
  return {
19176
19183
  buffer: thisBuf.buffer,
19177
19184
  count: pointsRead,
@@ -19188,6 +19195,7 @@
19188
19195
  close() {
19189
19196
  try {
19190
19197
  if (this.instance !== null) {
19198
+ Module._free(this.instance.buf);
19191
19199
  this.instance.delete();
19192
19200
  this.instance = null;
19193
19201
  }
@@ -19198,6 +19206,14 @@
19198
19206
  }
19199
19207
  };
19200
19208
  var LASDecoder = class {
19209
+ arrayb;
19210
+ decoder;
19211
+ pointsCount;
19212
+ pointSize;
19213
+ scale;
19214
+ offset;
19215
+ mins;
19216
+ maxs;
19201
19217
  constructor(buffer, len, header) {
19202
19218
  this.arrayb = buffer;
19203
19219
  this.decoder = POINT_FORMAT_READERS[header.pointsFormatId];
@@ -19222,12 +19238,14 @@
19222
19238
  }
19223
19239
  };
19224
19240
  var LASFile = class {
19241
+ arraybuffer;
19242
+ formatId = 0;
19243
+ loader;
19244
+ isCompressed = true;
19245
+ isOpen = false;
19246
+ version = 0;
19247
+ versionAsString = "";
19225
19248
  constructor(arraybuffer) {
19226
- this.formatId = 0;
19227
- this.isCompressed = true;
19228
- this.isOpen = false;
19229
- this.version = 0;
19230
- this.versionAsString = "";
19231
19249
  this.arraybuffer = arraybuffer;
19232
19250
  if (this.determineVersion() > 13) {
19233
19251
  throw new Error("Only file versions <= 1.3 are supported at this time");
@@ -1 +1 @@
1
- {"version":3,"file":"laslaz-decoder.d.ts","sourceRoot":"","sources":["../../src/lib/laslaz-decoder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,SAAS,EAAC,uBAAoB;AAa3C,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AA0FF,cAAM,SAAS;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,CAAK;IACvB,MAAM,EAAE,SAAS,CAaf;gBAEU,WAAW,EAAE,WAAW;IAIpC;;OAEG;IACH,IAAI;IAIJ;;;OAGG;IACH,SAAS;IAKT;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;IA8CpC;;;OAGG;IACH,KAAK;CAKN;AAED;;;GAGG;AACH,cAAM,SAAS;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,GAAG,CAAQ;IACrB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAEpB,WAAW,EAAE,WAAW;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Loader {
83
+ arraybuffer;
84
+ readOffset = 0;
85
+ header = {
86
+ pointsOffset: 0,
87
+ pointsFormatId: 0,
88
+ pointsStructSize: 0,
89
+ pointsCount: 0,
90
+ scale: [0, 0, 0],
91
+ offset: [0, 0, 0],
92
+ maxs: [0],
93
+ mins: [0],
94
+ totalToRead: 0,
95
+ totalRead: 0,
96
+ versionAsString: '',
97
+ isCompressed: true
98
+ };
83
99
  constructor(arraybuffer) {
84
- this.readOffset = 0;
85
- this.header = {
86
- pointsOffset: 0,
87
- pointsFormatId: 0,
88
- pointsStructSize: 0,
89
- pointsCount: 0,
90
- scale: [0, 0, 0],
91
- offset: [0, 0, 0],
92
- maxs: [0],
93
- mins: [0],
94
- totalToRead: 0,
95
- totalRead: 0,
96
- versionAsString: '',
97
- isCompressed: true
98
- };
99
100
  this.arraybuffer = arraybuffer;
100
101
  }
101
102
  /**
@@ -173,9 +174,10 @@ class LASLoader {
173
174
  * Uses NaCL module to load LAZ files
174
175
  */
175
176
  class LAZLoader {
177
+ arraybuffer;
178
+ instance = null; // LASZip instance
179
+ header = null;
176
180
  constructor(arraybuffer) {
177
- this.instance = null; // LASZip instance
178
- this.header = null;
179
181
  this.arraybuffer = arraybuffer;
180
182
  if (!Module) {
181
183
  // Avoid executing laz-perf on import
@@ -246,6 +248,7 @@ class LAZLoader {
246
248
  }
247
249
  instance.readOffset++;
248
250
  }
251
+ Module._free(bufRead);
249
252
  return {
250
253
  buffer: thisBuf.buffer,
251
254
  count: pointsRead,
@@ -263,6 +266,7 @@ class LAZLoader {
263
266
  close() {
264
267
  try {
265
268
  if (this.instance !== null) {
269
+ Module._free(this.instance.buf);
266
270
  this.instance.delete();
267
271
  this.instance = null;
268
272
  }
@@ -277,6 +281,14 @@ class LAZLoader {
277
281
  * Helper class: Decodes LAS records into points
278
282
  */
279
283
  class LASDecoder {
284
+ arrayb;
285
+ decoder;
286
+ pointsCount;
287
+ pointSize;
288
+ scale;
289
+ offset;
290
+ mins;
291
+ maxs;
280
292
  constructor(buffer, len, header) {
281
293
  this.arrayb = buffer;
282
294
  this.decoder = POINT_FORMAT_READERS[header.pointsFormatId];
@@ -304,12 +316,14 @@ class LASDecoder {
304
316
  * A single consistent interface for loading LAS/LAZ files
305
317
  */
306
318
  export class LASFile {
319
+ arraybuffer;
320
+ formatId = 0;
321
+ loader;
322
+ isCompressed = true;
323
+ isOpen = false;
324
+ version = 0;
325
+ versionAsString = '';
307
326
  constructor(arraybuffer) {
308
- this.formatId = 0;
309
- this.isCompressed = true;
310
- this.isOpen = false;
311
- this.version = 0;
312
- this.versionAsString = '';
313
327
  this.arraybuffer = arraybuffer;
314
328
  if (this.determineVersion() > 13) {
315
329
  throw new Error('Only file versions <= 1.3 are supported at this time');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/las",
3
- "version": "4.2.0-alpha.5",
3
+ "version": "4.2.0-beta.1",
4
4
  "description": "Framework-independent loader for the LAS and LAZ formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "sideEffects": false,
34
34
  "browser": {
35
+ "crypto": false,
35
36
  "fs": false,
36
37
  "path": false,
37
- "ws": false,
38
- "crypto": false
38
+ "ws": false
39
39
  },
40
40
  "files": [
41
41
  "src",
@@ -49,12 +49,12 @@
49
49
  "build-worker": "esbuild src/workers/las-worker.ts --bundle --outfile=dist/las-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
50
50
  },
51
51
  "dependencies": {
52
- "@loaders.gl/loader-utils": "4.2.0-alpha.5",
53
- "@loaders.gl/schema": "4.2.0-alpha.5",
52
+ "@loaders.gl/loader-utils": "4.2.0-beta.1",
53
+ "@loaders.gl/schema": "4.2.0-beta.1",
54
54
  "laz-perf": "^0.0.6"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@loaders.gl/core": "^4.0.0"
58
58
  },
59
- "gitHead": "32d95a81971f104e4dfeb88ab57065f05321a76a"
59
+ "gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905"
60
60
  }
package/src/index.ts CHANGED
@@ -13,10 +13,10 @@ export {LASWorkerLoader};
13
13
  * Loader for the LAS (LASer) point cloud format
14
14
  * @note Does not support LAS v1.4
15
15
  */
16
- export const LASLoader: LoaderWithParser<LASMesh, never, LASLoaderOptions> = {
16
+ export const LASLoader = {
17
17
  ...LASWorkerLoader,
18
18
  parse: async (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) =>
19
19
  parseLAS(arrayBuffer, options),
20
20
  parseSync: (arrayBuffer: ArrayBuffer, options?: LASLoaderOptions) =>
21
21
  parseLAS(arrayBuffer, options)
22
- };
22
+ } as const satisfies LoaderWithParser<LASMesh, never, LASLoaderOptions>;
package/src/las-loader.ts CHANGED
@@ -12,6 +12,8 @@ export type LASLoaderOptions = LoaderOptions & {
12
12
  fp64?: boolean;
13
13
  skip?: number;
14
14
  colorDepth?: number | string;
15
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
16
+ workerUrl?: string;
15
17
  };
16
18
  onProgress?: Function;
17
19
  };
@@ -20,7 +22,10 @@ export type LASLoaderOptions = LoaderOptions & {
20
22
  * Loader for the LAS (LASer) point cloud format
21
23
  * @note Does not support LAS v1.4
22
24
  */
23
- export const LASLoader: Loader<LASMesh, never, LASLoaderOptions> = {
25
+ export const LASLoader = {
26
+ dataType: null as unknown as LASMesh,
27
+ batchType: null as never,
28
+
24
29
  name: 'LAS',
25
30
  id: 'las',
26
31
  module: 'las',
@@ -39,4 +44,4 @@ export const LASLoader: Loader<LASMesh, never, LASLoaderOptions> = {
39
44
  colorDepth: 8
40
45
  }
41
46
  }
42
- };
47
+ } as const satisfies Loader<LASMesh, never, LASLoaderOptions>;
@@ -305,7 +305,7 @@ class LAZLoader {
305
305
 
306
306
  instance.readOffset++;
307
307
  }
308
-
308
+ Module._free(bufRead);
309
309
  return {
310
310
  buffer: thisBuf.buffer,
311
311
  count: pointsRead,
@@ -323,6 +323,7 @@ class LAZLoader {
323
323
  close(): boolean {
324
324
  try {
325
325
  if (this.instance !== null) {
326
+ Module._free(this.instance.buf);
326
327
  this.instance.delete();
327
328
  this.instance = null;
328
329
  }