@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/dist/index.d.mts CHANGED
@@ -211,6 +211,11 @@ type TileProps = {
211
211
  multires: string | TileMultiresConfig;
212
212
  /** Defaults to `${baseUrl}/previews/cube-vertical.webp`. */
213
213
  previewUrl?: string | null;
214
+ /**
215
+ * Face order in the vertical preview atlas, from top to bottom. Defaults to
216
+ * `l/f/r/b/u/d`.
217
+ */
218
+ previewFaceOrder?: readonly CubeFaceCode[];
214
219
  /**
215
220
  * Relative to `baseUrl`; supports krpano cube-tile `%s` and `%l` placeholders,
216
221
  * horizontal `%h`/`%x`/`%u`/`%c`, vertical `%v`/`%y`/`%w`/`%r`, and index padding
@@ -437,7 +442,7 @@ type VideoHotspotProps = HotspotCommonProps & {
437
442
  };
438
443
  declare function VideoHotspot({ id, src, playing, poster, loop, muted, volume, playsInline, preload, crossOrigin, width, height, opacity, onPlaybackStateChange, onPlaybackError, onEnded, onError, ...anchorProps }: VideoHotspotProps): react.JSX.Element;
439
444
 
440
- declare function Tile({ baseUrl, multires, previewUrl, urlTemplate, resolveTileUrl, maxTextureMemoryMb, maxConcurrentLoads, retryCount, loadMode, visible, onReady, onPreviewError, onLoadProgress, onTileError, onLevelChange, }: TileProps): react.JSX.Element;
445
+ declare function Tile({ baseUrl, multires, previewUrl, previewFaceOrder, urlTemplate, resolveTileUrl, maxTextureMemoryMb, maxConcurrentLoads, retryCount, loadMode, visible, onReady, onPreviewError, onLoadProgress, onTileError, onLevelChange, }: TileProps): react.JSX.Element;
441
446
 
442
447
  declare function normalizePanoYaw(yaw: number): number;
443
448
  declare function clampPanoPitch(pitch: number): number;
package/dist/index.d.ts CHANGED
@@ -211,6 +211,11 @@ type TileProps = {
211
211
  multires: string | TileMultiresConfig;
212
212
  /** Defaults to `${baseUrl}/previews/cube-vertical.webp`. */
213
213
  previewUrl?: string | null;
214
+ /**
215
+ * Face order in the vertical preview atlas, from top to bottom. Defaults to
216
+ * `l/f/r/b/u/d`.
217
+ */
218
+ previewFaceOrder?: readonly CubeFaceCode[];
214
219
  /**
215
220
  * Relative to `baseUrl`; supports krpano cube-tile `%s` and `%l` placeholders,
216
221
  * horizontal `%h`/`%x`/`%u`/`%c`, vertical `%v`/`%y`/`%w`/`%r`, and index padding
@@ -437,7 +442,7 @@ type VideoHotspotProps = HotspotCommonProps & {
437
442
  };
438
443
  declare function VideoHotspot({ id, src, playing, poster, loop, muted, volume, playsInline, preload, crossOrigin, width, height, opacity, onPlaybackStateChange, onPlaybackError, onEnded, onError, ...anchorProps }: VideoHotspotProps): react.JSX.Element;
439
444
 
440
- declare function Tile({ baseUrl, multires, previewUrl, urlTemplate, resolveTileUrl, maxTextureMemoryMb, maxConcurrentLoads, retryCount, loadMode, visible, onReady, onPreviewError, onLoadProgress, onTileError, onLevelChange, }: TileProps): react.JSX.Element;
445
+ declare function Tile({ baseUrl, multires, previewUrl, previewFaceOrder, urlTemplate, resolveTileUrl, maxTextureMemoryMb, maxConcurrentLoads, retryCount, loadMode, visible, onReady, onPreviewError, onLoadProgress, onTileError, onLevelChange, }: TileProps): react.JSX.Element;
441
446
 
442
447
  declare function normalizePanoYaw(yaw: number): number;
443
448
  declare function clampPanoPitch(pitch: number): number;
package/dist/index.mjs CHANGED
@@ -1244,7 +1244,7 @@ import {
1244
1244
  Vector3 as Vector32
1245
1245
  } from "three";
1246
1246
  var CUBE_FACES = ["f", "r", "b", "l", "u", "d"];
1247
- var PREVIEW_FACE_ORDER = ["f", "r", "b", "l", "u", "d"];
1247
+ var PREVIEW_FACE_ORDER = ["l", "f", "r", "b", "u", "d"];
1248
1248
  var CUBE_RADIUS = DEFAULT_PANORAMA_RADIUS;
1249
1249
  function getFaceTransform(face, radius = CUBE_RADIUS) {
1250
1250
  switch (face) {
@@ -1353,11 +1353,11 @@ function getPreferredLevel(levels, viewportHeight, pixelRatio, verticalFov, curr
1353
1353
  }
1354
1354
  return currentLevel;
1355
1355
  }
1356
- function previewAtlasVRange(face) {
1357
- const index = PREVIEW_FACE_ORDER.indexOf(face);
1356
+ function previewAtlasVRange(face, faceOrder = PREVIEW_FACE_ORDER) {
1357
+ const index = faceOrder.indexOf(face);
1358
1358
  return {
1359
- offset: (PREVIEW_FACE_ORDER.length - index - 1) / PREVIEW_FACE_ORDER.length,
1360
- scale: 1 / PREVIEW_FACE_ORDER.length
1359
+ offset: (faceOrder.length - index - 1) / faceOrder.length,
1360
+ scale: 1 / faceOrder.length
1361
1361
  };
1362
1362
  }
1363
1363
 
@@ -1478,7 +1478,8 @@ function usePreviewTexture(url, anisotropy, onError) {
1478
1478
  }
1479
1479
  function PreviewFace({
1480
1480
  face,
1481
- texture
1481
+ texture,
1482
+ faceOrder
1482
1483
  }) {
1483
1484
  const geometry = useMemo4(() => {
1484
1485
  const nextGeometry = new PlaneGeometry(
@@ -1486,7 +1487,7 @@ function PreviewFace({
1486
1487
  PREVIEW_RADIUS * 2
1487
1488
  );
1488
1489
  const uv = nextGeometry.getAttribute("uv");
1489
- const { offset, scale } = previewAtlasVRange(face);
1490
+ const { offset, scale } = previewAtlasVRange(face, faceOrder);
1490
1491
  const inset = scale / 512;
1491
1492
  for (let index = 0; index < uv.count; index += 1) {
1492
1493
  const sourceV = uv.getY(index);
@@ -1497,7 +1498,7 @@ function PreviewFace({
1497
1498
  }
1498
1499
  uv.needsUpdate = true;
1499
1500
  return nextGeometry;
1500
- }, [face]);
1501
+ }, [face, faceOrder]);
1501
1502
  useEffect7(
1502
1503
  () => () => {
1503
1504
  geometry.dispose();
@@ -1524,8 +1525,19 @@ function PreviewFace({
1524
1525
  }
1525
1526
  );
1526
1527
  }
1527
- function PreviewCube({ texture }) {
1528
- return CUBE_FACES.map((face) => /* @__PURE__ */ jsx6(PreviewFace, { face, texture }, face));
1528
+ function PreviewCube({
1529
+ texture,
1530
+ faceOrder
1531
+ }) {
1532
+ return CUBE_FACES.map((face) => /* @__PURE__ */ jsx6(
1533
+ PreviewFace,
1534
+ {
1535
+ face,
1536
+ texture,
1537
+ faceOrder
1538
+ },
1539
+ face
1540
+ ));
1529
1541
  }
1530
1542
  function useManagedTexture(manager, key, url, address) {
1531
1543
  const [managedState, setManagedState] = useState4(() => ({
@@ -1740,6 +1752,7 @@ function Tile({
1740
1752
  baseUrl,
1741
1753
  multires,
1742
1754
  previewUrl,
1755
+ previewFaceOrder = PREVIEW_FACE_ORDER,
1743
1756
  urlTemplate,
1744
1757
  resolveTileUrl,
1745
1758
  maxTextureMemoryMb = 128,
@@ -1923,7 +1936,13 @@ function Tile({
1923
1936
  commitLayers(nextLayers);
1924
1937
  });
1925
1938
  return /* @__PURE__ */ jsxs4("group", { visible, children: [
1926
- previewTexture ? /* @__PURE__ */ jsx6(PreviewCube, { texture: previewTexture }) : null,
1939
+ previewTexture ? /* @__PURE__ */ jsx6(
1940
+ PreviewCube,
1941
+ {
1942
+ texture: previewTexture,
1943
+ faceOrder: previewFaceOrder
1944
+ }
1945
+ ) : null,
1927
1946
  layers.map((layer) => /* @__PURE__ */ jsx6(
1928
1947
  TileLayerMeshes,
1929
1948
  {