@galacean/effects-plugin-model 0.0.1-alpha.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 +26 -0
- package/dist/gesture/controller.d.ts +95 -0
- package/dist/gesture/index.d.ts +38 -0
- package/dist/gesture/protocol.d.ts +143 -0
- package/dist/gltf/index.d.ts +3 -0
- package/dist/gltf/loader-ext.d.ts +53 -0
- package/dist/gltf/loader-helper.d.ts +18 -0
- package/dist/gltf/loader-impl.d.ts +84 -0
- package/dist/gltf/protocol.d.ts +90 -0
- package/dist/helper/index.d.ts +2 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +16137 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +9 -0
- package/dist/index.min.js.map +1 -0
- package/dist/index.mjs +16048 -0
- package/dist/index.mjs.map +1 -0
- package/dist/loader.d.ts +2 -0
- package/dist/loader.mjs +12040 -0
- package/dist/loader.mjs.map +1 -0
- package/dist/math/box3.d.ts +140 -0
- package/dist/math/euler.d.ts +139 -0
- package/dist/math/index.d.ts +11 -0
- package/dist/math/matrix2.d.ts +58 -0
- package/dist/math/matrix3.d.ts +113 -0
- package/dist/math/matrix4.d.ts +264 -0
- package/dist/math/quaternion.d.ts +214 -0
- package/dist/math/sphere.d.ts +81 -0
- package/dist/math/type.d.ts +29 -0
- package/dist/math/utilities/index.d.ts +9 -0
- package/dist/math/vector2.d.ts +394 -0
- package/dist/math/vector3.d.ts +164 -0
- package/dist/math/vector4.d.ts +132 -0
- package/dist/plugin/const.d.ts +2 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/model-plugin.d.ts +48 -0
- package/dist/plugin/model-tree-item.d.ts +30 -0
- package/dist/plugin/model-tree-plugin.d.ts +13 -0
- package/dist/plugin/model-tree-vfx-item.d.ts +15 -0
- package/dist/plugin/model-vfx-item.d.ts +25 -0
- package/dist/runtime/anim-sampler.d.ts +13 -0
- package/dist/runtime/animation.d.ts +189 -0
- package/dist/runtime/cache.d.ts +34 -0
- package/dist/runtime/camera.d.ts +43 -0
- package/dist/runtime/common.d.ts +113 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/light.d.ts +34 -0
- package/dist/runtime/material.d.ts +101 -0
- package/dist/runtime/mesh.d.ts +145 -0
- package/dist/runtime/object.d.ts +44 -0
- package/dist/runtime/scene.d.ts +131 -0
- package/dist/runtime/shader-libs/standard-shader-source.d.ts +3 -0
- package/dist/runtime/shader-libs/standard-shader.d.ts +6 -0
- package/dist/runtime/shader.d.ts +18 -0
- package/dist/runtime/shadow.d.ts +227 -0
- package/dist/runtime/skybox.d.ts +91 -0
- package/dist/utility/debug-helper.d.ts +7 -0
- package/dist/utility/hit-test-helper.d.ts +9 -0
- package/dist/utility/index.d.ts +6 -0
- package/dist/utility/plugin-helper.d.ts +197 -0
- package/dist/utility/ri-helper.d.ts +25 -0
- package/dist/utility/shader-helper.d.ts +13 -0
- package/dist/utility/ts-helper.d.ts +34 -0
- package/package.json +56 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Scene, SceneLoadOptions, Composition, RenderFrame, VFXItem } from '@galacean/effects';
|
|
2
|
+
import { AbstractPlugin } from '@galacean/effects';
|
|
3
|
+
export declare class ModelPlugin extends AbstractPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
deltaTime: number;
|
|
6
|
+
private runtimeEnv;
|
|
7
|
+
private compatibleMode;
|
|
8
|
+
private renderSkybox;
|
|
9
|
+
private visBoundingBox;
|
|
10
|
+
private autoAdjustScene;
|
|
11
|
+
/**
|
|
12
|
+
* 渲染插件是否启用动态排序功能
|
|
13
|
+
* 支持在渲染的时候对透明 Mesh 进行动态排序
|
|
14
|
+
*/
|
|
15
|
+
private enableDynamicSort;
|
|
16
|
+
/**
|
|
17
|
+
* 3D 渲染模式,支持可视化渲染中间结果
|
|
18
|
+
* none 表示正常的渲染结果
|
|
19
|
+
*/
|
|
20
|
+
private renderMode3D;
|
|
21
|
+
/**
|
|
22
|
+
* UV 渲染模式中,指定棋盘格的大小,相对于大小为 1 的纹理
|
|
23
|
+
* 取值范围(0, 1)
|
|
24
|
+
*/
|
|
25
|
+
private renderMode3DUVGridSize;
|
|
26
|
+
static prepareResource(scene: Scene, options: SceneLoadOptions): Promise<void>;
|
|
27
|
+
onCompositionConstructed(composition: Composition, scene: Scene): void;
|
|
28
|
+
onCompositionWillReset(composition: Composition, renderFrame: RenderFrame): void;
|
|
29
|
+
onCompositionReset(composition: Composition, renderFrame: RenderFrame): void;
|
|
30
|
+
onCompositionDestroyed(composition: Composition): void;
|
|
31
|
+
onCompositionUpdate(composition: Composition, dt: number): void;
|
|
32
|
+
onCompositionItemLifeBegin(composition: Composition, item: VFXItem<any>): void;
|
|
33
|
+
onCompositionItemRemoved(composition: Composition, item: VFXItem<any>): void;
|
|
34
|
+
prepareRenderFrame(composition: Composition, frame: RenderFrame): boolean;
|
|
35
|
+
postProcessFrame(composition: Composition, frame: RenderFrame): void;
|
|
36
|
+
private getLightItemCount;
|
|
37
|
+
/**
|
|
38
|
+
* 更新 SceneManager 中渲染用的相机,相机参数来自 composition.camera
|
|
39
|
+
*
|
|
40
|
+
* @param composition - 当前合成对象
|
|
41
|
+
* @param sceneManager - 当前合成对象绑定的 SceneManager
|
|
42
|
+
*/
|
|
43
|
+
private updateSceneCamera;
|
|
44
|
+
private getSceneManager;
|
|
45
|
+
private getCache;
|
|
46
|
+
private disposeCache;
|
|
47
|
+
private disposeSceneManager;
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Transform } from '@galacean/effects';
|
|
2
|
+
import { PAnimationManager } from '../runtime';
|
|
3
|
+
import type { ModelTreeVFXItem } from './model-tree-vfx-item';
|
|
4
|
+
import type { MarsTreeOptions } from '../index';
|
|
5
|
+
export interface ModelTreeNode {
|
|
6
|
+
name?: string;
|
|
7
|
+
transform: Transform;
|
|
8
|
+
children: ModelTreeNode[];
|
|
9
|
+
id: string;
|
|
10
|
+
tree: ModelTreeItem;
|
|
11
|
+
}
|
|
12
|
+
export declare class ModelTreeItem {
|
|
13
|
+
private allNodes;
|
|
14
|
+
private nodes;
|
|
15
|
+
private cacheMap;
|
|
16
|
+
readonly baseTransform: Transform;
|
|
17
|
+
animationManager: PAnimationManager;
|
|
18
|
+
constructor(props: MarsTreeOptions, owner: ModelTreeVFXItem);
|
|
19
|
+
tick(dt: number): void;
|
|
20
|
+
getNodes(): ModelTreeNode[];
|
|
21
|
+
getNodeById(nodeId: string | number): ModelTreeNode | undefined;
|
|
22
|
+
getNodeByName(name: string): ModelTreeNode | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* if node id not found,use tree.transform
|
|
25
|
+
* @param nodeId
|
|
26
|
+
*/
|
|
27
|
+
getNodeTransform(nodeId: string): Transform;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
private build;
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Scene, Composition, RenderFrame, VFXItem } from '@galacean/effects';
|
|
2
|
+
import { AbstractPlugin } from '@galacean/effects';
|
|
3
|
+
import type { ModelTreeItem } from './model-tree-item';
|
|
4
|
+
export declare class ModelTreePlugin extends AbstractPlugin {
|
|
5
|
+
name: string;
|
|
6
|
+
order: number;
|
|
7
|
+
onCompositionConstructed(composition: Composition, scene: Scene): void;
|
|
8
|
+
onCompositionWillReset(composition: Composition, renderFrame: RenderFrame): void;
|
|
9
|
+
onCompositionDestroyed(composition: Composition): void;
|
|
10
|
+
onCompositionItemLifeBegin(composition: Composition, item: VFXItem<ModelTreeItem>): void;
|
|
11
|
+
onCompositionItemRemoved(composition: Composition, item: VFXItem<ModelTreeItem>): void;
|
|
12
|
+
private getAnimationSystem;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { spec, Transform, Composition } from '@galacean/effects';
|
|
2
|
+
import { VFXItem, TimelineComponent } from '@galacean/effects';
|
|
3
|
+
import { ModelTreeItem } from './model-tree-item';
|
|
4
|
+
import type { MarsItemTree, MarsTreeOptions } from '../index';
|
|
5
|
+
export declare class ModelTreeVFXItem extends VFXItem<ModelTreeItem> {
|
|
6
|
+
options: MarsTreeOptions;
|
|
7
|
+
timeline?: TimelineComponent;
|
|
8
|
+
get type(): spec.ItemType;
|
|
9
|
+
onConstructed(props: MarsItemTree): 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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, Composition } from '@galacean/effects';
|
|
2
|
+
import { VFXItem, spec, TimelineComponent } from '@galacean/effects';
|
|
3
|
+
import type { MarsItemBounding, MarsItemCamera, MarsItemLight, MarsItemMesh, MarsItemSkybox } from '../index';
|
|
4
|
+
import { PCamera, PLight, PSkybox } from '../runtime';
|
|
5
|
+
import { PMesh } from '../runtime';
|
|
6
|
+
export type ModelItem = PMesh | PCamera | PLight | PSkybox;
|
|
7
|
+
export type ModelItemOptions = MarsItemMesh | MarsItemCamera | MarsItemLight | MarsItemSkybox;
|
|
8
|
+
export declare class ModelVFXItem extends VFXItem<ModelItem> {
|
|
9
|
+
options?: ModelItemOptions;
|
|
10
|
+
bounding?: MarsItemBounding;
|
|
11
|
+
timeline?: TimelineComponent;
|
|
12
|
+
get type(): spec.ItemType;
|
|
13
|
+
set type(v: spec.ItemType);
|
|
14
|
+
onConstructed(options: ModelItemOptions): void;
|
|
15
|
+
handleVisibleChanged(visible: boolean): void;
|
|
16
|
+
doCreateContent(composition: Composition): PLight | PMesh | PCamera | PSkybox;
|
|
17
|
+
private overwriteSkyboxFromCache;
|
|
18
|
+
computeBoundingBox(): MarsItemBounding | undefined;
|
|
19
|
+
updateTransform(): void;
|
|
20
|
+
updateTransformPosition(x: number, y: number, z: number): void;
|
|
21
|
+
onLifetimeBegin(composition: Composition, content: ModelItem): void;
|
|
22
|
+
onItemUpdate(dt: number, lifetime: number): void;
|
|
23
|
+
onItemRemoved(composition: Composition, content?: ModelItem): void;
|
|
24
|
+
getHitTestParams(force?: boolean): HitTestBoxParams | HitTestSphereParams | HitTestCustomParams | undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare abstract class InterpolationSampler {
|
|
2
|
+
protected time: Float32Array;
|
|
3
|
+
protected data: Float32Array;
|
|
4
|
+
protected componentCount: number;
|
|
5
|
+
protected cachedIndex: number;
|
|
6
|
+
constructor(time: Float32Array, data: Float32Array, componentCount: number);
|
|
7
|
+
evaluate(t: number): Float32Array;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
protected copySampleValue(index: number): Float32Array;
|
|
10
|
+
protected abstract intervalChanged(i1: number, t0: number, t1: number): void;
|
|
11
|
+
protected abstract interpolate(i1: number, t0: number, t: number, t1: number): Float32Array;
|
|
12
|
+
}
|
|
13
|
+
export declare function createAnimationSampler(type: string, times: Float32Array, data: Float32Array, size: number, path?: string): InterpolationSampler;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Geometry, Engine } from '@galacean/effects';
|
|
2
|
+
import { Texture } from '@galacean/effects';
|
|
3
|
+
import type { MarsSkinOptions, MarsAnimTrackOptions, MarsAnimationOptions, MarsTreeOptions } from '../index';
|
|
4
|
+
import { Matrix4 } from '../math';
|
|
5
|
+
import { PObject } from './object';
|
|
6
|
+
import type { PSceneManager } from './scene';
|
|
7
|
+
import type { ModelTreeVFXItem } from '../plugin';
|
|
8
|
+
export declare enum TextureDataMode {
|
|
9
|
+
none = 0,
|
|
10
|
+
float = 1,
|
|
11
|
+
half_float = 2
|
|
12
|
+
}
|
|
13
|
+
export declare class PSkin extends PObject {
|
|
14
|
+
parentItem?: ModelTreeVFXItem;
|
|
15
|
+
skeleton: number;
|
|
16
|
+
jointList: number[];
|
|
17
|
+
inverseBindMatrices: Matrix4[];
|
|
18
|
+
animationMatrices: Matrix4[];
|
|
19
|
+
textureDataMode: TextureDataMode;
|
|
20
|
+
create(options: MarsSkinOptions, engine: Engine, parentItem?: ModelTreeVFXItem): void;
|
|
21
|
+
updateSkinMatrices(): void;
|
|
22
|
+
computeMeshAnimMatrices(worldMatrix: Matrix4, matrixList: Float32Array, normalMatList: Float32Array): void;
|
|
23
|
+
updateParentItem(parentItem: ModelTreeVFXItem): void;
|
|
24
|
+
getJointCount(): number;
|
|
25
|
+
isTextureDataMode(): boolean;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
private getTextureDataMode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Morph 动画状态:
|
|
31
|
+
* 保存了动画状态相关的数据,包括 weights 数组数据
|
|
32
|
+
* 增加了状态数据的检查,保证数据的正确性
|
|
33
|
+
* Morph 动画非常消耗内存,谨慎使用。
|
|
34
|
+
*/
|
|
35
|
+
export declare class PMorph extends PObject {
|
|
36
|
+
/**
|
|
37
|
+
* weights 数组的长度,shader 中和更新的时候会用到
|
|
38
|
+
* 范围要在 `[0, 8]` 之间,否则会报错。
|
|
39
|
+
*/
|
|
40
|
+
morphWeightsLength: number;
|
|
41
|
+
/**
|
|
42
|
+
* weights 数组的具体数据,来自动画控制器的每帧更新
|
|
43
|
+
* 数组的长度必须和 morphWeightsLength 相同,否则会出错。
|
|
44
|
+
*/
|
|
45
|
+
morphWeightsArray?: Float32Array;
|
|
46
|
+
/**
|
|
47
|
+
* 是否有 Position 相关的 Morph 动画,shader 中需要知道
|
|
48
|
+
*/
|
|
49
|
+
hasPositionMorph: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 是否有 Normal 相关的 Morph 动画,shader 中需要知道
|
|
52
|
+
*/
|
|
53
|
+
hasNormalMorph: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 是否有 Tangent 相关的 Morph 动画,shader 中需要知道
|
|
56
|
+
*/
|
|
57
|
+
hasTangentMorph: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 通过 Mars 的 Geometry 数据创建 Morph 动画相关状态,并进行必要的正确性检查
|
|
60
|
+
*
|
|
61
|
+
* @param geometry - Mesh 的几何对象,是否包含 Morph 动画都是可以的
|
|
62
|
+
*/
|
|
63
|
+
create(geometry: Geometry): boolean;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
/**
|
|
66
|
+
* 初始化 Morph target 的权重数组
|
|
67
|
+
*
|
|
68
|
+
* @param weights - glTF Mesh 的权重数组,长度必须严格一致
|
|
69
|
+
*/
|
|
70
|
+
initWeights(weights: number[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* 当前状态是否有 Morph 动画:
|
|
73
|
+
* 需要判断 weights 数组长度,以及 Position、Normal 和 Tangent 是否有动画
|
|
74
|
+
*
|
|
75
|
+
* @returns 返回是否有 Morph 动画
|
|
76
|
+
*/
|
|
77
|
+
hasMorph(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 两个 Morph 动画状态是否相等:
|
|
80
|
+
* 这里只比较初始状态是否一样,不考虑 weights 数组的情况,提供给 Mesh 进行 Geometry 检查使用
|
|
81
|
+
*
|
|
82
|
+
* @param morph - Morph 动画状态对象
|
|
83
|
+
* @returns 返回两个 Morph 动画状态是否相等
|
|
84
|
+
*/
|
|
85
|
+
equals(morph: PMorph): boolean;
|
|
86
|
+
getMorphWeightsArray(): Float32Array;
|
|
87
|
+
/**
|
|
88
|
+
* 统计 Geometry 中 Attribute 名称个数:
|
|
89
|
+
* 主要用于统计 Morph 动画中新增的 Attribute 名称的个数,会作为最终的 weights 数组长度使用
|
|
90
|
+
*
|
|
91
|
+
* @param attributeNameList - Attribute 名数组列表,只与 Morph Target 中的属性有关
|
|
92
|
+
* @param geometry - Mars 的 Geometry 对象,是否有 Morph 动画都可以
|
|
93
|
+
* @returns 存在的 Attribute 名称数目
|
|
94
|
+
*/
|
|
95
|
+
getAttributeMorphCount(attributeNameList: string[], geometry: Geometry): number;
|
|
96
|
+
/**
|
|
97
|
+
* Morph 动画中 Position 相关的 Attribute 名称
|
|
98
|
+
*/
|
|
99
|
+
private static positionNameList;
|
|
100
|
+
/**
|
|
101
|
+
* Morph 动画中 Normal 相关的 Attribute 名称
|
|
102
|
+
*/
|
|
103
|
+
private static normalNameList;
|
|
104
|
+
/**
|
|
105
|
+
* Morph 动画中 Tangent 相关的 Attribute 名称
|
|
106
|
+
*/
|
|
107
|
+
private static tangentNameList;
|
|
108
|
+
}
|
|
109
|
+
export declare enum PAnimInterpType {
|
|
110
|
+
linear = 0,
|
|
111
|
+
step = 1,
|
|
112
|
+
cubicSpline = 2
|
|
113
|
+
}
|
|
114
|
+
export declare enum PAnimPathType {
|
|
115
|
+
translation = 0,
|
|
116
|
+
rotation = 1,
|
|
117
|
+
scale = 2,
|
|
118
|
+
weights = 3
|
|
119
|
+
}
|
|
120
|
+
export declare class PAnimTrack {
|
|
121
|
+
node: number;
|
|
122
|
+
timeArray: Float32Array;
|
|
123
|
+
dataArray: Float32Array;
|
|
124
|
+
path: PAnimPathType;
|
|
125
|
+
interp: PAnimInterpType;
|
|
126
|
+
component: number;
|
|
127
|
+
private sampler?;
|
|
128
|
+
constructor(options: MarsAnimTrackOptions);
|
|
129
|
+
dispose(): void;
|
|
130
|
+
tick(time: number, treeItem: ModelTreeVFXItem, sceneManager?: PSceneManager): void;
|
|
131
|
+
getEndTime(): number;
|
|
132
|
+
/**
|
|
133
|
+
* 生成 Mesh 元素的父节点
|
|
134
|
+
* 为 Mesh 元素生成 Mars 中的父节点,这里是和燃燃确定的生成方式
|
|
135
|
+
*
|
|
136
|
+
* @param parentId - 父节点 id 名称
|
|
137
|
+
* @param nodeIndex - Mesh 节点索引
|
|
138
|
+
*
|
|
139
|
+
* @returns 生成的 Mesh 节点名称
|
|
140
|
+
*/
|
|
141
|
+
private genParentId;
|
|
142
|
+
private getPathInfo;
|
|
143
|
+
private getInterpInfo;
|
|
144
|
+
}
|
|
145
|
+
export declare class PAnimTexture {
|
|
146
|
+
private engine;
|
|
147
|
+
private isHalfFloat;
|
|
148
|
+
private width;
|
|
149
|
+
private height;
|
|
150
|
+
private buffer?;
|
|
151
|
+
private texture?;
|
|
152
|
+
constructor(engine: Engine);
|
|
153
|
+
create(jointCount: number, isHalfFloat: boolean, name: string): void;
|
|
154
|
+
update(buffer: Float32Array): void;
|
|
155
|
+
dispose(): void;
|
|
156
|
+
getSize(): number;
|
|
157
|
+
getTexture(): Texture;
|
|
158
|
+
}
|
|
159
|
+
export declare class PAnimation extends PObject {
|
|
160
|
+
private time;
|
|
161
|
+
private duration;
|
|
162
|
+
private tracks;
|
|
163
|
+
create(options: MarsAnimationOptions): void;
|
|
164
|
+
tick(time: number, treeItem: ModelTreeVFXItem, sceneManager?: PSceneManager): void;
|
|
165
|
+
dispose(): void;
|
|
166
|
+
}
|
|
167
|
+
export declare class PAnimationManager extends PObject {
|
|
168
|
+
private ownerItem;
|
|
169
|
+
private animation;
|
|
170
|
+
private speed;
|
|
171
|
+
private delay;
|
|
172
|
+
private time;
|
|
173
|
+
private animations;
|
|
174
|
+
private sceneManager;
|
|
175
|
+
constructor(treeOptions: MarsTreeOptions, ownerItem: ModelTreeVFXItem);
|
|
176
|
+
createAnimation(animationOpts: MarsAnimationOptions): PAnimation;
|
|
177
|
+
tick(deltaSeconds: number): void;
|
|
178
|
+
dispose(): void;
|
|
179
|
+
getTreeItem(): ModelTreeVFXItem;
|
|
180
|
+
}
|
|
181
|
+
export declare class PAnimationSystem {
|
|
182
|
+
private engine;
|
|
183
|
+
private managers;
|
|
184
|
+
constructor(engine: Engine);
|
|
185
|
+
create(treeItems: ModelTreeVFXItem[]): void;
|
|
186
|
+
insert(animationManager: PAnimationManager): void;
|
|
187
|
+
delete(animationManager: PAnimationManager): void;
|
|
188
|
+
dispose(): void;
|
|
189
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Mesh, Geometry, TextureSourceOptions, RenderPass, spec, Engine } from '@galacean/effects';
|
|
2
|
+
import { Texture } from '@galacean/effects';
|
|
3
|
+
import type { MarsSkyboxOptions } from '../index';
|
|
4
|
+
import type { FBOOptions } from '../utility/ri-helper';
|
|
5
|
+
import type { PMaterialBase } from './material';
|
|
6
|
+
import type { PSkyboxParams } from './skybox';
|
|
7
|
+
export declare class CompositionCache {
|
|
8
|
+
private engine;
|
|
9
|
+
private loadSkybox;
|
|
10
|
+
private brdfLutTexture?;
|
|
11
|
+
private meshCache;
|
|
12
|
+
private textureCache;
|
|
13
|
+
private geometryCache;
|
|
14
|
+
private renderPassCache;
|
|
15
|
+
private static brdfLutTexOptions?;
|
|
16
|
+
private static skyboxOptions?;
|
|
17
|
+
static loadStaticResources(): Promise<void>;
|
|
18
|
+
static genSkyboxOptions(engine: Engine, params?: PSkyboxParams): Promise<MarsSkyboxOptions>;
|
|
19
|
+
constructor(engine: Engine);
|
|
20
|
+
setup(loadSkybox: boolean): void;
|
|
21
|
+
getTexture(name: string): Texture | undefined;
|
|
22
|
+
setTexture(name: string, tex: Texture): void;
|
|
23
|
+
getOrCreateTexture(name: string, options: TextureSourceOptions): Texture;
|
|
24
|
+
deleteTexture(name: string): boolean;
|
|
25
|
+
getOrCreateGeometry(name: string, geomJson: spec.GeometryOptionsJSON, bins: ArrayBuffer[]): Geometry;
|
|
26
|
+
getFilterMesh(name: string, material: PMaterialBase, uniformSemantics: Record<string, any>): Mesh;
|
|
27
|
+
getShadowBasePass(name: string, priority: number, meshList: Mesh[], fboOptions: FBOOptions): RenderPass;
|
|
28
|
+
getShadowFilterPass(name: string, priority: number, meshList: Mesh[], fboOptions: FBOOptions): RenderPass;
|
|
29
|
+
getRenderPass(name: string, priority: number, meshList: Mesh[], fboOptions: FBOOptions): RenderPass;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
getRenderPasses(): RenderPass[];
|
|
32
|
+
getBrdfLutTexture(): Texture | undefined;
|
|
33
|
+
getSkyboxOptions(): MarsSkyboxOptions | undefined;
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { spec } from '@galacean/effects';
|
|
2
|
+
import type { ModelVFXItem } from '../plugin/model-vfx-item';
|
|
3
|
+
import type { MarsItemCamera } from '../index';
|
|
4
|
+
import type { Quaternion, Box3 } from '../math';
|
|
5
|
+
import { Vector2, Vector3, Matrix4 } from '../math';
|
|
6
|
+
import { PEntity } from './object';
|
|
7
|
+
export declare class PCamera extends PEntity {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
nearPlane: number;
|
|
11
|
+
farPlane: number;
|
|
12
|
+
fovy: number;
|
|
13
|
+
aspect: number;
|
|
14
|
+
clipMode: spec.CameraClipMode;
|
|
15
|
+
projectionMatrix: Matrix4;
|
|
16
|
+
viewMatrix: Matrix4;
|
|
17
|
+
constructor(camera: MarsItemCamera, width: number, height: number, ownerItem?: ModelVFXItem);
|
|
18
|
+
update(): void;
|
|
19
|
+
getNewProjectionMatrix(fov: number): Matrix4;
|
|
20
|
+
computeViewAABB(box: Box3): Box3;
|
|
21
|
+
getSize(): Vector2;
|
|
22
|
+
isReversed(): boolean;
|
|
23
|
+
getEye(): Vector3;
|
|
24
|
+
setEye(val: Vector3): void;
|
|
25
|
+
}
|
|
26
|
+
export declare class PCameraManager {
|
|
27
|
+
private winWidth;
|
|
28
|
+
private winHeight;
|
|
29
|
+
private cameraList;
|
|
30
|
+
private defaultCamera;
|
|
31
|
+
constructor();
|
|
32
|
+
initial(width: number, height: number): void;
|
|
33
|
+
insert(inCamera: MarsItemCamera, ownerItem?: ModelVFXItem): PCamera;
|
|
34
|
+
insertCamera(camera: PCamera): void;
|
|
35
|
+
remove(camera: PCamera | number): void;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
updateDefaultCamera(fovy: number, nearPlane: number, farPlane: number, position: spec.vec3, rotation: Quaternion, clipMode: number): void;
|
|
38
|
+
getCameraList(): PCamera[];
|
|
39
|
+
getDefaultCamera(): PCamera;
|
|
40
|
+
getCameraCount(): number;
|
|
41
|
+
getActiveCamera(): PCamera;
|
|
42
|
+
getAspect(): number;
|
|
43
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Transform as MarsTransform, spec } from '@galacean/effects';
|
|
2
|
+
import { Quaternion, Euler, Vector3, Matrix4 } from '../math';
|
|
3
|
+
import type { BaseTransform } from '../index';
|
|
4
|
+
export declare enum PObjectType {
|
|
5
|
+
none = 0,
|
|
6
|
+
mesh = 1,
|
|
7
|
+
texture = 2,
|
|
8
|
+
material = 3,
|
|
9
|
+
light = 4,
|
|
10
|
+
camera = 5,
|
|
11
|
+
skybox = 6,
|
|
12
|
+
skin = 7,
|
|
13
|
+
morph = 8,
|
|
14
|
+
skeleton = 9,
|
|
15
|
+
animation = 10,
|
|
16
|
+
animationManager = 11,
|
|
17
|
+
reference = 12
|
|
18
|
+
}
|
|
19
|
+
export declare enum PLightType {
|
|
20
|
+
directional = 0,
|
|
21
|
+
point = 1,
|
|
22
|
+
spot = 2,
|
|
23
|
+
ambient = 3
|
|
24
|
+
}
|
|
25
|
+
export declare enum PTextureType {
|
|
26
|
+
none = 0,
|
|
27
|
+
t2d = 1,
|
|
28
|
+
t3d = 2,
|
|
29
|
+
cube = 3
|
|
30
|
+
}
|
|
31
|
+
export declare enum PMaterialType {
|
|
32
|
+
none = 0,
|
|
33
|
+
unlit = 1,
|
|
34
|
+
pbr = 2,
|
|
35
|
+
normalVis = 3,
|
|
36
|
+
simpleFilter = 4,
|
|
37
|
+
shadowBase = 5,
|
|
38
|
+
shadowFilter = 6,
|
|
39
|
+
skyboxFilter = 7
|
|
40
|
+
}
|
|
41
|
+
export declare enum PBlendMode {
|
|
42
|
+
opaque = 0,
|
|
43
|
+
masked = 1,
|
|
44
|
+
translucent = 2,
|
|
45
|
+
additive = 3
|
|
46
|
+
}
|
|
47
|
+
export declare enum PFaceSideMode {
|
|
48
|
+
both = 0,
|
|
49
|
+
front = 1,
|
|
50
|
+
back = 2
|
|
51
|
+
}
|
|
52
|
+
export declare enum PShadowType {
|
|
53
|
+
none = 0,
|
|
54
|
+
standard = 1,
|
|
55
|
+
variance = 2,
|
|
56
|
+
expVariance = 3
|
|
57
|
+
}
|
|
58
|
+
export declare class PTransform {
|
|
59
|
+
private translation;
|
|
60
|
+
private rotation;
|
|
61
|
+
private scale;
|
|
62
|
+
fromMatrix4(matrix: Matrix4): this;
|
|
63
|
+
fromMarsTransform(trans: MarsTransform | BaseTransform): this;
|
|
64
|
+
toMarsTransform(transform: MarsTransform): MarsTransform;
|
|
65
|
+
fromBaseTransform(trans: BaseTransform): this;
|
|
66
|
+
getTranslation(): Vector3;
|
|
67
|
+
setTranslation(val: Vector3 | spec.vec3): void;
|
|
68
|
+
getPosition(): Vector3;
|
|
69
|
+
setPosition(val: Vector3 | spec.vec3): void;
|
|
70
|
+
getRotation(): Quaternion;
|
|
71
|
+
setRotation(val: Quaternion | Euler | Vector3 | spec.vec4 | spec.vec3): void;
|
|
72
|
+
getScale(): Vector3;
|
|
73
|
+
setScale(val: Vector3 | spec.vec3): void;
|
|
74
|
+
getMatrix(): Matrix4;
|
|
75
|
+
setMatrix(mat: Matrix4 | spec.mat4): void;
|
|
76
|
+
}
|
|
77
|
+
export declare class PCoordinate {
|
|
78
|
+
origin: Vector3;
|
|
79
|
+
xAxis: Vector3;
|
|
80
|
+
yAxis: Vector3;
|
|
81
|
+
zAxis: Vector3;
|
|
82
|
+
constructor();
|
|
83
|
+
fromPTransform(trans: PTransform, inverse?: boolean): this;
|
|
84
|
+
fromRotationMatrix(matrix: Matrix4): void;
|
|
85
|
+
}
|
|
86
|
+
export declare class PGlobalState {
|
|
87
|
+
isWebGL2: boolean;
|
|
88
|
+
shaderShared: boolean;
|
|
89
|
+
runtimeEnv: string;
|
|
90
|
+
compatibleMode: string;
|
|
91
|
+
visBoundingBox: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 渲染输出结果模式,可以换中间渲染数据
|
|
94
|
+
*/
|
|
95
|
+
renderMode3D: spec.RenderMode3D;
|
|
96
|
+
/**
|
|
97
|
+
* UV结果输出时,棋盘格的大小控制,范围(0, 1)
|
|
98
|
+
*/
|
|
99
|
+
renderMode3DUVGridSize: number;
|
|
100
|
+
private static instance;
|
|
101
|
+
static getInstance(): PGlobalState;
|
|
102
|
+
private constructor();
|
|
103
|
+
reset(): void;
|
|
104
|
+
/**
|
|
105
|
+
* 是否可视化渲染中间结果
|
|
106
|
+
*/
|
|
107
|
+
hasRenderMode3D(): boolean;
|
|
108
|
+
get isEditorEnv(): boolean;
|
|
109
|
+
get isDeviceEnv(): boolean;
|
|
110
|
+
get isTiny3dMode(): boolean;
|
|
111
|
+
get isOasisMode(): boolean;
|
|
112
|
+
get isGLTFMode(): boolean;
|
|
113
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './anim-sampler';
|
|
2
|
+
export * from './animation';
|
|
3
|
+
export * from './cache';
|
|
4
|
+
export * from './camera';
|
|
5
|
+
export * from './common';
|
|
6
|
+
export * from './light';
|
|
7
|
+
export * from './material';
|
|
8
|
+
export * from './mesh';
|
|
9
|
+
export * from './object';
|
|
10
|
+
export * from './scene';
|
|
11
|
+
export * from './shader';
|
|
12
|
+
export * from './skybox';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { MarsItemLight } from '../index';
|
|
2
|
+
import { Vector2, Vector3 } from '../math';
|
|
3
|
+
import { PLightType } from './common';
|
|
4
|
+
import { PEntity } from './object';
|
|
5
|
+
import type { ModelVFXItem } from '../plugin/model-vfx-item';
|
|
6
|
+
export declare class PLight extends PEntity {
|
|
7
|
+
direction: Vector3;
|
|
8
|
+
range: number;
|
|
9
|
+
color: Vector3;
|
|
10
|
+
intensity: number;
|
|
11
|
+
outerConeAngle: number;
|
|
12
|
+
innerConeAngle: number;
|
|
13
|
+
lightType: PLightType;
|
|
14
|
+
padding: Vector2;
|
|
15
|
+
constructor(light: MarsItemLight, ownerItem?: ModelVFXItem);
|
|
16
|
+
tick(deltaSeconds: number): void;
|
|
17
|
+
isDirectional(): boolean;
|
|
18
|
+
isPoint(): boolean;
|
|
19
|
+
isSpot(): boolean;
|
|
20
|
+
isAmbient(): boolean;
|
|
21
|
+
get position(): Vector3;
|
|
22
|
+
getWorldPosition(): Vector3;
|
|
23
|
+
getWorldDirection(): Vector3;
|
|
24
|
+
}
|
|
25
|
+
export declare class PLightManager {
|
|
26
|
+
lightList: PLight[];
|
|
27
|
+
constructor();
|
|
28
|
+
tick(deltaSeconds: number): void;
|
|
29
|
+
insertItem(inLight: MarsItemLight, ownerItem?: ModelVFXItem): PLight;
|
|
30
|
+
insertLight(inLight: PLight): PLight;
|
|
31
|
+
remove(inLight: PLight): void;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
get lightCount(): number;
|
|
34
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Material, Texture } from '@galacean/effects';
|
|
2
|
+
import { spec } from '@galacean/effects';
|
|
3
|
+
import type { MarsMaterialOptions, MarsMaterialUnlitOptions, MarsMaterialPBROptions } from '../index';
|
|
4
|
+
import { Vector3, Vector4, Matrix3 } from '../math';
|
|
5
|
+
import { PMaterialType, PBlendMode, PFaceSideMode } from './common';
|
|
6
|
+
import { PObject } from './object';
|
|
7
|
+
export declare abstract class PMaterialBase extends PObject {
|
|
8
|
+
materialType: PMaterialType;
|
|
9
|
+
vertexShaderCode: string;
|
|
10
|
+
fragmentShaderCode: string;
|
|
11
|
+
/**
|
|
12
|
+
* 深度是否写入,默认是写入(true)
|
|
13
|
+
*/
|
|
14
|
+
depthMask: boolean;
|
|
15
|
+
depthTestHint: boolean;
|
|
16
|
+
blendMode: PBlendMode;
|
|
17
|
+
alphaCutOff: number;
|
|
18
|
+
faceSideMode: PFaceSideMode;
|
|
19
|
+
getShaderFeatures(): string[];
|
|
20
|
+
updateUniforms(material: Material): void;
|
|
21
|
+
build(inFeatureList?: string[]): void;
|
|
22
|
+
getBlendMode(mode?: spec.MaterialBlending): PBlendMode;
|
|
23
|
+
getFaceSideMode(mode?: spec.SideMode): PFaceSideMode;
|
|
24
|
+
setMaterialStates(material: Material): void;
|
|
25
|
+
protected setFaceSideStates(material: Material): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
isValid(): boolean;
|
|
28
|
+
isOpaque(): boolean;
|
|
29
|
+
isMasked(): boolean;
|
|
30
|
+
isTranslucent(): boolean;
|
|
31
|
+
isAdditive(): boolean;
|
|
32
|
+
requireBlend(): boolean;
|
|
33
|
+
isFrontFace(): boolean;
|
|
34
|
+
isBackFace(): boolean;
|
|
35
|
+
isBothFace(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare class PMaterialUnlit extends PMaterialBase {
|
|
38
|
+
private baseColorFactor;
|
|
39
|
+
private baseColorTexture?;
|
|
40
|
+
create(options: MarsMaterialUnlitOptions): void;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
getShaderFeatures(): string[];
|
|
43
|
+
updateUniforms(material: Material): void;
|
|
44
|
+
hasBaseColorTexture(): boolean;
|
|
45
|
+
getBaseColorTexture(): Texture;
|
|
46
|
+
setBaseColorTexture(val: Texture): void;
|
|
47
|
+
getBaseColorFactor(): Vector4;
|
|
48
|
+
setBaseColorFactor(val: Vector4 | spec.vec4): void;
|
|
49
|
+
}
|
|
50
|
+
export declare class PMaterialPBR extends PMaterialBase {
|
|
51
|
+
baseColorTexture?: Texture;
|
|
52
|
+
baseColorTextureTrans?: Matrix3;
|
|
53
|
+
baseColorFactor: Vector4;
|
|
54
|
+
metallicRoughnessTexture?: Texture;
|
|
55
|
+
metallicRoughnessTextureTrans?: Matrix3;
|
|
56
|
+
useSpecularAA: boolean;
|
|
57
|
+
metallicFactor: number;
|
|
58
|
+
roughnessFactor: number;
|
|
59
|
+
normalTexture?: Texture;
|
|
60
|
+
normalTextureTrans?: Matrix3;
|
|
61
|
+
normalTextureScale: number;
|
|
62
|
+
occlusionTexture?: Texture;
|
|
63
|
+
occlusionTextureTrans?: Matrix3;
|
|
64
|
+
occlusionTextureStrength: number;
|
|
65
|
+
emissiveTexture?: Texture;
|
|
66
|
+
emissiveTextureTrans?: Matrix3;
|
|
67
|
+
emissiveFactor: Vector3;
|
|
68
|
+
emissiveIntensity: number;
|
|
69
|
+
enableShadow: boolean;
|
|
70
|
+
create(options: MarsMaterialPBROptions): void;
|
|
71
|
+
dispose(): void;
|
|
72
|
+
getShaderFeatures(): string[];
|
|
73
|
+
updateUniforms(material: Material): void;
|
|
74
|
+
hasBaseColorTexture(): boolean;
|
|
75
|
+
hasBaseColorTextureTrans(): boolean;
|
|
76
|
+
setBaseColorTexture(val: Texture): void;
|
|
77
|
+
getBaseColorFactor(): Vector4;
|
|
78
|
+
setBaseColorFactor(val: Vector4 | spec.vec4): void;
|
|
79
|
+
hasMetallicRoughnessTexture(): boolean;
|
|
80
|
+
hasMetallicRoughnessTextureTrans(): boolean;
|
|
81
|
+
getMetallicRoughnessTexture(): Texture;
|
|
82
|
+
setMetallicRoughnessTexture(val: Texture): void;
|
|
83
|
+
hasNormalTexture(): boolean;
|
|
84
|
+
hasNormalTextureTrans(): boolean;
|
|
85
|
+
getNormalTexture(): Texture;
|
|
86
|
+
setNormalTexture(val: Texture): void;
|
|
87
|
+
hasOcclusionTexture(): boolean;
|
|
88
|
+
hasOcclusionTextureTrans(): boolean;
|
|
89
|
+
getOcclusionTexture(): Texture;
|
|
90
|
+
setOcclusionTexture(val: Texture): void;
|
|
91
|
+
hasEmissiveTexture(): boolean;
|
|
92
|
+
hasEmissiveTextureTrans(): boolean;
|
|
93
|
+
getEmissiveTexture(): Texture;
|
|
94
|
+
setEmissiveTexture(val: Texture): void;
|
|
95
|
+
hasEmissiveFactor(): boolean;
|
|
96
|
+
getEmissiveFactor(): Vector3;
|
|
97
|
+
setEmissiveFactor(val: Vector3 | spec.vec3): void;
|
|
98
|
+
}
|
|
99
|
+
export type PMaterial = PMaterialUnlit | PMaterialPBR;
|
|
100
|
+
export declare function createPluginMaterial(options: MarsMaterialOptions): PMaterial;
|
|
101
|
+
export declare function createInternalMaterial(options: {}): {};
|