Skip to content

Commit 35697e4

Browse files
authored
Merge pull request #106 from galacean/feat/2.1
Merge origin/feat/2.1 into origin/main
2 parents fbb4b33 + 0e9907f commit 35697e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1060
-543
lines changed

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
engine-strict=true
2+
enable-pre-post-scripts=true

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
}
1717
},
1818
"scripts": {
19-
"prebuild": "npm run clean:all",
20-
"build": "npm run build:lib",
19+
"prebuild": "pnpm clean",
20+
"build": "pnpm build:lib",
2121
"build:lib": "tsc -b tsconfig.build.json",
2222
"lint": "eslint src --ext .ts,.mjs",
2323
"lint:fix": "eslint src --fix --quiet --ext .ts,.mjs",
2424
"check:ts": "tsc -b tsconfig.check.json",
25-
"clean:all": "npm run clean:lib",
26-
"clean:lib": "rimraf es/**",
25+
"clean": "rimraf es/**",
2726
"prepare": "husky install",
2827
"prepublishOnly": "npm run build"
2928
},

src/animation-clip-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EffectsObjectData } from './components';
1+
import type { EffectsObjectData } from './effects-object-data';
22
import type { FixedNumberExpression, FixedVec3Expression, FixedQuatExpression } from './number-expression';
33

44
export interface AnimationClipData extends EffectsObjectData {
@@ -28,4 +28,4 @@ export interface FloatCurveData {
2828
property: string,
2929
className: string,
3030
keyFrames: FixedNumberExpression,
31-
}
31+
}

src/assets.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import type { RenderLevel } from './type';
2+
3+
/**
4+
* 资源基类
5+
*/
6+
export interface AssetBase {
7+
/**
8+
* 资源 ID
9+
*/
10+
id: string,
11+
/**
12+
* 资源类型
13+
*/
14+
url: string,
15+
/**
16+
* 渲染等级
17+
* 如果没有设置,按照 B+ 处理
18+
*/
19+
renderLevel?: RenderLevel,
20+
}
21+
22+
/**
23+
* 动态换图类型
24+
* @since 1.1.0
25+
*/
26+
export enum BackgroundType {
27+
video = 'video',
28+
image = 'image',
29+
}
30+
31+
/**
32+
* 多媒体资源类型
33+
* @since 2.1.0
34+
*/
35+
export enum MultimediaType {
36+
video = 'video',
37+
audio = 'audio',
38+
}
39+
40+
export interface TemplateContent {
41+
/**
42+
* 当 template 宽高和 image 不相同时,会对 template 进行缩放,使其和 image 相同。
43+
*/
44+
width: number,
45+
height: number,
46+
// 绘制 canvas 的背景图片,替换掉原来的那张图片,如果没有就不替换
47+
background?: {
48+
type: BackgroundType,
49+
name: string,
50+
url: string | HTMLImageElement,
51+
},
52+
}
53+
54+
export type TemplateVariables = Record<string, string | string[] | HTMLImageElement | HTMLImageElement[]>;
55+
56+
export type ImageSource = Image | TemplateImage | CompressedImage;
57+
58+
/**
59+
* 纹理贴图属性
60+
*/
61+
export interface Image extends AssetBase {
62+
/**
63+
* WebP 地址
64+
* 如果运行时支持 WebP,则优先使用 WebP
65+
*/
66+
webp?: string,
67+
/**
68+
* AVIF 地址
69+
* 如果运行时支持 AVIF,则优先使用 AVIF
70+
* @since 2.0.0
71+
*/
72+
avif?: string,
73+
/**
74+
* 是否使用 mipmap
75+
* loader 发布压缩纹理的时候会根据此参数决定是否生成压缩纹理
76+
* @default false
77+
*/
78+
mipmap?: boolean,
79+
/**
80+
* 图片 Y 轴的方向,如果 Y 轴向上(与 OpenGL 相同)则为 1
81+
* 如果 Y 轴向下(与 OpenGL 相反)则为 -1,图片再绘制数据模板的时候需要翻转绘制
82+
* @default 1
83+
*/
84+
oriY?: 1 | -1,
85+
}
86+
87+
/**
88+
* 模板贴图属性
89+
*/
90+
export interface TemplateImage extends Image {
91+
template: TemplateContent,
92+
}
93+
94+
/**
95+
* 压缩贴图属性
96+
*/
97+
export interface CompressedImage extends Image {
98+
/**
99+
* 压缩贴图地址
100+
*/
101+
compressed: {
102+
// 安卓
103+
astc?: string,
104+
pvrtc?: string,
105+
},
106+
}

src/binary.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { DataType, EffectsObjectData } from './components';
21
import type { RenderLevel } from './type';
32
import type { ValueType } from './number-expression';
3+
import type { DataType } from './data-type';
4+
import type { EffectsObjectData } from './effects-object-data';
45

56
/**
67
* index: 指向 json 中 bins 数组

src/buitin-object-guid.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const BuiltinObjectGUID = {
22
WhiteTexture: 'whitetexture00000000000000000000',
3+
TransparentTexture: 'transparenttexture00000000000000000000',
34
PBRShader: 'pbr00000000000000000000000000000',
45
UnlitShader: 'unlit000000000000000000000000000',
56
};

src/components/component-data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { EffectsObjectData } from '../effects-object-data';
2+
3+
export interface DataPath {
4+
id: string,
5+
}
6+
7+
export interface ComponentData extends EffectsObjectData {
8+
item: DataPath,
9+
}

src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './component-data';
2+
export * from './post-process-volume-data';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { ComponentData } from './component-data';
2+
3+
export interface PostProcessVolumeData extends ComponentData {
4+
/**
5+
* 泛光
6+
*/
7+
bloom?: Bloom,
8+
/**
9+
* 颜色调整
10+
*/
11+
colorAdjustments?: ColorAdjustments,
12+
/**
13+
* 晕影
14+
*/
15+
vignette?: Vignette,
16+
/**
17+
* 色调映射
18+
*/
19+
tonemapping?: Tonemapping,
20+
}
21+
22+
export interface PostProcessEffectSettings {
23+
active: boolean,
24+
}
25+
26+
export interface Bloom extends PostProcessEffectSettings {
27+
threshold: number,
28+
intensity: number,
29+
}
30+
31+
export interface Tonemapping extends PostProcessEffectSettings {
32+
33+
}
34+
35+
export interface ColorAdjustments extends PostProcessEffectSettings {
36+
brightness: number,
37+
saturation: number,
38+
contrast: number,
39+
}
40+
41+
export interface Vignette extends PostProcessEffectSettings {
42+
intensity: number,
43+
smoothness: number,
44+
roundness: number,
45+
}

src/composition.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ interface CompositionBase {
7878
* @default [0,0]
7979
*/
8080
previewSize?: [width: number, height: number],
81-
/**
82-
* 降级图
83-
*/
84-
fallbackImage?: string,
8581
}
8682

8783
/**

0 commit comments

Comments
 (0)