Skip to content

Commit

Permalink
Merge pull request #106 from galacean/feat/2.1
Browse files Browse the repository at this point in the history
Merge origin/feat/2.1 into origin/main
  • Loading branch information
yiiqii authored Nov 18, 2024
2 parents fbb4b33 + 0e9907f commit 35697e4
Show file tree
Hide file tree
Showing 59 changed files with 1,060 additions and 543 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
enable-pre-post-scripts=true
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
}
},
"scripts": {
"prebuild": "npm run clean:all",
"build": "npm run build:lib",
"prebuild": "pnpm clean",
"build": "pnpm build:lib",
"build:lib": "tsc -b tsconfig.build.json",
"lint": "eslint src --ext .ts,.mjs",
"lint:fix": "eslint src --fix --quiet --ext .ts,.mjs",
"check:ts": "tsc -b tsconfig.check.json",
"clean:all": "npm run clean:lib",
"clean:lib": "rimraf es/**",
"clean": "rimraf es/**",
"prepare": "husky install",
"prepublishOnly": "npm run build"
},
Expand Down
4 changes: 2 additions & 2 deletions src/animation-clip-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EffectsObjectData } from './components';
import type { EffectsObjectData } from './effects-object-data';
import type { FixedNumberExpression, FixedVec3Expression, FixedQuatExpression } from './number-expression';

export interface AnimationClipData extends EffectsObjectData {
Expand Down Expand Up @@ -28,4 +28,4 @@ export interface FloatCurveData {
property: string,
className: string,
keyFrames: FixedNumberExpression,
}
}
106 changes: 106 additions & 0 deletions src/assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import type { RenderLevel } from './type';

/**
* 资源基类
*/
export interface AssetBase {
/**
* 资源 ID
*/
id: string,
/**
* 资源类型
*/
url: string,
/**
* 渲染等级
* 如果没有设置,按照 B+ 处理
*/
renderLevel?: RenderLevel,
}

/**
* 动态换图类型
* @since 1.1.0
*/
export enum BackgroundType {
video = 'video',
image = 'image',
}

/**
* 多媒体资源类型
* @since 2.1.0
*/
export enum MultimediaType {
video = 'video',
audio = 'audio',
}

export interface TemplateContent {
/**
* 当 template 宽高和 image 不相同时,会对 template 进行缩放,使其和 image 相同。
*/
width: number,
height: number,
// 绘制 canvas 的背景图片,替换掉原来的那张图片,如果没有就不替换
background?: {
type: BackgroundType,
name: string,
url: string | HTMLImageElement,
},
}

export type TemplateVariables = Record<string, string | string[] | HTMLImageElement | HTMLImageElement[]>;

export type ImageSource = Image | TemplateImage | CompressedImage;

/**
* 纹理贴图属性
*/
export interface Image extends AssetBase {
/**
* WebP 地址
* 如果运行时支持 WebP,则优先使用 WebP
*/
webp?: string,
/**
* AVIF 地址
* 如果运行时支持 AVIF,则优先使用 AVIF
* @since 2.0.0
*/
avif?: string,
/**
* 是否使用 mipmap
* loader 发布压缩纹理的时候会根据此参数决定是否生成压缩纹理
* @default false
*/
mipmap?: boolean,
/**
* 图片 Y 轴的方向,如果 Y 轴向上(与 OpenGL 相同)则为 1
* 如果 Y 轴向下(与 OpenGL 相反)则为 -1,图片再绘制数据模板的时候需要翻转绘制
* @default 1
*/
oriY?: 1 | -1,
}

/**
* 模板贴图属性
*/
export interface TemplateImage extends Image {
template: TemplateContent,
}

/**
* 压缩贴图属性
*/
export interface CompressedImage extends Image {
/**
* 压缩贴图地址
*/
compressed: {
// 安卓
astc?: string,
pvrtc?: string,
},
}
3 changes: 2 additions & 1 deletion src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { DataType, EffectsObjectData } from './components';
import type { RenderLevel } from './type';
import type { ValueType } from './number-expression';
import type { DataType } from './data-type';
import type { EffectsObjectData } from './effects-object-data';

/**
* index: 指向 json 中 bins 数组
Expand Down
1 change: 1 addition & 0 deletions src/buitin-object-guid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const BuiltinObjectGUID = {
WhiteTexture: 'whitetexture00000000000000000000',
TransparentTexture: 'transparenttexture00000000000000000000',
PBRShader: 'pbr00000000000000000000000000000',
UnlitShader: 'unlit000000000000000000000000000',
};
9 changes: 9 additions & 0 deletions src/components/component-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { EffectsObjectData } from '../effects-object-data';

export interface DataPath {
id: string,
}

export interface ComponentData extends EffectsObjectData {
item: DataPath,
}
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './component-data';
export * from './post-process-volume-data';
45 changes: 45 additions & 0 deletions src/components/post-process-volume-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { ComponentData } from './component-data';

export interface PostProcessVolumeData extends ComponentData {
/**
* 泛光
*/
bloom?: Bloom,
/**
* 颜色调整
*/
colorAdjustments?: ColorAdjustments,
/**
* 晕影
*/
vignette?: Vignette,
/**
* 色调映射
*/
tonemapping?: Tonemapping,
}

export interface PostProcessEffectSettings {
active: boolean,
}

export interface Bloom extends PostProcessEffectSettings {
threshold: number,
intensity: number,
}

export interface Tonemapping extends PostProcessEffectSettings {

}

export interface ColorAdjustments extends PostProcessEffectSettings {
brightness: number,
saturation: number,
contrast: number,
}

export interface Vignette extends PostProcessEffectSettings {
intensity: number,
smoothness: number,
roundness: number,
}
4 changes: 0 additions & 4 deletions src/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ interface CompositionBase {
* @default [0,0]
*/
previewSize?: [width: number, height: number],
/**
* 降级图
*/
fallbackImage?: string,
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/curve-data/color-curve-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { BezierValue } from '../number-expression';

export type ColorCurveData = [
r: BezierValue,
g: BezierValue,
b: BezierValue,
a: BezierValue,
];
2 changes: 2 additions & 0 deletions src/curve-data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './color-curve-data';
export * from './vector4-curve-data';
8 changes: 8 additions & 0 deletions src/curve-data/vector4-curve-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { BezierValue } from '../number-expression';

export type Vector4CurveData = [
x: BezierValue,
y: BezierValue,
z: BezierValue,
w: BezierValue,
];
53 changes: 53 additions & 0 deletions src/data-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export enum DataType {
VFXItemData = 'VFXItemData',
EffectComponent = 'EffectComponent',
Material = 'Material',
Shader = 'Shader',
SpriteComponent = 'SpriteComponent',
ParticleSystem = 'ParticleSystem',
InteractComponent = 'InteractComponent',
CameraController = 'CameraController',
PostProcessVolume = 'PostProcessVolume',
Geometry = 'Geometry',
Texture = 'Texture',
Image = 'Image',
AnimationClip = 'AnimationClip',
TextComponent = 'TextComponent',
BinaryAsset = 'BinaryAsset',

// Timeline
TrackAsset = 'TrackAsset',
TimelineAsset = 'TimelineAsset',
ObjectBindingTrack = 'ObjectBindingTrack',
TransformTrack = 'TransformTrack',
SpriteColorTrack = 'SpriteColorTrack',
ActivationTrack = 'ActivationTrack',
SubCompositionTrack = 'SubCompositionTrack',
FloatPropertyTrack = 'FloatPropertyTrack',
ColorPropertyTrack = 'ColorPropertyTrack',
Vector4PropertyTrack = 'Vector4PropertyTrack',

TransformPlayableAsset = 'TransformPlayableAsset',
SpriteColorPlayableAsset = 'SpriteColorPlayableAsset',
ActivationPlayableAsset = 'ActivationPlayableAsset',
SubCompositionPlayableAsset = 'SubCompositionPlayableAsset',
FloatPropertyPlayableAsset = 'FloatPropertyPlayableAsset',
ColorPropertyPlayableAsset = 'ColorPropertyPlayableAsset',

MeshComponent = 'MeshComponent',
SkyboxComponent = 'SkyboxComponent',
LightComponent = 'LightComponent',
CameraComponent = 'CameraComponent',
ModelPluginComponent = 'ModelPluginComponent',
TreeComponent = 'TreeComponent',
AnimationComponent = 'AnimationComponent',
SpineComponent = 'SpineComponent',
VideoComponent = 'VideoComponent',
AudioComponent = 'AudioComponent',
RichTextComponent = 'RichTextComponent',
OrientationComponent = 'OrientationComponent',
ShapeComponent = 'ShapeComponent',

// Non-EffectObject
TimelineClip = 'TimelineClip',
}
7 changes: 7 additions & 0 deletions src/effects-object-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { DataType } from './data-type';

export interface EffectsObjectData {
id: string,
name?: string,
dataType: DataType,
}
11 changes: 11 additions & 0 deletions src/effects-package-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { EffectsObjectData } from './effects-object-data';

export interface EffectsPackageData {
fileSummary: FileSummary,
exportObjects: EffectsObjectData[],
}

export interface FileSummary {
guid: string,
assetType: string,
}
Loading

0 comments on commit 35697e4

Please sign in to comment.