@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.
Files changed (64) hide show
  1. package/README.md +26 -0
  2. package/dist/gesture/controller.d.ts +95 -0
  3. package/dist/gesture/index.d.ts +38 -0
  4. package/dist/gesture/protocol.d.ts +143 -0
  5. package/dist/gltf/index.d.ts +3 -0
  6. package/dist/gltf/loader-ext.d.ts +53 -0
  7. package/dist/gltf/loader-helper.d.ts +18 -0
  8. package/dist/gltf/loader-impl.d.ts +84 -0
  9. package/dist/gltf/protocol.d.ts +90 -0
  10. package/dist/helper/index.d.ts +2 -0
  11. package/dist/index.d.ts +38 -0
  12. package/dist/index.js +16137 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.min.js +9 -0
  15. package/dist/index.min.js.map +1 -0
  16. package/dist/index.mjs +16048 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/loader.d.ts +2 -0
  19. package/dist/loader.mjs +12040 -0
  20. package/dist/loader.mjs.map +1 -0
  21. package/dist/math/box3.d.ts +140 -0
  22. package/dist/math/euler.d.ts +139 -0
  23. package/dist/math/index.d.ts +11 -0
  24. package/dist/math/matrix2.d.ts +58 -0
  25. package/dist/math/matrix3.d.ts +113 -0
  26. package/dist/math/matrix4.d.ts +264 -0
  27. package/dist/math/quaternion.d.ts +214 -0
  28. package/dist/math/sphere.d.ts +81 -0
  29. package/dist/math/type.d.ts +29 -0
  30. package/dist/math/utilities/index.d.ts +9 -0
  31. package/dist/math/vector2.d.ts +394 -0
  32. package/dist/math/vector3.d.ts +164 -0
  33. package/dist/math/vector4.d.ts +132 -0
  34. package/dist/plugin/const.d.ts +2 -0
  35. package/dist/plugin/index.d.ts +6 -0
  36. package/dist/plugin/model-plugin.d.ts +48 -0
  37. package/dist/plugin/model-tree-item.d.ts +30 -0
  38. package/dist/plugin/model-tree-plugin.d.ts +13 -0
  39. package/dist/plugin/model-tree-vfx-item.d.ts +15 -0
  40. package/dist/plugin/model-vfx-item.d.ts +25 -0
  41. package/dist/runtime/anim-sampler.d.ts +13 -0
  42. package/dist/runtime/animation.d.ts +189 -0
  43. package/dist/runtime/cache.d.ts +34 -0
  44. package/dist/runtime/camera.d.ts +43 -0
  45. package/dist/runtime/common.d.ts +113 -0
  46. package/dist/runtime/index.d.ts +12 -0
  47. package/dist/runtime/light.d.ts +34 -0
  48. package/dist/runtime/material.d.ts +101 -0
  49. package/dist/runtime/mesh.d.ts +145 -0
  50. package/dist/runtime/object.d.ts +44 -0
  51. package/dist/runtime/scene.d.ts +131 -0
  52. package/dist/runtime/shader-libs/standard-shader-source.d.ts +3 -0
  53. package/dist/runtime/shader-libs/standard-shader.d.ts +6 -0
  54. package/dist/runtime/shader.d.ts +18 -0
  55. package/dist/runtime/shadow.d.ts +227 -0
  56. package/dist/runtime/skybox.d.ts +91 -0
  57. package/dist/utility/debug-helper.d.ts +7 -0
  58. package/dist/utility/hit-test-helper.d.ts +9 -0
  59. package/dist/utility/index.d.ts +6 -0
  60. package/dist/utility/plugin-helper.d.ts +197 -0
  61. package/dist/utility/ri-helper.d.ts +25 -0
  62. package/dist/utility/shader-helper.d.ts +13 -0
  63. package/dist/utility/ts-helper.d.ts +34 -0
  64. package/package.json +56 -0
@@ -0,0 +1,145 @@
1
+ import type { Geometry, Engine } from '@galacean/effects';
2
+ import { spec, Mesh, Material } from '@galacean/effects';
3
+ import type { MarsItemMesh, MarsMaterialOptions, MarsPrimitiveOptions } from '../index';
4
+ import { PShadowType } from './common';
5
+ import { PEntity } from './object';
6
+ import type { PMaterial } from './material';
7
+ import { Matrix4, Vector3, Box3 } from '../math';
8
+ import { PSkin, PMorph } from './animation';
9
+ import type { PSceneStates } from './scene';
10
+ import type { PSkybox } from './skybox';
11
+ import type { PMaterialShadowBase, PShadowRuntimeOptions } from './shadow';
12
+ import type { ModelVFXItem } from '../plugin/model-vfx-item';
13
+ import { BoxMesh } from '../utility/ri-helper';
14
+ import type { ModelTreeVFXItem } from '../plugin';
15
+ export declare class PMesh extends PEntity {
16
+ private engine;
17
+ /**
18
+ * 3D 元素父节点
19
+ */
20
+ parentIndex: number;
21
+ /**
22
+ * Mars 元素的父节点
23
+ */
24
+ parentItem?: ModelTreeVFXItem;
25
+ /**
26
+ * Mars 元素的父节点 Id
27
+ */
28
+ parentItemId?: string;
29
+ skin?: PSkin;
30
+ /**
31
+ * morph 动画状态数据,主要是 weights 数组
32
+ */
33
+ morph?: PMorph;
34
+ primitives: PPrimitive[];
35
+ hide: boolean;
36
+ priority: number;
37
+ boundingBox: Box3;
38
+ visBoundingBox: boolean;
39
+ boundingBoxMesh?: BoxMesh;
40
+ isBuilt: boolean;
41
+ isDisposed: boolean;
42
+ constructor(engine: Engine, itemMesh: MarsItemMesh, ownerItem?: ModelVFXItem, parentItem?: ModelTreeVFXItem);
43
+ build(lightCount: number, uniformSemantics: {
44
+ [k: string]: any;
45
+ }, skybox?: PSkybox): void;
46
+ tick(deltaSeconds: number): void;
47
+ addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
48
+ dispose(): void;
49
+ /**
50
+ * 更新 Morph 动画权重
51
+ * 每帧都会更新 Morph 动画权重,需要小心检查 Morph 动画参数
52
+ * 对于数组长度对不上的情况,直接报错
53
+ *
54
+ * @param weightsArray - Morph 动画的权重数组
55
+ */
56
+ updateMorphWeights(weightsArray: Float32Array): void;
57
+ updateParentItem(parentItem: ModelTreeVFXItem): void;
58
+ updateUniformsForScene(sceneStates: PSceneStates): void;
59
+ updateUniformForShadow(shadowOptions: PShadowRuntimeOptions): void;
60
+ hitTesting(rayOrigin: Vector3, rayDirection: Vector3): spec.vec3[];
61
+ computeBoundingBox(worldMatrix: Matrix4): Box3;
62
+ private getItemBoundingBox;
63
+ getParentId(): string | undefined;
64
+ get hasSkin(): boolean;
65
+ get mriMeshs(): Mesh[];
66
+ }
67
+ export declare class PPrimitive {
68
+ private engine;
69
+ /**
70
+ * 宿主 Mesh,包含了当前 Primitive
71
+ */
72
+ private parent?;
73
+ private skin?;
74
+ /**
75
+ * Morph 动画状态数据,来自 Mesh 对象,这里不创建不删除
76
+ */
77
+ private morph?;
78
+ private geometry;
79
+ private material;
80
+ private jointMatrixList?;
81
+ private jointNormalMatList?;
82
+ private jointMatrixTexture?;
83
+ private jointNormalMatTexture?;
84
+ name: string;
85
+ marsMesh: Mesh;
86
+ marsPriority: number;
87
+ boundingBox: Box3;
88
+ isCompressed: boolean;
89
+ shadowType: PShadowType;
90
+ shadowMesh?: Mesh;
91
+ shadowMaterial?: PMaterialShadowBase;
92
+ constructor(engine: Engine);
93
+ create(options: MarsPrimitiveOptions, parent: PMesh): void;
94
+ build(lightCount: number, uniformSemantics: {
95
+ [k: string]: any;
96
+ }, skybox?: PSkybox): void;
97
+ private getFeatureList;
98
+ addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
99
+ dispose(): void;
100
+ updateUniformsForScene(worldMatrix: Matrix4, nomralMatrix: Matrix4, sceneStates: PSceneStates): void;
101
+ updateUniformForShadow(shadowOpts: PShadowRuntimeOptions): void;
102
+ hitTesting(newOrigin: Vector3, newDirection: Vector3, worldMatrix: Matrix4, invWorldMatrix: Matrix4): number | undefined;
103
+ computeBoundingBox(inverseWorldMatrix: Matrix4): Box3;
104
+ /**
105
+ * 渲染输出模式转成 Shader 中的宏定义
106
+ *
107
+ * @param mode - 渲染输出模式
108
+ * @returns none 模式返回 undefined,其他模式返回相应宏定义
109
+ */
110
+ getRenderMode3DDefine(mode: spec.RenderMode3D): string | undefined;
111
+ private updateUniformsByAnimation;
112
+ private updateUniformsByScene;
113
+ hasSkin(): boolean;
114
+ getMarsGeometry(): Geometry;
115
+ setGeometry(val: PGeometry | Geometry): void;
116
+ setMaterial(val: PMaterial | MarsMaterialOptions): void;
117
+ getMarsMaterial(): Material;
118
+ getShadowMarsMaterial(): Material | undefined;
119
+ isEnableShadow(): boolean;
120
+ isUnlitMaterial(): boolean;
121
+ /**
122
+ * 是否有 Morph 动画:
123
+ * 需要注意 Morph 对象存在,但还是没有 Morph 动画的情况
124
+ *
125
+ * @returns 返回是否有 Morph 动画
126
+ */
127
+ hasMorph(): boolean;
128
+ getWorldBoundingBox(): Box3;
129
+ }
130
+ export declare class PGeometry {
131
+ geometry: Geometry;
132
+ attributeNames: string[];
133
+ constructor(geometry: Geometry);
134
+ dispose(): void;
135
+ hasAttribute(name: string): boolean;
136
+ setHide(hide: boolean): void;
137
+ isCompressed(): boolean;
138
+ hasPositions(): boolean;
139
+ hasNormals(): boolean;
140
+ hasTangents(): boolean;
141
+ hasUVCoords(index: number): boolean;
142
+ hasColors(): boolean;
143
+ hasJoints(): boolean;
144
+ hasWeights(): boolean;
145
+ }
@@ -0,0 +1,44 @@
1
+ import type { spec, Mesh } from '@galacean/effects';
2
+ import type { ModelVFXItem } from '../plugin/model-vfx-item';
3
+ import type { BaseTransform } from '../index';
4
+ import type { Quaternion, Euler, Vector3, Matrix4 } from '../math';
5
+ import { PObjectType, PTransform, PCoordinate } from './common';
6
+ import type { PSceneStates } from './scene';
7
+ export declare abstract class PObject {
8
+ name: string;
9
+ type: PObjectType;
10
+ dispose(): void;
11
+ isNone(): boolean;
12
+ isValid(): boolean;
13
+ protected genName(name: string): string;
14
+ }
15
+ export declare abstract class PEntity extends PObject {
16
+ private _visible;
17
+ private _transform;
18
+ deleted: boolean;
19
+ ownerItem?: ModelVFXItem;
20
+ tick(deltaSeconds: number): void;
21
+ onVisibleChanged(visible: boolean): void;
22
+ addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
23
+ updateUniformsForScene(sceneStates: PSceneStates): void;
24
+ /**
25
+ * 仅标记不可见和删除状态,但不进行 WebGL 相关资源的释放
26
+ * 最终释放 WebGL 相关资源是在 plugin destroy 的时候
27
+ */
28
+ onEntityRemoved(): void;
29
+ get visible(): boolean;
30
+ set visible(val: boolean);
31
+ get transform(): PTransform;
32
+ set transform(val: PTransform | BaseTransform);
33
+ get translation(): Vector3;
34
+ set translation(val: Vector3 | spec.vec3);
35
+ get position(): Vector3;
36
+ set position(val: Vector3 | spec.vec3);
37
+ get rotation(): Quaternion;
38
+ set rotation(val: Quaternion | Euler | Vector3 | spec.vec4 | spec.vec3);
39
+ get scale(): Vector3;
40
+ set scale(val: Vector3 | spec.vec3);
41
+ get matrix(): Matrix4;
42
+ set matrix(val: Matrix4);
43
+ get coordinate(): PCoordinate;
44
+ }
@@ -0,0 +1,131 @@
1
+ import type { CameraOptions, RenderFrame, Mesh, Renderer, Texture, Engine } from '@galacean/effects';
2
+ import { spec } from '@galacean/effects';
3
+ import type { ModelVFXItem, ModelItem } from '../plugin/model-vfx-item';
4
+ import { PMesh } from './mesh';
5
+ import type { PCamera } from './camera';
6
+ import { PCameraManager } from './camera';
7
+ import { PLight, PLightManager } from './light';
8
+ import type { Vector2 } from '../math';
9
+ import { Vector3, Matrix4, Box3 } from '../math';
10
+ import { PSkybox } from './skybox';
11
+ import type { CompositionCache } from './cache';
12
+ import { PShadowManager } from './shadow';
13
+ import type { PEntity } from './object';
14
+ import { TwoStatesSet } from '../utility/ts-helper';
15
+ export interface PSceneOptions {
16
+ componentName: string;
17
+ renderer: Renderer;
18
+ sceneCache: CompositionCache;
19
+ wireframeOnly?: boolean;
20
+ runtimeEnv?: string;
21
+ compatibleMode?: string;
22
+ visBoundingBox?: boolean;
23
+ enableDynamicSort?: boolean;
24
+ renderMode3D?: spec.RenderMode3D;
25
+ renderMode3DUVGridSize?: number;
26
+ renderSkybox: boolean;
27
+ lightItemCount: number;
28
+ }
29
+ export interface PSceneStates {
30
+ deltaSeconds: number;
31
+ camera: PCamera;
32
+ cameraPosition: Vector3;
33
+ viewMatrix: Matrix4;
34
+ projectionMatrix: Matrix4;
35
+ viewProjectionMatrix: Matrix4;
36
+ winSize: Vector2;
37
+ sceneRadius: number;
38
+ shadowMapSizeInv?: Vector2;
39
+ lightViewMatrix?: Matrix4;
40
+ lightProjectionMatrix?: Matrix4;
41
+ lightViewProjectionMatrix?: Matrix4;
42
+ lightList: PLight[];
43
+ maxLightCount: number;
44
+ skybox?: PSkybox;
45
+ }
46
+ export declare class PSceneManager {
47
+ compName: string;
48
+ itemList: PEntity[];
49
+ meshList: PMesh[];
50
+ lightManager: PLightManager;
51
+ cameraManager: PCameraManager;
52
+ shadowManager: PShadowManager;
53
+ /**
54
+ * 是否动态排序 Mesh 渲染优先级
55
+ * 默认 false,需要和 Tiny 对齐时为 true
56
+ */
57
+ enableDynamicSort: boolean;
58
+ brdfLUT?: Texture;
59
+ skybox?: PSkybox;
60
+ tickCount: number;
61
+ lastTickSecond: number;
62
+ /**
63
+ * 当前场景包围盒缓存,在阴影渲染中使用
64
+ */
65
+ sceneAABBCache: Box3;
66
+ /**
67
+ * 场景前帧和当前帧渲染的 Mesh 集合
68
+ */
69
+ renderedMeshSet: TwoStatesSet<Mesh>;
70
+ /**
71
+ * 场景中所有渲染过的 Mesh 集合
72
+ */
73
+ allRenderedMeshSet: Set<Mesh>;
74
+ private renderer?;
75
+ private sceneCache?;
76
+ private parentId2Mesh;
77
+ private maxLightCount;
78
+ private renderSkybox;
79
+ private engine;
80
+ constructor(engine: Engine);
81
+ initial(opts: PSceneOptions): void;
82
+ private initGlobalState;
83
+ private clean;
84
+ dispose(): void;
85
+ addItem(item: ModelVFXItem): void;
86
+ removeItem(item: ModelVFXItem): void;
87
+ updateDefaultCamera(camera: CameraOptions): void;
88
+ buildItem(item: ModelItem): void;
89
+ /**
90
+ * 编译运行时需要的 Shader 代码,包括 PBR、天空盒与阴影。
91
+ */
92
+ private build;
93
+ tick(deltaTime: number): void;
94
+ /**
95
+ * 更新 RI 帧对象中默认 Pass 的渲染队列
96
+ * 如果是动态排序模式,需要重新添加所有的 mesh,这样优先级才能生效
97
+ * 如果是正常模式,那就增量添加和删除
98
+ *
99
+ * @param frame - RI 帧对象
100
+ */
101
+ updateDefaultRenderPass(frame: RenderFrame): void;
102
+ /**
103
+ * 动态调整 Mesh 渲染优先级
104
+ * 主要是为了和 Tiny 渲染对齐,正常 Mars 渲染不进行调整
105
+ *
106
+ * @param states - 场景中的状态数据
107
+ */
108
+ dynamicSortMeshes(states: PSceneStates): void;
109
+ /**
110
+ * 查询场景中的 Mesh
111
+ * 通过 Mars 的 parentId 查询 Mesh 对象,可能找不到 Mesh 对象
112
+ *
113
+ * @param parentId - Mars Item 中定义的 parentId
114
+ * @returns 查询到的 PMesh,或者是没找到。如果 Mesh 不可见,也是没找到。
115
+ */
116
+ queryMesh(parentId: string): PMesh | undefined;
117
+ /**
118
+ * 删除 RenderFrame DefaultRenderPass 中添加的 Mesh,Player 要执行 Reset 操作
119
+ *
120
+ * @param renderFrame - 当前渲染帧对象
121
+ */
122
+ removeAllMeshesFromDefaultPass(renderFrame: RenderFrame): void;
123
+ getSceneAABB(box?: Box3): Box3;
124
+ printDebugInfo(): void;
125
+ getRenderer(): Renderer;
126
+ getSceneCache(): CompositionCache;
127
+ get activeCamera(): PCamera;
128
+ get lightCount(): number;
129
+ get shaderLightCount(): number;
130
+ get enableShadowPass(): boolean;
131
+ }
@@ -0,0 +1,3 @@
1
+ export declare namespace StandardShaderSource {
2
+ function build(source: string, features: string[], isWebGL2: boolean): string;
3
+ }
@@ -0,0 +1,6 @@
1
+ import type { PShaderContext } from '../shader';
2
+ export declare class StandardShader {
3
+ static environment: string;
4
+ static getVertexShaderCode(context: PShaderContext): string;
5
+ static getFragmentShaderCode(context: PShaderContext): string;
6
+ }
@@ -0,0 +1,18 @@
1
+ import type { PMaterialBase } from './material';
2
+ export interface PShaderContext {
3
+ material: PMaterialBase;
4
+ isWebGL2: boolean;
5
+ featureList: string[];
6
+ }
7
+ export interface PShaderResults {
8
+ vertexShaderCode: string;
9
+ fragmentShaderCode: string;
10
+ }
11
+ export type ShaderCodeFuncType = (context: PShaderContext) => PShaderResults;
12
+ export declare class PShaderManager {
13
+ private funcMap;
14
+ private static _instance;
15
+ static getInstance(): PShaderManager;
16
+ private constructor();
17
+ genShaderCode(context: PShaderContext): PShaderResults;
18
+ }
@@ -0,0 +1,227 @@
1
+ import type { RenderFrame, Mesh, Material, RenderPass, SemanticMap, Renderer, Engine } from '@galacean/effects';
2
+ import { Matrix4, Vector2, Box3 } from '../math';
3
+ import type { PShadowType } from './common';
4
+ import type { PMesh, PPrimitive } from './mesh';
5
+ import { PMaterialBase } from './material';
6
+ import type { PLight } from './light';
7
+ import type { PSceneManager, PSceneStates } from './scene';
8
+ import { FBOOptions } from '../utility/ri-helper';
9
+ import { TwoStatesSet } from '../utility/ts-helper';
10
+ export interface PMaterialShadowBaseOptions {
11
+ name: string;
12
+ shadowType: PShadowType;
13
+ }
14
+ export declare class PMaterialShadowBase extends PMaterialBase {
15
+ shadowType: PShadowType;
16
+ create(options: PMaterialShadowBaseOptions): void;
17
+ getShaderFeatures(): string[];
18
+ updateUniforms(material: Material): void;
19
+ }
20
+ export declare class PMaterialShadowBaseTest extends PMaterialBase {
21
+ shadowType: PShadowType;
22
+ create(options: PMaterialShadowBaseOptions): void;
23
+ getShaderFeatures(): string[];
24
+ updateUniforms(material: Material): void;
25
+ }
26
+ export interface PMaterialShadowFilterOptions {
27
+ name: string;
28
+ blurScale: Vector2;
29
+ }
30
+ export declare class PMaterialShadowFilter extends PMaterialBase {
31
+ blurScale: Vector2;
32
+ create(options: PMaterialShadowFilterOptions): void;
33
+ getShaderFeatures(): string[];
34
+ updateUniforms(material: Material): void;
35
+ }
36
+ /**
37
+ * 阴影初始化选项,包括控制选项和纹理选项
38
+ */
39
+ export interface PShadowInitOptions {
40
+ /**
41
+ * 控制相关的参数
42
+ */
43
+ enable?: boolean;
44
+ quality?: 'low' | 'medium' | 'high';
45
+ softness?: number;
46
+ /**
47
+ * 纹理相关的参数
48
+ */
49
+ width?: number;
50
+ height?: number;
51
+ type?: GLenum;
52
+ format?: GLenum;
53
+ filter?: GLenum;
54
+ }
55
+ /**
56
+ * 阴影运行时选项,包括 light 的变换矩阵和柔软度
57
+ */
58
+ export interface PShadowRuntimeOptions {
59
+ viewProjectionMatrix: Matrix4;
60
+ softness: number;
61
+ }
62
+ export declare class PShadowManager {
63
+ /**
64
+ * 是否启用阴影效果,会根据硬件等情况进行设置
65
+ */
66
+ enable: boolean;
67
+ /**
68
+ * 阴影质量参数,一般都用 medium
69
+ */
70
+ quality: 'low' | 'medium' | 'high';
71
+ /**
72
+ * 阴影柔软度,范围[0, 2]
73
+ */
74
+ softness: number;
75
+ /**
76
+ * 阴影纹理相关参数
77
+ */
78
+ width: number;
79
+ height: number;
80
+ type: GLenum;
81
+ format: GLenum;
82
+ filter: GLenum;
83
+ /**
84
+ * shadow map 渲染时 FBO
85
+ */
86
+ baseFBOOpts: FBOOptions;
87
+ /**
88
+ * shadow map 滤波时 FBO
89
+ */
90
+ filterFBOOpts: FBOOptions;
91
+ /**
92
+ * 是否激活运行时阴影
93
+ */
94
+ runtimeEnable: boolean;
95
+ /**
96
+ * 启用阴影效果的 Mesh 列表,来自场景中的 Mesh 列表
97
+ */
98
+ meshList: PMesh[];
99
+ /**
100
+ * 当前帧启用阴影效果的 Primitive 列表,来自上面的 Mesh 列表
101
+ */
102
+ primitiveList: PPrimitive[];
103
+ viewAABB: Box3;
104
+ sceneAABB: Box3;
105
+ shadowAABB: Box3;
106
+ shadowLight?: PLight;
107
+ lightView: Matrix4;
108
+ lightProjection: Matrix4;
109
+ lightViewProjection: Matrix4;
110
+ renderer?: Renderer;
111
+ sceneManager: PSceneManager;
112
+ xFilterMaterial: PMaterialShadowFilter;
113
+ yFilterMaterial: PMaterialShadowFilter;
114
+ basePass?: RenderPass;
115
+ xFilterPass?: RenderPass;
116
+ yFilterPass?: RenderPass;
117
+ /**
118
+ * Primitive 与 RenderPass 的前一帧与当前帧状态缓存
119
+ */
120
+ meshCacheSet: TwoStatesSet<Mesh>;
121
+ renderPassCacheSet: TwoStatesSet<RenderPass>;
122
+ engine: Engine;
123
+ constructor();
124
+ initial(sceneManager: PSceneManager, options?: PShadowInitOptions): void;
125
+ build(): void;
126
+ tick(sceneStates: PSceneStates): void;
127
+ /**
128
+ * 更新当前阴影物体的包围盒数据
129
+ * TODO: 需要注意动画物体的包围盒更新
130
+ */
131
+ private updateAABBInfo;
132
+ private updateLightViewProjection;
133
+ private updateDirectionalLightViewProjection;
134
+ private updateSpotLightViewProjection;
135
+ private getShadowOptions;
136
+ private updateShadowUniforms;
137
+ private getShadowLight;
138
+ /**
139
+ * 统计场景中启用阴影的 Primitive 数目
140
+ *
141
+ * @param sceneManager - Model 场景的场景管理器
142
+ * @returns 启用阴影的 Primitve 数目
143
+ */
144
+ private getShadowPrimitiveCount;
145
+ /**
146
+ * 更新阴影渲染时 Pass 中渲染的对象,注意阴影有 3 个渲染 Pass
147
+ * 开始时 Frame 中没有阴影 Pass,会先添加阴影 Pass
148
+ *
149
+ * @param frame - RI 帧对象
150
+ */
151
+ updateRenderPass(frame: RenderFrame): void;
152
+ updateFrameSemantics(map: SemanticMap, addSemantic: boolean): void;
153
+ /**
154
+ * 是否启用了阴影效果
155
+ * 是否有需要启用阴影效果的物体,以及当前硬件是否支持启用阴影效果
156
+ * @return 是否启用
157
+ */
158
+ isEnable(): boolean;
159
+ /**
160
+ * 是否有需要渲染的对象,需要先启用阴影
161
+ * @return 是否有渲染对象
162
+ */
163
+ hasRenderObject(): boolean;
164
+ /**
165
+ * 在当前 PMesh 列表中,查找需要在阴影 Pass 中渲染的 Primitive
166
+ *
167
+ * @returns 当前阴影 Pass 要渲染的 Primitive 列表
168
+ */
169
+ getCurrentPrimitiveList(): PPrimitive[];
170
+ isSupportTextureOptions(): boolean;
171
+ /**
172
+ * 根据当前阴影参数生成 BasePass 的 FBO 对象
173
+ *
174
+ * @returns BasePass 的 FBO 对象
175
+ */
176
+ getBaseFBOOptions(): FBOOptions;
177
+ /**
178
+ * 根据当前阴影参数生成 FilterPass 的 FBO 对象
179
+ *
180
+ * @returns FilterPass 的 FBO 对象
181
+ */
182
+ getFilterFBOOptions(): FBOOptions;
183
+ /**
184
+ * 返回 softness 值,并检查是否在指定范围内
185
+ *
186
+ * @param options - 阴影相关的初始化参数
187
+ * @returns 阴影柔软度值
188
+ */
189
+ getSoftness(options?: PShadowInitOptions): number;
190
+ /**
191
+ * 返回贴图大小,并检查是否在指定范围内
192
+ *
193
+ * @param options - 阴影相关的初始化参数
194
+ * @returns 阴影贴图大小
195
+ */
196
+ getTextureSize(options?: PShadowInitOptions): [number, number];
197
+ /**
198
+ * 返回纹理类型,并检查是否指定类型
199
+ *
200
+ * @param options - 阴影相关的初始化参数
201
+ * @returns 纹理类型
202
+ */
203
+ getTextureType(options?: PShadowInitOptions): GLenum;
204
+ /**
205
+ * 返回纹理格式,并检查是否指定格式
206
+ *
207
+ * @param options - 阴影相关的初始化参数
208
+ * @returns 纹理格式
209
+ */
210
+ getTextureFormat(options?: PShadowInitOptions): GLenum;
211
+ /**
212
+ * 返回纹理滤波格式,并检查是否指定滤波格式
213
+ *
214
+ * @param options - 阴影相关的初始化参数
215
+ * @returns 纹理滤波格式
216
+ */
217
+ getTextureFilter(options?: PShadowInitOptions): GLenum;
218
+ get mainPassUniformSemantics(): {
219
+ u_ShadowSampler: string;
220
+ };
221
+ get basePassName(): string;
222
+ get xFilterPassName(): string;
223
+ get yFilterPassName(): string;
224
+ get xFilterMeshName(): string;
225
+ get yFilterMeshName(): string;
226
+ get shadowPassList(): RenderPass[];
227
+ }
@@ -0,0 +1,91 @@
1
+ import type { Mesh, Material, TextureSourceOptions, Engine } from '@galacean/effects';
2
+ import { Texture } from '@galacean/effects';
3
+ import type { MarsItemSkybox, MarsSkyboxOptions } from '../index';
4
+ import { PEntity } from './object';
5
+ import { PMaterialBase } from './material';
6
+ import type { CompositionCache } from './cache';
7
+ import type { PSceneStates } from './scene';
8
+ import type { ModelVFXItem } from '../plugin/model-vfx-item';
9
+ export declare class PSkybox extends PEntity {
10
+ renderable: boolean;
11
+ intensity: number;
12
+ reflectionsIntensity: number;
13
+ irradianceCoeffs?: number[][];
14
+ diffuseImage?: Texture;
15
+ specularImage: Texture;
16
+ specularImageSize: number;
17
+ specularMipCount: number;
18
+ brdfLUT?: Texture;
19
+ priority: number;
20
+ skyboxMesh?: Mesh;
21
+ skyboxMaterial?: PMaterialSkyboxFilter;
22
+ isBuilt: boolean;
23
+ constructor(skybox: MarsItemSkybox, ownerItem?: ModelVFXItem);
24
+ setup(brdfLUT?: Texture): void;
25
+ build(sceneCache: CompositionCache): void;
26
+ dispose(): void;
27
+ addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
28
+ updateUniformsForScene(sceneStates: PSceneStates): void;
29
+ get available(): boolean;
30
+ get currentIntensity(): number;
31
+ get currentReflectionsIntensity(): number;
32
+ get hasDiffuseImage(): boolean;
33
+ get hasIrradianceCoeffs(): boolean;
34
+ }
35
+ export declare class PMaterialSkyboxFilter extends PMaterialBase {
36
+ intensity: number;
37
+ reflectionsIntensity: number;
38
+ brdfLUT?: Texture;
39
+ irradianceCoeffs?: number[][];
40
+ diffuseImage?: Texture;
41
+ specularImage: Texture;
42
+ specularMipCount: number;
43
+ create(skybox: PSkybox): void;
44
+ dispose(): void;
45
+ getShaderFeatures(): string[];
46
+ updateUniforms(material: Material): void;
47
+ setMaterialStates(material: Material): void;
48
+ }
49
+ export interface PImageBufferData {
50
+ type: 'buffer';
51
+ data: Uint8Array;
52
+ mimeType: string;
53
+ }
54
+ export type PImageData = string | PImageBufferData;
55
+ export interface PSkyboxBaseParams {
56
+ renderable: boolean;
57
+ intensity: number;
58
+ reflectionsIntensity: number;
59
+ irradianceCoeffs?: number[][];
60
+ specularMipCount: number;
61
+ specularImageSize: number;
62
+ }
63
+ export interface PSkyboxURLParams extends PSkyboxBaseParams {
64
+ type: 'url';
65
+ diffuseImage?: string[];
66
+ specularImage: string[][];
67
+ }
68
+ export interface PSkyboxBufferParams extends PSkyboxBaseParams {
69
+ type: 'buffer';
70
+ diffuseImage?: PImageBufferData[];
71
+ specularImage: PImageBufferData[][];
72
+ }
73
+ export type PSkyboxParams = PSkyboxURLParams | PSkyboxBufferParams;
74
+ export declare enum PSkyboxType {
75
+ NFT = 0,
76
+ FARM = 1
77
+ }
78
+ export declare class PSkyboxCreator {
79
+ static getBrdfLutTextureOptions(): Promise<TextureSourceOptions>;
80
+ static createBrdfLutTexture(engine: Engine): Promise<Texture>;
81
+ static createSkyboxOptions(engine: Engine, params: PSkyboxParams): Promise<MarsSkyboxOptions>;
82
+ static createSpecularCubeMap(engine: Engine, params: PSkyboxParams): Promise<Texture>;
83
+ static createDiffuseCubeMap(engine: Engine, params: PSkyboxParams): Promise<Texture | undefined>;
84
+ static getSkyboxParams(skyboxType?: PSkyboxType): PSkyboxURLParams;
85
+ private checkCubeMapImage;
86
+ private static getIrradianceCoeffs;
87
+ private static getDiffuseImageList;
88
+ private static getSpecularImageList;
89
+ private static getSpecularImageListNFT;
90
+ private static getSpecularImageListAntFarm;
91
+ }
@@ -0,0 +1,7 @@
1
+ import type { Player } from '@galacean/effects';
2
+ import type { PMesh } from '../runtime/mesh';
3
+ type WebGLContext = WebGL2RenderingContext | WebGLRenderingContext;
4
+ export declare function HookOGLFunc(ctx: WebGLContext): void;
5
+ export declare function getRendererGPUInfo(player: Player): string;
6
+ export declare function getPMeshList(player: Player): PMesh[];
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { Composition, Ray, Region, spec } from '@galacean/effects';
2
+ import { Vector3 } from '../math';
3
+ import type { MarsItemBounding } from '../index';
4
+ declare function RayIntersectsBoxWithRotation(ray: Ray, matrixData: spec.mat4, bounding: MarsItemBounding): number[][] | undefined;
5
+ declare function RayBoxTesting(ro: Vector3, rd: Vector3, bmin: Vector3, bmax: Vector3): number | undefined;
6
+ declare function RayTriangleTesting(ro: Vector3, rd: Vector3, a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean): number | undefined;
7
+ declare function CompositionHitTest(composition: Composition, x: number, y: number): Region[];
8
+ declare function ToggleItemBounding(composition: Composition, itemId: string): void;
9
+ export { RayIntersectsBoxWithRotation, RayBoxTesting, RayTriangleTesting, ToggleItemBounding, CompositionHitTest };