• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SceneType
2<!--Kit: ArkGraphics 3D-->
3<!--Subsystem: Graphics-->
4<!--Owner: @zzhao0-->
5<!--SE: @zdustc-->
6<!--TSE: @zhangyue283-->
7
8The module provides common data types in 3D graphics.
9
10> **NOTE**
11>
12> 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.
13
14## Modules to Import
15```ts
16import { Vec2, Vec3, Vec4, Quaternion, Aabb, Color, Rect, GeometryType, PrimitiveTopology, CustomGeometry, CubeGeometry, PlaneGeometry, SphereGeometry, Position3, Rotation3, Scale3 } from '@kit.ArkGraphics3D';
17```
18
19## Vec2
20A two-dimensional vector used to represent a point or a direction in 2D space. It consists of two components: x and y.
21
22**System capability**: SystemCapability.ArkUi.Graphics3D
23| Name| Type| Read Only| Optional| Description|
24| ---- | ---- | ---- | ---- | ---- |
25| x | number | No| No| Component on the X axis. The value is a real number.|
26| y | number | No| No| Component on the Y axis. The value is a real number.|
27
28## Vec3
29A 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.
30
31**System capability**: SystemCapability.ArkUi.Graphics3D
32| Name| Type| Read Only| Optional| Description|
33| ---- | ---- | ---- | ---- | ---- |
34| x | number | No| No| Component on the X axis. The value is a real number.|
35| y | number | No| No| Component on the Y axis. The value is a real number.|
36| z | number | No| No| Component on the Z axis. The value is a real number.|
37
38## Vec4
39A 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.
40
41**System capability**: SystemCapability.ArkUi.Graphics3D
42| Name| Type| Read Only| Optional| Description|
43| ---- | ---- | ---- | ---- | ---- |
44| x | number | No| No| Component on the X axis. The value is a real number.|
45| y | number | No| No| Component on the Y axis. The value is a real number.|
46| z | number | No| No| Component on the Z axis. The value is a real number.|
47| w | number | No| No| Component on the W axis. The value is a real number.|
48
49## Quaternion
50A 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.
51
52**System capability**: SystemCapability.ArkUi.Graphics3D
53| Name| Type| Read Only| Optional| Description|
54| ---- | ---- | ---- | ---- | ---- |
55| x | number | No| No| Component on the X axis. The value is a real number.|
56| y | number | No| No| Component on the Y axis. The value is a real number.|
57| z | number | No| No| Component on the Z axis. The value is a real number.|
58| w | number | No| No| Component on the W axis. The value is a real number.|
59
60## Aabb
61Axis aligned boundary box used to determine whether two objects in space are overlapping.
62
63**System capability**: SystemCapability.ArkUi.Graphics3D
64| Name| Type| Read Only| Optional| Description|
65| ---- | ---- | ---- | ---- | ---- |
66| aabbMin | [Vec3](#vec3) | No| No| Minimum bounds of the AABB.|
67| aabbMax | [Vec3](#vec3) | No| No| Maximum bounds of the AABB.|
68
69## Color
70Color in RGBA format. It consists of four components: red, green, blue, and alpha.
71
72**System capability**: SystemCapability.ArkUi.Graphics3D
73| Name| Type| Read Only| Optional| Description|
74| ---- | ---- | ---- | ---- | ---- |
75| r | number | No| No| Red component. The value range is [0, 1].|
76| g | number | No| No| Green component. The value range is [0, 1].|
77| b | number | No| No| Blue component. The value range is [0, 1].|
78| a | number | No| No| Alpha component. The value range is [0, 1].|
79
80## Rect
81Rectangle in a plane.
82
83**System capability**: SystemCapability.ArkUi.Graphics3D
84| Name| Type| Read Only| Optional| Description|
85| ---- | ---- | ---- | ---- | ---- |
86| x | number | No| No| X coordinate of the lower-left corner of the rectangle, in the units of the coordinate system it belongs to. It can be any real number, with the specific range depending on the scene's coordinate system settings.|
87| y | number | No| No| Y coordinate of the lower-left corner of the rectangle, in the units of the coordinate system it belongs to. It can be any real number, with the specific range depending on the scene's coordinate system settings.|
88| width | number | No| No| Width of the rectangle, in the units of the coordinate system it belongs to. The value must be greater than 0.|
89| height | number | No| No| Height of the rectangle, in the units of the coordinate system it belongs to. The value must be greater than 0.|
90## GeometryType<sup>18+</sup>
91Enumerates the geometry types.
92
93**System capability**: SystemCapability.ArkUi.Graphics3D
94
95| Name| Value| Description|
96| ---- | ---- | ---- |
97| CUSTOM | 0 | Undefined.|
98| CUBE | 1 | Cube.|
99| PLANE | 2 | Plane.|
100| SPHERE | 3 | Sphere.|
101
102## GeometryDefinition<sup>18+</sup>
103An abstract class used to define the properties of specific geometry types.
104
105**System capability**: SystemCapability.ArkUi.Graphics3D
106| Name| Type| Read Only| Optional| Description|
107| ---- | ---- | ---- | ---- | ---- |
108| geometryType | [GeometryType](#geometrytype18)| Yes| No| Type of geometry.|
109
110## PrimitiveTopology<sup>18+</sup>
111Enumerates the vertex processing methods.
112
113**System capability**: SystemCapability.ArkUi.Graphics3D
114
115| Name| Value| Description|
116| ---- | ---- | ---- |
117| TRIANGLE_LIST | 0 | A set of vertices forming separate triangles without intersecting.|
118| TRIANGLE_STRIP | 1 | Each vertex and the edge of the previous triangle create a new triangle.|
119
120## CustomGeometry<sup>18+</sup>
121A custom geometry type that inherits from [GeometryDefinition](#geometrydefinition18).
122
123**System capability**: SystemCapability.ArkUi.Graphics3D
124
125| Name| Type| Read Only| Optional| Description|
126| ---- | ---- | ---- | ---- | ---- |
127| topology | [PrimitiveTopology](#primitivetopology18)| No| Yes| Parsing mode of triangle primitives. The default value is **TRIANGLE_LIST**.|
128| vertices | [Vec3](#vec3)[] | No| No| Array of vertices that make up the model.|
129| indices | number[] | No| Yes| Array of indices for the vertices, with values starting at 0. The default value is undefined.|
130| normals | [Vec3](#vec3)[] | No| Yes| Array of normals corresponding to the vertices. The default value is undefined.|
131| uvs | [Vec2](#vec2)[] | No| Yes| Array of UV coordinates for the vertices. The default value is undefined.|
132| colors | [Color](#color)[] | No| Yes| Array of colors for the vertices. The default value is undefined.|
133
134## CubeGeometry<sup>18+</sup>
135A cube geometry type that inherits from [GeometryDefinition](#geometrydefinition18).
136
137**System capability**: SystemCapability.ArkUi.Graphics3D
138
139| Name| Type| Read Only| Optional| Description|
140| ---- | ---- | ---- | ---- | ---- |
141| size | [Vec3](#vec3) | No| No| Width, height, and depth of the cube, defining its size.|
142
143## PlaneGeometry<sup>18+</sup>
144A plane geometry type that inherits from [GeometryDefinition](#geometrydefinition18).
145
146**System capability**: SystemCapability.ArkUi.Graphics3D
147
148| Name| Type| Read Only| Optional| Description|
149| ---- | ---- | ---- | ---- | ---- |
150| size | [Vec2](#vec2) | No| No| Width and height of the plane, defining its size.|
151
152## SphereGeometry<sup>18+</sup>
153A sphere geometry type that inherits from [GeometryDefinition](#geometrydefinition18).
154
155**System capability**: SystemCapability.ArkUi.Graphics3D
156
157| Name| Type| Read Only| Optional| Description|
158| ---- | ---- | ---- | ---- | ---- |
159| radius | number | No| No| Radius of the sphere, measured in the world coordinate system's units (for example, cm, m, or km). The value must be greater than 0.|
160| segmentCount | number | No| No| Number of segments dividing the sphere along latitude and longitude. The value must be greater than 0.|
161
162## Position3
163type Position3 = Vec3
164
165Position of an object in 3D space. The value is of the [Vec3](#vec3) type.
166
167**System capability**: SystemCapability.ArkUi.Graphics3D
168
169| Type | Description|
170| ---- | ---- |
171| [Vec3](#vec3) | Any 3D vector.|
172
173## Rotation3
174type Rotation3 = Vec3
175
176Rotation of an object in 3D space. The value is of the [Vec3](#vec3) type.
177
178**System capability**: SystemCapability.ArkUi.Graphics3D
179
180| Type | Description|
181| ---- | ---- |
182| [Vec3](#vec3) | Any 3D vector.|
183
184## Scale3
185type Scale3 = Vec3
186
187Scaling of an object in 3D space. The type is [Vec3](#vec3).
188
189**System capability**: SystemCapability.ArkUi.Graphics3D
190
191| Type| Description|
192| ---- | ---- |
193| [Vec3](#vec3) | Any 3D vector.|
194