VertexElement — Aspose.3D TypeScript API Reference

gói : @sơm / 3d (v24.0) Đánh giá

VertexElement là lớp cơ sở trừu tượng cho các kênh thuộc tính per-vertex được gắn với một Geometry.Mỗi kênh có một chuỗi dữ liệu được kiểu và mappingMode / referenceMode metadata mà kiểm soát cách dữ liệu liên quan đến các nguyên thủy địa phương. Các subclass là: VertexElementNormal, VertexElementUV, và VertexElementVertexColor.

import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';

VertexElement (tốt cơ bản)

export abstract class VertexElement implements IIndexedVertexElement { }

Constructor

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

Default mappingModeMappingMode.CONTROL_POINT;· Lạm dụng referenceModeReferenceMode.DIRECT.

Properties

PropertyTypeAccessDescription
vertexElementTypeVertexElementTypeReadLoại seman của lớp này.
namestringĐọc / viếtTùy chọn nhãn cho lớp này.
mappingModeMappingModeĐọc / viếtKiểm soát mà địa phương nguyên thủy mỗi giá trị được liên kết với.
referenceModeReferenceModeĐọc / viếtKiểm tra xem các giá trị được hướng trực tiếp hoặc thông qua một chuỗi chỉ số.
indicesnumber[]ReadIndex cho IndexToDirect Mẫu tham khảo.

Methods

setIndices(data)

NOT IMPLEMENTED. trên cơ sở VertexElement lớp, phương pháp này ném Error('set_indices is not implemented') Lời bài hát: The Subclasses VertexElementFVectorVertexElementIntsTemplate cung cấp các hoạt động thực hiện.

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

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Trên cơ sở VertexElement lớp, phương pháp này ném Error('clear is not implemented') Lời bài hát: The Subclasses VertexElementFVectorVertexElementIntsTemplate cung cấp các hoạt động thực hiện.

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 { }

Inheritance

VertexElementVertexElementFVectorVertexElementNormal

Constructor

new VertexElementNormal(
  name: string = '',
  mappingMode: MappingMode | null = null,
  referenceMode: ReferenceMode | null = null,
)

vertexElementType được thiết lập để VertexElementType.NORMAL.


VertexElementUV

Lưu trữ 2D văn hóa phối hợp. một mảnh có thể mang nhiều lớp UV cho các kênh văn hoá khác nhau. textureMapping Tài sản xác định mục đích kênh.

export class VertexElementUV extends VertexElementFVector { }

Inheritance

VertexElementVertexElementFVectorVertexElementUV

Constructor

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

Lỗi của TextureMapping.DIFFUSE Khi nào textureMappingnull.

Thuộc tính bổ sung

PropertyTypeAccessDescription
textureMappingTextureMappingReadCác kênh kết cấu này lớp UV được liên quan đến.
dataFVector4[]ReadUV giá trị được tiết lộ như: FVector4 Các bước (z và w là 0).
uvDataFVector2[]ReadUV giá trị như FVector2 Các bài viết (x, y chỉ).

addData(data)

  • Đáp ứng UV giá trị. 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 { }

Inheritance

VertexElementVertexElementFVectorVertexElementVertexColor

Constructor

new VertexElementVertexColor(
  name: string = '',
  mappingMode: MappingMode | null = null,
  referenceMode: ReferenceMode | null = null,
)

vertexElementType được thiết lập để VertexElementType.VERTEX_COLOR.


Examples

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

See Also

 Tiếng Việt