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