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
| Property | Type | Access | Description |
|---|---|---|---|
vertexElementType | VertexElementType | Read | Семантичний тип цього шару. |
name | string | Читання/писання | Факультативна етикетка для цього шару. |
mappingMode | MappingMode | Читання/писання | Контролі, з якими первісними геометріями пов’язано кожне значення. |
referenceMode | ReferenceMode | Читання/писання | Контролює, чи адресуються значення безпосередньо або через масив індексу. |
indices | number[] | Read | Індексний масив для: IndexToDirect Референтний режим. |
Methods
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 VertexElementFVector { }Inheritance
VertexElement → VertexElementFVector → VertexElementNormal
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
VertexElement → VertexElementFVector → VertexElementUV
Constructor
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Невиконані вимоги до TextureMapping.DIFFUSE коли textureMapping є: null.
Додаткова властивість
| Property | Type | Access | Description |
|---|---|---|---|
textureMapping | TextureMapping | Read | Канал текстури, з яким пов’язаний цей ультрафіолетовий шар. |
data | FVector4[] | Read | Ультрафіолетові промені, що піддаються впливу як: FVector4 записи (z і w є 0). |
uvData | FVector2[] | Read | Ультрафіолетові значення як: FVector2 записи (только x, y). |
addData(data)
Додавати значення УФ. Приймає FVector2[], FVector3[], або FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Зберігає значення кольору RGBA для кожної вершини. Компоненти знаходяться в діапазоні 0–1.
export class VertexElementVertexColor extends VertexElementFVector { }Inheritance
VertexElement → VertexElementFVector → VertexElementVertexColor
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');