maplibre-gl-lidar 0.3.2 → 0.5.0
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/{LidarLayerAdapter-Cefl4jQL.js → LidarLayerAdapter-ZG9A0pFN.js} +109 -20
- package/dist/{LidarLayerAdapter-Cefl4jQL.js.map → LidarLayerAdapter-ZG9A0pFN.js.map} +1 -1
- package/dist/{LidarLayerAdapter-BFhI93Is.cjs → LidarLayerAdapter-zXSROe7Q.cjs} +109 -20
- package/dist/{LidarLayerAdapter-BFhI93Is.cjs.map → LidarLayerAdapter-zXSROe7Q.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +3 -3
- package/dist/react.mjs.map +1 -1
- package/dist/types/lib/adapters/LidarLayerAdapter.d.ts.map +1 -1
- package/dist/types/lib/core/LidarControl.d.ts.map +1 -1
- package/dist/types/lib/core/LidarControlReact.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +13 -1
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/dist/types/lib/gui/PanelBuilder.d.ts.map +1 -1
- package/dist/types/lib/gui/RangeSlider.d.ts +7 -0
- package/dist/types/lib/gui/RangeSlider.d.ts.map +1 -1
- package/dist/types/lib/layers/PointCloudManager.d.ts +2 -1
- package/dist/types/lib/layers/PointCloudManager.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -35461,11 +35461,17 @@ class PointCloudManager {
|
|
|
35461
35461
|
this.updateStyle({ pointSize: size });
|
|
35462
35462
|
}
|
|
35463
35463
|
/**
|
|
35464
|
-
* Sets the opacity.
|
|
35464
|
+
* Sets the global opacity for all point clouds.
|
|
35465
|
+
* This also clears any per-layer opacity overrides so the global value takes effect.
|
|
35465
35466
|
*
|
|
35466
35467
|
* @param opacity - Opacity value (0-1)
|
|
35467
35468
|
*/
|
|
35468
35469
|
setOpacity(opacity) {
|
|
35470
|
+
for (const [id, pc] of this._pointClouds) {
|
|
35471
|
+
if (pc.opacityOverride !== null) {
|
|
35472
|
+
this._pointClouds.set(id, { ...pc, opacityOverride: null });
|
|
35473
|
+
}
|
|
35474
|
+
}
|
|
35469
35475
|
this.updateStyle({ opacity });
|
|
35470
35476
|
}
|
|
35471
35477
|
/**
|
|
@@ -36040,6 +36046,20 @@ class RangeSlider {
|
|
|
36040
36046
|
this._slider.disabled = !enabled;
|
|
36041
36047
|
}
|
|
36042
36048
|
}
|
|
36049
|
+
/**
|
|
36050
|
+
* Sets the slider min and max bounds.
|
|
36051
|
+
*
|
|
36052
|
+
* @param min - New minimum value
|
|
36053
|
+
* @param max - New maximum value
|
|
36054
|
+
*/
|
|
36055
|
+
setBounds(min, max) {
|
|
36056
|
+
this._options.min = min;
|
|
36057
|
+
this._options.max = max;
|
|
36058
|
+
if (this._slider) {
|
|
36059
|
+
this._slider.min = String(min);
|
|
36060
|
+
this._slider.max = String(max);
|
|
36061
|
+
}
|
|
36062
|
+
}
|
|
36043
36063
|
/**
|
|
36044
36064
|
* Formats the value for display.
|
|
36045
36065
|
*/
|
|
@@ -36484,6 +36504,12 @@ class PanelBuilder {
|
|
|
36484
36504
|
this._zOffsetSliderContainer.style.display = state.zOffsetEnabled ? "block" : "none";
|
|
36485
36505
|
}
|
|
36486
36506
|
if (this._zOffsetSlider) {
|
|
36507
|
+
if (state.zOffsetBase !== void 0) {
|
|
36508
|
+
const defaultOffset = -state.zOffsetBase;
|
|
36509
|
+
const sliderMin = defaultOffset - 100;
|
|
36510
|
+
const sliderMax = defaultOffset + 100;
|
|
36511
|
+
this._zOffsetSlider.setBounds(sliderMin, sliderMax);
|
|
36512
|
+
}
|
|
36487
36513
|
this._zOffsetSlider.setValue(state.zOffset ?? 0);
|
|
36488
36514
|
}
|
|
36489
36515
|
if (this._elevationSlider && state.pointClouds.length > 0) {
|
|
@@ -36715,15 +36741,16 @@ class PanelBuilder {
|
|
|
36715
36741
|
sliderContainer.style.display = this._state.zOffsetEnabled ? "block" : "none";
|
|
36716
36742
|
sliderContainer.style.marginTop = "8px";
|
|
36717
36743
|
this._zOffsetSliderContainer = sliderContainer;
|
|
36718
|
-
const
|
|
36719
|
-
const
|
|
36720
|
-
const
|
|
36744
|
+
const zOffsetBase = this._state.zOffsetBase ?? 0;
|
|
36745
|
+
const defaultOffset = -zOffsetBase;
|
|
36746
|
+
const sliderMin = defaultOffset - 100;
|
|
36747
|
+
const sliderMax = defaultOffset + 100;
|
|
36721
36748
|
this._zOffsetSlider = new RangeSlider({
|
|
36722
36749
|
label: "Offset (m)",
|
|
36723
|
-
min:
|
|
36724
|
-
max:
|
|
36750
|
+
min: sliderMin,
|
|
36751
|
+
max: sliderMax,
|
|
36725
36752
|
step: 1,
|
|
36726
|
-
value: this._state.zOffset ??
|
|
36753
|
+
value: this._state.zOffset ?? defaultOffset,
|
|
36727
36754
|
onChange: (v) => this._callbacks.onZOffsetChange(v)
|
|
36728
36755
|
});
|
|
36729
36756
|
sliderContainer.appendChild(this._zOffsetSlider.render());
|
|
@@ -36968,6 +36995,8 @@ const DEFAULT_OPTIONS = {
|
|
|
36968
36995
|
// Show all fields by default
|
|
36969
36996
|
zOffsetEnabled: false,
|
|
36970
36997
|
zOffset: 0,
|
|
36998
|
+
autoZOffset: true,
|
|
36999
|
+
// Automatically calculate Z offset from 2nd percentile
|
|
36971
37000
|
copcLoadingMode: void 0,
|
|
36972
37001
|
// Auto-detect: 'dynamic' for COPC URLs, 'full' otherwise
|
|
36973
37002
|
streamingPointBudget: 5e6,
|
|
@@ -37202,7 +37231,7 @@ class LidarControl {
|
|
|
37202
37231
|
* @returns Promise resolving to the point cloud info
|
|
37203
37232
|
*/
|
|
37204
37233
|
async loadPointCloud(source, options) {
|
|
37205
|
-
var _a, _b;
|
|
37234
|
+
var _a, _b, _c;
|
|
37206
37235
|
const isCopcUrl = typeof source === "string" && (source.startsWith("http://") || source.startsWith("https://")) && /\.copc\./i.test(source);
|
|
37207
37236
|
const isCopcFile = source instanceof File && /\.copc\./i.test(source.name);
|
|
37208
37237
|
const isCopc = isCopcUrl || isCopcFile;
|
|
@@ -37229,6 +37258,23 @@ class LidarControl {
|
|
|
37229
37258
|
const data = await this._loader.load(source, onProgress);
|
|
37230
37259
|
onProgress(95, "Creating visualization layers...");
|
|
37231
37260
|
(_a = this._pointCloudManager) == null ? void 0 : _a.addPointCloud(id, data);
|
|
37261
|
+
let zOffsetBase;
|
|
37262
|
+
let zOffset;
|
|
37263
|
+
let zOffsetEnabled = this._state.zOffsetEnabled;
|
|
37264
|
+
if (this._options.autoZOffset && data.positions && data.pointCount > 0) {
|
|
37265
|
+
const zValues = new Float32Array(data.pointCount);
|
|
37266
|
+
for (let i = 0; i < data.pointCount; i++) {
|
|
37267
|
+
zValues[i] = data.positions[i * 3 + 2] ?? 0;
|
|
37268
|
+
}
|
|
37269
|
+
const percentileBounds = computePercentileBounds(zValues, 2, 98);
|
|
37270
|
+
zOffsetBase = percentileBounds.min;
|
|
37271
|
+
zOffset = -zOffsetBase;
|
|
37272
|
+
zOffsetEnabled = true;
|
|
37273
|
+
(_b = this._pointCloudManager) == null ? void 0 : _b.setZOffset(zOffset);
|
|
37274
|
+
console.log(`Auto Z offset applied: zOffsetBase=${zOffsetBase.toFixed(1)}, zOffset=${zOffset.toFixed(1)}, enabled=${zOffsetEnabled}`);
|
|
37275
|
+
} else {
|
|
37276
|
+
console.log("Auto Z offset skipped - conditions not met");
|
|
37277
|
+
}
|
|
37232
37278
|
onProgress(100, "Complete!");
|
|
37233
37279
|
const info2 = {
|
|
37234
37280
|
id,
|
|
@@ -37251,7 +37297,10 @@ class LidarControl {
|
|
|
37251
37297
|
loading: false,
|
|
37252
37298
|
pointClouds,
|
|
37253
37299
|
activePointCloudId: id,
|
|
37254
|
-
availableClassifications: mergedClassifications
|
|
37300
|
+
availableClassifications: mergedClassifications,
|
|
37301
|
+
zOffsetBase,
|
|
37302
|
+
zOffset: zOffset ?? this._state.zOffset,
|
|
37303
|
+
zOffsetEnabled
|
|
37255
37304
|
});
|
|
37256
37305
|
this._emitWithData("load", { pointCloud: info2 });
|
|
37257
37306
|
if (this._options.autoZoom) {
|
|
@@ -37266,7 +37315,7 @@ class LidarControl {
|
|
|
37266
37315
|
console.warn(
|
|
37267
37316
|
`CORS error detected for ${source}. Falling back to download mode...`
|
|
37268
37317
|
);
|
|
37269
|
-
(
|
|
37318
|
+
(_c = this._panelBuilder) == null ? void 0 : _c.updateLoadingProgress(5, "CORS blocked - downloading file...");
|
|
37270
37319
|
return this._loadPointCloudFullDownload(source);
|
|
37271
37320
|
}
|
|
37272
37321
|
this.setState({
|
|
@@ -37298,8 +37347,9 @@ class LidarControl {
|
|
|
37298
37347
|
hiddenClassifications: /* @__PURE__ */ new Set()
|
|
37299
37348
|
};
|
|
37300
37349
|
this.setState(stateUpdate);
|
|
37301
|
-
this.
|
|
37350
|
+
this._emitWithData("unload", { pointCloud: { id } });
|
|
37302
37351
|
} else {
|
|
37352
|
+
const allIds = this._state.pointClouds.map((pc) => pc.id);
|
|
37303
37353
|
this.stopStreaming();
|
|
37304
37354
|
(_c = this._pointCloudManager) == null ? void 0 : _c.clear();
|
|
37305
37355
|
this.setState({
|
|
@@ -37308,7 +37358,9 @@ class LidarControl {
|
|
|
37308
37358
|
availableClassifications: /* @__PURE__ */ new Set(),
|
|
37309
37359
|
hiddenClassifications: /* @__PURE__ */ new Set()
|
|
37310
37360
|
});
|
|
37311
|
-
|
|
37361
|
+
for (const removedId of allIds) {
|
|
37362
|
+
this._emitWithData("unload", { pointCloud: { id: removedId } });
|
|
37363
|
+
}
|
|
37312
37364
|
}
|
|
37313
37365
|
}
|
|
37314
37366
|
/**
|
|
@@ -37345,9 +37397,22 @@ class LidarControl {
|
|
|
37345
37397
|
(_a = this._panelBuilder) == null ? void 0 : _a.updateLoadingProgress(10, "Initializing COPC file...");
|
|
37346
37398
|
const { bounds: bounds2, totalPoints, hasRGB, spacing } = await streamingLoader.initialize();
|
|
37347
37399
|
(_b = this._panelBuilder) == null ? void 0 : _b.updateLoadingProgress(20, "Setting up streaming...");
|
|
37400
|
+
let autoZOffsetApplied = false;
|
|
37348
37401
|
streamingLoader.setOnPointsLoaded((data) => {
|
|
37349
|
-
var _a2;
|
|
37402
|
+
var _a2, _b2;
|
|
37350
37403
|
(_a2 = this._pointCloudManager) == null ? void 0 : _a2.updatePointCloud(id, data);
|
|
37404
|
+
if (this._options.autoZOffset && !autoZOffsetApplied && data.bounds) {
|
|
37405
|
+
const zOffsetBase = data.bounds.minZ;
|
|
37406
|
+
const zOffset = -zOffsetBase;
|
|
37407
|
+
(_b2 = this._pointCloudManager) == null ? void 0 : _b2.setZOffset(zOffset);
|
|
37408
|
+
console.log(`Auto Z offset applied (streaming): ${zOffset.toFixed(1)}m (ground level from bounds: ${zOffsetBase.toFixed(1)}m)`);
|
|
37409
|
+
this.setState({
|
|
37410
|
+
zOffsetBase,
|
|
37411
|
+
zOffset,
|
|
37412
|
+
zOffsetEnabled: true
|
|
37413
|
+
});
|
|
37414
|
+
autoZOffsetApplied = true;
|
|
37415
|
+
}
|
|
37351
37416
|
const newClassifications = getAvailableClassifications(data);
|
|
37352
37417
|
if (newClassifications.size > 0) {
|
|
37353
37418
|
const mergedClassifications = /* @__PURE__ */ new Set([
|
|
@@ -37471,7 +37536,7 @@ class LidarControl {
|
|
|
37471
37536
|
* Used as fallback when streaming fails due to CORS.
|
|
37472
37537
|
*/
|
|
37473
37538
|
async _loadPointCloudFullDownload(url) {
|
|
37474
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
37539
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37475
37540
|
const id = generateId("pc");
|
|
37476
37541
|
const name = getFilename(url);
|
|
37477
37542
|
try {
|
|
@@ -37516,7 +37581,22 @@ class LidarControl {
|
|
|
37516
37581
|
const data = await this._loader.load(buffer.buffer, onProgress);
|
|
37517
37582
|
(_e = this._panelBuilder) == null ? void 0 : _e.updateLoadingProgress(95, "Creating visualization layers...");
|
|
37518
37583
|
(_f = this._pointCloudManager) == null ? void 0 : _f.addPointCloud(id, data);
|
|
37519
|
-
|
|
37584
|
+
let zOffsetBase;
|
|
37585
|
+
let zOffset;
|
|
37586
|
+
let zOffsetEnabled = this._state.zOffsetEnabled;
|
|
37587
|
+
if (this._options.autoZOffset && data.positions && data.pointCount > 0) {
|
|
37588
|
+
const zValues = new Float32Array(data.pointCount);
|
|
37589
|
+
for (let i = 0; i < data.pointCount; i++) {
|
|
37590
|
+
zValues[i] = data.positions[i * 3 + 2] ?? 0;
|
|
37591
|
+
}
|
|
37592
|
+
const percentileBounds = computePercentileBounds(zValues, 2, 98);
|
|
37593
|
+
zOffsetBase = percentileBounds.min;
|
|
37594
|
+
zOffset = -zOffsetBase;
|
|
37595
|
+
zOffsetEnabled = true;
|
|
37596
|
+
(_g = this._pointCloudManager) == null ? void 0 : _g.setZOffset(zOffset);
|
|
37597
|
+
console.log(`Auto Z offset applied (download): ${zOffset.toFixed(1)}m (ground level: ${zOffsetBase.toFixed(1)}m)`);
|
|
37598
|
+
}
|
|
37599
|
+
(_h = this._panelBuilder) == null ? void 0 : _h.updateLoadingProgress(100, "Complete!");
|
|
37520
37600
|
const info2 = {
|
|
37521
37601
|
id,
|
|
37522
37602
|
name,
|
|
@@ -37538,7 +37618,10 @@ class LidarControl {
|
|
|
37538
37618
|
loading: false,
|
|
37539
37619
|
pointClouds,
|
|
37540
37620
|
activePointCloudId: id,
|
|
37541
|
-
availableClassifications: mergedClassifications
|
|
37621
|
+
availableClassifications: mergedClassifications,
|
|
37622
|
+
zOffsetBase,
|
|
37623
|
+
zOffset: zOffset ?? this._state.zOffset,
|
|
37624
|
+
zOffsetEnabled
|
|
37542
37625
|
});
|
|
37543
37626
|
this._emitWithData("load", { pointCloud: info2 });
|
|
37544
37627
|
if (this._options.autoZoom) {
|
|
@@ -37613,7 +37696,7 @@ class LidarControl {
|
|
|
37613
37696
|
hiddenClassifications: /* @__PURE__ */ new Set()
|
|
37614
37697
|
});
|
|
37615
37698
|
this._emit("streamingstop");
|
|
37616
|
-
this.
|
|
37699
|
+
this._emitWithData("unload", { pointCloud: { id } });
|
|
37617
37700
|
} else {
|
|
37618
37701
|
const streamingIds = Array.from(this._streamingLoaders.keys());
|
|
37619
37702
|
for (const viewportManager of this._viewportManagers.values()) {
|
|
@@ -37640,7 +37723,9 @@ class LidarControl {
|
|
|
37640
37723
|
});
|
|
37641
37724
|
if (streamingIds.length > 0) {
|
|
37642
37725
|
this._emit("streamingstop");
|
|
37643
|
-
|
|
37726
|
+
for (const removedId of streamingIds) {
|
|
37727
|
+
this._emitWithData("unload", { pointCloud: { id: removedId } });
|
|
37728
|
+
}
|
|
37644
37729
|
}
|
|
37645
37730
|
}
|
|
37646
37731
|
}
|
|
@@ -38295,7 +38380,11 @@ class LidarLayerAdapter {
|
|
|
38295
38380
|
this._notifyLayerAdded(event.pointCloud.id);
|
|
38296
38381
|
}
|
|
38297
38382
|
};
|
|
38298
|
-
const handleUnload = () => {
|
|
38383
|
+
const handleUnload = (event) => {
|
|
38384
|
+
var _a;
|
|
38385
|
+
if ((_a = event.pointCloud) == null ? void 0 : _a.id) {
|
|
38386
|
+
this.notifyLayerRemoved(event.pointCloud.id);
|
|
38387
|
+
}
|
|
38299
38388
|
};
|
|
38300
38389
|
this._lidarControl.on("load", handleLoad);
|
|
38301
38390
|
this._lidarControl.on("unload", handleUnload);
|
|
@@ -38436,4 +38525,4 @@ export {
|
|
|
38436
38525
|
getFilename as l,
|
|
38437
38526
|
throttle as t
|
|
38438
38527
|
};
|
|
38439
|
-
//# sourceMappingURL=LidarLayerAdapter-
|
|
38528
|
+
//# sourceMappingURL=LidarLayerAdapter-ZG9A0pFN.js.map
|