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

VertexElement (абстрактна база)

export abstract class VertexElement implements IIndexedVertexElement { }

Constructor

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

Default mappingMode є: MappingMode.CONTROL_POINT; по умові referenceMode є: ReferenceMode.DIRECT.

Properties

PropertyTypeAccessDescription
vertexElementTypeVertexElementTypeReadСемантичний тип цього шару.
namestringЧитання/писанняФакультативна етикетка для цього шару.
mappingModeMappingModeЧитання/писанняКонтролі, з якими первісними геометріями пов’язано кожне значення.
referenceModeReferenceModeЧитання/писанняКонтролює, чи адресуються значення безпосередньо або через масив індексу.
indicesnumber[]ReadІндексний масив для: IndexToDirect Референтний режим.

Methods

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

Inheritance

VertexElementVertexElementFVectorVertexElementNormal

Constructor

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

vertexElementType встановлено на: VertexElementType.NORMAL.


VertexElementUV

Зберігає координати 2D текстури. Мешка може нести кілька УФ-половин для різних каналів текстурі. textureMapping властивість визначає ціль каналу.

export class VertexElementUV extends VertexElementFVector { }

Inheritance

VertexElementVertexElementFVectorVertexElementUV

Constructor

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

Невиконані вимоги до TextureMapping.DIFFUSE коли textureMapping є: null.

Додаткова властивість

PropertyTypeAccessDescription
textureMappingTextureMappingReadКанал текстури, з яким пов’язаний цей ультрафіолетовий шар.
dataFVector4[]ReadУльтрафіолетові промені, що піддаються впливу як: FVector4 записи (z і w є 0).
uvDataFVector2[]ReadУльтрафіолетові значення як: FVector2 записи (только x, y).

addData(data)

Додавати значення УФ. Приймає FVector2[], FVector3[], або FVector4[].

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

VertexElementVertexColor

Зберігає значення кольору RGBA для кожної вершини. Компоненти знаходяться в діапазоні 0–1.

export class VertexElementVertexColor extends VertexElementFVector { }

Inheritance

VertexElementVertexElementFVectorVertexElementVertexColor

Constructor

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

vertexElementType встановлено на: VertexElementType.VERTEX_COLOR.


Examples

Додати нормалі до трикутної сітки:

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

See Also

 Українська