VertexElement — Aspose.3D TypeScript API Reference

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

VertexElement è la classe base astratta per i canali di attributi per vertice collegati a un Geometry. Ogni canale contiene un array di dati tipizzato e mappingMode / referenceMode metadati che controllano come i dati si relazionano alle primitive geometriche. Le sottoclassi sono: VertexElementNormal, VertexElementUV, e VertexElementVertexColor.

import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';

ImageRenderOptions

export abstract class VertexElement implements IIndexedVertexElement

ImageRenderOptions

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

ImageRenderOptions mappingMode è MappingMode.CONTROL_POINT; predefinito referenceMode è ReferenceMode.DIRECT.

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
vertexElementTypeVertexElementTypeletturaTipo semantico di questo livello.
namestringlettura/scritturaEtichetta opzionale per questo livello.
mappingModeMappingModelettura/scritturaControlla a quale primitive geometrica è associato ciascun valore.
referenceModeReferenceModelettura/scritturaControlla se i valori sono indirizzati direttamente o tramite un array di indice.
indicesnumber[]letturaArray di indice per IndexToDirect modalità di riferimento.

ImageRenderOptions

setIndices(data)

NOT IMPLEMENTED. Sulla base VertexElement classe, questo metodo genera Error('set_indices is not implemented') a runtime. Le subclassi VertexElementFVector e VertexElementIntsTemplate forniscono implementazioni funzionanti.

Sostituisce l’array di indici.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Sulla base VertexElement classe, questo metodo genera Error('clear is not implemented') a runtime. Le subclassi VertexElementFVector e VertexElementIntsTemplate forniscono implementazioni funzionanti.

Rimuove tutti i dati e gli indici dallo strato.

clear(): void

VertexElementNormal

Memorizza i vettori normali di superficie. I dati delle normali sono richiesti dalla maggior parte dei renderer per un’illuminazione corretta.

export class VertexElementNormal extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementNormal

ImageRenderOptions

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

vertexElementType è fissato a VertexElementType.NORMAL.


VertexElementUV

Memorizza coordinate di texture 2D. Una mesh può contenere più livelli UV per diversi canali di texture. Il textureMapping proprietà identifica lo scopo del canale.

export class VertexElementUV extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementUV

ImageRenderOptions

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

Predefinito a TextureMapping.DIFFUSE quando textureMapping è null.

Proprietà aggiuntiva

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
textureMappingTextureMappingleggiIl canale di texture a cui è associato questo livello UV.
dataFVector4[]leggiValori UV esposti come FVector4 voci (z e w sono 0).
uvDataFVector2[]leggiValori UV come FVector2 voci (solo x, y).

addData(data)

Aggiungi valori UV. Accetta FVector2[], FVector3[], o FVector4[].

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

VertexElementVertexColor

Memorizza i valori di colore RGBA per vertice. I componenti sono nell’intervallo 0–1.

export class VertexElementVertexColor extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementVertexColor

ImageRenderOptions

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

vertexElementType è fissato a VertexElementType.VERTEX_COLOR.


ImageRenderOptions

Aggiungi le normali a una mesh triangolare:

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

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

Vedi anche

 Italiano