@galacean/effects-plugin-model 1.2.3 → 2.0.0-alpha.1

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.
Files changed (41) hide show
  1. package/dist/gesture/index.d.ts +5 -4
  2. package/dist/gltf/loader-helper.d.ts +1 -3
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +8358 -6785
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +2 -2
  7. package/dist/index.mjs +8357 -6784
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/loader.mjs +10070 -4913
  10. package/dist/loader.mjs.map +1 -1
  11. package/dist/plugin/const.d.ts +3 -0
  12. package/dist/plugin/index.d.ts +0 -2
  13. package/dist/plugin/model-item.d.ts +258 -0
  14. package/dist/plugin/model-plugin.d.ts +91 -18
  15. package/dist/plugin/model-tree-item.d.ts +113 -6
  16. package/dist/plugin/model-tree-plugin.d.ts +9 -8
  17. package/dist/runtime/anim-sampler.d.ts +20 -0
  18. package/dist/runtime/animation.d.ts +179 -26
  19. package/dist/runtime/cache.d.ts +75 -0
  20. package/dist/runtime/camera.d.ts +130 -5
  21. package/dist/runtime/common.d.ts +143 -4
  22. package/dist/runtime/light.d.ts +95 -6
  23. package/dist/runtime/material.d.ts +306 -1
  24. package/dist/runtime/math.d.ts +2 -0
  25. package/dist/runtime/mesh.d.ts +242 -32
  26. package/dist/runtime/object.d.ts +88 -10
  27. package/dist/runtime/scene.d.ts +156 -27
  28. package/dist/runtime/shader-libs/standard-shader-source.d.ts +10 -0
  29. package/dist/runtime/shader-libs/standard-shader.d.ts +16 -0
  30. package/dist/runtime/shader.d.ts +33 -1
  31. package/dist/runtime/skybox.d.ts +233 -9
  32. package/dist/utility/debug-helper.d.ts +14 -0
  33. package/dist/utility/hit-test-helper.d.ts +39 -3
  34. package/dist/utility/plugin-helper.d.ts +665 -14
  35. package/dist/utility/ri-helper.d.ts +67 -0
  36. package/dist/utility/shader-helper.d.ts +55 -0
  37. package/dist/utility/ts-helper.d.ts +6 -0
  38. package/package.json +4 -4
  39. package/dist/plugin/model-tree-vfx-item.d.ts +0 -15
  40. package/dist/plugin/model-vfx-item.d.ts +0 -28
  41. package/dist/runtime/shadow.d.ts +0 -230
@@ -2,24 +2,91 @@ import type { GeometryProps, Engine } from '@galacean/effects';
2
2
  import { Mesh } from '@galacean/effects';
3
3
  import type { Matrix4 } from '../runtime/math';
4
4
  import { Vector2, Vector3 } from '../runtime/math';
5
+ /**
6
+ * FBO 选项类,负责构造 FBO 创建时的选项信息
7
+ */
5
8
  export declare class FBOOptions {
9
+ /**
10
+ * 分辨率
11
+ */
6
12
  resolution: Vector2;
13
+ /**
14
+ * 颜色附件列表
15
+ */
7
16
  colorAttachments: object[];
17
+ /**
18
+ * 深度附件
19
+ */
8
20
  depthAttachment?: any;
21
+ /**
22
+ * 构造函数
23
+ * @param options - FBO 参数
24
+ */
9
25
  constructor(options: Record<string, any>);
26
+ /**
27
+ * 添加深度附件
28
+ * @param options - 深度附件参数
29
+ */
10
30
  addDepthAttachment(options: Record<string, any>): void;
31
+ /**
32
+ * 添加默认深度附件,数据格式是 depth_16_texture
33
+ */
11
34
  addDefaultDepthAttachment(): void;
35
+ /**
36
+ * 删除深度附件
37
+ */
12
38
  deleteDepthAttachment(): void;
39
+ /**
40
+ * 添加颜色附件
41
+ * @param options - 颜色附件参数
42
+ */
13
43
  addColorAttachment(options: Record<string, any>): void;
44
+ /**
45
+ * 删除颜色附件,按照索引值
46
+ * @param target - 颜色附件索引值
47
+ */
14
48
  deleteColorAttachment(target: number): void;
49
+ /**
50
+ * 获取视口大小
51
+ */
15
52
  get viewport(): [number, number, number, number];
16
53
  }
54
+ /**
55
+ * 包围盒 Mesh 类,负责 3D Mesh 测试包围盒的显示
56
+ */
17
57
  export declare class BoxMesh {
58
+ /**
59
+ * core 层 Mesh 对象
60
+ */
18
61
  mesh: Mesh;
62
+ /**
63
+ * 构造函数,创建基础 Mesh 对象
64
+ * @param engine - 引擎
65
+ * @param priority - 优先级
66
+ */
19
67
  constructor(engine: Engine, priority: number);
68
+ /**
69
+ * 更新包围盒着色器 Uniform 数据
70
+ * @param modelMatrix - 模型矩阵
71
+ * @param viewProjMatrix - 相机投影矩阵
72
+ * @param positions - 位置数组
73
+ * @param lineColor - 线颜色
74
+ */
20
75
  update(modelMatrix: Matrix4, viewProjMatrix: Matrix4, positions: Float32Array, lineColor: Vector3): void;
76
+ /**
77
+ * 销毁,需要销毁 Mesh 对象
78
+ */
21
79
  dispose(): void;
80
+ /**
81
+ * 获取顶点着色器代码
82
+ */
22
83
  get vertexShader(): string;
84
+ /**
85
+ * 获取片段着色器代码
86
+ */
23
87
  get fragmentShader(): string;
88
+ /**
89
+ * 获取基础几何体
90
+ */
24
91
  get geometry(): GeometryProps;
25
92
  }
@@ -1,13 +1,68 @@
1
1
  import type { PShaderContext, PShaderResults } from '../runtime/shader';
2
+ /**
3
+ * 获取 PBR 材质着色器代码
4
+ * @param context - 着色器上下文
5
+ * @returns
6
+ */
2
7
  export declare function getPBRPassShaderCode(context: PShaderContext): PShaderResults;
3
8
  export declare function getShadowPassShaderCode(context: PShaderContext): PShaderResults;
9
+ /**
10
+ * 获取天空盒着色器代码
11
+ * @param context - 着色器上下文
12
+ * @returns
13
+ */
4
14
  export declare function getSkyBoxShaderCode(context: PShaderContext): PShaderResults;
15
+ /**
16
+ * 获取四边形滤波着色器代码
17
+ * @param context - 着色器上下文
18
+ * @returns
19
+ */
5
20
  export declare function getQuadFilterShaderCode(context: PShaderContext): PShaderResults;
21
+ /**
22
+ * 获取法线可视化着色器代码
23
+ * @param context - 着色器上下文
24
+ * @returns
25
+ */
6
26
  export declare function getNormalVisShaderCode(context: PShaderContext): PShaderResults;
27
+ /**
28
+ * 获取仅漫反射着色器代码
29
+ * @param context - 着色器上下文
30
+ * @returns
31
+ */
7
32
  export declare function getDiffuseOnlyShaderCode(context: PShaderContext): PShaderResults;
33
+ /**
34
+ * 获取 Kawase 模糊着色器代码
35
+ * @param context - 着色器上下文
36
+ * @returns
37
+ */
8
38
  export declare function getKawaseBlurShaderCode(context: PShaderContext): PShaderResults;
39
+ /**
40
+ * 获取简单滤波着色器代码
41
+ * @param context - 着色器上下文
42
+ * @returns
43
+ */
9
44
  export declare function getSimpleFilterShaderCode(context: PShaderContext): PShaderResults;
45
+ /**
46
+ * 获取高斯模糊着色器代码
47
+ * @param context - 着色器上下文
48
+ * @returns
49
+ */
10
50
  export declare function getGaussianBlurShaderCodeV2(context: PShaderContext): PShaderResults;
51
+ /**
52
+ * 获取高斯模糊着色器代码
53
+ * @param context - 着色器上下文
54
+ * @returns
55
+ */
11
56
  export declare function getGaussianBlurShaderCodeV1(context: PShaderContext): PShaderResults;
57
+ /**
58
+ * 获取透明效果着色器代码
59
+ * @param isVertexShader - 是否顶点着色器
60
+ * @returns
61
+ */
12
62
  export declare function getTransparecyBaseShader(isVertexShader: boolean): string;
63
+ /**
64
+ * 获取透明效果滤波着色器代码
65
+ * @param isVertexShader - 是否顶点着色器
66
+ * @returns
67
+ */
13
68
  export declare function getTransparecyFilterShader(isVertexShader: boolean): string;
@@ -31,4 +31,10 @@ export declare class TwoStatesSet<T> {
31
31
  * @param callbackfn - 删除旧元素的回调
32
32
  */
33
33
  forRemovedItem(callbackfn: (value: T) => void): void;
34
+ /**
35
+ * 遍历当前帧所有的元素
36
+ *
37
+ * @param callbackfn - 当前帧元素的回调
38
+ */
39
+ forNowItem(callbackfn: (value: T) => void): void;
34
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-plugin-model",
3
- "version": "1.2.3",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "Galacean Effects player model plugin",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -33,15 +33,15 @@
33
33
  "registry": "https://registry.npmjs.org"
34
34
  },
35
35
  "dependencies": {
36
- "@galacean/effects-helper": "1.2.3"
36
+ "@galacean/effects-helper": "2.0.0-alpha.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@vvfx/resource-detection": "0.4.2-alpha.22",
40
40
  "@types/hammerjs": "^2.0.45",
41
41
  "fpsmeter": "^0.3.1",
42
42
  "hammerjs": "^2.0.8",
43
- "@galacean/effects": "1.2.3",
44
- "@galacean/effects-plugin-editor-gizmo": "1.2.3"
43
+ "@galacean/effects": "2.0.0-alpha.1",
44
+ "@galacean/effects-plugin-editor-gizmo": "2.0.0-alpha.1"
45
45
  },
46
46
  "scripts": {
47
47
  "dev": "vite",
@@ -1,15 +0,0 @@
1
- import type { Transform, Composition } from '@galacean/effects';
2
- import { spec, VFXItem, TimelineComponent } from '@galacean/effects';
3
- import { ModelTreeItem } from './model-tree-item';
4
- import type { ModelItemTree, ModelTreeOptions } from '../index';
5
- export declare class ModelTreeVFXItem extends VFXItem<ModelTreeItem> {
6
- options: ModelTreeOptions;
7
- timeline?: TimelineComponent;
8
- get type(): spec.ItemType;
9
- onConstructed(props: ModelItemTree): void;
10
- onLifetimeBegin(): void;
11
- protected onItemRemoved(composition: Composition, content?: ModelTreeItem | undefined): void;
12
- onItemUpdate(dt: number, lifetime: number): void;
13
- protected doCreateContent(): ModelTreeItem;
14
- getNodeTransform(itemId: string): Transform;
15
- }
@@ -1,28 +0,0 @@
1
- import type { HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, Composition, math } from '@galacean/effects';
2
- import { VFXItem, spec, TimelineComponent } from '@galacean/effects';
3
- import type { ModelItemBounding, ModelItemCamera, ModelItemLight, ModelItemMesh, ModelItemSkybox } from '../index';
4
- import { PCamera, PLight, PSkybox } from '../runtime';
5
- import { PMesh } from '../runtime';
6
- import { Vector3 } from '../runtime/math';
7
- type Euler = math.Euler;
8
- export type ModelItem = PMesh | PCamera | PLight | PSkybox;
9
- export type ModelItemOptions = ModelItemMesh | ModelItemCamera | ModelItemLight | ModelItemSkybox;
10
- export declare class ModelVFXItem extends VFXItem<ModelItem> {
11
- options?: ModelItemOptions;
12
- bounding?: ModelItemBounding;
13
- timeline?: TimelineComponent;
14
- get type(): spec.ItemType;
15
- set type(v: spec.ItemType);
16
- onConstructed(options: ModelItemOptions): void;
17
- handleVisibleChanged(visible: boolean): void;
18
- doCreateContent(composition: Composition): PLight | PMesh | PCamera | PSkybox;
19
- private overwriteSkyboxFromCache;
20
- computeBoundingBox(): ModelItemBounding | undefined;
21
- updateTransform(): void;
22
- setTransform(position?: Vector3, rotation?: Euler): void;
23
- onLifetimeBegin(composition: Composition, content: ModelItem): void;
24
- onItemUpdate(dt: number, lifetime: number): void;
25
- onItemRemoved(composition: Composition, content?: ModelItem): void;
26
- getHitTestParams(force?: boolean): HitTestBoxParams | HitTestSphereParams | HitTestCustomParams | undefined;
27
- }
28
- export {};
@@ -1,230 +0,0 @@
1
- import type { RenderFrame, Mesh, Material, RenderPass, SemanticMap, Renderer, Engine } from '@galacean/effects';
2
- import { math } from '@galacean/effects';
3
- import { Matrix4, Vector2, Box3 } from './math';
4
- import type { PShadowType } from './common';
5
- import type { PMesh, PPrimitive } from './mesh';
6
- import { PMaterialBase } from './material';
7
- import type { PLight } from './light';
8
- import type { PSceneManager, PSceneStates } from './scene';
9
- import { FBOOptions } from '../utility/ri-helper';
10
- import { TwoStatesSet } from '../utility/ts-helper';
11
- type Box3 = math.Box3;
12
- export interface PMaterialShadowBaseOptions {
13
- name: string;
14
- shadowType: PShadowType;
15
- }
16
- export declare class PMaterialShadowBase extends PMaterialBase {
17
- shadowType: PShadowType;
18
- create(options: PMaterialShadowBaseOptions): void;
19
- getShaderFeatures(): string[];
20
- updateUniforms(material: Material): void;
21
- }
22
- export declare class PMaterialShadowBaseTest extends PMaterialBase {
23
- shadowType: PShadowType;
24
- create(options: PMaterialShadowBaseOptions): void;
25
- getShaderFeatures(): string[];
26
- updateUniforms(material: Material): void;
27
- }
28
- export interface PMaterialShadowFilterOptions {
29
- name: string;
30
- blurScale: Vector2;
31
- }
32
- export declare class PMaterialShadowFilter extends PMaterialBase {
33
- blurScale: Vector2;
34
- create(options: PMaterialShadowFilterOptions): void;
35
- getShaderFeatures(): string[];
36
- updateUniforms(material: Material): void;
37
- }
38
- /**
39
- * 阴影初始化选项,包括控制选项和纹理选项
40
- */
41
- export interface PShadowInitOptions {
42
- /**
43
- * 控制相关的参数
44
- */
45
- enable?: boolean;
46
- quality?: 'low' | 'medium' | 'high';
47
- softness?: number;
48
- /**
49
- * 纹理相关的参数
50
- */
51
- width?: number;
52
- height?: number;
53
- type?: GLenum;
54
- format?: GLenum;
55
- filter?: GLenum;
56
- }
57
- /**
58
- * 阴影运行时选项,包括 light 的变换矩阵和柔软度
59
- */
60
- export interface PShadowRuntimeOptions {
61
- viewProjectionMatrix: Matrix4;
62
- softness: number;
63
- }
64
- export declare class PShadowManager {
65
- /**
66
- * 是否启用阴影效果,会根据硬件等情况进行设置
67
- */
68
- enable: boolean;
69
- /**
70
- * 阴影质量参数,一般都用 medium
71
- */
72
- quality: 'low' | 'medium' | 'high';
73
- /**
74
- * 阴影柔软度,范围[0, 2]
75
- */
76
- softness: number;
77
- /**
78
- * 阴影纹理相关参数
79
- */
80
- width: number;
81
- height: number;
82
- type: GLenum;
83
- format: GLenum;
84
- filter: GLenum;
85
- /**
86
- * shadow map 渲染时 FBO
87
- */
88
- baseFBOOpts: FBOOptions;
89
- /**
90
- * shadow map 滤波时 FBO
91
- */
92
- filterFBOOpts: FBOOptions;
93
- /**
94
- * 是否激活运行时阴影
95
- */
96
- runtimeEnable: boolean;
97
- /**
98
- * 启用阴影效果的 Mesh 列表,来自场景中的 Mesh 列表
99
- */
100
- meshList: PMesh[];
101
- /**
102
- * 当前帧启用阴影效果的 Primitive 列表,来自上面的 Mesh 列表
103
- */
104
- primitiveList: PPrimitive[];
105
- viewAABB: Box3;
106
- sceneAABB: Box3;
107
- shadowAABB: Box3;
108
- shadowLight?: PLight;
109
- lightView: Matrix4;
110
- lightProjection: Matrix4;
111
- lightViewProjection: Matrix4;
112
- renderer?: Renderer;
113
- sceneManager: PSceneManager;
114
- xFilterMaterial: PMaterialShadowFilter;
115
- yFilterMaterial: PMaterialShadowFilter;
116
- basePass?: RenderPass;
117
- xFilterPass?: RenderPass;
118
- yFilterPass?: RenderPass;
119
- /**
120
- * Primitive 与 RenderPass 的前一帧与当前帧状态缓存
121
- */
122
- meshCacheSet: TwoStatesSet<Mesh>;
123
- renderPassCacheSet: TwoStatesSet<RenderPass>;
124
- engine: Engine;
125
- constructor();
126
- initial(sceneManager: PSceneManager, options?: PShadowInitOptions): void;
127
- build(): void;
128
- tick(sceneStates: PSceneStates): void;
129
- /**
130
- * 更新当前阴影物体的包围盒数据
131
- * TODO: 需要注意动画物体的包围盒更新
132
- */
133
- private updateAABBInfo;
134
- private updateLightViewProjection;
135
- private updateDirectionalLightViewProjection;
136
- private updateSpotLightViewProjection;
137
- private getShadowOptions;
138
- private updateShadowUniforms;
139
- private getShadowLight;
140
- /**
141
- * 统计场景中启用阴影的 Primitive 数目
142
- *
143
- * @param sceneManager - Model 场景的场景管理器
144
- * @returns 启用阴影的 Primitve 数目
145
- */
146
- private getShadowPrimitiveCount;
147
- /**
148
- * 更新阴影渲染时 Pass 中渲染的对象,注意阴影有 3 个渲染 Pass
149
- * 开始时 Frame 中没有阴影 Pass,会先添加阴影 Pass
150
- *
151
- * @param frame - RI 帧对象
152
- */
153
- updateRenderPass(frame: RenderFrame): void;
154
- updateFrameSemantics(map: SemanticMap, addSemantic: boolean): void;
155
- /**
156
- * 是否启用了阴影效果
157
- * 是否有需要启用阴影效果的物体,以及当前硬件是否支持启用阴影效果
158
- * @return 是否启用
159
- */
160
- isEnable(): boolean;
161
- /**
162
- * 是否有需要渲染的对象,需要先启用阴影
163
- * @return 是否有渲染对象
164
- */
165
- hasRenderObject(): boolean;
166
- /**
167
- * 在当前 PMesh 列表中,查找需要在阴影 Pass 中渲染的 Primitive
168
- *
169
- * @returns 当前阴影 Pass 要渲染的 Primitive 列表
170
- */
171
- getCurrentPrimitiveList(): PPrimitive[];
172
- isSupportTextureOptions(): boolean;
173
- /**
174
- * 根据当前阴影参数生成 BasePass 的 FBO 对象
175
- *
176
- * @returns BasePass 的 FBO 对象
177
- */
178
- getBaseFBOOptions(): FBOOptions;
179
- /**
180
- * 根据当前阴影参数生成 FilterPass 的 FBO 对象
181
- *
182
- * @returns FilterPass 的 FBO 对象
183
- */
184
- getFilterFBOOptions(): FBOOptions;
185
- /**
186
- * 返回 softness 值,并检查是否在指定范围内
187
- *
188
- * @param options - 阴影相关的初始化参数
189
- * @returns 阴影柔软度值
190
- */
191
- getSoftness(options?: PShadowInitOptions): number;
192
- /**
193
- * 返回贴图大小,并检查是否在指定范围内
194
- *
195
- * @param options - 阴影相关的初始化参数
196
- * @returns 阴影贴图大小
197
- */
198
- getTextureSize(options?: PShadowInitOptions): [number, number];
199
- /**
200
- * 返回纹理类型,并检查是否指定类型
201
- *
202
- * @param options - 阴影相关的初始化参数
203
- * @returns 纹理类型
204
- */
205
- getTextureType(options?: PShadowInitOptions): GLenum;
206
- /**
207
- * 返回纹理格式,并检查是否指定格式
208
- *
209
- * @param options - 阴影相关的初始化参数
210
- * @returns 纹理格式
211
- */
212
- getTextureFormat(options?: PShadowInitOptions): GLenum;
213
- /**
214
- * 返回纹理滤波格式,并检查是否指定滤波格式
215
- *
216
- * @param options - 阴影相关的初始化参数
217
- * @returns 纹理滤波格式
218
- */
219
- getTextureFilter(options?: PShadowInitOptions): GLenum;
220
- get mainPassUniformSemantics(): {
221
- u_ShadowSampler: string;
222
- };
223
- get basePassName(): string;
224
- get xFilterPassName(): string;
225
- get yFilterPassName(): string;
226
- get xFilterMeshName(): string;
227
- get yFilterMeshName(): string;
228
- get shadowPassList(): RenderPass[];
229
- }
230
- export {};