VertexElement — Aspose.3D TypeScript API Reference
Package: @aspose/3d (v24.12.0)
‘VertexElement’ es la clase de base abstracta para los canales de atributo pervertex anexados a una ‘Geometría’.Cada canal tiene un array de datos tipado y ‘mappingMode’ / ‘referenceModa’ metadatos que controlan cómo los datos se relacionan con los primitivos geométricos.Los subclases son: ‘VertexElmentNormal’, ’ VertexElementoUV’, y `VerdexElementsVertxColor’.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';Elemento Vertex (base abstracta)
export abstract class VertexElement implements IIndexedVertexElement { }Constructor
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)El mappingMode predeterminado es MappingMode.CONTROL_POINT; el referenceMode predeterminado es ReferenceMode.DIRECT.
Propiedades
| Property | Type | Access | Description |
|---|---|---|---|
vertexElementType | VertexElementType | Read | Semantic type of this layer. |
name | string | Read/Write | Optional label for this layer. |
mappingMode | MappingMode | Read/Write | Controls which geometry primitive each value is associated with. |
referenceMode | ReferenceMode | Read/Write | Controls whether values are addressed directly or through an index array. |
indices | number[] | Read | Index array for IndexToDirect reference mode. |
Metodología
«Segundos (Data) »
NO IMPLEMENTADO. En la clase base VertexElement, este método lanza Error('set_indices is not implemented') en tiempo de ejecución. Las subclases VertexElementFVector y VertexElementIntsTemplate proporcionan implementaciones funcionales.
Substituir el índice de la array.
setIndices(data: number[]): void“Claro”
NO IMPLEMENTADO.En la base de la clase ‘VertexElement’, este método lanza ‘Error (‘claro no se implementa’)’ en el tiempo de trabajo.Los subclasses ’ VerteXElmentFVector’ y ‘Template’ proporcionan implementaciones laborales.
Removemos todos los datos e indicios de la capa.
clear(): voidVertexNormal
Almacenan vectores normales de superficie. los datos normalizados son requeridos por la mayoría de los renderes para la iluminación correcta.
export class VertexElementNormal extends VertexElementFVector { }Herencia
‘VertexElement’ → ‘VertexElementoFVector’ > ’ Vertex ElementoNormal’
Constructor
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)‘vertexElementType’ se fija a ‘VertexElmentTYpe.NORMAL’.
VertexElementUV
Almacenan las coordenadas de textura 2D. Una mezcla puede llevar múltiples capas UV para diferentes canales de texture. La propiedad ’textureMapping’ identifica el propósito del canal.
export class VertexElementUV extends VertexElementFVector { }Herencia
‘VertexElement’ → ‘VertexElementsFVector’ > ’ Vertex ElementsUV’
Constructor
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Defaultos en ‘TextureMapping.DIFFUSE’ cuando ’texturePappingu’ es ’null’.
Propiedad adicional
| Property | Type | Access | Description |
|---|---|---|---|
textureMapping | TextureMapping | Read | The texture channel this UV layer is associated with. |
data | FVector4[] | Read | UV values exposed as FVector4 entries (z and w are 0). |
uvData | FVector2[] | Read | UV values as FVector2 entries (x, y only). |
“Data de los datos” (addDate)
Añade valores UV. Accepta FVector2[]', FVektor3[], o `fVutor4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementoVertexColor
Almacena valores de color RGBA per-vertex. Los componentes están en el rango 0-1 .
export class VertexElementVertexColor extends VertexElementFVector { }Herencia
‘VertexElement’ → ‘VertexElementoFVector’ > ’ Vertex ElementoVertexColor’
Constructor
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)‘vertexElementType’ se fija a ‘VertexElmentTYpe.VERTEX_COLOR’.
Exemplos
Añade las normas a una mezcla triángular:
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');Añadir coordenadas 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');Ver también
- Referencia de la clase Mesh
- Referencia de Enumerations
- Referencia Vector2, Vector4
- Aspose.3D - Referencia de API Enterprise