VertexElement — Aspose.3D TypeScript API Reference
Gói: @aspose/3d (v24.12.0)
VertexElement là lớp cơ sở trừu tượng cho các kênh thuộc tính mỗi đỉnh được gắn vào một Geometry. Mỗi kênh chứa một mảng dữ liệu có kiểu và mappingMode / referenceMode siêu dữ liệu kiểm soát cách dữ liệu liên quan đến các nguyên thủy hình học. Các lớp con là: VertexElementNormal, VertexElementUV, và VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';Enumerations
export abstract class VertexElement implements IIndexedVertexElementEnumerations
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Enumerations mappingMode là MappingMode.CONTROL_POINT; mặc định referenceMode là ReferenceMode.DIRECT.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
vertexElementType | VertexElementType | đọc | Kiểu ngữ nghĩa của lớp này. |
name | string | đọc/ghi | Nhãn tùy chọn cho lớp này. |
mappingMode | MappingMode | đọc/ghi | Kiểm soát nguyên thủy hình học nào mà mỗi giá trị được gắn kết. |
referenceMode | ReferenceMode | đọc/ghi | Kiểm soát việc các giá trị được truy cập trực tiếp hay thông qua một mảng chỉ mục. |
indices | number[] | đọc | Mảng chỉ mục cho IndexToDirect chế độ tham chiếu. |
Enumerations
setIndices(data)
NOT IMPLEMENTED. Trên lớp cơ sở VertexElement class, phương thức này ném ra Error('set_indices is not implemented') khi chạy. Các lớp con VertexElementFVector và VertexElementIntsTemplate cung cấp các triển khai hoạt động.
Thay thế mảng chỉ mục.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Trên lớp cơ sở VertexElement class, phương thức này ném ra Error('clear is not implemented') khi chạy. Các lớp con VertexElementFVector và VertexElementIntsTemplate cung cấp các triển khai hoạt động.
Xóa tất cả dữ liệu và chỉ mục khỏi lớp.
clear(): voidVertexElementNormal
Lưu trữ các vector pháp tuyến bề mặt. Dữ liệu pháp tuyến cần thiết cho hầu hết các bộ render để ánh sáng chính xác.
export class VertexElementNormal extends VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementNormal
Enumerations
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType được cố định thành VertexElementType.NORMAL.
VertexElementUV
Lưu trữ tọa độ texture 2D. Một lưới có thể mang nhiều lớp UV cho các kênh texture khác nhau. The textureMapping thuộc tính xác định mục đích của kênh.
export class VertexElementUV extends VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementUV
Enumerations
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Mặc định là TextureMapping.DIFFUSE khi textureMapping là null.
Thuộc tính bổ sung
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
textureMapping | TextureMapping | đọc | Kênh texture mà lớp UV này được liên kết với. |
data | FVector4[] | đọc | Các giá trị UV được hiển thị dưới dạng FVector4 các mục (z và w là 0). |
uvData | FVector2[] | đọc | Các giá trị UV dưới dạng FVector2 các mục (chỉ x, y). |
addData(data)
Thêm các giá trị UV. Chấp nhận FVector2[], FVector3[], hoặc FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Lưu trữ các giá trị màu RGBA cho mỗi đỉnh. Các thành phần nằm trong khoảng 0–1.
export class VertexElementVertexColor extends VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementVertexColor
Enumerations
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType được cố định thành VertexElementType.VERTEX_COLOR.
Enumerations
Thêm các vector pháp tuyến vào lưới tam giác:
import { Scene, Mesh, Vector4, VertexElementType, MappingMode, ReferenceMode, FVector4 } from '@aspose/3d';
const mesh = new Mesh();
mesh.controlPoints.push(new Vector4(0, 0, 0, 1));
mesh.controlPoints.push(new Vector4(1, 0, 0, 1));
mesh.controlPoints.push(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);
const normals = mesh.createElement(
VertexElementType.NORMAL,
MappingMode.CONTROL_POINT,
ReferenceMode.DIRECT,
);
normals.setData([
new FVector4(0, 0, 1, 0),
new FVector4(0, 0, 1, 0),
new FVector4(0, 0, 1, 0),
]);
const scene = new Scene();
scene.rootNode.createChildNode('tri', mesh);
scene.save('triangle_normals.glb');Thêm các tọa độ UV:
import { Scene, Mesh, Vector4, TextureMapping, MappingMode, ReferenceMode, FVector2 } from '@aspose/3d';
const mesh = new Mesh();
for (const [x, z] of [[0,0],[1,0],[1,1],[0,1]]) {
mesh.controlPoints.push(new Vector4(x, 0, z, 1));
}
mesh.createPolygon(0, 1, 2, 3);
const uv = mesh.createElementUV(TextureMapping.DIFFUSE, MappingMode.CONTROL_POINT, ReferenceMode.DIRECT);
uv.addData([
new FVector2(0, 0),
new FVector2(1, 0),
new FVector2(1, 1),
new FVector2(0, 1),
]);
const scene = new Scene();
scene.rootNode.createChildNode('quad', mesh);
scene.save('quad_uv.glb');