openharmony 鸿蒙 js-apis-inner-scene-types

2025-06-12 浏览 (1)

SceneType

The SceneType module provides common data types in 3D graphics.

NOTE

The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { Vec2, Vec3, Vec4, Quaternion, Aabb, Color, Rect, GeometryType, PrimitiveTopology, CustomGeometry, CubeGeometry, PlaneGeometry, SphereGeometry, Position3, Rotation3, Scale3 } from '@kit.ArkGraphics3D';

Vec2

A two-dimensional vector used to represent a point or a direction in 2D space. It consists of two components: x and y.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
xnumberNoNoComponent on the X axis. The value is a real number.
ynumberNoNoComponent on the Y axis. The value is a real number.

Vec3

A three-dimensional vector used to represent a point, a direction, or a vector transformation in 3D space. It consists of three components: x, y, and z.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
xnumberNoNoComponent on the X axis. The value is a real number.
ynumberNoNoComponent on the Y axis. The value is a real number.
znumberNoNoComponent on the Z axis. The value is a real number.

Vec4

A four-dimensional vector used to represent a point, a direction, or a vector transformation in 4D space. It consists of four components: x, y, z, and w. The fourth component (w) enhances normalization and convenience for various calculations and transformations.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
xnumberNoNoComponent on the X axis. The value is a real number.
ynumberNoNoComponent on the Y axis. The value is a real number.
znumberNoNoComponent on the Z axis. The value is a real number.
wnumberNoNoComponent on the W axis. The value is a real number.

Quaternion

A mathematical notation for representing spatial rotations of elements in 3D space. Compared with Euler angles, a quaternion has advantages in numerical stability and avoiding the gimbal lock problem.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
xnumberNoNoComponent on the X axis. The value is a real number.
ynumberNoNoComponent on the Y axis. The value is a real number.
znumberNoNoComponent on the Z axis. The value is a real number.
wnumberNoNoComponent on the W axis. The value is a real number.

Aabb

Axis aligned boundary box used to determine whether two objects in space are overlapping.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
aabbMinVec3NoNoMinimum bounds of the AABB.
aabbMaxVec3NoNoMaximum bounds of the AABB.

Color

Color in RGBA format. It consists of four components: red, green, blue, and alpha.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
rnumberNoNoRed component. The value range is [0, 1].
gnumberNoNoGreen component. The value range is [0, 1].
bnumberNoNoBlue component. The value range is [0, 1].
anumberNoNoAlpha component. The value range is [0, 1].

Rect

Rectangle in a plane.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
xnumberNoNoX axis component in the lower left corner of the rectangle. The value is a real number.
ynumberNoNoY axis component in the lower left corner of the rectangle. The value is a real number.
widthnumberNoNoWidth of the rectangle. The value must be greater than 0.
heightnumberNoNoHeight of the rectangle. The value must be greater than 0.

GeometryType18+

Enumerates the geometry types.

System capability: SystemCapability.ArkUi.Graphics3D

NameValueDescription
CUSTOM0Undefined.
CUBE1Cube.
PLANE2Plane.
SPHERE3Sphere.

GeometryDefinition18+

An abstract class used to define the properties of specific geometry types.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
geometryTypeGeometryTypeYesNoType of geometry.

PrimitiveTopology18+

Enumerates the vertex processing methods.

System capability: SystemCapability.ArkUi.Graphics3D

NameValueDescription
TRIANGLE_LIST0A set of vertices forming separate triangles without intersecting.
TRIANGLE_STRIP1Each vertex and the edge of the previous triangle create a new triangle.

CustomGeometry18+

A custom geometry type that inherits from GeometryDefinition.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
topologyPrimitiveTopologyNoYesParsing mode of triangle primitives. The default value is TRIANGLE_LIST.
verticesVec3[]NoNoArray of vertices that make up the model.
indicesnumber[]NoYesArray of indices for the vertices, with values starting at 0. The default value is undefined.
normalsVec3[]NoYesArray of normals corresponding to the vertices. The default value is undefined.
uvsVec2[]NoYesArray of UV coordinates for the vertices. The default value is undefined.
colorsColor[]NoYesArray of colors for the vertices. The default value is undefined.

CubeGeometry18+

A cube geometry type that inherits from GeometryDefinition.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
sizeVec3NoNoWidth, height, and depth of the cube, defining its size.

PlaneGeometry18+

A plane geometry type that inherits from GeometryDefinition.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
sizeVec2NoNoWidth and height of the plane, defining its size.

SphereGeometry18+

A sphere geometry type that inherits from GeometryDefinition.

System capability: SystemCapability.ArkUi.Graphics3D

NameTypeRead OnlyOptionalDescription
radiusnumberNoNoRadius of the sphere. The value must be greater than 0.
segmentCountnumberNoNoNumber of segments dividing the sphere along latitude and longitude. The value must be greater than 0.

Position3

type Position3 = Vec3

Position of an object in 3D space. The value is of the Vec3 type.

System capability: SystemCapability.ArkUi.Graphics3D

TypeDescription
Vec3Any 3D vector.

Rotation3

type Rotation3 = Vec3

Rotation of an object in 3D space. The value is of the Vec3 type.

System capability: SystemCapability.ArkUi.Graphics3D

TypeDescription
Vec3Any 3D vector.

Scale3

type Scale3 = Vec3

Scaling of an object in 3D space. The type is Vec3.

System capability: SystemCapability.ArkUi.Graphics3D

TypeDescription
Vec3Any 3D vector.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 3D

harmony 鸿蒙SceneNode

harmony 鸿蒙ScenePostProcessSettings

harmony 鸿蒙SceneResource

harmony 鸿蒙Scene

harmony 鸿蒙@ohos.graphics.scene (ArkGraphics 3D)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/gipYaT