lythreeframe 1.2.52 → 1.2.53

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.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export { AssetManager } from "./lythreeframe/AssetManagement/AssetManager";
2
- export { TAssetPointer } from "./lythreeframe/AssetManagement/AssetPointer/AssetPointer";
2
+ export { TAssetPointer, ASSET_POINTER_KEY, EDITOR_ASSET_ID_KEY } from "./lythreeframe/AssetManagement/AssetPointer/AssetPointer";
3
3
  export { TSmartPointer } from './lythreeframe/Container/SmartPointer';
4
4
  export { MaterialAssetPointer } from "./lythreeframe/AssetManagement/AssetPointer/Assets/MaterialAssetPointer";
5
5
  export { GeometryAssetPointer } from "./lythreeframe/AssetManagement/AssetPointer/Assets/GeometryAssetPointer";
6
6
  export { TextureAssetPointer } from "./lythreeframe/AssetManagement/AssetPointer/Assets/TextureAssetPointer";
7
+ export { AssetCategory, AssetLoadState, ReferenceType, AssetType } from "./lythreeframe/AssetManagement/AssetDefines";
8
+ export type { AssetReference, AssetDescriptor } from "./lythreeframe/AssetManagement/AssetDefines";
7
9
  export { AttachmentRules } from "./lythreeframe/Defines";
8
10
  export { Delegate } from "./lythreeframe/Delegate";
9
11
  export { ThreeJsApp } from "./lythreeframe/ThreeJsApp";
@@ -1,3 +1,62 @@
1
+ /**
2
+ * 资产类别 - 用于底层资产管理
3
+ */
4
+ export declare enum AssetCategory {
5
+ Geometry = "geometry",
6
+ Material = "material",
7
+ Texture = "texture",
8
+ Actor = "actor",
9
+ ActorManager = "actorManager",
10
+ Level = "level",
11
+ HTML = "html",
12
+ Code = "code",
13
+ Undefined = "undefined"
14
+ }
15
+ /**
16
+ * 资产加载状态
17
+ */
18
+ export declare enum AssetLoadState {
19
+ Unloaded = "unloaded",
20
+ Loading = "loading",
21
+ Loaded = "loaded",
22
+ Error = "error"
23
+ }
24
+ /**
25
+ * 引用者类型
26
+ */
27
+ export declare enum ReferenceType {
28
+ Actor = "actor",
29
+ Component = "component",
30
+ Material = "material",
31
+ Level = "level",
32
+ AssetPointer = "assetPointer",
33
+ External = "external"
34
+ }
35
+ /**
36
+ * 资产引用信息
37
+ */
38
+ export interface AssetReference {
39
+ /** 引用者的 UUID */
40
+ refererId: string;
41
+ /** 引用者类型 */
42
+ refererType: ReferenceType;
43
+ /** 属性路径 (如 "map", "normalMap") */
44
+ propertyPath?: string;
45
+ }
46
+ /**
47
+ * 资产描述符 - 用于序列化和延迟加载
48
+ */
49
+ export interface AssetDescriptor {
50
+ uuid: string;
51
+ name: string;
52
+ category: AssetCategory;
53
+ thumbnail?: string;
54
+ packageName?: string;
55
+ contentPath?: string;
56
+ }
57
+ /**
58
+ * @deprecated 使用 AssetCategory 替代
59
+ */
1
60
  export declare enum AssetType {
2
61
  geometry = 1,
3
62
  material = 2,
@@ -1,9 +1,20 @@
1
1
  import { BufferGeometry, Material, Texture } from "three/webgpu";
2
2
  import { TSmartPointer } from "../../Container/SmartPointer";
3
+ /**
4
+ * userData 键名常量
5
+ */
6
+ export declare const ASSET_POINTER_KEY: "assetPointer";
7
+ export declare const EDITOR_ASSET_ID_KEY: "editorAssetId";
8
+ /**
9
+ * Three.js 资源的智能指针
10
+ * 管理 BufferGeometry、Material、Texture 的生命周期
11
+ */
3
12
  export declare abstract class TAssetPointer<T extends BufferGeometry | Texture | Material> extends TSmartPointer<T> {
4
- get uuid(): string;
5
13
  private readonly _uuid;
14
+ get uuid(): string;
6
15
  constructor(value: T, referenceCount?: number);
7
- release(): void;
8
- forceRelease(): void;
16
+ /**
17
+ * 释放资源,清理 userData 并调用 Three.js 的 dispose
18
+ */
19
+ protected dispose(): void;
9
20
  }
@@ -1,11 +1,24 @@
1
1
  import { Material } from "three/webgpu";
2
2
  import { TAssetPointer } from "../AssetPointer";
3
3
  import { TextureAssetPointer } from "./TextureAssetPointer";
4
+ /**
5
+ * 材质资产指针
6
+ * 管理材质及其关联的纹理引用
7
+ */
4
8
  export declare class MaterialAssetPointer extends TAssetPointer<Material> {
5
9
  protected textures: Map<string, TextureAssetPointer>;
6
10
  constructor(value: Material, usedTextures: Map<string, TextureAssetPointer>, referenceCount?: number);
7
11
  get texturePointers(): Map<string, TextureAssetPointer>;
12
+ /**
13
+ * 设置材质的纹理属性
14
+ */
8
15
  setTexture(name: string, texturePtr: TextureAssetPointer): void;
9
- release(): void;
10
- forceRelease(): void;
16
+ /**
17
+ * 移除纹理属性
18
+ */
19
+ removeTexture(name: string): void;
20
+ /**
21
+ * 释放材质时同时释放所有关联的纹理引用
22
+ */
23
+ protected dispose(): void;
11
24
  }
@@ -3,8 +3,13 @@ export declare class TSmartPointer<T> {
3
3
  protected value: T | null;
4
4
  constructor(value: T, referenceCount?: number);
5
5
  getRefCount(): number;
6
+ isValid(): boolean;
6
7
  addRef(count?: number): void;
7
8
  release(): void;
8
9
  forceRelease(): void;
10
+ /**
11
+ * 子类覆盖此方法以执行清理逻辑
12
+ */
13
+ protected dispose(): void;
9
14
  getValue(): T | null;
10
15
  }
@@ -3,40 +3,85 @@ import { Euler, Intersection, OrthographicCamera, PerspectiveCamera, Quaternion,
3
3
  import { World } from "./World";
4
4
  import { Viewport } from "./Viewport";
5
5
  import { Pawn } from "../Object/PawnV2/Pawn";
6
+ import { SceneComponent } from "../Object/Components/SceneComponent";
6
7
  import { Delegate } from "../Delegate";
8
+ /** 组件交互事件基类 */
9
+ export interface ComponentInteractionEvent {
10
+ component: SceneComponent;
11
+ hit: Intersection;
12
+ /** 设置为 true 阻止组件自身的回调被调用 */
13
+ handled: boolean;
14
+ }
15
+ /** 组件悬停事件 */
16
+ export interface ComponentHoverEvent {
17
+ component: SceneComponent;
18
+ hit: Intersection | null;
19
+ /** 设置为 true 阻止组件自身的 onHoveringBegin/End 被调用 */
20
+ handled: boolean;
21
+ }
22
+ /** 组件按下事件 */
23
+ export interface ComponentPointerDownEvent {
24
+ component: SceneComponent;
25
+ hit: Intersection;
26
+ button: number;
27
+ /** 设置为 true 阻止默认处理 */
28
+ handled: boolean;
29
+ }
7
30
  export declare class Controller {
8
- private prepareClickComponent;
9
- get camera(): PerspectiveCamera | OrthographicCamera;
10
- get world(): World;
11
- get viewPort(): Viewport;
12
- get pawn(): Pawn;
13
- get app(): ThreeJsApp;
14
31
  private _app;
15
32
  private _pawn;
16
33
  private raycaster;
34
+ private prepareClickComponent;
35
+ private prepareClickHit;
36
+ private hoveringComponent;
37
+ private _pointButtonIsDown;
38
+ private _onClickNothingDelegate;
39
+ private _onComponentClickDelegate;
40
+ private _onComponentDoubleClickDelegate;
41
+ private _onComponentHoverBeginDelegate;
42
+ private _onComponentHoverEndDelegate;
43
+ private _onComponentPointerDownDelegate;
44
+ private pointerPosition;
45
+ private pointerLeftDownPosition;
46
+ private readonly _tempVec2;
47
+ private readonly _raycastVec2;
48
+ private readonly doubleClickDelay;
49
+ private leftClickTimer;
17
50
  private onPointerMove;
18
51
  private onPointerEnter;
19
52
  private onPointerLeave;
20
53
  private onPointerUp;
21
54
  private onPointerDown;
22
- private pointerPosition;
23
- private readonly doubleClickDelay;
24
- private leftClickTimer;
25
- private pointerLeftDownPosition;
26
- private hoveringComponent;
27
- private _pointButtonIsDown;
55
+ get camera(): PerspectiveCamera | OrthographicCamera;
56
+ get world(): World;
57
+ get viewPort(): Viewport;
58
+ get app(): ThreeJsApp;
28
59
  get onClickNothingDelegate(): Delegate<[void]>;
29
- private _onClickNothingDelegate;
60
+ get onComponentClickDelegate(): Delegate<[ComponentInteractionEvent]>;
61
+ get onComponentDoubleClickDelegate(): Delegate<[ComponentInteractionEvent]>;
62
+ get onComponentHoverBeginDelegate(): Delegate<[ComponentHoverEvent]>;
63
+ get onComponentHoverEndDelegate(): Delegate<[ComponentHoverEvent]>;
64
+ get onComponentPointerDownDelegate(): Delegate<[ComponentPointerDownEvent]>;
65
+ get pawn(): Pawn;
30
66
  constructor(app: ThreeJsApp);
31
- updateCamera(): void;
32
67
  init(): void;
68
+ updateCamera(): void;
33
69
  tick(deltaTime: number): void;
34
70
  destroy(): void;
35
71
  onPointerMoveEvent(event: MouseEvent): void;
72
+ private clearHoveringComponent;
73
+ private fireHoverEvent;
36
74
  onPointerUpEvent(event: MouseEvent): void;
75
+ private handleFirstClick;
76
+ private handleDoubleClick;
77
+ private fireClickEvent;
78
+ private clearClickTimer;
37
79
  onPointerDownEvent(event: MouseEvent): void;
80
+ private firePointerDownEvent;
38
81
  onPointerEnterEvent(event: MouseEvent): void;
39
82
  onPointerLeaveEvent(event: MouseEvent): void;
83
+ private addCorePointerListeners;
84
+ private removeCorePointerListeners;
40
85
  getHitResultUnderCursor(): Intersection | null;
41
86
  getHitResultFromScreenPoint(x: number, y: number): Intersection | null;
42
87
  focusTo(targetPos: Vector3, targetQuat: Quaternion | Euler, distance: number, time: number, onGoing?: (() => void) | null, onFinished?: (() => void) | null): void;
@@ -0,0 +1,23 @@
1
+ import { Camera, Object3D, PostProcessing, Scene, WebGPURenderer } from "three/webgpu";
2
+ import { PostProcessParam, PostProcessStepParam } from '../../PostProcess/PostProcessParam';
3
+ export declare class PostProcessManager {
4
+ private postProcessParam;
5
+ private postProcessing;
6
+ private outlineObjects;
7
+ private renderer;
8
+ private scene;
9
+ private camera;
10
+ private onDirtyCallback;
11
+ constructor(renderer: WebGPURenderer, scene: Scene, camera: Camera, postProcessParam: PostProcessParam, onDirtyCallback?: () => void);
12
+ get processing(): PostProcessing | null;
13
+ updateCamera(camera: Camera): void;
14
+ setup(): void;
15
+ updateSteps(steps: PostProcessStepParam[]): void;
16
+ addOutlineObject(obj: Object3D): void;
17
+ setOutlineObjects(objects: Object3D[]): void;
18
+ removeOutlineObject(obj: Object3D): void;
19
+ render(): boolean;
20
+ renderAsync(): Promise<boolean>;
21
+ destroy(): void;
22
+ private markDirty;
23
+ }
@@ -1,4 +1,4 @@
1
- import { ShadowMapType, ToneMapping, WebGPURenderer, Object3D } from "three/webgpu";
1
+ import { Object3D, ShadowMapType, ToneMapping, WebGPURenderer } from "three/webgpu";
2
2
  import { ThreeJsApp } from "../ThreeJsApp";
3
3
  import { PostProcessParam, PostProcessStepParam } from './../PostProcess/PostProcessParam';
4
4
  import { RendererParameters } from './Parameters/RendererParameters';
@@ -18,8 +18,7 @@ export declare class Viewport {
18
18
  private _canvasContainer;
19
19
  private isRenderStateDirty;
20
20
  private postProcessParam;
21
- private postProcessing;
22
- private outlineObjects;
21
+ private postProcessManager;
23
22
  constructor(app: ThreeJsApp, viewportParam: ViewportParam, rendererParam: RendererParameters, postProcessParam: PostProcessParam);
24
23
  protected createRenderer(rendererParam: RendererParameters): void;
25
24
  protected createLabelRenderer(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.52",
3
+ "version": "1.2.53",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",