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 IIndexedVertexElement

Enumerations

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

Enumerations mappingMode е MappingMode.CONTROL_POINT; по подразбиране referenceMode е ReferenceMode.DIRECT.

Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
vertexElementTypeVertexElementTypeчетенеСемантичен тип на този слой.
namestringчетене/записОпционален етикет за този слой.
mappingModeMappingModeчетене/записКонтролира кой геометричен примитив е свързан с всяка стойност.
referenceModeReferenceModeчетене/писанеКонтролира дали стойностите се адресират директно или чрез индексен масив.
indicesnumber[]четенеИндексен масив за IndexToDirect режим на референция.

Enumerations

setIndices(data)

NOT IMPLEMENTED. В базовия VertexElement клас, този метод хвърля Error('set_indices is not implemented') по време на изпълнение. Подкласовете VertexElementFVector и VertexElementIntsTemplate предоставят работещи реализации.

Заменете масива с индекси.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. В базовия VertexElement клас, този метод хвърля Error('clear is not implemented') по време на изпълнение. Подкласовете VertexElementFVector и VertexElementIntsTemplate предоставят работещи реализации.

Премахнете всички данни и индекси от слоя.

clear(): void

VertexElementNormal

Съхранява векторите на повърхностните нормали. Данните за нормалите са необходими за повечето рендеръри за правилно осветление.

export class VertexElementNormal extends VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementNormal

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 VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementUV

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.

EnumerationsEnumerationsEnumerationsEnumerations
textureMappingTextureMappingчетенеТекстурният канал, с който е свързан този UV слой.
dataFVector4[]четенеUV стойности, изложени като FVector4 записи (z и w са 0).
uvDataFVector2[]четениUV стойности като FVector2 записи (само x, y).

addData(data)

Добавяне на UV стойности. Приема FVector2[], FVector3[], или FVector4[].

addData(data: FVector2[] | FVector3[] | FVector4[]): void

VertexElementVertexColor

Съхранява RGBA стойности за всеки връх. Компонентите са в диапазона 0–1.

export class VertexElementVertexColor extends VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementVertexColor

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

Вижте също

 Български