@ericchen1990/pano-view 0.1.3 → 0.1.5
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/README.md +12 -1
- package/dist/index.cjs +30 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +30 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,18 @@ export function TileExample() {
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
The first `multires` value is the tile size. Remaining values are ascending cube-face sizes for `l1`, `l2`, and later levels. The default preview is `${baseUrl}/previews/cube-vertical.webp`, with faces stacked as `f/r/b/
|
|
68
|
+
The first `multires` value is the tile size. Remaining values are ascending cube-face sizes for `l1`, `l2`, and later levels. The default preview is `${baseUrl}/previews/cube-vertical.webp`, with six square faces stacked from top to bottom as `l/f/r/b/u/d`. Use `previewFaceOrder` when an atlas uses a different order:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<Tile
|
|
72
|
+
baseUrl="/panoramas/room"
|
|
73
|
+
multires="512,1000,2000"
|
|
74
|
+
previewUrl="/panoramas/room/previews/cube-vertical.webp"
|
|
75
|
+
previewFaceOrder={["l", "f", "r", "b", "u", "d"]}
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`previewFaceOrder` must list the six face codes in their top-to-bottom atlas order: `f`, `r`, `b`, `l`, `u`, and `d`.
|
|
69
80
|
|
|
70
81
|
During rapid rotation or zoom, loaded tiles remain visible while newly visible tiles use their parent level or the preview as a local fallback.
|
|
71
82
|
|
package/dist/index.cjs
CHANGED
|
@@ -1208,7 +1208,7 @@ var import_three7 = require("three");
|
|
|
1208
1208
|
// src/tile/face-layout.ts
|
|
1209
1209
|
var import_three6 = require("three");
|
|
1210
1210
|
var CUBE_FACES = ["f", "r", "b", "l", "u", "d"];
|
|
1211
|
-
var PREVIEW_FACE_ORDER = ["
|
|
1211
|
+
var PREVIEW_FACE_ORDER = ["l", "f", "r", "b", "u", "d"];
|
|
1212
1212
|
var CUBE_RADIUS = DEFAULT_PANORAMA_RADIUS;
|
|
1213
1213
|
function getFaceTransform(face, radius = CUBE_RADIUS) {
|
|
1214
1214
|
switch (face) {
|
|
@@ -1317,11 +1317,11 @@ function getPreferredLevel(levels, viewportHeight, pixelRatio, verticalFov, curr
|
|
|
1317
1317
|
}
|
|
1318
1318
|
return currentLevel;
|
|
1319
1319
|
}
|
|
1320
|
-
function previewAtlasVRange(face) {
|
|
1321
|
-
const index =
|
|
1320
|
+
function previewAtlasVRange(face, faceOrder = PREVIEW_FACE_ORDER) {
|
|
1321
|
+
const index = faceOrder.indexOf(face);
|
|
1322
1322
|
return {
|
|
1323
|
-
offset: (
|
|
1324
|
-
scale: 1 /
|
|
1323
|
+
offset: (faceOrder.length - index - 1) / faceOrder.length,
|
|
1324
|
+
scale: 1 / faceOrder.length
|
|
1325
1325
|
};
|
|
1326
1326
|
}
|
|
1327
1327
|
|
|
@@ -1442,7 +1442,8 @@ function usePreviewTexture(url, anisotropy, onError) {
|
|
|
1442
1442
|
}
|
|
1443
1443
|
function PreviewFace({
|
|
1444
1444
|
face,
|
|
1445
|
-
texture
|
|
1445
|
+
texture,
|
|
1446
|
+
faceOrder
|
|
1446
1447
|
}) {
|
|
1447
1448
|
const geometry = (0, import_react7.useMemo)(() => {
|
|
1448
1449
|
const nextGeometry = new import_three7.PlaneGeometry(
|
|
@@ -1450,7 +1451,7 @@ function PreviewFace({
|
|
|
1450
1451
|
PREVIEW_RADIUS * 2
|
|
1451
1452
|
);
|
|
1452
1453
|
const uv = nextGeometry.getAttribute("uv");
|
|
1453
|
-
const { offset, scale } = previewAtlasVRange(face);
|
|
1454
|
+
const { offset, scale } = previewAtlasVRange(face, faceOrder);
|
|
1454
1455
|
const inset = scale / 512;
|
|
1455
1456
|
for (let index = 0; index < uv.count; index += 1) {
|
|
1456
1457
|
const sourceV = uv.getY(index);
|
|
@@ -1461,7 +1462,7 @@ function PreviewFace({
|
|
|
1461
1462
|
}
|
|
1462
1463
|
uv.needsUpdate = true;
|
|
1463
1464
|
return nextGeometry;
|
|
1464
|
-
}, [face]);
|
|
1465
|
+
}, [face, faceOrder]);
|
|
1465
1466
|
(0, import_react7.useEffect)(
|
|
1466
1467
|
() => () => {
|
|
1467
1468
|
geometry.dispose();
|
|
@@ -1488,8 +1489,19 @@ function PreviewFace({
|
|
|
1488
1489
|
}
|
|
1489
1490
|
);
|
|
1490
1491
|
}
|
|
1491
|
-
function PreviewCube({
|
|
1492
|
-
|
|
1492
|
+
function PreviewCube({
|
|
1493
|
+
texture,
|
|
1494
|
+
faceOrder
|
|
1495
|
+
}) {
|
|
1496
|
+
return CUBE_FACES.map((face) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1497
|
+
PreviewFace,
|
|
1498
|
+
{
|
|
1499
|
+
face,
|
|
1500
|
+
texture,
|
|
1501
|
+
faceOrder
|
|
1502
|
+
},
|
|
1503
|
+
face
|
|
1504
|
+
));
|
|
1493
1505
|
}
|
|
1494
1506
|
function useManagedTexture(manager, key, url, address) {
|
|
1495
1507
|
const [managedState, setManagedState] = (0, import_react7.useState)(() => ({
|
|
@@ -1704,6 +1716,7 @@ function Tile({
|
|
|
1704
1716
|
baseUrl,
|
|
1705
1717
|
multires,
|
|
1706
1718
|
previewUrl,
|
|
1719
|
+
previewFaceOrder = PREVIEW_FACE_ORDER,
|
|
1707
1720
|
urlTemplate,
|
|
1708
1721
|
resolveTileUrl,
|
|
1709
1722
|
maxTextureMemoryMb = 128,
|
|
@@ -1887,7 +1900,13 @@ function Tile({
|
|
|
1887
1900
|
commitLayers(nextLayers);
|
|
1888
1901
|
});
|
|
1889
1902
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("group", { visible, children: [
|
|
1890
|
-
previewTexture ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1903
|
+
previewTexture ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1904
|
+
PreviewCube,
|
|
1905
|
+
{
|
|
1906
|
+
texture: previewTexture,
|
|
1907
|
+
faceOrder: previewFaceOrder
|
|
1908
|
+
}
|
|
1909
|
+
) : null,
|
|
1891
1910
|
layers.map((layer) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1892
1911
|
TileLayerMeshes,
|
|
1893
1912
|
{
|