Ai
46 Star 180 Fork 4.8K

OpenHarmony/interface_sdk-js
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SceneResources.d.ts 19.54 KB
一键复制 编辑 原始数据 按行查看 历史
liqianqian4 提交于 2025-08-08 19:38 +08:00 . Correction of typos
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
/*
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file Defines 3D resource related interfaces
* @kit ArkGraphics3D
*/
import { Vec2, Vec3, Vec4, Aabb } from './SceneTypes';
import { Callback } from '../@ohos.base';
/**
* The enum of SceneResource type.
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum SceneResourceType {
/**
* The resource is an Unknown.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
UNKNOWN = 0,
/**
* The resource is a Node.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
NODE = 1,
/**
* The resource is an Environment.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
ENVIRONMENT = 2,
/**
* The resource is a Material.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
MATERIAL = 3,
/**
* The resource is a Mesh.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
MESH = 4,
/**
* The resource is an Animation.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
ANIMATION = 5,
/**
* The resource is a Shader.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
SHADER = 6,
/**
* The resource is an Image.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
IMAGE = 7,
/**
* The resource is a mesh resource
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 18
*/
MESH_RESOURCE = 8,
}
/**
* Define scene resource extended by other 3d resource.
*
* @interface SceneResource
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface SceneResource {
/**
* Scene resource name.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
name: string;
/**
* Scene resource type.
*
* @type { SceneResourceType }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly resourceType: SceneResourceType;
/**
* Scene resource uri.
*
* @type { ?ResourceStr }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly uri?: ResourceStr;
/**
* Release scene resource.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
destroy(): void;
}
/**
* Shader resource.
*
* @extends SceneResource
* @interface Shader
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Shader extends SceneResource {
/**
* Shader inputs.
*
* @type { Record<string, number | Vec2 | Vec3 | Vec4 | Image> }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly inputs: Record<string, number | Vec2 | Vec3 | Vec4 | Image>;
}
/**
* The enum of material type.
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum MaterialType {
/**
* The material type is a Shader.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
SHADER = 1,
/**
* The material is a physically-based metallic roughness material.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
METALLIC_ROUGHNESS = 2,
}
/**
* The enum of PBR material cull mode.
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export enum CullMode {
/**
* Disable culling.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
NONE = 0,
/**
* Front face culling.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
FRONT = 1,
/**
* Back face culling.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
BACK = 2
}
/**
* Blend interface.
*
* @interface Blend
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface Blend {
/**
* Control whether blending is enabled
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
enabled: boolean;
}
/**
* Render sort Layer. Within a render slot a layer can define a sort layer order.
* There are 0-63 values available (0 first, 63 last). Default id value is 32.
* 1. Typical use case is to set render sort layer to objects which render with depth test without depth write.
* 2. Typical use case is to always render character and/or camera object first to cull large parts of the view.
* 3. Sort e.g. plane layers.
*
* @interface RenderSort
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface RenderSort {
/**
* Sort layer used sorting submeshes in rendering in render slots.
* Valid values are 0 - 63.
*
* @type { ?number }
* @default 32 Default render sort layer id.
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
renderSortLayer?: number;
/**
* Sort layer order to describe fine order within sort layer.
* Valid values are 0 - 255.
*
* @type { ?number }
* @default 0 Default render sort layer order.
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
renderSortLayerOrder?: number;
}
/**
* Material resource.
*
* @extends SceneResource
* @interface Material
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Material extends SceneResource {
/**
* Material resource type.
*
* @type { MaterialType }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly materialType: MaterialType;
/**
* Defines if the material can receive shadows.
*
* @type { ?boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
shadowReceiver?: boolean;
/**
* Culling mode.
*
* @type { ?CullMode }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
cullMode?: CullMode;
/**
* Control whether the blend is enabled
*
* @type { ?Blend }
* @default undefined, which means that blending is disabled.
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
blend?: Blend;
/**
* Alpha cutoff value [0,1]. Enabled if < 1.
*
* @type { ?number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
alphaCutoff?: number;
/**
* Render sorting priority for layers.
*
* @type { ?RenderSort }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
renderSort?: RenderSort;
}
/**
* Material property interface.
*
* @interface MaterialProperty
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface MaterialProperty {
/**
* Texture to use. If undefined, factor defines the diffuse color.
*
* @type { Image | null }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
image: Image | null;
/**
* Texture coefficient. Default is {1,1,1,1}, meaning no effect.
*
* @type { Vec4 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
factor: Vec4;
/**
* Texture Sampler.
*
* @type { ?Sampler }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
sampler?: Sampler;
}
/**
* Physically-based metallic roughness material resource.
*
* @extends Material
* @interface MetallicRoughnessMaterial
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface MetallicRoughnessMaterial extends Material {
/**
* Base color factor of PBR material.
* Value of factor.xyzw defines rgba color.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
baseColor: MaterialProperty;
/**
* Normal factor of PBR material.
* Value of factor.x defines normal scale.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
normal: MaterialProperty;
/**
* Metallic roughness material parameters.
* Value of factor.y defines roughness, factor.z defines metallic and factor.a defines reflectance.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
material: MaterialProperty;
/**
* Ambient occlusion of PBR material.
* Value of factor.x defines ambient occlusion factor.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
ambientOcclusion: MaterialProperty;
/**
* Emissive property of PBR material.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
emissive: MaterialProperty;
/**
* Clearcoat intensity.
* Value of factor.x defines clearcoat layer intensity.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
clearCoat: MaterialProperty;
/**
* Clearcoat roughness.
* Value of factor.y defines clearcoat layer roughness.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
clearCoatRoughness: MaterialProperty;
/**
* Clearcoat normal.
* Value of factor.xyz defines RGB clearcoat normal scale.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
clearCoatNormal: MaterialProperty;
/**
* Sheen color of PBR material.
* Value of factor.xyz defines RGB sheen color,
* Value of factor.w defines sheen roughness.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
sheen: MaterialProperty;
/**
* Specular color of PBR material.
* Value of factor.xyz defines RGB specular color,
* Value of factor.w defines specular intensity.
*
* @type { MaterialProperty }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
specular: MaterialProperty;
}
/**
* Shader material resource.
*
* @extends Material
* @interface ShaderMaterial
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface ShaderMaterial extends Material {
/**
* Color shader of material.
*
* @type { ?Shader }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
colorShader?: Shader;
}
/**
* Sampler filter Mode
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export enum SamplerFilter {
/**
* Use nearest filtering
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
NEAREST = 0,
/**
* Use linear filtering
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
LINEAR = 1,
}
/**
* Addressing mode for Sampler
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export enum SamplerAddressMode {
/**
* Repeat
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
REPEAT = 0,
/**
* Mirrored repeat
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
MIRRORED_REPEAT = 1,
/**
* clamp to edge
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
CLAMP_TO_EDGE = 2,
}
/**
* Sampler interface
*
* @interface { Sampler }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface Sampler {
/**
* Mag filter
*
* @type { ?SamplerFilter }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
magFilter?: SamplerFilter;
/**
* Min filter
*
* @type { ?SamplerFilter }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
minFilter?: SamplerFilter;
/**
* Mip-map mode
*
* @type { ?SamplerFilter }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
mipMapMode?: SamplerFilter;
/**
* U addressing mode
*
* @type { ?SamplerAddressMode }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
addressModeU?: SamplerAddressMode;
/**
* V addressing mode
*
* @type { ?SamplerAddressMode }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
addressModeV?: SamplerAddressMode;
}
/**
* Sub mesh resource.
*
* @interface SubMesh
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface SubMesh {
/**
* The name of the sub mesh.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
name: string;
/**
* The material of the sub mesh.
*
* @type { Material }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
material: Material;
/**
* The axis aligned bounding box of the sub mesh.
*
* @type { Aabb }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly aabb: Aabb;
}
/**
* Defines Morpher interface for specifying morph targets for Node's geometry.
*
* @interface Morpher
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
export interface Morpher {
/**
* Morph target names and weights
*
* @type { Record<string, number> }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
readonly targets: Record<string, number>;
}
/**
* Mesh resource.
*
* @extends SceneResource
* @interface Mesh
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Mesh extends SceneResource {
/**
* The sub meshes of the mesh.
*
* @type { SubMesh[] }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly subMeshes: SubMesh[];
/**
* The axis aligned bounding box of the mesh.
*
* @type { Aabb }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly aabb: Aabb;
/**
* The material override sub mesh's material.
*
* @type { ?Material }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
materialOverride?: Material;
}
/**
* Mesh resource.
*
*
* @extends SceneResource
* @interface MeshResource
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 18
*/
export interface MeshResource extends SceneResource {
}
/**
* Animation resource.
*
* @extends SceneResource
* @interface Animation
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Animation extends SceneResource {
/**
* The animation is enabled.
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
enabled: boolean;
/**
* Animation speed factor
* A negative value runs the animation in reverse using the given speed factor
*
* @type { ?number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 20
*/
speed?: number;
/**
* The duration of the animation.
*
* @type { number }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly duration: number;
/**
* Whether the animation is running.
*
* @type { boolean }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly running: boolean;
/**
* The progress of the animation between 0~1.
*
* @type { number }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly progress: number;
/**
* Register a callback when animation finished.
*
* @param { Callback<void> } callback - the callback invoked when animation finished
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
onFinished(callback: Callback<void>): void;
/**
* Register a callback when animation started.
*
* @param { Callback<void> } callback - the callback invoked when animation started
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
onStarted(callback: Callback<void>): void;
/**
* Pause the animation.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
pause(): void;
/**
* Restart the animation.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
restart(): void;
/**
* Seek the animation to the position.
*
* @param { number } position - the position seek between 0~1
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
seek(position: number): void;
/**
* Start the animation.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
start(): void;
/**
* Stop the animation and seek the position to the beginning.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
stop(): void;
/**
* Finish the animation and seek the position to the end.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
finish(): void;
}
/**
* The enum of environment background type.
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum EnvironmentBackgroundType {
/**
* The background is none.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
BACKGROUND_NONE = 0,
/**
* The background is image.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
BACKGROUND_IMAGE = 1,
/**
* The background is cubemap.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
BACKGROUND_CUBEMAP = 2,
/**
* The background is equirectangular.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
BACKGROUND_EQUIRECTANGULAR = 3,
}
/**
* Environment resource.
*
* @extends SceneResource
* @interface Environment
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Environment extends SceneResource {
/**
* The background type of the environment.
*
* @type { EnvironmentBackgroundType }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
backgroundType: EnvironmentBackgroundType;
/**
* The indirect diffuse factor of the environment.
*
* @type { Vec4 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
indirectDiffuseFactor: Vec4;
/**
* The indirect specular factor of the environment.
*
* @type { Vec4 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
indirectSpecularFactor: Vec4;
/**
* The environment map factor of the environment.
*
* @type { Vec4 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
environmentMapFactor: Vec4;
/**
* The environment image of the environment.
*
* @type { ?(Image | null) }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
environmentImage?: Image | null;
/**
* The radiance image of the environment.
*
* @type { ?(Image | null) }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
radianceImage?: Image | null;
/**
* The irradiance coefficients (array of nine Vec3).
*
* @type { ?Vec3[] }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
irradianceCoefficients?: Vec3[];
}
/**
* Image resource.
*
* @extends SceneResource
* @interface Image
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Image extends SceneResource {
/**
* The width of the image.
*
* @type { number }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly width: number;
/**
* The height of the image.
*
* @type { number }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly height: number;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/interface_sdk-js.git
git@gitee.com:openharmony/interface_sdk-js.git
openharmony
interface_sdk-js
interface_sdk-js
master

搜索帮助