VertexElement — Aspose.3D TypeScript API Reference

Paquet: @aspose/3d (v24.12.0)

VertexElement és la classe base abstracta per a canals d’atributs per vèrtex adjuntats a una Geometry.Cada canal conté una matriu de dades tipada i mappingMode / referenceMode metadades que controlen com les dades es relacionen amb les primitives geomètriques. Les subclasses són: VertexElementNormal, VertexElementUV, i 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 és MappingMode.CONTROL_POINT; per defecte referenceMode és ReferenceMode.DIRECT.

Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
vertexElementTypeVertexElementTypellegirTipus semàntic d’aquesta capa.
namestringRead/WriteEtiqueta opcional per a aquesta capa.
mappingModeMappingModeRead/WriteControla quina primitiva geomètrica s’associa a cada valor.
referenceModeReferenceModeRead/WriteControla si els valors s’adrecen directament o a través d’un array d’índex.
indicesnumber[]ReadArray d’índex per a IndexToDirect mode de referència.

Enumerations

setIndices(data)

NOT IMPLEMENTED. A la base VertexElement classe, aquest mètode llança Error('set_indices is not implemented') en temps d’execució. Les subclasses VertexElementFVector i VertexElementIntsTemplate proporcionen implementacions funcionals.

Reemplaça la matriu d’índexs.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. En la base VertexElement classe, aquest mètode llança Error('clear is not implemented') en temps d’execució. Les subclasses VertexElementFVector i VertexElementIntsTemplate proporcionen implementacions funcionals.

Elimina totes les dades i índexs de la capa.

clear(): void

VertexElementNormal

Emmagatzema vectors normals de superfície. Les dades normals són requerides per la majoria de renderitzadors per a una il·luminació correcta.

export class VertexElementNormal extends VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementNormal

Enumerations

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

vertexElementType està fixat a VertexElementType.NORMAL.


Retorna: VertexElementUV

Emmagatzema coordenades de textura 2D. Una malla pot contenir diverses capes UV per a diferents canals de textura. El textureMapping la propietat identifica la finalitat del canal.

export class VertexElementUV extends VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementUV

Enumerations

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

Per defecte a TextureMapping.DIFFUSE quan textureMapping és null.

Opcions de càrrega i desament

EnumerationsEnumerationsEnumerationsEnumerations
textureMappingTextureMappingllegirEl canal de textura amb el qual està associada aquesta capa UV.
dataFVector4[]llegirValors UV exposats com a FVector4 entrades (z i w són 0).
uvDataFVector2[]llegirValors UV com a FVector2 entrades (només x, y).

addData(data)

Afegeix valors UV. Accepta FVector2[], FVector3[], o FVector4[].

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

VertexElementVertexColor

Emmagatzema valors de color RGBA per vèrtex. Els components són en el rang 0–1.

export class VertexElementVertexColor extends VertexElementFVector

Enumerations

VertexElementVertexElementFVectorVertexElementVertexColor

Enumerations

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

vertexElementType està fixat a VertexElementType.VERTEX_COLOR.


Enumerations

Afegeix normals a una malla triangular:

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

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

Vegeu també

 Català