@galacean/effects-core 0.0.0-experimental-downgrade624-20240904
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/LICENSE +22 -0
- package/README.md +152 -0
- package/dist/asset-manager.d.ts +142 -0
- package/dist/camera.d.ts +183 -0
- package/dist/comp-vfx-item.d.ts +73 -0
- package/dist/composition-source-manager.d.ts +45 -0
- package/dist/composition.d.ts +451 -0
- package/dist/config.d.ts +6 -0
- package/dist/constants.d.ts +11 -0
- package/dist/downloader.d.ts +73 -0
- package/dist/engine.d.ts +42 -0
- package/dist/filter.d.ts +63 -0
- package/dist/filters/alpha-frame.d.ts +5 -0
- package/dist/filters/alpha-mask.d.ts +5 -0
- package/dist/filters/bloom.d.ts +8 -0
- package/dist/filters/camera-move.d.ts +5 -0
- package/dist/filters/delay.d.ts +14 -0
- package/dist/filters/distortion.d.ts +5 -0
- package/dist/filters/gaussian.d.ts +27 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/lum.d.ts +5 -0
- package/dist/filters/utils.d.ts +7 -0
- package/dist/gl/create-gl-context.d.ts +9 -0
- package/dist/gl/gpu-time.d.ts +5 -0
- package/dist/gl/index.d.ts +6 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +26243 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +25994 -0
- package/dist/index.mjs.map +1 -0
- package/dist/libs/earcut.d.ts +37 -0
- package/dist/material/index.d.ts +4 -0
- package/dist/material/material-data-block.d.ts +27 -0
- package/dist/material/material.d.ts +347 -0
- package/dist/material/types.d.ts +66 -0
- package/dist/material/utils.d.ts +17 -0
- package/dist/math/bezier.d.ts +84 -0
- package/dist/math/float16array-wrapper.d.ts +5 -0
- package/dist/math/index.d.ts +4 -0
- package/dist/math/keyframe-info.d.ts +39 -0
- package/dist/math/translate.d.ts +10 -0
- package/dist/math/utils.d.ts +23 -0
- package/dist/math/value-getter.d.ts +128 -0
- package/dist/paas-texture-cache.d.ts +24 -0
- package/dist/pass-render-level.d.ts +1 -0
- package/dist/plugin-system.d.ts +34 -0
- package/dist/plugins/cal/calculate-item.d.ts +84 -0
- package/dist/plugins/cal/calculate-loader.d.ts +3 -0
- package/dist/plugins/cal/calculate-vfx-item.d.ts +26 -0
- package/dist/plugins/camera/camera-controller-node.d.ts +17 -0
- package/dist/plugins/camera/camera-vfx-item-loader.d.ts +3 -0
- package/dist/plugins/camera/camera-vfx-item.d.ts +13 -0
- package/dist/plugins/index.d.ts +26 -0
- package/dist/plugins/interact/click-handler.d.ts +66 -0
- package/dist/plugins/interact/event-system.d.ts +37 -0
- package/dist/plugins/interact/interact-item.d.ts +2 -0
- package/dist/plugins/interact/interact-loader.d.ts +13 -0
- package/dist/plugins/interact/interact-mesh.d.ts +16 -0
- package/dist/plugins/interact/interact-vfx-item.d.ts +41 -0
- package/dist/plugins/particle/burst.d.ts +21 -0
- package/dist/plugins/particle/link.d.ts +21 -0
- package/dist/plugins/particle/particle-loader.d.ts +18 -0
- package/dist/plugins/particle/particle-mesh.d.ts +165 -0
- package/dist/plugins/particle/particle-system.d.ts +196 -0
- package/dist/plugins/particle/particle-vfx-item.d.ts +28 -0
- package/dist/plugins/particle/trail-mesh.d.ts +61 -0
- package/dist/plugins/plugin.d.ts +125 -0
- package/dist/plugins/sprite/filter-sprite-vfx-item.d.ts +13 -0
- package/dist/plugins/sprite/sprite-group.d.ts +95 -0
- package/dist/plugins/sprite/sprite-item.d.ts +106 -0
- package/dist/plugins/sprite/sprite-loader.d.ts +20 -0
- package/dist/plugins/sprite/sprite-mesh.d.ts +67 -0
- package/dist/plugins/sprite/sprite-vfx-item.d.ts +33 -0
- package/dist/plugins/text/text-item.d.ts +122 -0
- package/dist/plugins/text/text-layout.d.ts +36 -0
- package/dist/plugins/text/text-loader.d.ts +18 -0
- package/dist/plugins/text/text-mesh.d.ts +15 -0
- package/dist/plugins/text/text-style.d.ts +67 -0
- package/dist/plugins/text/text-vfx-item.d.ts +28 -0
- package/dist/render/create-copy-shader.d.ts +6 -0
- package/dist/render/frame-buffer.d.ts +48 -0
- package/dist/render/geometry.d.ts +118 -0
- package/dist/render/global-volume.d.ts +15 -0
- package/dist/render/gpu-capability.d.ts +49 -0
- package/dist/render/index.d.ts +12 -0
- package/dist/render/mesh.d.ts +82 -0
- package/dist/render/post-process-pass.d.ts +37 -0
- package/dist/render/render-buffer.d.ts +20 -0
- package/dist/render/render-frame.d.ts +269 -0
- package/dist/render/render-pass.d.ts +309 -0
- package/dist/render/renderer.d.ts +62 -0
- package/dist/render/shader.d.ts +97 -0
- package/dist/render/types.d.ts +5 -0
- package/dist/scene.d.ts +36 -0
- package/dist/semantic-map.d.ts +14 -0
- package/dist/shader/index.d.ts +29 -0
- package/dist/shape/2d-shape.d.ts +32 -0
- package/dist/shape/cone.d.ts +11 -0
- package/dist/shape/donut.d.ts +9 -0
- package/dist/shape/earcut.d.ts +1 -0
- package/dist/shape/geometry.d.ts +30 -0
- package/dist/shape/index.d.ts +3 -0
- package/dist/shape/shape.d.ts +21 -0
- package/dist/shape/sphere.d.ts +15 -0
- package/dist/shape/texture-shape.d.ts +11 -0
- package/dist/template-image/index.d.ts +68 -0
- package/dist/template-image/qcanvas-viewer.d.ts +21 -0
- package/dist/template-image/qtext.d.ts +96 -0
- package/dist/template-image/template-v1.d.ts +27 -0
- package/dist/template-image/text-metrics.d.ts +18 -0
- package/dist/texture/index.d.ts +5 -0
- package/dist/texture/ktx-texture.d.ts +21 -0
- package/dist/texture/texture-factory.d.ts +13 -0
- package/dist/texture/texture.d.ts +78 -0
- package/dist/texture/types.d.ts +165 -0
- package/dist/texture/utils.d.ts +5 -0
- package/dist/ticker.d.ts +48 -0
- package/dist/transform.d.ts +221 -0
- package/dist/utils/array.d.ts +19 -0
- package/dist/utils/asserts.d.ts +2 -0
- package/dist/utils/color.d.ts +10 -0
- package/dist/utils/device.d.ts +5 -0
- package/dist/utils/image-data.d.ts +10 -0
- package/dist/utils/index.d.ts +72 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/sortable.d.ts +23 -0
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/timeline-component.d.ts +39 -0
- package/dist/vfx-item.d.ts +361 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-present Ant Group Co., Ltd. https://www.antgroup.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Galacean Effects Core
|
|
2
|
+
|
|
3
|
+
## Basic Concepts
|
|
4
|
+
In Galacean Effects, a Composition is the unit of animation playback. It is managed by the abstract class `Composition`, which is responsible for parsing data (JSON -> VFXItem / Texture -> mesh), creating and updating render frames (`renderFrame`) and render passes (renderPass).
|
|
5
|
+
|
|
6
|
+
Each composition uses animation data for different types of elements (`VFXItems`), including camera properties, multiple layers, particles, and interactive elements. When a composition is created, it completes the creation of elements (`VFXItems`), loading and creation of animation texture maps (`Textures`), and initialization of render frames (`renderFrame`) and render passes (`renderPass`).
|
|
7
|
+
At the beginning of the composition's lifecycle, the corresponding mesh is added to the default render pass (`renderPass`).
|
|
8
|
+
During the lifecycle, the `Geometry` and `Material` data contained in the mesh is updated.
|
|
9
|
+
When post-processing is required, the mesh is split into the appropriate `renderPass`.At the end of the lifecycle, the corresponding mesh is removed from the `renderFrame`.
|
|
10
|
+
|
|
11
|
+
To play the animation, the engine retrieves the mesh from the `renderFrame` and adds it to the scene, continuously calls the update function of the `Composition` during the rendering loop to `update` the data.
|
|
12
|
+
|
|
13
|
+
## Process
|
|
14
|
+
### 1. Resource Loading and Creation
|
|
15
|
+
- Asset Download [AssetManager](./src/asset-manager.ts): Before playing the animation, JSON data along with binary resources (`processBins`) and image resources (`processImages`) are downloaded. Upon completion of image downloads, parameters for creating textures (`Texture`) are returned. In addition to basic resource downloading functionality, the following features are supported:
|
|
16
|
+
1. Selective downloading of resources based on rendering levels.
|
|
17
|
+
2. After loading the image, image/text replacement is performed according to the configuration, and the modified image is saved as an `imageData` object by drawing on a Canvas.
|
|
18
|
+
3. Enable the gl extension `KHR_parallel_shader_compile` to compile shaders after resource loading is completed.
|
|
19
|
+
- Texture Creation [Texture](./src/texture/texture.ts): `Textures` are created based on the parameters obtained from the resource download process. The current texture object may be based on one of the creation types defined in the `TextureSourceType` enumeration.
|
|
20
|
+
|
|
21
|
+
### 2. Animation Playback
|
|
22
|
+
- [Composition](./src/composition.ts): The composition manages the data processing and rendering setup for animation playback. The `initialize` function is called to initialize the `VFXItemManager` for JSON -> VFXItem processing. Additionally, the engine needs to retrieve the mesh when appropriate through `composition.renderFrame` and add the retrieved mesh to the scene.
|
|
23
|
+
1. Static `initialize` method:
|
|
24
|
+
- The engine needs to implement the creation of `VFXItemManager`, `Composition` instances, and converting texture parameters to `Texture` usable by the engine.
|
|
25
|
+
2. In the constructor, the following functions need to be called:
|
|
26
|
+
- Plugin system `pluginSystem.initializeComposition()`.
|
|
27
|
+
- `composition.resetRenderFrame()`: Create and initialize the `renderFrame`.
|
|
28
|
+
- `composition.reset()`: Parse the animation data and initialize the state of the render instance.
|
|
29
|
+
- `composition.play()`: Start playing the composition animation.
|
|
30
|
+
3. `update` method: Used to call the `renderFrame`'s methods to add/modify/delete meshes and drive the update and vertex data, uniform variable values, etc., of `VFXItems`. The following functions need to be implemented:
|
|
31
|
+
- `updateVideo`: Update video frames for video playback.
|
|
32
|
+
- `getRendererOptions`: Return a blank `Texture` created using the data.
|
|
33
|
+
- `reloadTexture/offloadTexture`: Reload/unload textures.
|
|
34
|
+
4. The mesh or rendering objects added to the scene can be retrieved through the `renderFrame`, and the interface can be freely designed in the `Composition` according to the engine's needs.
|
|
35
|
+
5. `dispose` method: When the composition's lifecycle comes to an end, this method is called based on the termination behavior. It executes the composition's disposal callback for `VFXItem` and also destroys associated objects such as meshes and textures.
|
|
36
|
+
|
|
37
|
+
- [RenderFrame](./src/render/render-frame.ts): The `RenderFrame` can be understood as the rendering data object corresponding to each frame of the composition. In addition to managing the `renderPass`, it also stores the camera properties and common uniform variable table (semantics) associated with the composition. The meshes corresponding to different types of elements are added and removed using `addMeshToDefaultRenderPass` and `removeMeshFromDefaultRenderPass` methods of `renderFrame`. The mesh is added to the appropriate position in the `renderPass` based on its `priority` property.
|
|
38
|
+
1. `addMeshToDefaultRenderPass/removeMeshFromDefaultRenderPass`:
|
|
39
|
+
- For compositions without filter elements, the engine can manage all meshes through the `defRenderPass`, or it can directly place the passed-in mesh into its own scene. The engine can also organize and manage the meshes as required.
|
|
40
|
+
- For compositions with filter elements involving post-processing, the effects-core will call the `splitDefaultRenderPassByMesh` function to split the `renderPass` using the splitting parameters. In this case, the engine needs to iterate over `renderFrame._renderPasses` to retrieve meshes and add them to the scene.
|
|
41
|
+
- When adding a mesh, the common uniforms used by the material can be obtained through `mesh.material.uniformSemantics`, including matrices related to MVP transformations and the attachments used.
|
|
42
|
+
2. `setEditorTransformUniform`: This method is used to set the translation/scaling transformation of an element after model transformation. The engine may not necessarily understand this concept but can set the value to `semantics[EDITOR_TRANSFORM]`.
|
|
43
|
+
- [RenderPass](./src/render/render-pass.ts): The meshes added to the scene can be obtained through `renderPass.meshes`. The render pass `renderPass` contains the meshes for the current pass, the operations for clearing the buffer before and after rendering, and attachments related to color, depth, and stencil. The `delegate` property is used to specify the callbacks before and after rendering for the `renderPass`, as defined in [filters](./src/filters). The engine needs to execute these callbacks before actually rendering the meshes to ensure the correct operation of the filters.
|
|
44
|
+
- [Mesh](./src/render/mesh.ts): Each `VFXItem` calls the `Mesh.create()` function during initialization, passing in parameters such as geometry and material, and sets/retrieves the rendering order for the current mesh using `priority`.
|
|
45
|
+
1. The static `create` method is used to create a new `Mesh` object that the engine can render. The engine needs to add geometry, material, and other objects to the mesh here.
|
|
46
|
+
- The primitive type to be rendered can be obtained from `geometry.mode`.
|
|
47
|
+
2. The `setter` and `getter` functions for `priority` are used to set the rendering order of the current mesh. Meshes with lower `priority` values should be drawn before those with higher values.
|
|
48
|
+
3. `setVisible/getVisible` sets the visibility of the mesh.
|
|
49
|
+
|
|
50
|
+
> Tips
|
|
51
|
+
>
|
|
52
|
+
> - Each `spriteVFXItem` does not necessarily correspond to a single mesh. Layer elements are compared using a diff algorithm during frame updates to determine whether adjacent meshes have the same material properties, and then the meshes are split or merged accordingly.
|
|
53
|
+
> - To obtain the mesh corresponding to the current `VFXItem`, you can use `VFXItem.content.mesh` to retrieve it.
|
|
54
|
+
|
|
55
|
+
### 3. [Geometry](./src/render/geometry.ts)
|
|
56
|
+
Each `VFXItem` calls the `Geometry.create()` function during initialization, passing in the drawing type, vertex data, and index data of the element. During each frame update, new vertex data is passed to the attribute data.
|
|
57
|
+
1. The static create method: It processes the passed attribute data. If the data contains the dataSource property, it indicates that the attribute shares a buffer with the data source.
|
|
58
|
+
- `size`, `offset`, and `stride` are also passed in. If the data length is 0 and the engine does not allow dynamic modification of the GPU cache length, an initialization array should be created using the `maxVertex` parameter.
|
|
59
|
+
2. `setAttributeData/getAttributeData`: Sets/retrieves attribute data for the specified attribute name.
|
|
60
|
+
3. `setAttributeSubData`: Sets partial attribute updates.
|
|
61
|
+
4. `getIndexData/setIndexData`: Sets/retrieves index data.
|
|
62
|
+
5. `setDrawCount/getDrawCount`: Sets/retrieves the draw count.
|
|
63
|
+
|
|
64
|
+
Attributes involved:
|
|
65
|
+
#### Sprite
|
|
66
|
+
```
|
|
67
|
+
1. aPoint: Float32Array - Vertex data
|
|
68
|
+
2. aIndex: Float32Array - Shared buffer with aPoint
|
|
69
|
+
3. Index data: Uint16Array
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Particle
|
|
73
|
+
```
|
|
74
|
+
1. aPos: Float32Array
|
|
75
|
+
2. aVel: Float32Array - Shared buffer with aPos
|
|
76
|
+
3. aDirX: Float32Array - Shared buffer with aPos
|
|
77
|
+
4. aDirY: Float32Array - Shared buffer with aPos
|
|
78
|
+
5. aRot: Float32Array - Shared buffer with aPos
|
|
79
|
+
6. aSeed: Float32Array - Shared buffer with aRot
|
|
80
|
+
7. aColor: Float32Array - Shared buffer with aRot
|
|
81
|
+
8. aOffset: Float32Array
|
|
82
|
+
9. aSprite: Float32Array
|
|
83
|
+
10. Index data: Uint16Array
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Particle-trail
|
|
87
|
+
```
|
|
88
|
+
1. aColor: Float32Array
|
|
89
|
+
2. aSeed: Float32Array - Shared buffer with aColor
|
|
90
|
+
3. aInfo: Float32Array - Shared buffer with aColor
|
|
91
|
+
4. aPos: Float32Array - Shared buffer with aColor
|
|
92
|
+
5. aTime: Float32Array
|
|
93
|
+
6. aDir: Float32Array
|
|
94
|
+
7. aTrailStart: Float32Array
|
|
95
|
+
8. aTrailStartIndex: Float32Array
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. [Material](./src/material/material.ts)
|
|
99
|
+
Each `VFXItem` calls the `Material.create()` function during initialization, passing the shader and uniform semantics. The states and uniform data of the material are not passed in the constructor parameters but are set through functions after material creation.
|
|
100
|
+
1. Static `create` method: It needs to handle the provided shader text and set the `uniformSemantics`.
|
|
101
|
+
2. Implementation of `setter/getter` methods for states: The constant type passed is `glContext`, which may need to be converted to constants defined by the engine.
|
|
102
|
+
3. `set[dataType]/get[dataType]` methods for uniforms: effects-core will invoke the corresponding methods based on the type of the uniform to set data.
|
|
103
|
+
|
|
104
|
+
> ⚠️ Note:
|
|
105
|
+
> **The related UBO calls are deprecated, and `material-data-block` does not need to be implemented.**
|
|
106
|
+
|
|
107
|
+
Uniforms involved and their types:
|
|
108
|
+
#### Sprite
|
|
109
|
+
```
|
|
110
|
+
1. uMainData: mat4
|
|
111
|
+
2. uTexParams: vec4
|
|
112
|
+
3. uTexOffset: vec4
|
|
113
|
+
4. uSampler\[i]: sampler2D
|
|
114
|
+
5. uSamplerPre: sampler2D
|
|
115
|
+
6. uFeatherSampler: sampler2D
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Particle
|
|
119
|
+
```
|
|
120
|
+
1. uSprite: vec4
|
|
121
|
+
2. uParams: vec4
|
|
122
|
+
3. uAcceleration: vec4
|
|
123
|
+
4. uGravityModifierValue: vec4
|
|
124
|
+
5. uOpacityOverLifetimeValue: vec4
|
|
125
|
+
6. uRXByLifeTimeValue: vec4
|
|
126
|
+
7. uRYByLifeTimeValue: vec4
|
|
127
|
+
8. uRZByLifeTimeValue: vec4
|
|
128
|
+
9. uLinearXByLifetimeValue: vec4
|
|
129
|
+
10. uLinearYByLifetimeValue: vec4
|
|
130
|
+
11. uLinearZByLifetimeValue: vec4
|
|
131
|
+
12. uSpeedLifetimeValue: vec4
|
|
132
|
+
13. uOrbXByLifetimeValue: vec4
|
|
133
|
+
14. uOrbYByLifetimeValue: vec4
|
|
134
|
+
15. uOrbZByLifetimeValue: vec4
|
|
135
|
+
16. uSizeByLifetimeValue: vec4
|
|
136
|
+
17. uSizeYByLifetimeValue:vec4
|
|
137
|
+
18. uColorParams: vec4
|
|
138
|
+
19. uFSprite: vec4
|
|
139
|
+
20. uPreviewColor: vec4
|
|
140
|
+
21. uVCurveValues: vec4Array
|
|
141
|
+
22. uFCurveValues: vec4
|
|
142
|
+
23. uFinalTarget: vec3
|
|
143
|
+
24. uForceCurve: vec4
|
|
144
|
+
25. uOrbCenter: vec3
|
|
145
|
+
26. uTexOffset: vec2
|
|
146
|
+
27. uPeriodValue: vec4
|
|
147
|
+
28. uMovementValue: vec4
|
|
148
|
+
29. uStrengthValue: vec4
|
|
149
|
+
30. uWaveParams: vec4
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## [API Documentation](https://galacean.antgroup.com/effects/#/api/modules_galacean_effects_core)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as spec from '@galacean/effects-specification';
|
|
2
|
+
import { Downloader } from './downloader';
|
|
3
|
+
import type { Disposable } from './utils';
|
|
4
|
+
import type { Scene } from './scene';
|
|
5
|
+
import type { Renderer } from './render';
|
|
6
|
+
/**
|
|
7
|
+
* 场景加载参数
|
|
8
|
+
*/
|
|
9
|
+
export interface SceneLoadOptions {
|
|
10
|
+
/**
|
|
11
|
+
* 动态数据的参数
|
|
12
|
+
* key 是 JSON 中配置的字段名
|
|
13
|
+
* value 是要使用的值,图片使用 url 链接
|
|
14
|
+
* 图片链接可以使用数组传递,如果第一个加载失败,将尝试使用第二个地址
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ``` ts
|
|
18
|
+
* {
|
|
19
|
+
* variables: {
|
|
20
|
+
* bg: ['url','fallback_url'], // 如果两个图片都失败,将会触发加载失败
|
|
21
|
+
* fg: 'url' // 如果图片加载失败,将会触发加载失败,
|
|
22
|
+
* amount: 88.8,
|
|
23
|
+
* name: 'abc'
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
variables?: Record<string, number | string | string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* 模板图片缩放倍数
|
|
31
|
+
* @default 1 如果图片比较糊,可以用 2(但会增大图片内存)
|
|
32
|
+
*/
|
|
33
|
+
templateScale?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 是否使用压缩纹理
|
|
36
|
+
*/
|
|
37
|
+
useCompressedTexture?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 渲染分级。
|
|
40
|
+
* 分级之后,只会加载当前渲染等级的资源。
|
|
41
|
+
* 当渲染等级被设置为 B 后,player 的 fps 会降到 30 帧
|
|
42
|
+
* @default 's'
|
|
43
|
+
*/
|
|
44
|
+
renderLevel?: spec.RenderLevel;
|
|
45
|
+
/**
|
|
46
|
+
* 资源加载超时,时间单位秒
|
|
47
|
+
* @default 10s
|
|
48
|
+
*/
|
|
49
|
+
timeout?: number;
|
|
50
|
+
/***
|
|
51
|
+
* 用于给 plugin 的加载数据
|
|
52
|
+
* key/value 的内容由 plugin 自己实现
|
|
53
|
+
*/
|
|
54
|
+
pluginData?: Record<string, any>;
|
|
55
|
+
/**
|
|
56
|
+
* 场景加载时的环境(加载后把 env 结果写入 scene)
|
|
57
|
+
* @default '' - 编辑器中为 'editor'
|
|
58
|
+
*/
|
|
59
|
+
env?: string;
|
|
60
|
+
/**
|
|
61
|
+
* 加载后是否自动播放
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
autoplay?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 合成播放完成后是否需要再使用,是的话生命周期结束后不会 `dispose`
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
reusable?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* 播放速度,当速度为负数时,合成倒播
|
|
72
|
+
*/
|
|
73
|
+
speed?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 被接受用于加载的数据类型
|
|
77
|
+
*/
|
|
78
|
+
export type SceneType = string | Scene | Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* 资源管理器
|
|
81
|
+
* 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
|
|
82
|
+
*/
|
|
83
|
+
export declare class AssetManager implements Disposable {
|
|
84
|
+
private options;
|
|
85
|
+
private readonly downloader;
|
|
86
|
+
/**
|
|
87
|
+
* 相对url的基本路径
|
|
88
|
+
*/
|
|
89
|
+
private baseUrl;
|
|
90
|
+
/**
|
|
91
|
+
* 图像资源,用于创建和释放GPU纹理资源
|
|
92
|
+
*/
|
|
93
|
+
private assets;
|
|
94
|
+
/**
|
|
95
|
+
* 自定义文本缓存,随页面销毁而销毁
|
|
96
|
+
*/
|
|
97
|
+
static fonts: Set<string>;
|
|
98
|
+
private id;
|
|
99
|
+
/**
|
|
100
|
+
* 加载超时时间
|
|
101
|
+
* @default 10
|
|
102
|
+
*/
|
|
103
|
+
private timeout;
|
|
104
|
+
/**
|
|
105
|
+
* 场景加载的超时定时器
|
|
106
|
+
*/
|
|
107
|
+
private timers;
|
|
108
|
+
/**
|
|
109
|
+
* 构造函数
|
|
110
|
+
* @param options - 场景加载参数
|
|
111
|
+
* @param downloader - 资源下载对象
|
|
112
|
+
*/
|
|
113
|
+
constructor(options?: SceneLoadOptions, downloader?: Downloader);
|
|
114
|
+
updateOptions(options?: SceneLoadOptions): void;
|
|
115
|
+
/**
|
|
116
|
+
* 根据用户传入的参数修改场景数据
|
|
117
|
+
*/
|
|
118
|
+
private updateSceneData;
|
|
119
|
+
/**
|
|
120
|
+
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
121
|
+
* @param url - json 的 URL 链接或者 json 对象
|
|
122
|
+
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
123
|
+
* @param options - 扩展参数
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
loadScene(url: SceneType, renderer?: Renderer, options?: {
|
|
127
|
+
env: string;
|
|
128
|
+
}): Promise<Scene>;
|
|
129
|
+
private precompile;
|
|
130
|
+
private processJSON;
|
|
131
|
+
private processBins;
|
|
132
|
+
private processFontURL;
|
|
133
|
+
private processImages;
|
|
134
|
+
private processTextures;
|
|
135
|
+
private loadJSON;
|
|
136
|
+
private loadBins;
|
|
137
|
+
private removeTimer;
|
|
138
|
+
/**
|
|
139
|
+
* 销毁方法
|
|
140
|
+
*/
|
|
141
|
+
dispose(): void;
|
|
142
|
+
}
|
package/dist/camera.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as spec from '@galacean/effects-specification';
|
|
2
|
+
import { Matrix4, Vector3, Euler, Quaternion } from '@galacean/effects-math/es/core/index';
|
|
3
|
+
interface CameraOptionsBase {
|
|
4
|
+
/**
|
|
5
|
+
* 相机近平面
|
|
6
|
+
*/
|
|
7
|
+
near: number;
|
|
8
|
+
/**
|
|
9
|
+
* 相机远平面
|
|
10
|
+
*/
|
|
11
|
+
far: number;
|
|
12
|
+
/**
|
|
13
|
+
* 视锥体垂直视野角度
|
|
14
|
+
*/
|
|
15
|
+
fov: number;
|
|
16
|
+
/**
|
|
17
|
+
* 视锥体的长宽比
|
|
18
|
+
*/
|
|
19
|
+
aspect: number;
|
|
20
|
+
/**
|
|
21
|
+
* 相机的裁剪模式
|
|
22
|
+
*/
|
|
23
|
+
clipMode: spec.CameraClipMode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export interface CameraOptions extends CameraOptionsBase {
|
|
29
|
+
/**
|
|
30
|
+
* 相机的位置
|
|
31
|
+
*/
|
|
32
|
+
position: spec.vec3;
|
|
33
|
+
/**
|
|
34
|
+
* 相机的旋转,欧拉角
|
|
35
|
+
*/
|
|
36
|
+
rotation: spec.vec3;
|
|
37
|
+
/**
|
|
38
|
+
* 相机的旋转,四元数
|
|
39
|
+
*/
|
|
40
|
+
quat?: spec.vec4;
|
|
41
|
+
}
|
|
42
|
+
export interface CameraOptionsEx extends CameraOptionsBase {
|
|
43
|
+
/**
|
|
44
|
+
* 相机的位置
|
|
45
|
+
*/
|
|
46
|
+
position: Vector3;
|
|
47
|
+
/**
|
|
48
|
+
* 相机的旋转,欧拉角
|
|
49
|
+
*/
|
|
50
|
+
rotation: Euler;
|
|
51
|
+
/**
|
|
52
|
+
* 相机的旋转,四元数
|
|
53
|
+
*/
|
|
54
|
+
quat?: Quaternion;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 合成的相机对象,采用透视投影
|
|
58
|
+
*/
|
|
59
|
+
export declare class Camera {
|
|
60
|
+
name: string;
|
|
61
|
+
private options;
|
|
62
|
+
private viewMatrix;
|
|
63
|
+
private projectionMatrix;
|
|
64
|
+
private viewProjectionMatrix;
|
|
65
|
+
private inverseViewMatrix;
|
|
66
|
+
private inverseProjectionMatrix;
|
|
67
|
+
private inverseViewProjectionMatrix;
|
|
68
|
+
private dirty;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param name - 相机名称
|
|
72
|
+
* @param options
|
|
73
|
+
*/
|
|
74
|
+
constructor(name: string, options?: Partial<CameraOptions>);
|
|
75
|
+
/**
|
|
76
|
+
* 设置相机近平面
|
|
77
|
+
* @param near
|
|
78
|
+
*/
|
|
79
|
+
set near(near: number);
|
|
80
|
+
get near(): number;
|
|
81
|
+
/**
|
|
82
|
+
* 设置相机远平面
|
|
83
|
+
* @param far
|
|
84
|
+
*/
|
|
85
|
+
set far(far: number);
|
|
86
|
+
get far(): number;
|
|
87
|
+
/**
|
|
88
|
+
* 设置相机视锥体垂直视野角度
|
|
89
|
+
* @param fov
|
|
90
|
+
*/
|
|
91
|
+
set fov(fov: number);
|
|
92
|
+
get fov(): number;
|
|
93
|
+
/**
|
|
94
|
+
* 设置相机视锥体的长宽比
|
|
95
|
+
* @param aspect
|
|
96
|
+
*/
|
|
97
|
+
set aspect(aspect: number);
|
|
98
|
+
get aspect(): number;
|
|
99
|
+
/**
|
|
100
|
+
* 相机的裁剪模式
|
|
101
|
+
* @param clipMode
|
|
102
|
+
*/
|
|
103
|
+
set clipMode(clipMode: spec.CameraClipMode | undefined);
|
|
104
|
+
get clipMode(): spec.CameraClipMode | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* 设置相机的位置
|
|
107
|
+
* @param value
|
|
108
|
+
*/
|
|
109
|
+
set position(value: Vector3);
|
|
110
|
+
get position(): Vector3;
|
|
111
|
+
/**
|
|
112
|
+
* 设置相机的旋转角度
|
|
113
|
+
* @param value
|
|
114
|
+
*/
|
|
115
|
+
set rotation(value: Euler);
|
|
116
|
+
get rotation(): Euler;
|
|
117
|
+
/**
|
|
118
|
+
* 获取相机的视图变换矩阵
|
|
119
|
+
* @return
|
|
120
|
+
*/
|
|
121
|
+
getViewMatrix(): Matrix4;
|
|
122
|
+
/**
|
|
123
|
+
* 获取视图变换的逆矩阵
|
|
124
|
+
*/
|
|
125
|
+
getInverseViewMatrix(): Matrix4;
|
|
126
|
+
/**
|
|
127
|
+
* 获取相机的投影矩阵
|
|
128
|
+
* @return
|
|
129
|
+
*/
|
|
130
|
+
getProjectionMatrix(): Matrix4;
|
|
131
|
+
/**
|
|
132
|
+
* 获取相机投影矩阵的逆矩阵
|
|
133
|
+
* @return
|
|
134
|
+
*/
|
|
135
|
+
getInverseProjectionMatrix(): Matrix4;
|
|
136
|
+
/**
|
|
137
|
+
* 获取相机的 VP 矩阵
|
|
138
|
+
* @return
|
|
139
|
+
*/
|
|
140
|
+
getViewProjectionMatrix(): Matrix4;
|
|
141
|
+
/**
|
|
142
|
+
* 获取相机 VP 矩阵的逆矩阵
|
|
143
|
+
* @return
|
|
144
|
+
*/
|
|
145
|
+
getInverseViewProjectionMatrix(): Matrix4;
|
|
146
|
+
/**
|
|
147
|
+
* 根据相机的视图投影矩阵对指定模型矩阵做变换
|
|
148
|
+
* @param out - 结果矩阵
|
|
149
|
+
* @param model - 模型变换矩阵
|
|
150
|
+
*/
|
|
151
|
+
getModelViewProjection(out: Matrix4, model: Matrix4): Matrix4;
|
|
152
|
+
/**
|
|
153
|
+
* 获取归一化坐标和 3D 世界坐标的换算比例
|
|
154
|
+
* @param z - 当前的位置 z
|
|
155
|
+
*/
|
|
156
|
+
getInverseVPRatio(z: number): Vector3;
|
|
157
|
+
/**
|
|
158
|
+
* 设置相机的旋转四元数
|
|
159
|
+
* @param value - 旋转四元数
|
|
160
|
+
*/
|
|
161
|
+
setQuat(value: Quaternion): void;
|
|
162
|
+
/**
|
|
163
|
+
* 获取相机旋转对应的四元数
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
getQuat(): Quaternion;
|
|
167
|
+
/**
|
|
168
|
+
* 获取相机内部的 options
|
|
169
|
+
* @returns 相机 options
|
|
170
|
+
*/
|
|
171
|
+
getOptions(): CameraOptionsEx;
|
|
172
|
+
/**
|
|
173
|
+
* 复制指定相机元素的属性到当前相机
|
|
174
|
+
* @param camera
|
|
175
|
+
*/
|
|
176
|
+
copy(camera: Camera): void;
|
|
177
|
+
/**
|
|
178
|
+
* 更新相机相关的矩阵,获取矩阵前会自动调用
|
|
179
|
+
*/
|
|
180
|
+
updateMatrix(): void;
|
|
181
|
+
private setRotationByQuat;
|
|
182
|
+
}
|
|
183
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Ray } from '@galacean/effects-math/es';
|
|
2
|
+
import * as spec from '@galacean/effects-specification';
|
|
3
|
+
import { CalculateItem } from './plugins';
|
|
4
|
+
import type { Region } from './plugins';
|
|
5
|
+
import type { VFXItemContent, VFXItemProps } from './vfx-item';
|
|
6
|
+
import { VFXItem } from './vfx-item';
|
|
7
|
+
import type { Composition, CompositionHitTestOptions } from './composition';
|
|
8
|
+
export interface ItemNode {
|
|
9
|
+
id: string;
|
|
10
|
+
item: VFXItem<VFXItemContent>;
|
|
11
|
+
children: ItemNode[];
|
|
12
|
+
parentId?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class CompVFXItem extends VFXItem<void | CalculateItem> {
|
|
15
|
+
/**
|
|
16
|
+
* 创建好的元素数组
|
|
17
|
+
*/
|
|
18
|
+
items: VFXItem<VFXItemContent>[];
|
|
19
|
+
/**
|
|
20
|
+
* 根据父子关系构建的元素树
|
|
21
|
+
*/
|
|
22
|
+
itemTree: ItemNode[];
|
|
23
|
+
startTime: number;
|
|
24
|
+
contentProps: any;
|
|
25
|
+
timeInms: number;
|
|
26
|
+
/**
|
|
27
|
+
* id和元素的映射关系Map,方便查找
|
|
28
|
+
*/
|
|
29
|
+
readonly itemCacheMap: Map<string, ItemNode>;
|
|
30
|
+
private itemProps;
|
|
31
|
+
private freezeOnEnd;
|
|
32
|
+
private startTimeInms;
|
|
33
|
+
private itemsToRemove;
|
|
34
|
+
private tempQueue;
|
|
35
|
+
private extraCamera;
|
|
36
|
+
private refId;
|
|
37
|
+
get type(): spec.ItemType;
|
|
38
|
+
onConstructed(props: VFXItemProps): void;
|
|
39
|
+
createContent(): void;
|
|
40
|
+
protected doCreateContent(): CalculateItem;
|
|
41
|
+
onLifetimeBegin(): void;
|
|
42
|
+
doStop(): void;
|
|
43
|
+
onItemUpdate(dt: number, lifetime: number): void;
|
|
44
|
+
onItemRemoved(composition: Composition): void;
|
|
45
|
+
reset(): void;
|
|
46
|
+
handleVisibleChanged(visible: boolean): void;
|
|
47
|
+
setScale(x: number, y: number, z: number): void;
|
|
48
|
+
scale(x: number, y: number, z: number): void;
|
|
49
|
+
getUpdateTime(t: number): number;
|
|
50
|
+
removeItem(item: VFXItem<VFXItemContent>): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 设置指定元素的父元素
|
|
53
|
+
* @param item
|
|
54
|
+
* @param parentItem - 为 undefined 时表示设置父变换为合成的变换
|
|
55
|
+
*/
|
|
56
|
+
setItemParent(item: VFXItem<VFXItemContent>, parentItem?: VFXItem<VFXItemContent>): void;
|
|
57
|
+
/**
|
|
58
|
+
* 获取指定元素当前时刻真正起作用的父元素, 需要在元素生命周期内获取
|
|
59
|
+
* @internal
|
|
60
|
+
* @param item - 指定元素
|
|
61
|
+
* @return 当父元素生命周期结束时,返回空
|
|
62
|
+
*/
|
|
63
|
+
getItemCurrentParent(item: VFXItem<VFXItemContent>): VFXItem<VFXItemContent> | void;
|
|
64
|
+
getItemByName(name: string): VFXItem<VFXItemContent>[];
|
|
65
|
+
hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions): Region[];
|
|
66
|
+
protected isEnded(now: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 构建父子树,同时保存到 itemCacheMap 中便于查找
|
|
69
|
+
*/
|
|
70
|
+
private buildItemTree;
|
|
71
|
+
private getParentIdWithoutSuffix;
|
|
72
|
+
private restart;
|
|
73
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as spec from '@galacean/effects-specification';
|
|
2
|
+
import { Texture } from './texture';
|
|
3
|
+
import type { Disposable } from './utils';
|
|
4
|
+
import type { Scene } from './scene';
|
|
5
|
+
import type { PluginSystem } from './plugin-system';
|
|
6
|
+
import type { Engine } from './engine';
|
|
7
|
+
import type { GlobalVolume } from './render';
|
|
8
|
+
import type { VFXItemProps } from './vfx-item';
|
|
9
|
+
export interface ContentOptions {
|
|
10
|
+
id: string;
|
|
11
|
+
duration: number;
|
|
12
|
+
name: string;
|
|
13
|
+
endBehavior: spec.CompositionEndBehavior;
|
|
14
|
+
items: any[];
|
|
15
|
+
camera: spec.CameraOptions;
|
|
16
|
+
startTime: number;
|
|
17
|
+
globalVolume: GlobalVolume;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 合成资源管理
|
|
21
|
+
*/
|
|
22
|
+
export declare class CompositionSourceManager implements Disposable {
|
|
23
|
+
composition?: spec.Composition;
|
|
24
|
+
refCompositions: Map<string, spec.Composition>;
|
|
25
|
+
sourceContent?: ContentOptions;
|
|
26
|
+
refCompositionProps: Map<string, VFXItemProps>;
|
|
27
|
+
renderLevel?: spec.RenderLevel;
|
|
28
|
+
pluginSystem?: PluginSystem;
|
|
29
|
+
totalTime: number;
|
|
30
|
+
imgUsage: Record<string, number[]>;
|
|
31
|
+
textures: Texture[];
|
|
32
|
+
jsonScene?: spec.JSONScene;
|
|
33
|
+
mask: number;
|
|
34
|
+
textureOptions: Record<string, any>[];
|
|
35
|
+
constructor(scene: Scene, engine: Engine);
|
|
36
|
+
private getContent;
|
|
37
|
+
private assembleItems;
|
|
38
|
+
private changeTex;
|
|
39
|
+
private addTextureUsage;
|
|
40
|
+
/**
|
|
41
|
+
* 处理蒙版和遮挡关系写入 stencil 的 ref 值
|
|
42
|
+
*/
|
|
43
|
+
private processMask;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|