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';Enumerations
export abstract class VertexElement implements IIndexedVertexElementEnumerations
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Enumerations mappingMode е MappingMode.CONTROL_POINT; по подразбиране referenceMode е ReferenceMode.DIRECT.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
vertexElementType | VertexElementType | четене | Семантичен тип на този слой. |
name | string | четене/запис | Опционален етикет за този слой. |
mappingMode | MappingMode | четене/запис | Контролира кой геометричен примитив е свързан с всяка стойност. |
referenceMode | ReferenceMode | четене/писане | Контролира дали стойностите се адресират директно или чрез индексен масив. |
indices | number[] | четене | Индексен масив за IndexToDirect режим на референция. |
Enumerations
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 VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementNormal
Enumerations
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType е фиксиран на VertexElementType.NORMAL.
VertexElementUV
Съхранява 2D координати на текстурата. Мрежата може да съдържа множество UV слоеве за различни текстурни канали. The textureMapping свойството определя предназначението на канала.
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,
)По подразбиране е TextureMapping.DIFFUSE когато textureMapping е null.
Връща true, ако дадената точка или ограничителна кутия е напълно вътре в тази кутия. Приема обект точка {x, y, z}, Vector3 или друга BoundingBox.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
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 VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementVertexColor
Enumerations
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType е фиксирано на VertexElementType.VERTEX_COLOR.
Enumerations
Добавете нормали към триъгълна мрежа:
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');