-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(mdedia): 增加音视频规范 * chore(mdeida): 优化注释 * style: 调整音视频类型规范结构 --------- Co-authored-by: yiiqii <[email protected]>
- Loading branch information
Showing
11 changed files
with
326 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import type { RenderLevel } from './type'; | ||
|
||
/** | ||
* 资源基类 | ||
*/ | ||
export interface AssetBaseOptions { | ||
/** | ||
* 资源 ID | ||
*/ | ||
id: string, | ||
/** | ||
* 资源类型 | ||
*/ | ||
url: string, | ||
/** | ||
* 渲染等级 | ||
* 如果没有设置,按照 B+ 处理 | ||
*/ | ||
renderLevel?: RenderLevel, | ||
} | ||
|
||
/** | ||
* 纹理贴图属性 | ||
*/ | ||
export interface Image extends AssetBaseOptions { | ||
/** | ||
* 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, | ||
} | ||
|
||
/** | ||
* 动态换图类型 | ||
* @since 1.1.0 | ||
*/ | ||
export enum BackgroundType { | ||
video = 'video', | ||
image = 'image', | ||
} | ||
|
||
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 interface TemplateImage extends Image { | ||
template: TemplateContent, | ||
} | ||
|
||
/** | ||
* 压缩贴图属性 | ||
*/ | ||
export interface CompressedImage extends Image { | ||
/** | ||
* 压缩贴图地址 | ||
*/ | ||
compressed: { | ||
// 安卓 | ||
astc?: string, | ||
pvrtc?: string, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { ComponentData, DataPath } from '../components'; | ||
import type { ItemType } from '../type'; | ||
import type { BaseItem } from './base-item'; | ||
|
||
/** | ||
* 音频元素 | ||
*/ | ||
export interface AudioItem extends BaseItem { | ||
/** | ||
* 元素类型(指定为 audio) | ||
*/ | ||
type: ItemType.audio, | ||
/** | ||
* 音频元素基础属性 | ||
*/ | ||
content: AudioComponentData, | ||
} | ||
|
||
export interface AudioContentOptions { | ||
/** | ||
* 音频链接,索引到 scene 中的 audios 数组 | ||
*/ | ||
audio: DataPath, | ||
/** | ||
* 音频播放速度 | ||
* @default 1 | ||
*/ | ||
playbackRate?: number, | ||
/** | ||
* 是否静音播放 | ||
* @default false | ||
*/ | ||
muted?: boolean, | ||
/** | ||
* 音频音量大小 | ||
* @default 1 | ||
*/ | ||
volume?: number, | ||
} | ||
|
||
/** | ||
* 音频组件属性 | ||
*/ | ||
export interface AudioComponentData extends ComponentData { | ||
/** | ||
* 音频元素基础属性 | ||
*/ | ||
options: AudioContentOptions, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.