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 IIndexedVertexElementImageRenderOptions
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)ImageRenderOptions mappingMode è MappingMode.CONTROL_POINT; predefinito referenceMode è ReferenceMode.DIRECT.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
vertexElementType | VertexElementType | lettura | Tipo semantico di questo livello. |
name | string | lettura/scrittura | Etichetta opzionale per questo livello. |
mappingMode | MappingMode | lettura/scrittura | Controlla a quale primitive geometrica è associato ciascun valore. |
referenceMode | ReferenceMode | lettura/scrittura | Controlla se i valori sono indirizzati direttamente o tramite un array di indice. |
indices | number[] | lettura | Array 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[]): voidclear()
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(): voidVertexElementNormal
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 VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementNormal
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 VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementUV
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
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
textureMapping | TextureMapping | leggi | Il canale di texture a cui è associato questo livello UV. |
data | FVector4[] | leggi | Valori UV esposti come FVector4 voci (z e w sono 0). |
uvData | FVector2[] | leggi | Valori UV come FVector2 voci (solo x, y). |
addData(data)
Aggiungi valori UV. Accetta FVector2[], FVector3[], o FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Memorizza i valori di colore RGBA per vertice. I componenti sono nell’intervallo 0–1.
export class VertexElementVertexColor extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementVertexColor
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');