VertexElement Цель.3D TypeScript Ссылка на API
Пакет: @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(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)По умолчанию mappingMode - это … MappingMode.CONTROL_POINT; по умолчанию referenceMode - это … ReferenceMode.DIRECT.
Свойства
| Собственность | Тип: | Доступ к информации | Описание: |
|---|---|---|---|
vertexElementType | VertexElementType | Читайте . | Семантический тип этого слоя. |
name | string | Читать/писать | Факультативная этикетка для этого слоя. |
mappingMode | MappingMode | Читать/писать | Контролирует, с какой первичной геометрии связано каждое значение. |
referenceMode | ReferenceMode | Читать/писать | Контролирует, адресуются ли значения непосредственно или через массив индекса. |
indices | number[] | Читайте . | Индексный массив для: IndexToDirect эталонный режим. |
Методы
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Наследство
VertexElement → VertexElementFVector → VertexElementNormal
Строитель
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType закреплено на: VertexElementType.NORMAL.
VertexElementUV (Вертексэлемент)
Сохраняет координаты 2D-текстуры. Сеть может нести несколько УФ-слоев для различных каналов текстуры . textureMapping свойство определяет цель канала.
export class VertexElementUV extends VertexElementFVectorНаследство
VertexElement → VertexElementFVector → VertexElementUV
Строитель
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Недостаточность в TextureMapping.DIFFUSE когда? textureMapping - это … null.
Дополнительное имущество
| Собственность | Тип: | Доступ к ним | Описание: |
|---|---|---|---|
textureMapping | TextureMapping | Читайте . | Канал текстуры, с которым связано это УФ-слой. |
data | FVector4[] | Читайте . | Ультрафиолетовые значения, подвергаемые воздействию: FVector4 вложения (z и w - это 0). |
uvData | FVector2[] | Читайте . | Ультрафиолетовые значения как: FVector2 записи (только x, y). |
addData(data)
Присоединяйте значения УФ. FVector2[], FVector3[], или FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Сохраняет цветные значения RGBA на вертикаль. Компоненты в диапазоне 01.
export class VertexElementVertexColor extends VertexElementFVectorНаследство
VertexElement → VertexElementFVector → VertexElementVertexColor
Строитель
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType закреплено на: VertexElementType.VERTEX_COLOR.
Примеры:
Добавить нормалы в треугольную сетку:
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');Добавить УФ-координаты:
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');