@d5techs/3dgs-lib 1.4.77 → 1.4.79
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 +124 -90
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +124 -90
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/editor/SelectionVolumeRenderer.d.ts +0 -2
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -17613,19 +17613,19 @@ class SphereSelection {
|
|
|
17613
17613
|
inputWrap.style.cssText = "display:inline-flex; align-items:center; gap:2px;";
|
|
17614
17614
|
const input = document.createElement("input");
|
|
17615
17615
|
input.type = "number";
|
|
17616
|
-
input.min = "
|
|
17617
|
-
input.step = "
|
|
17618
|
-
input.value = this._radius
|
|
17616
|
+
input.min = "1";
|
|
17617
|
+
input.step = "1";
|
|
17618
|
+
input.value = String(this._radius);
|
|
17619
17619
|
input.style.cssText = `
|
|
17620
|
-
width:
|
|
17620
|
+
width:40px; padding:3px 4px; border:1px solid #555; border-radius:4px;
|
|
17621
17621
|
background:#222; color:#ddd; font-size:12px; text-align:center;
|
|
17622
17622
|
`;
|
|
17623
17623
|
const label = document.createElement("span");
|
|
17624
17624
|
label.textContent = "Radius";
|
|
17625
17625
|
label.style.cssText = "color:#888; font-size:11px;";
|
|
17626
17626
|
input.addEventListener("change", () => {
|
|
17627
|
-
const v = Math.max(
|
|
17628
|
-
input.value = v
|
|
17627
|
+
const v = Math.max(1, Math.round(parseFloat(input.value) || 1));
|
|
17628
|
+
input.value = String(v);
|
|
17629
17629
|
this._radius = v;
|
|
17630
17630
|
this.callbacks.onRadiusChanged(v);
|
|
17631
17631
|
});
|
|
@@ -17642,8 +17642,8 @@ class SphereSelection {
|
|
|
17642
17642
|
return this._radius;
|
|
17643
17643
|
}
|
|
17644
17644
|
setRadius(radius) {
|
|
17645
|
-
this._radius = radius;
|
|
17646
|
-
this.radiusInput.value =
|
|
17645
|
+
this._radius = Math.round(radius);
|
|
17646
|
+
this.radiusInput.value = String(this._radius);
|
|
17647
17647
|
}
|
|
17648
17648
|
activate() {
|
|
17649
17649
|
this.toolbar.style.display = "flex";
|
|
@@ -17702,19 +17702,19 @@ class BoxSelection {
|
|
|
17702
17702
|
wrap.style.cssText = "display:inline-flex; align-items:center; gap:2px;";
|
|
17703
17703
|
const input = document.createElement("input");
|
|
17704
17704
|
input.type = "number";
|
|
17705
|
-
input.min = "
|
|
17706
|
-
input.step = "
|
|
17707
|
-
input.value =
|
|
17705
|
+
input.min = "1";
|
|
17706
|
+
input.step = "1";
|
|
17707
|
+
input.value = String(Math.round(initial));
|
|
17708
17708
|
input.style.cssText = `
|
|
17709
|
-
width:
|
|
17709
|
+
width:40px; padding:3px 4px; border:1px solid #555; border-radius:4px;
|
|
17710
17710
|
background:#222; color:#ddd; font-size:12px; text-align:center;
|
|
17711
17711
|
`;
|
|
17712
17712
|
const label = document.createElement("span");
|
|
17713
17713
|
label.textContent = placeholder;
|
|
17714
17714
|
label.style.cssText = "color:#888; font-size:11px;";
|
|
17715
17715
|
input.addEventListener("change", () => {
|
|
17716
|
-
const v = Math.max(
|
|
17717
|
-
input.value = v
|
|
17716
|
+
const v = Math.max(1, Math.round(parseFloat(input.value) || 1));
|
|
17717
|
+
input.value = String(v);
|
|
17718
17718
|
onChange(v);
|
|
17719
17719
|
});
|
|
17720
17720
|
wrap.appendChild(input);
|
|
@@ -17757,12 +17757,12 @@ class BoxSelection {
|
|
|
17757
17757
|
return this._lenZ;
|
|
17758
17758
|
}
|
|
17759
17759
|
setDimensions(lenX, lenY, lenZ) {
|
|
17760
|
-
this._lenX = lenX;
|
|
17761
|
-
this._lenY = lenY;
|
|
17762
|
-
this._lenZ = lenZ;
|
|
17763
|
-
this.inputX.value =
|
|
17764
|
-
this.inputY.value =
|
|
17765
|
-
this.inputZ.value =
|
|
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);
|
|
17766
17766
|
}
|
|
17767
17767
|
activate() {
|
|
17768
17768
|
this.toolbar.style.display = "flex";
|
|
@@ -17875,8 +17875,10 @@ function exportEditedPLY(positions, scales, rotations, colors, opacities, shCoef
|
|
|
17875
17875
|
}
|
|
17876
17876
|
return buffer;
|
|
17877
17877
|
}
|
|
17878
|
-
const
|
|
17879
|
-
const
|
|
17878
|
+
const SEG = 64;
|
|
17879
|
+
const LAT_COUNT = 8;
|
|
17880
|
+
const LON_COUNT = 12;
|
|
17881
|
+
const BOX_GRID_SUBDIV = 4;
|
|
17880
17882
|
class SelectionVolumeRenderer {
|
|
17881
17883
|
constructor(renderer, camera) {
|
|
17882
17884
|
__publicField(this, "renderer");
|
|
@@ -17887,16 +17889,14 @@ class SelectionVolumeRenderer {
|
|
|
17887
17889
|
__publicField(this, "vertexBuffer", null);
|
|
17888
17890
|
__publicField(this, "_volume", { type: null, center: [0, 0, 0], dimensions: [2, 2, 2] });
|
|
17889
17891
|
__publicField(this, "vertexCount", 0);
|
|
17890
|
-
__publicField(this, "
|
|
17891
|
-
__publicField(this, "lineColor", [0.2, 0.8, 1]);
|
|
17892
|
+
__publicField(this, "lineColor", [0.4, 0.9, 1]);
|
|
17892
17893
|
this.renderer = renderer;
|
|
17893
17894
|
this.camera = camera;
|
|
17894
|
-
this.maxVertices = Math.max(
|
|
17895
|
-
24,
|
|
17896
|
-
SPHERE_SEGMENTS * 2 * SPHERE_RINGS
|
|
17897
|
-
);
|
|
17898
17895
|
this.createPipeline();
|
|
17899
|
-
this.
|
|
17896
|
+
this.vertexBuffer = this.renderer.device.createBuffer({
|
|
17897
|
+
size: 65536,
|
|
17898
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
|
17899
|
+
});
|
|
17900
17900
|
}
|
|
17901
17901
|
get volume() {
|
|
17902
17902
|
return this._volume;
|
|
@@ -17930,7 +17930,7 @@ class SelectionVolumeRenderer {
|
|
|
17930
17930
|
return o;
|
|
17931
17931
|
}
|
|
17932
17932
|
@fragment fn fs(i: VO) -> @location(0) vec4<f32> {
|
|
17933
|
-
return vec4(i.color, 0.
|
|
17933
|
+
return vec4(i.color, 0.6);
|
|
17934
17934
|
}
|
|
17935
17935
|
`
|
|
17936
17936
|
);
|
|
@@ -17968,78 +17968,115 @@ class SelectionVolumeRenderer {
|
|
|
17968
17968
|
depthStencil: { format: this.renderer.depthFormat, depthWriteEnabled: false, depthCompare: "always" }
|
|
17969
17969
|
});
|
|
17970
17970
|
}
|
|
17971
|
-
|
|
17972
|
-
const size = this.maxVertices * 24;
|
|
17973
|
-
this.vertexBuffer = this.renderer.device.createBuffer({
|
|
17974
|
-
size,
|
|
17975
|
-
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
|
17976
|
-
});
|
|
17977
|
-
}
|
|
17971
|
+
// ========== Box: 12 edges + grid lines on all 6 faces ==========
|
|
17978
17972
|
generateBoxVertices() {
|
|
17979
17973
|
const [cx, cy, cz] = this._volume.center;
|
|
17980
17974
|
const [lx, ly, lz] = this._volume.dimensions;
|
|
17981
17975
|
const hx = lx / 2, hy = ly / 2, hz = lz / 2;
|
|
17982
17976
|
const [r, g, b] = this.lineColor;
|
|
17983
17977
|
const v = [];
|
|
17984
|
-
const
|
|
17978
|
+
const line = (x12, y12, z12, x2, y2, z2) => {
|
|
17985
17979
|
v.push(x12, y12, z12, r, g, b, x2, y2, z2, r, g, b);
|
|
17986
17980
|
};
|
|
17987
17981
|
const x0 = cx - hx, x1 = cx + hx;
|
|
17988
17982
|
const y0 = cy - hy, y1 = cy + hy;
|
|
17989
17983
|
const z0 = cz - hz, z1 = cz + hz;
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
17984
|
+
line(x0, y0, z0, x1, y0, z0);
|
|
17985
|
+
line(x1, y0, z0, x1, y0, z1);
|
|
17986
|
+
line(x1, y0, z1, x0, y0, z1);
|
|
17987
|
+
line(x0, y0, z1, x0, y0, z0);
|
|
17988
|
+
line(x0, y1, z0, x1, y1, z0);
|
|
17989
|
+
line(x1, y1, z0, x1, y1, z1);
|
|
17990
|
+
line(x1, y1, z1, x0, y1, z1);
|
|
17991
|
+
line(x0, y1, z1, x0, y1, z0);
|
|
17992
|
+
line(x0, y0, z0, x0, y1, z0);
|
|
17993
|
+
line(x1, y0, z0, x1, y1, z0);
|
|
17994
|
+
line(x1, y0, z1, x1, y1, z1);
|
|
17995
|
+
line(x0, y0, z1, x0, y1, z1);
|
|
17996
|
+
const n = BOX_GRID_SUBDIV;
|
|
17997
|
+
for (let i = 1; i < n; i++) {
|
|
17998
|
+
const t = i / n;
|
|
17999
|
+
const px = x0 + (x1 - x0) * t;
|
|
18000
|
+
const pz = z0 + (z1 - z0) * t;
|
|
18001
|
+
line(px, y0, z0, px, y0, z1);
|
|
18002
|
+
line(px, y1, z0, px, y1, z1);
|
|
18003
|
+
line(x0, y0, pz, x1, y0, pz);
|
|
18004
|
+
line(x0, y1, pz, x1, y1, pz);
|
|
18005
|
+
}
|
|
18006
|
+
for (let i = 1; i < n; i++) {
|
|
18007
|
+
const t = i / n;
|
|
18008
|
+
const px = x0 + (x1 - x0) * t;
|
|
18009
|
+
const py = y0 + (y1 - y0) * t;
|
|
18010
|
+
line(px, y0, z0, px, y1, z0);
|
|
18011
|
+
line(px, y0, z1, px, y1, z1);
|
|
18012
|
+
line(x0, py, z0, x1, py, z0);
|
|
18013
|
+
line(x0, py, z1, x1, py, z1);
|
|
18014
|
+
}
|
|
18015
|
+
for (let i = 1; i < n; i++) {
|
|
18016
|
+
const t = i / n;
|
|
18017
|
+
const py = y0 + (y1 - y0) * t;
|
|
18018
|
+
const pz = z0 + (z1 - z0) * t;
|
|
18019
|
+
line(x0, py, z0, x0, py, z1);
|
|
18020
|
+
line(x1, py, z0, x1, py, z1);
|
|
18021
|
+
line(x0, y0, pz, x0, y1, pz);
|
|
18022
|
+
line(x1, y0, pz, x1, y1, pz);
|
|
18023
|
+
}
|
|
18002
18024
|
return new Float32Array(v);
|
|
18003
18025
|
}
|
|
18026
|
+
// ========== Sphere: latitude + longitude rings ==========
|
|
18004
18027
|
generateSphereVertices() {
|
|
18005
18028
|
const [cx, cy, cz] = this._volume.center;
|
|
18006
18029
|
const radius = this._volume.dimensions[0];
|
|
18007
18030
|
const [r, g, b] = this.lineColor;
|
|
18008
18031
|
const v = [];
|
|
18009
|
-
const
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
const
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
y1 = cy + Math.cos(a1) * radius;
|
|
18028
|
-
z1 = cz + Math.sin(a1) * radius;
|
|
18029
|
-
} else {
|
|
18030
|
-
x0 = cx + Math.cos(a0) * radius;
|
|
18031
|
-
y0 = cy + Math.sin(a0) * radius;
|
|
18032
|
-
z0 = cz;
|
|
18033
|
-
x1 = cx + Math.cos(a1) * radius;
|
|
18034
|
-
y1 = cy + Math.sin(a1) * radius;
|
|
18035
|
-
z1 = cz;
|
|
18036
|
-
}
|
|
18037
|
-
v.push(x0, y0, z0, r, g, b, x1, y1, z1, r, g, b);
|
|
18032
|
+
const addRing = (centerY, ringRadius) => {
|
|
18033
|
+
for (let i = 0; i < SEG; i++) {
|
|
18034
|
+
const a0 = i / SEG * Math.PI * 2;
|
|
18035
|
+
const a1 = (i + 1) / SEG * Math.PI * 2;
|
|
18036
|
+
v.push(
|
|
18037
|
+
cx + Math.cos(a0) * ringRadius,
|
|
18038
|
+
cy + centerY,
|
|
18039
|
+
cz + Math.sin(a0) * ringRadius,
|
|
18040
|
+
r,
|
|
18041
|
+
g,
|
|
18042
|
+
b,
|
|
18043
|
+
cx + Math.cos(a1) * ringRadius,
|
|
18044
|
+
cy + centerY,
|
|
18045
|
+
cz + Math.sin(a1) * ringRadius,
|
|
18046
|
+
r,
|
|
18047
|
+
g,
|
|
18048
|
+
b
|
|
18049
|
+
);
|
|
18038
18050
|
}
|
|
18039
18051
|
};
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18052
|
+
for (let i = 0; i <= LAT_COUNT; i++) {
|
|
18053
|
+
const phi = -Math.PI / 2 + i / LAT_COUNT * Math.PI;
|
|
18054
|
+
const y = Math.sin(phi) * radius;
|
|
18055
|
+
const ringR = Math.cos(phi) * radius;
|
|
18056
|
+
if (ringR < 1e-3) continue;
|
|
18057
|
+
addRing(y, ringR);
|
|
18058
|
+
}
|
|
18059
|
+
for (let j = 0; j < LON_COUNT; j++) {
|
|
18060
|
+
const theta = j / LON_COUNT * Math.PI;
|
|
18061
|
+
for (let i = 0; i < SEG; i++) {
|
|
18062
|
+
const phi0 = i / SEG * Math.PI * 2;
|
|
18063
|
+
const phi1 = (i + 1) / SEG * Math.PI * 2;
|
|
18064
|
+
v.push(
|
|
18065
|
+
cx + Math.cos(phi0) * Math.sin(theta) * radius,
|
|
18066
|
+
cy + Math.sin(phi0) * radius,
|
|
18067
|
+
cz + Math.cos(phi0) * Math.cos(theta) * radius,
|
|
18068
|
+
r,
|
|
18069
|
+
g,
|
|
18070
|
+
b,
|
|
18071
|
+
cx + Math.cos(phi1) * Math.sin(theta) * radius,
|
|
18072
|
+
cy + Math.sin(phi1) * radius,
|
|
18073
|
+
cz + Math.cos(phi1) * Math.cos(theta) * radius,
|
|
18074
|
+
r,
|
|
18075
|
+
g,
|
|
18076
|
+
b
|
|
18077
|
+
);
|
|
18078
|
+
}
|
|
18079
|
+
}
|
|
18043
18080
|
return new Float32Array(v);
|
|
18044
18081
|
}
|
|
18045
18082
|
render(pass) {
|
|
@@ -18152,16 +18189,13 @@ class SplatEditor {
|
|
|
18152
18189
|
this.toolOverlay.style.display = name && !isVolumeTool ? "block" : "none";
|
|
18153
18190
|
if (isVolumeTool && this.volumeRenderer) {
|
|
18154
18191
|
const volType = name;
|
|
18155
|
-
const
|
|
18156
|
-
const defaultSize = Math.max(bounds.size[0], bounds.size[1], bounds.size[2]) * 0.3;
|
|
18157
|
-
const safeSize = Math.max(defaultSize, 0.5);
|
|
18192
|
+
const center = this.getModelCenter();
|
|
18158
18193
|
if (volType === "box") {
|
|
18159
|
-
this.boxTool.
|
|
18160
|
-
this.volumeRenderer.setVolume("box",
|
|
18194
|
+
const lx = this.boxTool.lenX, ly = this.boxTool.lenY, lz = this.boxTool.lenZ;
|
|
18195
|
+
this.volumeRenderer.setVolume("box", center, [lx, ly, lz]);
|
|
18161
18196
|
} else {
|
|
18162
|
-
const r =
|
|
18163
|
-
this.
|
|
18164
|
-
this.volumeRenderer.setVolume("sphere", bounds.center, [r, 0, 0]);
|
|
18197
|
+
const r = this.sphereTool.radius;
|
|
18198
|
+
this.volumeRenderer.setVolume("sphere", center, [r, 0, 0]);
|
|
18165
18199
|
}
|
|
18166
18200
|
(_b2 = (_a2 = this.callbacks).onVolumeToolActivated) == null ? void 0 : _b2.call(_a2, this.volumeRenderer.volume);
|
|
18167
18201
|
} else {
|