update graphics3d scene api

Signed-off-by: huxiaoming5@huawei.com <huxiaoming5@huawei.com>
Change-Id: I7b7280276fea9abbef539a0f2805fe5b5c14f65a
This commit is contained in:
huxiaoming5@huawei.com 2024-04-16 10:44:29 +08:00
parent f71df3bda2
commit a4e5d4e584
7 changed files with 1726 additions and 0 deletions

56
api/@ohos.graphics.scene.d.ts vendored Normal file
View File

@ -0,0 +1,56 @@
/*
* 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
* @kit ArkGraphics3D
*/
/**
* Export post processing settings
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export { TonemapType, TonemapSettings, PostProcessSettings } from './graphics3d/scenePostProcessSettings';
/**
* Export scene types
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export { Vec2, Vec3, Vec4, Color, Rect, Quaternion, Aabb, Position3, Rotation3, Scale3 } from './graphics3d/sceneTypes';
/**
* Export scene resources
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export { SceneResourceType, SceneResource, Shader, MaterialType, Material, ShaderMaterial,
SubMesh, Mesh, Animation, EnvironmentBackgroundType, Environment, Image } from './graphics3d/sceneResources';
/**
* Export scene nodes
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export { Layermask, NodeType, Container, Node, Geometry, LightType, Light, SpotLight, DirectionalLight,
Camera } from './graphics3d/sceneNodes';
/**
* Export scene
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export { SceneResourceParameters, SceneNodeParameters, SceneResourceFactory, Scene } from './graphics3d/scene';

231
api/graphics3d/Scene.d.ts vendored Normal file
View File

@ -0,0 +1,231 @@
/*
* 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
* @kit ArkGraphics3D
*/
import { Shader, MaterialType, Material, Animation, Environment, Image } from './sceneResources'
import { Camera, LightType, Light, Node, NodeType } from './sceneNodes'
import { Resource } from 'GlobalResource';
/**
* The scene resource parameters type.
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type SceneResourceParameters = {
/**
* The name of the scene resource parameters.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
name: string;
/**
* The resource uri of the scene resource parameters.
*
* @type { ?Resource }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
uri?: Resource;
}
/**
* The scene node parameters type.
*
* @typedef SceneNodeParameters
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface SceneNodeParameters = {
/**
* The name of the scene node parameters.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
name: string;
/**
* The path of the scene node parameters.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
path?: string;
}
/**
* The scene resource factory.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface SceneResourceFactory {
/**
* Create a camera.
*
* @param { SceneNodeParameters } params - the param of creating a camera
* @returns { Promise<Camera> } promise a camera
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createCamera(params: SceneNodeParameters): Promise<Camera>;
/**
* Create a light.
*
* @param { SceneNodeParameters } params - the param of creating a light
* @param { LightType } lightType - the type of the light
* @returns { Promise<Light> } promise a light
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createLight(params: SceneNodeParameters, lightType: LightType): Promise<Light>;
/**
* Create a node.
*
* @param { SceneNodeParameters } params - the param of creating a node
* @returns { Promise<Node> } promise a node
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createNode(params: SceneNodeParameters): Promise<Node>;
/**
* Create a material.
*
* @param { SceneResourceParameters } params - the param of creating a material
* @param { MaterialType } materialType - the type of the material
* @returns { Promise<Material> } promise a material
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createMaterial(params: SceneResourceParametersm materialType: MaterialType): Promise<Material>;
/**
* Create a shader.
*
* @param { SceneResourceParameters } params - the param of creating a shader
* @returns { Promise<Shader> } promise a shader
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createShader(params: SceneResourceParameters): Promise<Shader>;
/**
* Create a image.
*
* @param { SceneResourceParameters } params - the param of creating a image
* @returns { Promise<Image> } promise a image
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createImage(params: SceneResourceParameters): Promise<Image>;
/**
* Create a environment.
*
* @param { SceneResourceParameters } params - the param of creating a Environment object
* @returns { Promise<Environment> } promise a Environment
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
createEnvironment(params: SceneResourceParameters): Promise<Environment>;
}
/**
* Define the 3d scene.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export class Scene {
/**
* Create a new scene from a Resource.
*
* @param { ?Resource } uri - the resource of creating a scene
* @returns { Promise<Scene> } promise a scene
* @static
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
static load(uri? : Resource): Promise<Scene>;
/**
* The environment of the scene.
*
* @type { Environment }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
environment: Environment;
/**
* The animations of the scene.
*
* @type { Animation[] }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly animations: Animation[];
/**
* The root node of the scene.
*
* @type { Node | null }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly root: Node | null;
/**
* Get a node by path.
*
* @param { string } path - the path of the node
* @param { ?NodeType } type - verify the type of node, if it does not match, return null
* @returns { Node | null} if the node is found by it's path
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
getNodeByPath(path: string, type?: NodeType): Node | null;
/**
* Get resource factory.
*
* @returns { SceneResourceFactory } if the node is found by it's path
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
getResourceFactory(): SceneResourceFactory;
/**
* Release all native scene resources. All TS references will be undefined.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
destroy(): void;
}

446
api/graphics3d/SceneNodes.d.ts vendored Normal file
View File

@ -0,0 +1,446 @@
/*
* 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
* @kit ArkGraphics3D
*/
import { SceneResource, Mesh } from './sceneResources';
import { Position3, Quaterion, Scale3, Color } from './sceneTypes';
import { PostProcessSettings } from './scenePostProcessSettings';
/**
* Define the layer mask of the node.
*
* @interface LayerMask
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface LayerMask {
/**
* Get whether layer mask is enabled.
*
* @param { number } index - the layer mask
* @returns { boolean } whether layer mask is enabled
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
getEnabled(index: number): boolean;
/**
* Set whether layer mask is enabled.
*
* @param { number } index - the layer mask
* @param { boolean } whether layer mask is enabled
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
setEnabled(indx: number, enabled: boolean): void;
}
/**
* The enum of node type.
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum NodeType {
/**
* The node is an empty node.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
NODE = 1,
/**
* The node is a geometry node.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
GEOMETRY = 2,
/**
* The node is a camera node.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
CAMERA = 3,
/**
* The node is a light node.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
LIGHT = 4
}
/**
* Define a scene object container.
*
* @interface Container
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Container<T> {
/**
* Append a item to the container.
*
* @param { T } item - the item append to the end of container
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
append(item: T): void;
/**
* Insert a item.
*
* @param { T } item - the item insert to the container
* @param { T } sibling - insert after this item, insert to the head if sibling is null
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
insertAfter(item: T, sibling: T | null): void;
/**
* Remove a item from Container's children.
*
* @param { T } item - the item to be removed
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
remove(item: T): void;
/**
* Return a child at given index from this Container's child list.
*
* @param { T } index - the index of the child to return
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
get(index: number): T | null;
/**
* Clear all children.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
clear(): void;
/**
* Return the number of items in the container.
*
* @returns { number } the number of the container
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
count(): number;
}
/**
* Define Node interface.
*
* @interface Node
* @extends SceneResource
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Node extends SceneResource {
/**
* position of the node.
*
* @type { Position3 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
position: Position3;
/**
* Rotation of the node.
*
* @type { Quaternion }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
rotation: Quaternion;
/**
* Scale of the node.
*
* @type { Scale3 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
scale: Scale3;
/**
* Visibility flag for the node.
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
visible: boolean;
/**
* Type of the node.
*
* @type { NodeType }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly nodeType: NodeType;
/**
* Layer mask of the node.
*
* @type { LayerMask }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly layerMask: LayerMask;
/**
* Path of the node.
*
* @type { string }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly path: string;
/**
* Parent of the node.
*
* @type { Node | null }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly parent: Node | null;
/**
* Get node by path.
*
* @param { string } path - the path of the node queried
* @returns { Node | null }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
getNodeByPath(path: string): Node | null;
/**
* Children of the node.
*
* @type { Container<Node> }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly children: Container<Node>
}
/**
* Define Geometry interface.
*
* @interface Geometry
* @extends Node
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Geometry extends Node {
/**
* Mesh of the node.
*
* @type { Mesh }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly mesh: Mesh;
}
/**
* The enum of light type.
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum LightType {
/**
* Directional light.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
DIRECTIONAL = 1,
/**
* Spot light.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
SPOT = 2,
}
/**
* Define light interface.
* @interface Light
* @extends Node
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Light extends Node {
/**
* The type of the light.
*
* @type { LightType }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly lightType: LightType;
/**
* The color of the light.
*
* @type { Color }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
color: Color;
/**
* The intensity of the light.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
intensity: number;
/**
* Whether casting shadows.
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
shadowEnabled: boolean;
/**
* Whether enable the light.
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
enabled: boolean;
}
/**
* Define spot light.
*
* @interface SpotLight
* @extends Light
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface SpotLight extends Light {
}
/**
* Define directional light.
*
* @interface DirectionalLight
* @extends Light
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface DirectionalLight extends Light {
/**
* Near plane of the directional light.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
nearPlane: number;
}
/**
* Define camera.
* @interface Camera
* @extends node
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Camera extends Node {
/**
* Field of view of the camera.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
fov: number;
/**
* Near plane of the directional light.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
nearPlane: number;
/**
* Far plane of the directional light.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
farPlane: number;
/**
* Whether enabled the camera.
*
* @type { boolean }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
enabled: boolean;
/**
* The post processing settings of the camera.
*
* @type { PostProcessSettings | null }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
postProcess: PostProcessSettings | null;
}

View File

@ -0,0 +1,97 @@
/*
* 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
* @kit ArkGraphics3D
*/
/**
* The enum of tone mapping type.
*
* @enum { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export enum TonemapType {
/**
* The tone mapping type is ACES.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
ACES = 0,
/**
* The tone mapping type is ACES_2020.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
ACES_2020 = 1,
/**
* The tone mapping type is FILMIC.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
FILMIC = 2,
}
/**
* Define tone mapping parameters.
*
* @typedef TonemapSettings
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type TonemapSettings = {
/**
* Type of the tone mapping.
*
* @type { TonemapType }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
type?: TonemapType;
/**
* Exposure of the tone mapping.
*
* @type { ?number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
exposure?: number;
}
/**
* Define post processing settings.
*
* @typedef PostProcessingSettings
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type PostProcessSettings = {
/**
* Tone mapping settings of the post processing settings.
*
* @type { ?TonemapSettings }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
tonemap?: TonemapSettings;
}

551
api/graphics3d/SceneResource.d.ts vendored Normal file
View File

@ -0,0 +1,551 @@
/*
* 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.
*/
import { Vec2, Vec3, Vec4, Aabb } from './sceneTypes'
import { Resource } from './GlobalResource';
/**
* @file
* @kit ArkGraphic3D
*/
/**
* 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,
}
/**
* 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 { string }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly resourceType: SceneResourceType;
/**
* Scene resource uri.
*
* @type { ?Resource }
* @readonly
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
readonly uri?: Resource;
/**
* Release scene resource.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
destroy(): void;
}
/**
* Shader resource.
* @interface Shader
* @extends SceneResource
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Shader extends SceneResource {
/**
* Shader inputs.
*
* @type { Record<string, number | Vec2 | Vec3 | Vec4 | Image> }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
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,
}
/**
* Material resource.
*
* @interface Material
* @extends SceneResource
* @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;
}
/**
* Shader material resource.
*
* @interface ShaderMaterial
* @extends Material
* @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;
}
/**
* 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;
}
/**
* Mesh resource.
*
* @interface Mesh
* @extends SceneResource
* @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;
}
/**
* Animation resource.
*
* @interface Animation
* @extends SceneResource
* @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;
/**
* The duration of the animation.
*
* @type { boolean }
* @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 { () => void } callback - the callback invoked when animation finished
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
onFinished(callback: () => void): void;
/**
* Register a callback when animation started.
*
* @param { () => void } callback - the callback invoked when animation started
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
onStarted(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.
*
* @interface Environment
* @extends SceneResource
* @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.
*
* @interface Image
* @extends SceneResource
* @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;
}

312
api/graphics3d/SceneTypes.d.ts vendored Normal file
View File

@ -0,0 +1,312 @@
/*
* 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
* @kit ArkGraphics3D
*/
/**
* Defines Vec2.
*
* @typedef Vec2
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Vec2 {
/**
* X component of the vec2.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
x: number;
/**
* Y component of the vec2.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
y: number;
}
/**
* Defines Vec3.
*
* @typedef Vec3
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Vec3 {
/**
* X component of the vec3.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
x: number;
/**
* Y component of the vec3.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
y: number;
/**
* Z component of the vec3.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
z: number;
}
/**
* Defines Vec4.
*
* @typedef Vec4
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Vec4 {
/**
* X component of the vec4.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
x: number;
/**
* Y component of the vec4.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
y: number;
/**
* Z component of the vec4.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
z: number;
/**
* W component of the vec4.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
w: number;
}
/**
* Quaternion representing a rotation.
*
* @typedef Quaternion
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Quternion {
/**
* X component of the quaternion.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
x: number;
/**
* Y component of the quaternion.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
y: number;
/**
* Z component of the quaternion.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
z: number;
/**
* W component of the quaternion.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
w: number;
}
/**
* Axis aligned bounding box.
*
* @typedef Aabb
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Aabb {
/**
* Coordinates of the AABB minimum corner.
*
* @type { Vec3 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
aabbMin: Vec3;
/**
* Coordinates of the AABB maximum corner.
*
* @type { Vec3 }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
aabbMax: Vec3;
}
/**
* Defines Color.
*
* @typedef Color
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Color {
/**
* R component of the color.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
r: number;
/**
* G component of the color.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
g: number;
/**
* B component of the color.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
b: number;
/**
* A component of the color.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
a: number;
}
/**
* Defines rectangle.
* @typedef Rect
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export interface Rect {
/**
* Left up x coordinate.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
x: number;
/**
* Left up y coordinate.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
y: number;
/**
* The width of the rectangle.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
width: number;
/**
* The height of the rectangle.
*
* @type { number }
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
height: number;
}
/**
* 3D position information.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type Position3 = Vec3;
/**
* 3D rotation info as euler angles.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type Rotation3 = Vec3;
/**
* 3D scale information.
*
* @syscap SystemCapability.ArkUi.Graphics3D
* @since 12
*/
export type Scale3 = Vec3;

33
kits/@kit.ArkGraphics3D.d.ts vendored Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2022-2023 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
* @kit ArkGraphics3D
*/
import { TonemapType, TonemapSettings, PostProcessSettings,
Vec2, Vec3, Vec4, Color, Rect, Quaternion, Aabb, Position3, Rotation3, Scale3,
SceneResourceType, SceneResource, Shader, MaterialType, Material, ShaderMaterial,
SubMesh, Mesh, Animation, EnvironmentBackgroundType, Environment, Image,
Layermask, NodeType, Container, Node, Geometry, LightType, Light, SpotLight, DirectionalLight, Camera,
SceneResourceParameters, SceneNodeParameters, SceneResourceFactory, Scene } from '@ohos.graphics.scene.d.ts';
export { TonemapType, TonemapSettings, PostProcessSettings,
Vec2, Vec3, Vec4, Color, Rect, Quaternion, Aabb, Position3, Rotation3, Scale3,
SceneResourceType, SceneResource, Shader, MaterialType, Material, ShaderMaterial,
SubMesh, Mesh, Animation, EnvironmentBackgroundType, Environment, Image,
Layermask, NodeType, Container, Node, Geometry, LightType, Light, SpotLight, DirectionalLight, Camera,
SceneResourceParameters, SceneNodeParameters, SceneResourceFactory, Scene };