@heliguy-xyz/splat-viewer 1.0.0-rc.2 → 1.0.0-rc.3
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/web-component/SplatViewerCore.d.ts.map +1 -1
- package/dist/web-component/splat-viewer.esm.js +80 -20
- package/dist/web-component/splat-viewer.esm.min.js +1 -1
- package/dist/web-component/splat-viewer.js +80 -20
- package/dist/web-component/splat-viewer.min.js +1 -1
- package/dist/web-component/types/SplatViewerCore.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -140833,33 +140833,93 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
140833
140833
|
if (!this.app)
|
|
140834
140834
|
return;
|
|
140835
140835
|
const canvas = this.app.graphicsDevice.canvas;
|
|
140836
|
-
//
|
|
140836
|
+
// Ensure canvas and its parent fill available space by default (non-destructive)
|
|
140837
|
+
if (!canvas.style.display)
|
|
140838
|
+
canvas.style.display = 'block';
|
|
140839
|
+
if (!canvas.style.width)
|
|
140840
|
+
canvas.style.width = '100%';
|
|
140841
|
+
if (!canvas.style.height)
|
|
140842
|
+
canvas.style.height = '100%';
|
|
140843
|
+
if (canvas.parentElement) {
|
|
140844
|
+
const ps = canvas.parentElement.style;
|
|
140845
|
+
if (!ps.width)
|
|
140846
|
+
ps.width = '100%';
|
|
140847
|
+
if (!ps.height)
|
|
140848
|
+
ps.height = '100%';
|
|
140849
|
+
}
|
|
140850
|
+
// Helper: apply resolution and notify dependents
|
|
140851
|
+
const applyResolution = (width, height) => {
|
|
140852
|
+
if (canvas.width === width && canvas.height === height)
|
|
140853
|
+
return;
|
|
140854
|
+
canvas.width = width;
|
|
140855
|
+
canvas.height = height;
|
|
140856
|
+
this.app.resizeCanvas(width, height);
|
|
140857
|
+
if (this._orbit &&
|
|
140858
|
+
this._orbit.navigationCube &&
|
|
140859
|
+
typeof this._orbit.navigationCube.onCanvasResize === 'function') {
|
|
140860
|
+
this._orbit.navigationCube.onCanvasResize();
|
|
140861
|
+
}
|
|
140862
|
+
};
|
|
140863
|
+
// Fallback: compute from CSS box * devicePixelRatio
|
|
140837
140864
|
const updateResolution = () => {
|
|
140838
140865
|
const rect = canvas.getBoundingClientRect();
|
|
140839
140866
|
const pixelRatio = window.devicePixelRatio || 1;
|
|
140840
|
-
// Set canvas internal resolution to match display size * pixel ratio
|
|
140841
140867
|
const width = Math.floor(rect.width * pixelRatio);
|
|
140842
140868
|
const height = Math.floor(rect.height * pixelRatio);
|
|
140843
|
-
|
|
140844
|
-
|
|
140845
|
-
|
|
140846
|
-
|
|
140847
|
-
|
|
140848
|
-
|
|
140849
|
-
|
|
140850
|
-
|
|
140851
|
-
|
|
140852
|
-
|
|
140853
|
-
|
|
140869
|
+
applyResolution(width, height);
|
|
140870
|
+
};
|
|
140871
|
+
// Prefer ResizeObserver entry data (devicePixelContentBoxSize when available)
|
|
140872
|
+
const updateFromEntry = (entry) => {
|
|
140873
|
+
let width = null;
|
|
140874
|
+
let height = null;
|
|
140875
|
+
const dpcb = entry.devicePixelContentBoxSize;
|
|
140876
|
+
if (dpcb && dpcb.length > 0) {
|
|
140877
|
+
width = Math.ceil(dpcb[0].inlineSize);
|
|
140878
|
+
height = Math.ceil(dpcb[0].blockSize);
|
|
140879
|
+
}
|
|
140880
|
+
else {
|
|
140881
|
+
const cbs = entry.contentBoxSize;
|
|
140882
|
+
if (cbs && cbs.length > 0) {
|
|
140883
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
140884
|
+
width = Math.ceil(cbs[0].inlineSize * pixelRatio);
|
|
140885
|
+
height = Math.ceil(cbs[0].blockSize * pixelRatio);
|
|
140854
140886
|
}
|
|
140855
140887
|
}
|
|
140888
|
+
if (width !== null && height !== null) {
|
|
140889
|
+
applyResolution(width, height);
|
|
140890
|
+
}
|
|
140891
|
+
else {
|
|
140892
|
+
updateResolution();
|
|
140893
|
+
}
|
|
140856
140894
|
};
|
|
140857
140895
|
// Initial resolution setup
|
|
140858
140896
|
updateResolution();
|
|
140859
140897
|
// Set up resize observer for automatic resolution updates
|
|
140860
140898
|
if (window.ResizeObserver) {
|
|
140861
|
-
this._resizeObserver = new ResizeObserver(() => {
|
|
140862
|
-
|
|
140899
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
|
140900
|
+
if (!entries || entries.length === 0) {
|
|
140901
|
+
updateResolution();
|
|
140902
|
+
return;
|
|
140903
|
+
}
|
|
140904
|
+
const canvasEntry = entries.find(e => e.target === canvas);
|
|
140905
|
+
if (canvasEntry) {
|
|
140906
|
+
updateFromEntry(canvasEntry);
|
|
140907
|
+
}
|
|
140908
|
+
else {
|
|
140909
|
+
// Fall back to the first entry if canvas wasn't explicitly included
|
|
140910
|
+
if (entries.length > 0) {
|
|
140911
|
+
const firstEntry = entries[0];
|
|
140912
|
+
if (firstEntry) {
|
|
140913
|
+
updateFromEntry(firstEntry);
|
|
140914
|
+
}
|
|
140915
|
+
else {
|
|
140916
|
+
updateResolution();
|
|
140917
|
+
}
|
|
140918
|
+
}
|
|
140919
|
+
else {
|
|
140920
|
+
updateResolution();
|
|
140921
|
+
}
|
|
140922
|
+
}
|
|
140863
140923
|
});
|
|
140864
140924
|
// Observe both the canvas and its parent container for resize events
|
|
140865
140925
|
this._resizeObserver.observe(canvas);
|
|
@@ -140867,11 +140927,11 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
140867
140927
|
this._resizeObserver.observe(canvas.parentElement);
|
|
140868
140928
|
}
|
|
140869
140929
|
}
|
|
140870
|
-
|
|
140871
|
-
|
|
140872
|
-
|
|
140873
|
-
|
|
140874
|
-
|
|
140930
|
+
// Additionally listen to window resize to handle viewport changes
|
|
140931
|
+
// (e.g., when resizing dev tools). This mirrors superSplat behavior
|
|
140932
|
+
// and ensures the canvas always matches the available space.
|
|
140933
|
+
window.addEventListener('resize', updateResolution);
|
|
140934
|
+
this._resizeHandler = updateResolution;
|
|
140875
140935
|
}
|
|
140876
140936
|
}
|
|
140877
140937
|
|