@galacean/effects-specification 1.0.1 → 2.0.0-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.
@@ -1,6 +1,7 @@
1
1
  import type { RGBAColorValue } from '../../numberExpression';
2
2
  import type { BaseItem, ItemEndBehavior } from '../base-item';
3
3
  import type { RotationOverLifetime, PositionOverLifetime, ItemType } from '../../type';
4
+ import type { ColorData, ComponentData } from '../../components';
4
5
  export interface ModelLightBaseOptions {
5
6
  /**
6
7
  * 挂靠的父节点
@@ -70,3 +71,49 @@ export interface ModelLightItem extends BaseItem {
70
71
  content: ModelLightContent;
71
72
  endBehavior: ItemEndBehavior;
72
73
  }
74
+ export declare enum LightType {
75
+ /**
76
+ * 点光源
77
+ */
78
+ point = "point",
79
+ /**
80
+ * 聚光灯
81
+ */
82
+ spot = "spot",
83
+ /**
84
+ * 方向光
85
+ */
86
+ directional = "directional",
87
+ /**
88
+ * 环境光
89
+ */
90
+ ambient = "ambient"
91
+ }
92
+ export interface ModelLightComponentData extends ComponentData {
93
+ lightType: LightType;
94
+ /**
95
+ * 灯光颜色,线性空间
96
+ * @default [255,255,255]
97
+ */
98
+ color: ColorData;
99
+ /**
100
+ * 灯光强度
101
+ * @default 1
102
+ */
103
+ intensity: number;
104
+ /**
105
+ * 点光源和聚光灯
106
+ * @default Infinity
107
+ */
108
+ range?: number;
109
+ /**
110
+ * 聚光灯
111
+ * @default 0
112
+ */
113
+ innerConeAngle?: number;
114
+ /**
115
+ * 聚光灯
116
+ * @default 45度
117
+ */
118
+ outerConeAngle?: number;
119
+ }
@@ -5,6 +5,7 @@ import type { GeometryPointer } from './binary';
5
5
  import type { vec3 } from '../../numberExpression';
6
6
  import type { InteractBehavior, ItemType } from '../../type';
7
7
  import type { ModelAnimationTrackDataPointer } from './binary';
8
+ import type { ComponentData, DataPath, GeometryData, MaterialData } from '../../components';
8
9
  export type BufferType = WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'] | WebGLRenderingContext['BYTE'] | WebGLRenderingContext['UNSIGNED_INT'] | WebGLRenderingContext['UNSIGNED_SHORT'] | WebGLRenderingContext['UNSIGNED_BYTE'];
9
10
  export interface PrimitiveOptions<T extends BinaryEnv> {
10
11
  geometry: GeometryPointer<T>;
@@ -67,3 +68,29 @@ export interface ModelMeshItem<T extends BinaryEnv> extends BaseItem {
67
68
  content: ModelMeshItemContent<T>;
68
69
  endBehavior: ItemEndBehavior;
69
70
  }
71
+ export interface PrimitiveData {
72
+ geometry: GeometryData;
73
+ material: MaterialData;
74
+ }
75
+ export interface SkinData {
76
+ name?: string;
77
+ joints: DataPath[];
78
+ skeleton?: DataPath;
79
+ inverseBindMatrices: number[];
80
+ }
81
+ export interface MorphData {
82
+ weights: number[];
83
+ }
84
+ export interface ModelMeshComponentData extends ComponentData {
85
+ hide?: boolean;
86
+ /**
87
+ * 蒙皮数据
88
+ */
89
+ skin?: SkinData;
90
+ /**
91
+ * Morph数据
92
+ */
93
+ morph?: MorphData;
94
+ primitives: PrimitiveData[];
95
+ interaction?: ModelItemBounding;
96
+ }
@@ -2,6 +2,7 @@ import type { BaseItem, ItemEndBehavior } from '../base-item';
2
2
  import type { BinaryEnv } from '../../binary';
3
3
  import type { SkyboxCubeTexturePointer } from './binary';
4
4
  import type { ItemType } from 'src/type';
5
+ import type { ComponentData, DataPath } from '../../components';
5
6
  export interface SkyboxOptions<T extends BinaryEnv> {
6
7
  renderable: boolean;
7
8
  intensity: number;
@@ -48,3 +49,47 @@ export interface ModelSkyboxItem<T extends BinaryEnv> extends BaseItem {
48
49
  * },
49
50
  * bins:[{url:'https://big/bin/'}]
50
51
  */
52
+ export interface SkyboxComponentOptions {
53
+ renderable: boolean;
54
+ intensity: number;
55
+ reflectionsIntensity: number;
56
+ irradianceCoeffs?: number[];
57
+ diffuseImage?: DataPath;
58
+ specularImage: DataPath;
59
+ specularImageSize: number;
60
+ specularMipCount: number;
61
+ }
62
+ export interface SkyboxComponentData extends ComponentData {
63
+ /**
64
+ * Skybox 是否渲染,UI显示"可见"
65
+ */
66
+ renderable: boolean;
67
+ /**
68
+ * Diffuse 强度,UI显示"环境光强度"
69
+ */
70
+ intensity: number;
71
+ /**
72
+ * Specular 强度,UI显示"环境反射强度"
73
+ */
74
+ reflectionsIntensity: number;
75
+ /**
76
+ * SH 系数,先不在UI面板上显示(原先为二维数组,注意兼容性!!!)
77
+ */
78
+ irradianceCoeffs?: number[];
79
+ /**
80
+ * 漫反射贴图,UI显示"漫反射贴图"
81
+ */
82
+ diffuseImage?: DataPath;
83
+ /**
84
+ * 高光贴图,UI显示"高光贴图"
85
+ */
86
+ specularImage: DataPath;
87
+ /**
88
+ * 高光贴图大小,UI不显示
89
+ */
90
+ specularImageSize: number;
91
+ /**
92
+ * 高光贴图 mipmap 数,UI不显示
93
+ */
94
+ specularMipCount: number;
95
+ }
@@ -2,6 +2,7 @@ import type { BinaryEnv } from '../../binary';
2
2
  import type { ModelAnimationTrackDataPointer } from './binary';
3
3
  import type { BaseItem, BaseItemTransform } from '../base-item';
4
4
  import type { SizeOverLifetime, RotationOverLifetime, PositionOverLifetime, ItemType } from '../../type';
5
+ import type { ComponentData, DataPath } from '../../components';
5
6
  export interface TreeNodeOptions {
6
7
  name?: string;
7
8
  transform?: BaseItemTransform;
@@ -63,3 +64,24 @@ export interface ModelTreeItem<T extends BinaryEnv> extends BaseItem {
63
64
  type: ItemType.tree;
64
65
  content: ModelTreeContent<T>;
65
66
  }
67
+ export interface ModelAnimationTrackData {
68
+ item: DataPath;
69
+ input: number[];
70
+ output: number[];
71
+ path: 'translation' | 'rotation' | 'scale' | 'weights';
72
+ interpolation: 'LINEAR' | 'STEP' | 'CUBICSPLINE';
73
+ }
74
+ export interface ModelAnimationData {
75
+ name?: string;
76
+ tracks: ModelAnimationTrackData[];
77
+ }
78
+ export interface ModelAnimationComponentData extends ComponentData {
79
+ /**
80
+ * 默认动画索引,-1表示不播放动画
81
+ */
82
+ animation?: number;
83
+ /**
84
+ * 3D场景树中所有的动画数据
85
+ */
86
+ animations: ModelAnimationData[];
87
+ }
@@ -1,6 +1,7 @@
1
1
  import type { SizeOverLifetime, RotationOverLifetime, PositionOverLifetime, ColorOverLifetime, ItemType } from '../type';
2
2
  import type { RGBAColorValue } from '../numberExpression';
3
3
  import type { BaseItem } from './base-item';
4
+ import type { ComponentData, DataPath, EffectsObjectData } from '../components';
4
5
  /**
5
6
  * 空节点元素
6
7
  */
@@ -44,3 +45,50 @@ export interface NullContent {
44
45
  */
45
46
  colorOverLifetime?: ColorOverLifetime;
46
47
  }
48
+ export interface TimelineComponentData extends ComponentData {
49
+ /**
50
+ * 轨道数据
51
+ */
52
+ tracks: TrackAssetData[];
53
+ }
54
+ export interface PlayableAssetData {
55
+ dataType: string;
56
+ }
57
+ export interface TrackAssetData extends PlayableAssetData {
58
+ clips: TimelineClipData[];
59
+ }
60
+ export interface TimelineClipData {
61
+ start: number;
62
+ duration: number;
63
+ clipAsset: DataPath;
64
+ }
65
+ export interface TransformAnimationPlayableAssetData extends PlayableAssetData {
66
+ animationClip: DataPath;
67
+ }
68
+ export interface SpriteColorAnimationPlayableAssetData extends PlayableAssetData {
69
+ animationClip: DataPath;
70
+ }
71
+ export interface TransformAnimationClipData extends EffectsObjectData {
72
+ /**
73
+ * 空节点元素大小变化属性
74
+ */
75
+ sizeOverLifetime?: SizeOverLifetime;
76
+ /**
77
+ * 空节点元素旋转变化属性
78
+ */
79
+ rotationOverLifetime?: RotationOverLifetime;
80
+ /**
81
+ * 空节点元素位置变化属性
82
+ */
83
+ positionOverLifetime?: PositionOverLifetime;
84
+ }
85
+ export interface SpriteColorAnimationClipData extends EffectsObjectData {
86
+ /**
87
+ * 空节点元素色彩变化属性
88
+ */
89
+ colorOverLifetime?: ColorOverLifetime;
90
+ /**
91
+ * 图层初始颜色
92
+ */
93
+ startColor?: RGBAColorValue;
94
+ }
@@ -3,6 +3,7 @@ import type { FixedNumberExpression, NumberExpression, GradientColor, vec3, Fixe
3
3
  import type { BaseItem, ItemEndBehavior } from './base-item';
4
4
  import type { ParticleShape } from './particle-shape';
5
5
  import type { DistortionFilterParams } from './filter-item';
6
+ import type { ComponentData } from 'src/components';
6
7
  /**
7
8
  * 粒子交互行为
8
9
  */
@@ -335,6 +336,77 @@ export interface ParticleContent {
335
336
  };
336
337
  filter?: DistortionFilterParams;
337
338
  }
339
+ /**
340
+ * 粒子元素渲染属性
341
+ */
342
+ export interface ParticleSystemData extends ComponentData {
343
+ splits?: SplitParameter[];
344
+ /**
345
+ * 粒子元素基础属性
346
+ */
347
+ options: ParticleOptions;
348
+ /**
349
+ * 粒子元素材质渲染属性
350
+ */
351
+ renderer: RendererOptions;
352
+ /**
353
+ * 粒子元素发射器形状属性
354
+ */
355
+ shape?: ParticleShape;
356
+ /**
357
+ * 粒子元素发射参数属性
358
+ */
359
+ emission: ParticleEmission;
360
+ /**
361
+ * 粒子元素大小变化属性
362
+ */
363
+ sizeOverLifetime?: ParticleSizeOverLifetime;
364
+ /**
365
+ * 发射器 transform 变化
366
+ */
367
+ emitterTransform?: {
368
+ /**
369
+ * 位置变化
370
+ */
371
+ path?: FixedVec3Expression;
372
+ };
373
+ positionOverLifetime?: ParticlePositionOverLifetime;
374
+ /**
375
+ * 粒子元素旋转变化属性
376
+ */
377
+ rotationOverLifetime?: ParticleRotationOverLifetime;
378
+ /**
379
+ * 粒子元素色彩变化属性
380
+ */
381
+ colorOverLifetime?: ParticleColorOverLifetime;
382
+ /**
383
+ * 粒子元素贴图变化属性
384
+ */
385
+ textureSheetAnimation?: ParticleTextureSheetAnimation;
386
+ /**
387
+ * 粒子元素拖尾参数
388
+ */
389
+ trails?: ParticleTrail;
390
+ /**
391
+ * 粒子元素交互参数
392
+ */
393
+ interaction?: {
394
+ /**
395
+ * 交互行为
396
+ */
397
+ behavior?: ParticleInteractionBehavior;
398
+ /**
399
+ * 重叠元素响应开关
400
+ */
401
+ multiple?: boolean;
402
+ /**
403
+ * ray cast 射线拾取时 sphere 的半径
404
+ * @default 0.4
405
+ */
406
+ radius?: number;
407
+ };
408
+ filter?: DistortionFilterParams;
409
+ }
338
410
  /**
339
411
  * 粒子拖尾参数
340
412
  */
@@ -1,6 +1,7 @@
1
1
  import type { BaseItem, ItemEndBehavior } from './base-item';
2
2
  import type { SizeOverLifetime, RotationOverLifetime, PositionOverLifetime, ColorOverLifetime, ItemType, TextureSheetAnimation, RendererOptions, SplitParameter, InteractBehavior } from '../type';
3
3
  import type { RGBAColorValue } from '../numberExpression';
4
+ import type { ComponentData } from 'src/components';
4
5
  /**
5
6
  * 图层元素
6
7
  */
@@ -69,3 +70,50 @@ export interface SpriteContent {
69
70
  behavior: InteractBehavior;
70
71
  };
71
72
  }
73
+ /**
74
+ * 图层组件属性
75
+ */
76
+ export interface SpriteComponentData extends ComponentData {
77
+ /**
78
+ * added by loader
79
+ * @default null
80
+ */
81
+ splits?: SplitParameter[];
82
+ /**
83
+ * 图层元素基础属性
84
+ */
85
+ options: SpriteContentOptions;
86
+ /**
87
+ * 图层元素材质渲染属性
88
+ */
89
+ renderer: RendererOptions;
90
+ /**
91
+ * 图层元素大小变化属性
92
+ */
93
+ sizeOverLifetime?: SizeOverLifetime;
94
+ /**
95
+ * 图层元素旋转变化属性
96
+ */
97
+ rotationOverLifetime?: RotationOverLifetime;
98
+ /**
99
+ * 图层元素位置变化属性
100
+ */
101
+ positionOverLifetime?: PositionOverLifetime;
102
+ /**
103
+ * 图层元素色彩变化属性
104
+ */
105
+ colorOverLifetime?: ColorOverLifetime;
106
+ /**
107
+ * 图层元素贴图变化属性
108
+ */
109
+ textureSheetAnimation?: TextureSheetAnimation;
110
+ /**
111
+ * 图层交互
112
+ */
113
+ interaction?: {
114
+ /**
115
+ * 交互行为
116
+ */
117
+ behavior: InteractBehavior;
118
+ };
119
+ }
@@ -2,6 +2,7 @@ import type { BaseItem, ItemEndBehavior } from './base-item';
2
2
  import type { SizeOverLifetime, RotationOverLifetime, PositionOverLifetime, ColorOverLifetime, ItemType, TextureSheetAnimation, RendererOptions, InteractBehavior } from '../type';
3
3
  import type { RGBAColorValue } from '../numberExpression';
4
4
  import type { FontStyle, TextAlignment, TextBaseline, TextOverflow, TextWeight } from 'src/text';
5
+ import type { ComponentData } from 'src/components';
5
6
  /**
6
7
  * 文本元素
7
8
  */
@@ -170,3 +171,45 @@ export interface TextContent {
170
171
  behavior: InteractBehavior;
171
172
  };
172
173
  }
174
+ /**
175
+ * 文本元素渲染属性
176
+ */
177
+ export interface TextComponentData extends ComponentData {
178
+ /**
179
+ * 文本元素基础属性
180
+ */
181
+ options: TextContentOptions;
182
+ /**
183
+ * 文本元素材质渲染属性
184
+ */
185
+ renderer: RendererOptions;
186
+ /**
187
+ * 文本元素大小变化属性
188
+ */
189
+ sizeOverLifetime?: SizeOverLifetime;
190
+ /**
191
+ * 文本元素旋转变化属性
192
+ */
193
+ rotationOverLifetime?: RotationOverLifetime;
194
+ /**
195
+ * 文本元素位置变化属性
196
+ */
197
+ positionOverLifetime?: PositionOverLifetime;
198
+ /**
199
+ * 文本元素色彩变化属性
200
+ */
201
+ colorOverLifetime?: ColorOverLifetime;
202
+ /**
203
+ * 文本元素贴图变化属性
204
+ */
205
+ textureSheetAnimation?: TextureSheetAnimation;
206
+ /**
207
+ * 图层交互
208
+ */
209
+ interaction?: {
210
+ /**
211
+ * 交互行为
212
+ */
213
+ behavior: InteractBehavior;
214
+ };
215
+ }
@@ -4,6 +4,8 @@ import type { PlayerVersion, Shape } from './type';
4
4
  import type { TemplateImage, Image, CompressedImage, TextureDefine } from './image';
5
5
  import type { FontBase, FontDefine } from './text';
6
6
  import type { BinaryFile } from './binary';
7
+ import type { ComponentData, GeometryData, MaterialData, ShaderData } from './components';
8
+ import type { VFXItemData } from './vfx-item-data';
7
9
  /**
8
10
  * 场景信息
9
11
  * 素材信息存放于统一数据结构中
@@ -13,8 +15,8 @@ export interface JSONScene {
13
15
  /**
14
16
  * JSON 版本
15
17
  *
16
- * 1.1 增加数据模板 https://yuque.antfin.com/ndl7nd/mars/ib13fw
17
- * 1.2 增加 anchor https://yuque.antfin.com/ndl7nd/mars/dyccyr
18
+ * 1.1 增加数据模板
19
+ * 1.2 增加 anchor
18
20
  * 1.3 增加二进制文件格式
19
21
  * 1.5 增加 Spine 数据
20
22
  * 2.0 改造升级
@@ -91,3 +93,106 @@ export interface JSONScene {
91
93
  * 如果是内置模块,但是需要额外的代码引入,比如滤镜则会加入 requires 数组中
92
94
  */
93
95
  export type SceneRequire = 'filter';
96
+ /**
97
+ * 2.0 场景信息
98
+ * 素材信息存放于统一数据结构中
99
+ */
100
+ export interface JSONSceneVersion3 {
101
+ /************** 文件版本不是 Player 版本,应用于文件变更后在 editor/player 中加载时的分类处理 **************/
102
+ /**
103
+ * JSON 版本
104
+ *
105
+ * 1.1 增加数据模板
106
+ * 1.2 增加 anchor
107
+ * 1.3 增加二进制文件格式
108
+ * 1.5 增加 Spine 数据
109
+ * 2.0 改造升级
110
+ * 2.1 增加文本元素
111
+ * 2.2 数据类型兼容
112
+ */
113
+ version: string;
114
+ /**
115
+ * 播放器版本信息
116
+ */
117
+ playerVersion: PlayerVersion;
118
+ /**
119
+ * 类型为 Galacean Effects
120
+ */
121
+ type: string;
122
+ /*************************************** 用于加载 json 后复原合成 **************************************/
123
+ /**
124
+ * 选中合成ID
125
+ * 如果没有设置,选择合成中的第一个
126
+ */
127
+ compositionId?: string;
128
+ /**
129
+ * 渲染所需合成列表
130
+ */
131
+ compositions: Composition[];
132
+ /******************************** 以下皆为可复用信息,加载在对应 Manager 中 *******************************/
133
+ /**
134
+ * 贴图信息
135
+ */
136
+ images: (TemplateImage | Image | CompressedImage)[];
137
+ /**
138
+ * 根据合成ID,每个合成用到的 image 的数组索引
139
+ */
140
+ imgUsage?: Record<string, number[]>;
141
+ /**
142
+ * 根据合成id,每个合成用到的 bin 的数组索引
143
+ */
144
+ binUsage?: Record<string, number[]>;
145
+ /**
146
+ * 蒙版形状信息
147
+ */
148
+ shapes: Shape[];
149
+ /**
150
+ * 插件类型信息
151
+ * 'model@1.0'
152
+ */
153
+ plugins: string[];
154
+ /**
155
+ * 保留字段
156
+ */
157
+ requires: SceneRequire[];
158
+ /**
159
+ * 字体资源
160
+ * 数据模板下掉可以不要 FontBase[]
161
+ */
162
+ fonts?: FontBase[] | FontDefine[];
163
+ /**
164
+ * spine 资源
165
+ * @version 1.5
166
+ */
167
+ spines?: SpineResource[];
168
+ /**
169
+ * 二进制文件地址
170
+ * @version 1.3
171
+ */
172
+ bins?: BinaryFile[];
173
+ /**
174
+ * textures 配置
175
+ * 从 v1.3 开始,images 数组会对应创建 textures 数组
176
+ */
177
+ textures?: TextureDefine[];
178
+ /**
179
+ * 元素数据
180
+ */
181
+ items: VFXItemData[];
182
+ /**
183
+ * 组件数据
184
+ */
185
+ components: ComponentData[];
186
+ /**
187
+ * 材质数据
188
+ */
189
+ materials: MaterialData[];
190
+ /**
191
+ * 着色器数据
192
+ */
193
+ shaders: ShaderData[];
194
+ /**
195
+ * 几何体数据
196
+ */
197
+ geometries: GeometryData[];
198
+ }
@@ -0,0 +1,74 @@
1
+ import type { ComponentData, EffectsObjectData } from './components';
2
+ import type { ItemEndBehavior, ParentItemEndBehavior, BaseContent, TransformData } from './item/base-item';
3
+ import type { ItemType, RenderLevel } from './type';
4
+ export interface VFXItemData extends EffectsObjectData {
5
+ /**
6
+ * 元素 id
7
+ * 非预合成的元素 id 为 int 类型的数字字符串
8
+ * 预合成元素 id 为 `'{ref元素id}+{合成内id}'` 字符串
9
+ */
10
+ id: string;
11
+ /**
12
+ * 元素名称
13
+ */
14
+ name: string;
15
+ /**
16
+ * 元素时常,单位秒
17
+ */
18
+ duration: number;
19
+ /**
20
+ * 元素类型,string 类型
21
+ * Galacean Effects 内部元素使用 int 数字字符串
22
+ * plugin 模块实现者自由实现命名
23
+ * 2022.12更新: spine: "spine", 陀螺仪: "5"
24
+ */
25
+ type: ItemType | string;
26
+ /**
27
+ * 父节点ID
28
+ * 如果父节点无法找到,播放将直接报错
29
+ */
30
+ parentId?: string;
31
+ /**
32
+ * 元素可视状态
33
+ * 如果为 true 或者不存在时,元素可见
34
+ * 仅当为 false 时,元素不被创建
35
+ */
36
+ visible?: boolean;
37
+ /**
38
+ * 元素结束行为
39
+ * @default destroy
40
+ */
41
+ endBehavior: ItemEndBehavior | ParentItemEndBehavior;
42
+ /**
43
+ * 元素播放延时(单位秒)
44
+ * @default 0
45
+ */
46
+ delay?: number;
47
+ /**
48
+ * 元素渲染信息属性
49
+ */
50
+ content: BaseContent;
51
+ /**
52
+ * 元素渲染等级
53
+ */
54
+ renderLevel?: RenderLevel;
55
+ /**
56
+ * 元素的插件模块名,如果不指定,则和 type 相同
57
+ * 从数组的 plugins 中获取 name
58
+ * 例如:pn:1, plugins:["model@1.0",'spine@1.0']
59
+ * pn 实际为 spine
60
+ */
61
+ pn?: number;
62
+ /**
63
+ * 元素的插件模块名, 优先级高于 pn
64
+ */
65
+ pluginName?: string;
66
+ /**
67
+ * 元素的基础位置
68
+ */
69
+ transform?: TransformData;
70
+ /**
71
+ * 元素的组件数据
72
+ */
73
+ components: ComponentData[];
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-specification",
3
- "version": "1.0.1",
3
+ "version": "2.0.0-alpha.0",
4
4
  "description": "Galacean Effects JSON Specification",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",