@d5techs/3dgs-lib 1.4.83 → 1.4.84

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/3dgs-lib.cjs CHANGED
@@ -17568,186 +17568,31 @@ class EyedropperSelection {
17568
17568
  }
17569
17569
  }
17570
17570
  class SphereSelection {
17571
- constructor(parent, callbacks) {
17572
- __publicField(this, "parent");
17573
- __publicField(this, "toolbar");
17574
- __publicField(this, "callbacks");
17571
+ constructor(onRadiusChanged) {
17575
17572
  __publicField(this, "_radius", 1);
17576
- __publicField(this, "radiusInput");
17577
- this.parent = parent;
17578
- this.callbacks = callbacks;
17579
- this.toolbar = document.createElement("div");
17580
- this.toolbar.className = "volume-select-toolbar";
17581
- this.toolbar.style.cssText = `
17582
- position:absolute; bottom:90px; left:50%; transform:translateX(-50%);
17583
- display:none; z-index:20; background:rgba(30,30,30,0.92);
17584
- border-radius:8px; padding:6px 10px; gap:6px;
17585
- align-items:center; font-size:13px; color:#ddd;
17586
- backdrop-filter:blur(6px); user-select:none; white-space:nowrap;
17587
- box-shadow:0 2px 12px rgba(0,0,0,0.4);
17588
- `;
17589
- this.toolbar.addEventListener("pointerdown", (e) => e.stopPropagation());
17590
- this.toolbar.addEventListener("wheel", (e) => e.stopPropagation());
17591
- const mkBtn = (label2, op) => {
17592
- const btn = document.createElement("button");
17593
- btn.textContent = label2;
17594
- btn.style.cssText = `
17595
- padding:4px 12px; border:1px solid #555; border-radius:4px;
17596
- background:#333; color:#ddd; cursor:pointer; font-size:13px;
17597
- transition: background 0.15s;
17598
- `;
17599
- btn.addEventListener("mouseenter", () => {
17600
- btn.style.background = "#555";
17601
- });
17602
- btn.addEventListener("mouseleave", () => {
17603
- btn.style.background = "#333";
17604
- });
17605
- btn.addEventListener("pointerdown", (e) => {
17606
- e.stopPropagation();
17607
- this.callbacks.onApply(op);
17608
- });
17609
- return btn;
17610
- };
17611
- const setBtn = mkBtn("Set", "set");
17612
- const addBtn = mkBtn("Add", "add");
17613
- const removeBtn = mkBtn("Remove", "remove");
17614
- const inputWrap = document.createElement("span");
17615
- inputWrap.style.cssText = "display:inline-flex; align-items:center; gap:2px;";
17616
- const input = document.createElement("input");
17617
- input.type = "number";
17618
- input.min = "1";
17619
- input.step = "1";
17620
- input.value = String(this._radius);
17621
- input.style.cssText = `
17622
- width:40px; padding:3px 4px; border:1px solid #555; border-radius:4px;
17623
- background:#222; color:#ddd; font-size:12px; text-align:center;
17624
- `;
17625
- const label = document.createElement("span");
17626
- label.textContent = "Radius";
17627
- label.style.cssText = "color:#888; font-size:11px;";
17628
- input.addEventListener("change", () => {
17629
- const v = Math.max(1, Math.round(parseFloat(input.value) || 1));
17630
- input.value = String(v);
17631
- this._radius = v;
17632
- this.callbacks.onRadiusChanged(v);
17633
- });
17634
- inputWrap.appendChild(input);
17635
- inputWrap.appendChild(label);
17636
- this.radiusInput = input;
17637
- this.toolbar.appendChild(setBtn);
17638
- this.toolbar.appendChild(addBtn);
17639
- this.toolbar.appendChild(removeBtn);
17640
- this.toolbar.appendChild(inputWrap);
17641
- parent.appendChild(this.toolbar);
17573
+ __publicField(this, "_onRadiusChanged");
17574
+ this._onRadiusChanged = onRadiusChanged;
17642
17575
  }
17643
17576
  get radius() {
17644
17577
  return this._radius;
17645
17578
  }
17646
17579
  setRadius(radius) {
17647
- this._radius = Math.round(radius);
17648
- this.radiusInput.value = String(this._radius);
17580
+ var _a2;
17581
+ this._radius = radius;
17582
+ (_a2 = this._onRadiusChanged) == null ? void 0 : _a2.call(this, radius);
17649
17583
  }
17650
17584
  activate() {
17651
- this.toolbar.style.display = "flex";
17652
17585
  }
17653
17586
  deactivate() {
17654
- this.toolbar.style.display = "none";
17655
17587
  }
17656
17588
  }
17657
17589
  class BoxSelection {
17658
- constructor(parent, callbacks) {
17659
- __publicField(this, "parent");
17660
- __publicField(this, "toolbar");
17661
- __publicField(this, "callbacks");
17590
+ constructor(onDimensionsChanged) {
17662
17591
  __publicField(this, "_lenX", 2);
17663
17592
  __publicField(this, "_lenY", 2);
17664
17593
  __publicField(this, "_lenZ", 2);
17665
- __publicField(this, "inputX");
17666
- __publicField(this, "inputY");
17667
- __publicField(this, "inputZ");
17668
- this.parent = parent;
17669
- this.callbacks = callbacks;
17670
- this.toolbar = document.createElement("div");
17671
- this.toolbar.className = "volume-select-toolbar";
17672
- this.toolbar.style.cssText = `
17673
- position:absolute; bottom:90px; left:50%; transform:translateX(-50%);
17674
- display:none; z-index:20; background:rgba(30,30,30,0.92);
17675
- border-radius:8px; padding:6px 10px; gap:6px;
17676
- align-items:center; font-size:13px; color:#ddd;
17677
- backdrop-filter:blur(6px); user-select:none; white-space:nowrap;
17678
- box-shadow:0 2px 12px rgba(0,0,0,0.4);
17679
- `;
17680
- this.toolbar.addEventListener("pointerdown", (e) => e.stopPropagation());
17681
- this.toolbar.addEventListener("wheel", (e) => e.stopPropagation());
17682
- const mkBtn = (label, op) => {
17683
- const btn = document.createElement("button");
17684
- btn.textContent = label;
17685
- btn.style.cssText = `
17686
- padding:4px 12px; border:1px solid #555; border-radius:4px;
17687
- background:#333; color:#ddd; cursor:pointer; font-size:13px;
17688
- transition: background 0.15s;
17689
- `;
17690
- btn.addEventListener("mouseenter", () => {
17691
- btn.style.background = "#555";
17692
- });
17693
- btn.addEventListener("mouseleave", () => {
17694
- btn.style.background = "#333";
17695
- });
17696
- btn.addEventListener("pointerdown", (e) => {
17697
- e.stopPropagation();
17698
- this.callbacks.onApply(op);
17699
- });
17700
- return btn;
17701
- };
17702
- const mkInput = (placeholder, initial, onChange) => {
17703
- const wrap = document.createElement("span");
17704
- wrap.style.cssText = "display:inline-flex; align-items:center; gap:2px;";
17705
- const input = document.createElement("input");
17706
- input.type = "number";
17707
- input.min = "1";
17708
- input.step = "1";
17709
- input.value = String(Math.round(initial));
17710
- input.style.cssText = `
17711
- width:40px; padding:3px 4px; border:1px solid #555; border-radius:4px;
17712
- background:#222; color:#ddd; font-size:12px; text-align:center;
17713
- `;
17714
- const label = document.createElement("span");
17715
- label.textContent = placeholder;
17716
- label.style.cssText = "color:#888; font-size:11px;";
17717
- input.addEventListener("change", () => {
17718
- const v = Math.max(1, Math.round(parseFloat(input.value) || 1));
17719
- input.value = String(v);
17720
- onChange(v);
17721
- });
17722
- wrap.appendChild(input);
17723
- wrap.appendChild(label);
17724
- return { wrap, input };
17725
- };
17726
- const setBtn = mkBtn("Set", "set");
17727
- const addBtn = mkBtn("Add", "add");
17728
- const removeBtn = mkBtn("Remove", "remove");
17729
- const xInput = mkInput("LenX", this._lenX, (v) => {
17730
- this._lenX = v;
17731
- this.emitDims();
17732
- });
17733
- const yInput = mkInput("LenY", this._lenY, (v) => {
17734
- this._lenY = v;
17735
- this.emitDims();
17736
- });
17737
- const zInput = mkInput("LenZ", this._lenZ, (v) => {
17738
- this._lenZ = v;
17739
- this.emitDims();
17740
- });
17741
- this.inputX = xInput.input;
17742
- this.inputY = yInput.input;
17743
- this.inputZ = zInput.input;
17744
- this.toolbar.appendChild(setBtn);
17745
- this.toolbar.appendChild(addBtn);
17746
- this.toolbar.appendChild(removeBtn);
17747
- this.toolbar.appendChild(xInput.wrap);
17748
- this.toolbar.appendChild(yInput.wrap);
17749
- this.toolbar.appendChild(zInput.wrap);
17750
- parent.appendChild(this.toolbar);
17594
+ __publicField(this, "_onDimensionsChanged");
17595
+ this._onDimensionsChanged = onDimensionsChanged;
17751
17596
  }
17752
17597
  get lenX() {
17753
17598
  return this._lenX;
@@ -17759,21 +17604,15 @@ class BoxSelection {
17759
17604
  return this._lenZ;
17760
17605
  }
17761
17606
  setDimensions(lenX, lenY, lenZ) {
17762
- this._lenX = Math.round(lenX);
17763
- this._lenY = Math.round(lenY);
17764
- this._lenZ = Math.round(lenZ);
17765
- this.inputX.value = String(this._lenX);
17766
- this.inputY.value = String(this._lenY);
17767
- this.inputZ.value = String(this._lenZ);
17607
+ var _a2;
17608
+ this._lenX = lenX;
17609
+ this._lenY = lenY;
17610
+ this._lenZ = lenZ;
17611
+ (_a2 = this._onDimensionsChanged) == null ? void 0 : _a2.call(this, lenX, lenY, lenZ);
17768
17612
  }
17769
17613
  activate() {
17770
- this.toolbar.style.display = "flex";
17771
17614
  }
17772
17615
  deactivate() {
17773
- this.toolbar.style.display = "none";
17774
- }
17775
- emitDims() {
17776
- this.callbacks.onDimensionsChanged(this._lenX, this._lenY, this._lenZ);
17777
17616
  }
17778
17617
  }
17779
17618
  function exportEditedPLY(positions, scales, rotations, colors, opacities, shCoeffs, state) {
@@ -18280,20 +18119,14 @@ class SplatEditor {
18280
18119
  if (this.gpuRenderer) {
18281
18120
  this.volumeRenderer = new SelectionVolumeRenderer(this.gpuRenderer, this.camera);
18282
18121
  }
18283
- this.sphereTool = new SphereSelection(this.container, {
18284
- onApply: (op) => this.applyVolumeSelection(op),
18285
- onRadiusChanged: (radius) => {
18286
- var _a2;
18287
- (_a2 = this.volumeRenderer) == null ? void 0 : _a2.setDimensions(radius, 0, 0);
18288
- }
18122
+ this.sphereTool = new SphereSelection((radius) => {
18123
+ var _a2;
18124
+ (_a2 = this.volumeRenderer) == null ? void 0 : _a2.setDimensions(radius, 0, 0);
18289
18125
  });
18290
18126
  this.toolManager.register("sphere", this.sphereTool);
18291
- this.boxTool = new BoxSelection(this.container, {
18292
- onApply: (op) => this.applyVolumeSelection(op),
18293
- onDimensionsChanged: (lx, ly, lz) => {
18294
- var _a2;
18295
- (_a2 = this.volumeRenderer) == null ? void 0 : _a2.setDimensions(lx, ly, lz);
18296
- }
18127
+ this.boxTool = new BoxSelection((lx, ly, lz) => {
18128
+ var _a2;
18129
+ (_a2 = this.volumeRenderer) == null ? void 0 : _a2.setDimensions(lx, ly, lz);
18297
18130
  });
18298
18131
  this.toolManager.register("box", this.boxTool);
18299
18132
  this.gsRenderer.setEditorState(this.splatState.data);
@@ -18651,6 +18484,24 @@ class SplatEditor {
18651
18484
  }
18652
18485
  };
18653
18486
  }
18487
+ // ============================================
18488
+ // 体积工具参数 API(供前端 UI 调用)
18489
+ // ============================================
18490
+ setBoxDimensions(lx, ly, lz) {
18491
+ var _a2;
18492
+ (_a2 = this.boxTool) == null ? void 0 : _a2.setDimensions(lx, ly, lz);
18493
+ }
18494
+ getBoxDimensions() {
18495
+ return this.boxTool ? [this.boxTool.lenX, this.boxTool.lenY, this.boxTool.lenZ] : [2, 2, 2];
18496
+ }
18497
+ setSphereRadius(radius) {
18498
+ var _a2;
18499
+ (_a2 = this.sphereTool) == null ? void 0 : _a2.setRadius(radius);
18500
+ }
18501
+ getSphereRadius() {
18502
+ var _a2;
18503
+ return ((_a2 = this.sphereTool) == null ? void 0 : _a2.radius) ?? 1;
18504
+ }
18654
18505
  /**
18655
18506
  * 获取模型世界空间包围盒(中心 + 尺寸)
18656
18507
  */