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 IIndexedVertexElementEnumerations
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
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
vertexElementType | VertexElementType | llegir | Tipus semàntic d’aquesta capa. |
name | string | Read/Write | Etiqueta opcional per a aquesta capa. |
mappingMode | MappingMode | Read/Write | Controla quina primitiva geomètrica s’associa a cada valor. |
referenceMode | ReferenceMode | Read/Write | Controla si els valors s’adrecen directament o a través d’un array d’índex. |
indices | number[] | Read | Array 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[]): voidclear()
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(): voidVertexElementNormal
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 VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementNormal
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 VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementUV
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
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
textureMapping | TextureMapping | llegir | El canal de textura amb el qual està associada aquesta capa UV. |
data | FVector4[] | llegir | Valors UV exposats com a FVector4 entrades (z i w són 0). |
uvData | FVector2[] | llegir | Valors UV com a FVector2 entrades (només x, y). |
addData(data)
Afegeix valors UV. Accepta FVector2[], FVector3[], o FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Emmagatzema valors de color RGBA per vèrtex. Els components són en el rang 0–1.
export class VertexElementVertexColor extends VertexElementFVectorEnumerations
VertexElement → VertexElementFVector → VertexElementVertexColor
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');