VertexElement — Aspose.3D TypeScript API Reference

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

VertexElement este clasa de bază abstractă pentru canalele de atribute per-vertex atașate la un Geometry. Fiecare canal deține un tablou de date tipizat și mappingMode / referenceMode metadate care controlează modul în care datele se raportează la primitivele geometrice. Subclasele sunt: VertexElementNormal, VertexElementUV, și 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 este MappingMode.CONTROL_POINT; implicit referenceMode este ReferenceMode.DIRECT.

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
vertexElementTypeVertexElementTypecitireTip semantic al acestui strat.
namestringcitire/scriereEtichetă opțională pentru acest strat.
mappingModeMappingModecitire/scriereControlează cu ce primitivă geometrică este asociată fiecare valoare.
referenceModeReferenceModecitire/scriereControlează dacă valorile sunt adresate direct sau printr-un tablou de indici.
indicesnumber[]citireTablou de indici pentru IndexToDirect modul de referință.

ImageRenderOptions

setIndices(data)

NOT IMPLEMENTED. Pe baza VertexElement clasă, această metodă aruncă Error('set_indices is not implemented') în timpul execuției. Subclasele VertexElementFVector și VertexElementIntsTemplate furnizează implementări funcționale.

Înlocuiește tabloul de indici.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Pe clasa de bază VertexElement clasă, această metodă aruncă Error('clear is not implemented') în timpul execuției. Subclasele VertexElementFVector și VertexElementIntsTemplate furnizează implementări funcționale.

Elimină toate datele și indicii din strat.

clear(): void

VertexElementNormal

Stochează vectorii normali ai suprafeței. Datele de normale sunt necesare majorității rendererelor pentru iluminare corectă.

export class VertexElementNormal extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementNormal

ImageRenderOptions

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

vertexElementType este fixat la VertexElementType.NORMAL.


VertexElementUV

Stochează coordonate de textură 2D. O plasă poate conține mai multe straturi UV pentru diferite canale de textură. The textureMapping proprietatea identifică scopul canalului.

export class VertexElementUV extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementUV

ImageRenderOptions

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

Valoarea implicită este TextureMapping.DIFFUSE când textureMapping este null.

Proprietate suplimentară

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
textureMappingTextureMappingciteșteCanalul de textură cu care este asociat acest strat UV.
dataFVector4[]citeșteValorile UV expuse ca FVector4 intrări (z și w sunt 0).
uvDataFVector2[]citeșteValorile UV ca FVector2 intrări (doar x, y).

addData(data)

Adaugă valorile UV. Acceptă FVector2[], FVector3[], sau FVector4[].

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

VertexElementVertexColor

Stochează valori de culoare RGBA per vertex. Componentele sunt în intervalul 0–1.

export class VertexElementVertexColor extends VertexElementFVector

ImageRenderOptions

VertexElementVertexElementFVectorVertexElementVertexColor

ImageRenderOptions

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

vertexElementType este fixat la VertexElementType.VERTEX_COLOR.


ImageRenderOptions

Adaugă normale la o rețea triunghiulară:

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

Adaugă coordonate 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');

Vezi și

 Română