lythreeframe 2.0.8 → 2.0.10

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.
@@ -1,6 +1,6 @@
1
- import type { PostProcessParam } from 'lythreeframe/src/PostProcess/PostProcessParam';
2
1
  import { type WebGLRendererParameters } from 'three';
3
2
  import { type WebGPURendererParameters } from 'three/src/renderers/webgpu/WebGPURenderer.js';
3
+ import { PostProcessParam } from '../../PostProcess/PostProcessParam';
4
4
  export declare enum RendererType {
5
5
  WebGPU = 0,
6
6
  WebGL = 1
@@ -4,6 +4,14 @@ export declare class PostProcessManager {
4
4
  private postProcessParam;
5
5
  private postProcessing;
6
6
  private outlineObjects;
7
+ /**
8
+ * 永远留在描边选择列表中的占位对象:它是一个不在场景中的空 Mesh。
9
+ * OutlineNode 在 _updateSelectionCache 中会把它计入 _selectionCache(因为 isMesh
10
+ * 为真),从而保证选择列表永不为空;但它不在场景中,所有描边 pass 都不会
11
+ * 渲染它,因此不会产生任何可见描边。这样可彻底避免「清空选择 -> 空选过渡帧」
12
+ * 在 WebGPU 上(裸 renderer.clear() 无 active pass)导致的闪屏。
13
+ */
14
+ private _outlinePlaceholder;
7
15
  private effectUniforms;
8
16
  private outlinePass;
9
17
  private bloomPass;
@@ -27,6 +35,14 @@ export declare class PostProcessManager {
27
35
  private getStepParam;
28
36
  private updateAllUniforms;
29
37
  updateSteps(steps: PostProcessStepParam[]): void;
38
+ /**
39
+ * 确保描边选择列表中始终存在一个不会渲染出描边的占位对象。
40
+ * 占位对象是一个不在场景中的空 Mesh:OutlineNode 在 _updateSelectionCache 中
41
+ * 会把它计入 _selectionCache(因为 isMesh 为真),从而使选择永不为空;但它
42
+ * 不在场景中,所有描边 pass 都不会渲染它,因此不会产生任何可见描边。
43
+ * 这从机制上消除了「选择被清空时空选过渡帧」在 WebGPU 上导致的闪屏。
44
+ */
45
+ private ensureOutlinePlaceholder;
30
46
  addOutlineObject(obj: Object3D): void;
31
47
  setOutlineObjects(objects: Object3D[]): void;
32
48
  removeOutlineObject(obj: Object3D): void;
@@ -13,12 +13,20 @@ export declare class Orbital extends Pawn {
13
13
  maxAzimuthAngle: number;
14
14
  enableDamping: boolean;
15
15
  dampingFactor: number;
16
+ enableRotate: boolean;
17
+ enablePan: boolean;
18
+ enableZoom: boolean;
16
19
  private _isDragging;
17
20
  private _lastPointerPosition;
18
21
  private _targetPosition;
19
22
  private _targetQuaternion;
20
23
  private _targetDistance;
21
24
  private _focusTween;
25
+ private _touchGesture;
26
+ private _touches;
27
+ private _lastTouchDistance;
28
+ private _lastTouchPanCenter;
29
+ private _touchStartPositions;
22
30
  constructor(app: ThreeJsApp);
23
31
  possess(): void;
24
32
  getTargetCameraState(): {
@@ -33,6 +41,13 @@ export declare class Orbital extends Pawn {
33
41
  private onPointerUp;
34
42
  private setCameraDraggingState;
35
43
  private onWheel;
44
+ private onTouchStart;
45
+ private onTouchMove;
46
+ private onTouchEnd;
47
+ /** 应用旋转变换 */
48
+ private applyRotation;
49
+ /** 应用平移变换 */
50
+ private applyPan;
36
51
  tick(deltaTime: number): void;
37
52
  setPosition(position: Vector3): void;
38
53
  setPosition(x: number, y: number, z: number): void;
@@ -20,10 +20,13 @@ export declare class ThreeJsApp {
20
20
  protected _world: World;
21
21
  protected _viewport: Viewport;
22
22
  protected _controller: Controller;
23
- protected _assetManager: AssetManager;
23
+ /** AssetManager 可能会被延迟(动态 import)创建,故在就绪前保持 null */
24
+ protected _assetManager: AssetManager | null;
24
25
  protected _assetManagerReady: Promise<void>;
25
26
  protected _tickingFunctions: Array<(delta: number) => void>;
26
27
  protected _isTickPaused: boolean;
28
+ /** 销毁幂等标志:destroy() 可被组件卸载与页面卸载(beforeunload)两条路径重复触发 */
29
+ protected _destroyed: boolean;
27
30
  get onCameraChangedDelegate(): Delegate<[void]>;
28
31
  protected _onCameraChangedDelegate: Delegate<[void]>;
29
32
  constructor(appParam?: AppParam);
@@ -33,7 +36,19 @@ export declare class ThreeJsApp {
33
36
  setTickPaused(pause: boolean): void;
34
37
  addTickingFunction(func: (deltaTime: number) => void): void;
35
38
  removeTickingFunction(func: (deltaTime: number) => void): void;
36
- destroy(): Promise<void>;
39
+ /**
40
+ * 销毁整个应用:controller / world / assetManager / viewport(含 renderer 与 GPU 设备)。
41
+ *
42
+ * 同步实现的原因:此前是 async 且首句 await this._assetManagerReady,
43
+ * 导致真正的清理被推迟到微任务;而页面刷新/关闭时 beforeunload 是同步 handler,
44
+ * 微任务不保证执行(_assetManagerReady 未就绪时甚至永不执行),
45
+ * 造成每次刷新残留一份 WebGPU 上下文。卸载路径无法等待 Promise,故整体改为同步。
46
+ *
47
+ * 幂等:重复调用安全(destroySync 与本方法共用 _destroyed 守卫)。
48
+ */
49
+ destroy(): void;
50
+ /** 释放 AssetManager;若其仍在异步就绪中,则在就绪后补一次释放(不阻塞调用方) */
51
+ private _disposeAssetManager;
37
52
  updateCamera(param: CameraParam): void;
38
53
  onWindowResize(width: number, height: number): void;
39
54
  renderAsImage(width?: number, height?: number): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",