VertexElement Aspose.3D TypeScript Referència API
Paquet: @aspose/3d (v24.12.0)
VertexElement és la classe de base abstracta per a canals d’atributs per-vertex vinculats a una geometria. Cada canal conté un matriu de dades tipitzada i metadades del mode mappingMode / ̋referenceMade que controlen com les dades es relacionen amb els primitius geomètrics. Les subclasses són: ∂VertexElementNormal⌒, ゚VertexElementUV, i ゙VertexElementVertexColorヽ .
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';VertexElement (base abstracta)
VertexElement is the abstract base class for per-vertex attribute channels attached to a Geometry. Each channel holds a typed data array and mappingMode / referenceMode metadata that control how the data relates to geometry primitives. The subclasses are: VertexElementNormal, VertexElementUV, and VertexElementVertexColor.
Default mappingMode is MappingMode.CONTROL_POINT; default referenceMode is ReferenceMode.DIRECT.
VertexElement → VertexElementFVector → VertexElementNormal
vertexElementType is fixed to VertexElementType.NORMAL.
VertexElement → VertexElementFVector → VertexElementUV
Defaults to TextureMapping.DIFFUSE when textureMapping is null.
Append UV values. Accepts FVector2[], FVector3[], or FVector4[].
VertexElement → VertexElementFVector → VertexElementVertexColor
vertexElementType is fixed to VertexElementType.VERTEX_COLOR.
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 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), ]);
export abstract class VertexElement implements IIndexedVertexElementConstructor
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)El mode de mapeig ` per defecte és ゚MappingMode.CONTROL_POINT⌒; el mode d’esmentament ̋ referència ∂ és ο (p. ex., “PlaceHolder1”) ̨.
Propietats
| 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. |
Mètodes
`setIndexos(dates) ¬
NO IMPLEMENTED. En la classe base VertexElement, aquest mètode arrossega un error en el moment d’execució. Les subclasses ⌒VertexElementFVector` i ゚{ PLACHEHOLODER2’) ■ proporcionen implementacions de treball.
Reemplaceu l’arrel·la d’índex.
setIndices(data: number[]): void` clar ((() ¬
NO IMPLEMENTED. En la classe base VertexElement, aquest mètode arrossega un error en el moment d’execució. Les subclasses ⌒VertexElementFVector゚ i ヽ PLACHEHOLODER2∂ proporcionen implementacions de treball.
Elimina totes les dades i indicis de la capa.
clear(): voidVertexElementNormal
La majoria dels renders requereixen dades normals per a una il·luminació correcta.
export class VertexElementNormal extends VertexElementFVectorSuccessió
VertexElement → ̋VertexElementFVector⌒ →
Constructor
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType està fixat a ⌒VertexElementType.NORMAL`.
VertexElementUV
Emmagatzemen coordenades de textura 2D. Una malla pot portar múltiples capes UV per a diferents canals de textures. La propietat textureMapping identifica l’objectiu del canal.
export class VertexElementUV extends VertexElementFVectorSuccessió
VertexElement → ̋VertexElementFVector⌒ →
Constructor
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Defaults per TextureMapping.DIFFUSE quan ̋textureMapping∂ és ̆null∂.
Propietat addicional
| 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). |
`addData(data) ¬
Adjuntar valors UV. Accepta FVector2[], ̋F Vector3[ ]` o ∂FVECTOR4 [ ]⌒'.
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Emmagatzemen valors de color per vértex RGBA. Els components estan en el rang 01.
export class VertexElementVertexColor extends VertexElementFVectorSuccessió
VertexElement → ̋VertexElementFVector⌒ →
Constructor
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType està fixat a ⌒VertexElementType.VERTEX_COLOR`.
Exemples
Afegir normales 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');Afegir les 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');Veure també
- Referència de classe de malla
- Referència de les enumeracions
- Referència de vector2, vecteur4