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 IIndexedVertexElement

Enumerations

constructor(
  elementType: VertexElementType,
  name: string = '',
  mappingMode: MappingMode | null = null,
  referenceMode: ReferenceMode | null = null,
)

Enumerations mappingModeMappingMode.CONTROL_POINT; mặc định referenceModeReferenceMode.DIRECT.

Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
vertexElementTypeVertexElementTypeđọcKiểu ngữ nghĩa của lớp này.
namestringđọc/ghiNhãn tùy chọn cho lớp này.
mappingModeMappingModeđọc/ghiKiểm soát nguyên thủy hình học nào mà mỗi giá trị được gắn kết.
referenceModeReferenceModeđọc/ghiKiể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.
indicesnumber[]đọcMả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 VertexElementFVectorVertexElementIntsTemplate cung cấp các triển khai hoạt động.

Thay thế mảng chỉ mục.

setIndices(data: number[]): void

clear()

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 VertexElementFVectorVertexElementIntsTemplate 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(): void

VertexElementNormal

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 VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementNormal

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 VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementUV

Enumerations

new VertexElementUV(
  textureMapping: TextureMapping | null = null,
  name: string = '',
  mappingMode: MappingMode | null = null,
  referenceMode: ReferenceMode | null = null,
)

Mặc định là TextureMapping.DIFFUSE khi textureMappingnull.

Thuộc tính bổ sung

EnumerationsEnumerationsEnumerationsEnumerations
textureMappingTextureMappingđọcKênh texture mà lớp UV này được liên kết với.
dataFVector4[]đọcCác giá trị UV được hiển thị dưới dạng FVector4 các mục (z và w là 0).
uvDataFVector2[]đọcCá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[]): void

VertexElementVertexColor

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 VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementVertexColor

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');

Xem Thêm

 Tiếng Việt