@ericchen1990/pano-view 3.2.3 → 3.4.0

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 CHANGED
@@ -702,11 +702,14 @@ a single non-stereo cube panorama.
702
702
 
703
703
  ## Scenes
704
704
 
705
- `Scenes` switches controlled sphere and cube-tile scenes with GPU-only
706
- snapshot blending. The target scene loads its sphere or tile preview first;
707
- once ready, the current framebuffer becomes a temporary GPU texture, its source
708
- textures are released, and the target scene blends in. This avoids holding two
709
- high-resolution tile scenes in WebGL memory at once.
705
+ `Scenes` switches controlled sphere, cube-tile, and equirectangular-tile scenes with GPU-only
706
+ snapshot blending. The incoming scene stays hidden while it preloads its preview and base
707
+ tiles. Once that preview can be drawn, the current framebuffer becomes a temporary GPU
708
+ texture and the outgoing source textures are released. The incoming scene then switches to
709
+ full detail immediately: tiles that are already sharp replace the preview during the blend,
710
+ and tiles that are still loading keep the coarser parent tile or the preview. The viewer
711
+ does not keep two high-resolution tile sets resident, and it does not preload tiles outside
712
+ the current view.
710
713
 
711
714
  ```tsx
712
715
  import {
@@ -749,7 +752,25 @@ GPU framebuffer snapshot over the incoming panorama; they do not mix two full
749
752
  360 textures. Pass `{ preset: "crossfade", duration: 0.6 }` to override a
750
753
  preset duration.
751
754
 
752
- While a transition runs, panorama drag/zoom input is locked and
755
+ `transitionWaitForDetailMs` defaults to `0`. The blend starts as soon as the incoming
756
+ scene can paint, and detail keeps loading during that blend. A positive value such as
757
+ `200` starts only after the outgoing snapshot is stored and the incoming scene is in
758
+ `full`. The blend starts early when the current view is already sharp, and otherwise
759
+ waits at most that many milliseconds. This wait is timed separately from the blend
760
+ duration. During the wait the outgoing snapshot stays fully visible while the incoming
761
+ scene draws and uploads underneath. For a normal `Sphere`, sharp means the full image
762
+ can be drawn. For cube and sphere tiles, sharp means every in-view tile at the level
763
+ chosen from viewport size, device pixel ratio, field of view, and the existing memory
764
+ budget can be drawn. Tiles outside the view are not required. Negative and non-finite
765
+ values are treated as `0`. `transition="none"` uses the same condition and then cuts
766
+ over directly. A new target, an interrupt, unmount, or a lost WebGL context cancels a
767
+ pending wait so a stale readiness report cannot affect the next scene.
768
+
769
+ `onReady` still means a source can paint for the first time. `onSceneReady` still fires
770
+ for the first paintable scene and when an incoming scene takes over after the outgoing
771
+ snapshot. It does not mean the current view's full detail has finished loading.
772
+
773
+ While a detail wait or transition runs, panorama drag/zoom input is locked and
753
774
  `renderHotspots` is hidden. New `activeSceneId` values supersede a target that
754
775
  is still being prepared. `maxTextureMemoryMb` and `maxConcurrentTileLoads`
755
776
  apply to the whole `Scenes` viewer rather than to each tile scene.
@@ -1834,8 +1855,43 @@ if the preview failed. `onPreviewError`, `onTileError`, `onLoadProgress`, and
1834
1855
  `onLevelChange` expose failures/progress; levels in callbacks start at 0.
1835
1856
  Unmounting disposes owned textures and ignores late results.
1836
1857
 
1837
- Use `SphereTile` directly as a `PanoViewer` child; `Scenes` currently accepts
1838
- `sphere` and cube `tile` definitions only.
1858
+ Use `SphereTile` directly as a `PanoViewer` child, or define a `SphereTileScene`
1859
+ with `type: "sphereTile"` inside `Scenes`. All transition presets, including
1860
+ `dissolve`, work across `sphere`, cube `tile`, and `sphereTile` scenes:
1861
+
1862
+ ```tsx
1863
+ import { Scenes, type Scene } from "@ericchen1990/pano-view";
1864
+
1865
+ const scenes: Scene[] = [
1866
+ {
1867
+ id: "courtyard",
1868
+ type: "sphereTile",
1869
+ baseUrl: "/panoramas/courtyard/",
1870
+ multires: "512,500x250,1000x500,2000x1000",
1871
+ previewUrl: "previews/400.webp",
1872
+ urlTemplate: "tiles/%l/%h_%v.webp",
1873
+ indexBase: 1,
1874
+ },
1875
+ // Add sphere, tile, or other sphereTile scenes here.
1876
+ ];
1877
+
1878
+ <Scenes scenes={scenes} activeSceneId={activeSceneId} transition="dissolve" />;
1879
+ ```
1880
+
1881
+ `onSceneReady(sceneId)` fires when the first scene becomes paintable and when an
1882
+ incoming scene takes over after the outgoing snapshot is captured. The transition
1883
+ may still be running; use this callback to apply the incoming camera view without
1884
+ changing the outgoing snapshot. Full detail loads after that handoff, including during
1885
+ the blend. `transitionWaitForDetailMs` can hold the outgoing snapshot until the current
1886
+ view is sharp; it does not change when `onSceneReady` fires. `onTransitionEnd` marks
1887
+ completion of the blend.
1888
+
1889
+ `SphereTileScene` accepts the source options of `SphereTile`, including
1890
+ `indexBase`, `resolveTileUrl`, and `yawOffset`. `Scenes` owns visibility,
1891
+ preloading, readiness, and transitions. Use `onTransitionEnd` and
1892
+ `onTransitionError` on `Scenes`; its shared texture budget and request limit
1893
+ apply to both cube and equirectangular tiles. Standalone `SphereTile` retains
1894
+ its own cache, callbacks, and loading options.
1839
1895
 
1840
1896
  ## Accessibility matrices and tooltip typography
1841
1897
 
package/README.zh-CN.md CHANGED
@@ -637,7 +637,7 @@ MAKE PANO (MULTIRES) 文件夹布局常为 `tiles/%s/l%l/%v/l%l_%s_%v_%h.jpg`,
637
637
 
638
638
  ## Scenes
639
639
 
640
- `Scenes` 在受控的球面与立方体 tile 场景之间切换,采用纯 GPU 快照混合。目标场景先加载其球面或 tile 预览;就绪后,当前帧缓冲成为临时 GPU 纹理,释放其源纹理,目标场景再混合进入。这样避免在 WebGL 内存中同时持有两个高分辨率 tile 场景。
640
+ `Scenes` 在受控的普通球面、立方体瓦片与球面多级瓦片场景之间切换,采用纯 GPU 快照混合。目标场景在隐藏状态下预加载预览和基础层。预览可绘制后,当前帧缓冲成为临时 GPU 纹理,并释放旧场景的源纹理。目标随即进入 `full`:转场期间已经清晰的瓦片立刻盖住预览,尚未就绪的区域继续显示父层瓦片或预览。查看器不会同时保留两套高清瓦片,也不会预加载当前视野之外的瓦片。
641
641
 
642
642
  ```tsx
643
643
  import {
@@ -671,7 +671,11 @@ const scenes: Scene[] = [
671
671
 
672
672
  可用的 KRpano 风格预设包括 `none`、`crossfade`、`zoom`、`blackout`、`whiteFlash`、`slideRightToLeft`、`slideTopToBottom`、`slideDiagonal`、`circleOpen`、`verticalOpen`、`horizontalOpen`、`ellipticZoomOpen`。网格类预设为 `pixelate`、`gridWipe`、`gridWipeUp`、`gridWipeRight`、`gridWipeDiagonal`、`gridWipeCenter`、`gridWipeChecker`、`hexDissolve`。电影感预设为 `dissolve`、`shatter`、`particles`、`glitch`、`swirl`、`clockWipe`、`ripple`、`zoomBlur`、`filmBurn`。它们均在入画全景之上混合 GPU 帧缓冲快照,不会混合两个完整 360 纹理。传 `{ preset: "crossfade", duration: 0.6 }` 可覆盖预设时长。
673
673
 
674
- 过渡进行时,全景拖拽/缩放输入被锁定,`renderHotspots` 被隐藏。新的 `activeSceneId` 会取代仍在准备中的目标。`maxTextureMemoryMb` 与 `maxConcurrentTileLoads` 作用于整个 `Scenes` 查看器,而非每个 tile 场景单独计算。
674
+ `transitionWaitForDetailMs` 默认为 `0`:目标一旦可绘制就开始转场,高清在转场期间继续加载。正数(例如 `200`)从旧画面快照完成、目标进入 `full` 之后开始计时;当前视野已经清晰就提前转场,否则最多再等待指定毫秒。该等待与转场动画时长分开计算。等待期间完整显示旧快照,目标在其下正常绘制并上传纹理。普通球面的“清晰”指完整图片可绘制;立方体和球面瓦片指按视口尺寸、设备像素比、FOV 和现有内存预算选出的当前视野目标层级全部可绘制,不要求视野外瓦片。负值或非有限值按 `0` 处理。`transition="none"` 使用同一条件,满足后直接切换。新的目标、中断、卸载或 WebGL 上下文丢失会取消尚未结束的等待,避免过期的就绪通知影响下一个场景。
675
+
676
+ `onReady` 仍表示源第一次可绘制。`onSceneReady` 仍在首个场景可绘制,或旧画面快照完成且新场景接管时触发,并不表示当前视野的高清已经到齐。
677
+
678
+ 清晰等待或转场进行时,全景拖拽/缩放输入被锁定,`renderHotspots` 被隐藏。新的 `activeSceneId` 会取代仍在准备中的目标。`maxTextureMemoryMb` 与 `maxConcurrentTileLoads` 作用于整个 `Scenes` 查看器,而非每个 tile 场景单独计算。
675
679
 
676
680
  ## PanoFilter
677
681
 
@@ -1529,8 +1533,40 @@ import { PanoViewer, SphereTile } from "@ericchen1990/pano-view";
1529
1533
  `onLoadProgress`、`onLevelChange` 提供;回调中的层级同样从 0 开始。
1530
1534
  卸载时释放组件纹理,丢弃迟到的加载结果。
1531
1535
 
1532
- 将 `SphereTile` 直接放在 `PanoViewer` 下;当前 `Scenes` 仍只接受 `sphere` 和立方体
1533
- `tile` 场景定义。
1536
+ 可以将 `SphereTile` 直接放在 `PanoViewer` 下,也可以在 `Scenes` 中使用
1537
+ `type: "sphereTile"` 的 `SphereTileScene`。所有过渡预设(包括 `dissolve`)均支持
1538
+ `sphere`、立方体 `tile` 和球面多级瓦片 `sphereTile` 之间的切换:
1539
+
1540
+ ```tsx
1541
+ import { Scenes, type Scene } from "@ericchen1990/pano-view";
1542
+
1543
+ const scenes: Scene[] = [
1544
+ {
1545
+ id: "courtyard",
1546
+ type: "sphereTile",
1547
+ baseUrl: "/panoramas/courtyard/",
1548
+ multires: "512,500x250,1000x500,2000x1000",
1549
+ previewUrl: "previews/400.webp",
1550
+ urlTemplate: "tiles/%l/%h_%v.webp",
1551
+ indexBase: 1,
1552
+ },
1553
+ // 在此添加 sphere、tile 或其他 sphereTile 场景。
1554
+ ];
1555
+
1556
+ <Scenes scenes={scenes} activeSceneId={activeSceneId} transition="dissolve" />;
1557
+ ```
1558
+
1559
+ `onSceneReady(sceneId)` 在首个场景可绘制、或旧画面截图完成且新场景接管时触发。
1560
+ 此时过渡可能仍在进行,可在该回调中设置新场景视角而不改变旧画面快照。
1561
+ 高清在这次交接之后加载,转场期间也会继续加载。`transitionWaitForDetailMs`
1562
+ 可以让旧快照多停留到当前视野清晰,但不会改变 `onSceneReady` 的触发时机。
1563
+ `onTransitionEnd` 表示混合效果播放完成。
1564
+
1565
+ `SphereTileScene` 保留 `SphereTile` 的资源选项,包括 `indexBase`、`resolveTileUrl`
1566
+ 和 `yawOffset`。可见性、预加载、就绪判断与过渡由 `Scenes` 管理;通过其
1567
+ `onTransitionEnd` 和 `onTransitionError` 接收结果。`Scenes` 的共享纹理预算与请求
1568
+ 并发上限同时作用于立方体和球面瓦片。独立使用的 `SphereTile` 仍保留原有缓存、
1569
+ 回调与加载选项。
1534
1570
 
1535
1571
  ## 无障碍颜色矩阵与标签排版
1536
1572