VertexElement — Aspose.3D TypeScript API Reference
Пакет: @aspose/3d (v24.12.0)
VertexElement является абстрактным базовым классом для каналов атрибутов вершин, прикреплённых к Geometry. Каждый канал содержит типизированный массив данных и mappingMode / referenceMode метаданные, которые управляют тем, как данные соотносятся с геометрическими примитивами. Подклассы: VertexElementNormal, VertexElementUV, и VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';ImageRenderOptions
export abstract class VertexElement implements IIndexedVertexElementImageRenderOptions
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)ImageRenderOptions mappingMode является MappingMode.CONTROL_POINT; по умолчанию referenceMode является ReferenceMode.DIRECT.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
vertexElementType | VertexElementType | чтение | Семантический тип этого слоя. |
name | string | чтение/запись | Необязательная метка для этого слоя. |
mappingMode | MappingMode | чтение/запись | Определяет, с какой геометрической примитивой связано каждое значение. |
referenceMode | ReferenceMode | чтение/запись | Управляет тем, обращаются ли значения напрямую или через индексный массив. |
indices | number[] | чтение | Индексный массив для IndexToDirect режим ссылки. |
ImageRenderOptions
setIndices(data)
NOT IMPLEMENTED. В базовом VertexElement классе, этот метод бросает Error('set_indices is not implemented') во время выполнения. Подклассы VertexElementFVector и VertexElementIntsTemplate предоставляют рабочие реализации.
Заменить массив индексов.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. В базовом VertexElement классе этот метод бросает Error('clear is not implemented') во время выполнения. Подклассы VertexElementFVector и VertexElementIntsTemplate предоставляют рабочие реализации.
Удалить все данные и индексы из слоя.
clear(): voidVertexElementNormal
Хранит векторы нормалей поверхности. Данные о нормалях требуются большинством рендереров для корректного освещения.
export class VertexElementNormal extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementNormal
ImageRenderOptions
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType исправлен на VertexElementType.NORMAL.
VertexElementUV
Хранит 2D координаты текстуры. Сетка может содержать несколько UV‑слоёв для разных каналов текстур. Этот textureMapping свойство определяет назначение канала.
export class VertexElementUV extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementUV
ImageRenderOptions
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)По умолчанию TextureMapping.DIFFUSE когда textureMapping является null.
Дополнительное свойство
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
textureMapping | TextureMapping | читается | Текстурный канал, с которым связан этот UV‑слой. |
data | FVector4[] | читается | UV‑значения, представленные как FVector4 записи (z и w являются 0). |
uvData | FVector2[] | читаются | UV‑значения как FVector2 записи (только x, y). |
addData(data)
Добавить UV‑значения. Принимает FVector2[], FVector3[], или FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Хранит значения цвета RGBA для каждой вершины. Компоненты находятся в диапазоне 0–1.
export class VertexElementVertexColor extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementVertexColor
ImageRenderOptions
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType зафиксировано на VertexElementType.VERTEX_COLOR.
ImageRenderOptions
Добавить нормали к треугольной сетке:
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');Добавить 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');