@loaders.gl/potree 4.3.1 → 4.4.0-alpha.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/dist.dev.js CHANGED
@@ -12,6 +12,7 @@ var __exports__ = (() => {
12
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
13
  var __getProtoOf = Object.getPrototypeOf;
14
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
16
  var __commonJS = (cb, mod) => function __require() {
16
17
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
18
  };
@@ -37,6 +38,10 @@ var __exports__ = (() => {
37
38
  mod
38
39
  ));
39
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => {
42
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
+ return value;
44
+ };
40
45
 
41
46
  // external-global-plugin:@loaders.gl/core
42
47
  var require_core = __commonJS({
@@ -203,6 +208,29 @@ var __exports__ = (() => {
203
208
  // src/lib/potree-node-source.ts
204
209
  var import_core = __toESM(require_core(), 1);
205
210
 
211
+ // ../loader-utils/src/lib/option-utils/merge-options.ts
212
+ function mergeOptions(baseOptions, newOptions) {
213
+ return mergeOptionsRecursively(baseOptions || {}, newOptions);
214
+ }
215
+ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
216
+ if (level > 3) {
217
+ return newOptions;
218
+ }
219
+ const options = { ...baseOptions };
220
+ for (const [key, newValue] of Object.entries(newOptions)) {
221
+ if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
222
+ options[key] = mergeOptionsRecursively(
223
+ options[key] || {},
224
+ newOptions[key],
225
+ level + 1
226
+ );
227
+ } else {
228
+ options[key] = newOptions[key];
229
+ }
230
+ }
231
+ return options;
232
+ }
233
+
206
234
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
207
235
  var pathPrefix = "";
208
236
  var fileAliases = {};
@@ -220,20 +248,29 @@ var __exports__ = (() => {
220
248
  }
221
249
 
222
250
  // ../loader-utils/src/lib/sources/data-source.ts
223
- var DataSource = class {
224
- /** A resolved fetch function extracted from loadOptions prop */
225
- fetch;
251
+ var _DataSource = class {
252
+ optionsType;
253
+ options;
254
+ data;
255
+ url;
226
256
  /** The actual load options, if calling a loaders.gl loader */
227
257
  loadOptions;
258
+ /** A resolved fetch function extracted from loadOptions prop */
259
+ fetch;
228
260
  _needsRefresh = true;
229
- props;
230
- constructor(props) {
231
- this.props = { ...props };
232
- this.loadOptions = { ...props.loadOptions };
261
+ constructor(data, options, defaultOptions) {
262
+ if (defaultOptions) {
263
+ this.options = mergeOptions({ ...defaultOptions, core: _DataSource.defaultOptions }, options);
264
+ } else {
265
+ this.options = { ...options };
266
+ }
267
+ this.data = data;
268
+ this.url = typeof data === "string" ? resolvePath(data) : "";
269
+ this.loadOptions = { ...this.options.core?.loadOptions };
233
270
  this.fetch = getFetchFunction(this.loadOptions);
234
271
  }
235
- setProps(props) {
236
- this.props = Object.assign(this.props, props);
272
+ setProps(options) {
273
+ this.options = Object.assign(this.options, options);
237
274
  this.setNeedsRefresh();
238
275
  }
239
276
  /** Mark this data source as needing a refresh (redraw) */
@@ -252,6 +289,15 @@ var __exports__ = (() => {
252
289
  return needsRefresh;
253
290
  }
254
291
  };
292
+ var DataSource = _DataSource;
293
+ __publicField(DataSource, "defaultOptions", {
294
+ core: {
295
+ type: "auto",
296
+ attributions: [],
297
+ loadOptions: {},
298
+ loaders: []
299
+ }
300
+ });
255
301
  function getFetchFunction(options) {
256
302
  const fetchFunction = options?.fetch;
257
303
  if (fetchFunction && typeof fetchFunction === "function") {
@@ -264,34 +310,21 @@ var __exports__ = (() => {
264
310
  return (url) => fetch(url);
265
311
  }
266
312
 
267
- // ../las/src/las-loader.ts
268
- var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
269
- var LASLoader = {
270
- dataType: null,
271
- batchType: null,
313
+ // ../las/src/las-format.ts
314
+ var LASFormat = {
272
315
  name: "LAS",
273
316
  id: "las",
274
317
  module: "las",
275
- version: VERSION3,
276
- worker: true,
277
318
  extensions: ["las", "laz"],
278
319
  // LAZ is the "compressed" flavor of LAS,
279
320
  mimeTypes: ["application/octet-stream"],
280
321
  // TODO - text version?
281
322
  text: true,
282
323
  binary: true,
283
- tests: ["LAS"],
284
- options: {
285
- las: {
286
- shape: "mesh",
287
- fp64: false,
288
- skip: 1,
289
- colorDepth: 8
290
- }
291
- }
324
+ tests: ["LAS"]
292
325
  };
293
326
 
294
- // ../schema/src/lib/table/simple-table/data-type.ts
327
+ // ../schema-utils/src/lib/schema/data-type.ts
295
328
  function getDataTypeFromTypedArray(array) {
296
329
  switch (array.constructor) {
297
330
  case Int8Array:
@@ -316,7 +349,7 @@ var __exports__ = (() => {
316
349
  }
317
350
  }
318
351
 
319
- // ../schema/src/lib/mesh/mesh-utils.ts
352
+ // ../schema-utils/src/lib/mesh/mesh-utils.ts
320
353
  function getMeshBoundingBox(attributes) {
321
354
  let minX = Infinity;
322
355
  let minY = Infinity;
@@ -343,7 +376,7 @@ var __exports__ = (() => {
343
376
  ];
344
377
  }
345
378
 
346
- // ../schema/src/lib/mesh/deduce-mesh-schema.ts
379
+ // ../schema-utils/src/lib/mesh/deduce-mesh-schema.ts
347
380
  function deduceMeshSchema(attributes, metadata = {}) {
348
381
  const fields = deduceMeshFields(attributes);
349
382
  return { fields, metadata };
@@ -19063,7 +19096,7 @@ var __exports__ = (() => {
19063
19096
  o.mins = [bounds[1], bounds[3], bounds[5]];
19064
19097
  return o;
19065
19098
  }
19066
- var LASLoader2 = class {
19099
+ var LASLoader = class {
19067
19100
  arraybuffer;
19068
19101
  readOffset = 0;
19069
19102
  header = {
@@ -19302,7 +19335,7 @@ var __exports__ = (() => {
19302
19335
  if (POINT_FORMAT_READERS[this.formatId] === void 0) {
19303
19336
  throw new Error("The point format ID is not supported");
19304
19337
  }
19305
- this.loader = this.isCompressed ? new LAZLoader(this.arraybuffer) : new LASLoader2(this.arraybuffer);
19338
+ this.loader = this.isCompressed ? new LAZLoader(this.arraybuffer) : new LASLoader(this.arraybuffer);
19306
19339
  }
19307
19340
  /**
19308
19341
  * Determines format in parameters of LASHeaer
@@ -19544,9 +19577,35 @@ var __exports__ = (() => {
19544
19577
  return twoByteColor;
19545
19578
  }
19546
19579
 
19547
- // ../las/src/index.ts
19548
- var LASLoader3 = {
19549
- ...LASLoader,
19580
+ // ../las/src/las-loader.ts
19581
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
19582
+ var LASWorkerLoader = {
19583
+ ...LASFormat,
19584
+ dataType: null,
19585
+ batchType: null,
19586
+ name: "LAS",
19587
+ id: "las",
19588
+ module: "las",
19589
+ version: VERSION3,
19590
+ worker: true,
19591
+ extensions: ["las", "laz"],
19592
+ // LAZ is the "compressed" flavor of LAS,
19593
+ mimeTypes: ["application/octet-stream"],
19594
+ // TODO - text version?
19595
+ text: true,
19596
+ binary: true,
19597
+ tests: ["LAS"],
19598
+ options: {
19599
+ las: {
19600
+ shape: "mesh",
19601
+ fp64: false,
19602
+ skip: 1,
19603
+ colorDepth: 8
19604
+ }
19605
+ }
19606
+ };
19607
+ var LASLoader2 = {
19608
+ ...LASWorkerLoader,
19550
19609
  parse: async (arrayBuffer, options) => parseLAS(arrayBuffer, options),
19551
19610
  parseSync: (arrayBuffer, options) => parseLAS(arrayBuffer, options)
19552
19611
  };
@@ -19561,10 +19620,6 @@ var __exports__ = (() => {
19561
19620
  var PotreeNodesSource = class extends DataSource {
19562
19621
  /** Dataset base URL */
19563
19622
  baseUrl = "";
19564
- /** Input data: string - dataset url, blob - single file data */
19565
- data;
19566
- /** Input props */
19567
- props;
19568
19623
  /** Meta information from `cloud.js` */
19569
19624
  metadata = null;
19570
19625
  /** Root node */
@@ -19576,12 +19631,10 @@ var __exports__ = (() => {
19576
19631
  * @constructor
19577
19632
  * @param data - if string - data set path url or path to `cloud.js` metadata file
19578
19633
  * - if Blob - single file data
19579
- * @param props - data source properties
19634
+ * @param options - data source properties
19580
19635
  */
19581
- constructor(data, props) {
19582
- super(props);
19583
- this.props = props;
19584
- this.data = data;
19636
+ constructor(data, options) {
19637
+ super(data, options);
19585
19638
  this.makeBaseUrl(this.data);
19586
19639
  this.initPromise = this.init();
19587
19640
  }
@@ -19630,7 +19683,7 @@ var __exports__ = (() => {
19630
19683
  `${this.baseUrl}/${this.metadata?.octreeDir}/r/r${path.join(
19631
19684
  ""
19632
19685
  )}.${this.getContentExtension()}`,
19633
- LASLoader3
19686
+ LASLoader2
19634
19687
  );
19635
19688
  }
19636
19689
  return null;
@@ -19696,12 +19749,15 @@ var __exports__ = (() => {
19696
19749
  version: VERSION4,
19697
19750
  extensions: ["bin", "las", "laz"],
19698
19751
  mimeTypes: ["application/octet-stream"],
19699
- options: { url: void 0, potree: {} },
19700
19752
  type: "potree",
19701
19753
  fromUrl: true,
19702
19754
  fromBlob: true,
19755
+ defaultOptions: {
19756
+ potree: {}
19757
+ },
19703
19758
  testURL: (url) => url.endsWith(".js"),
19704
- createDataSource: (url, props) => new PotreeNodesSource(url, props)
19759
+ createDataSource: (url, options) => new PotreeNodesSource(url, options)
19760
+ // , PotreeNodesSource.defaultOptions)
19705
19761
  };
19706
19762
  return __toCommonJS(bundle_exports);
19707
19763
  })();