PropertyCollection{Categorie:Documentele de activitate}

VertexElement Scopul.3D TypeScript Referință API

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

VertexElement este clasa de bază abstractă pentru canalele atributive per-vertex atașate unui Geometry.Fiecare canal conţine o matrice de date tipate şi un sistem de informaţii. mappingMode / referenceMode Metadatele care controlează modul în care datele se referă la primitive de geometrie. Subclasele sunt: VertexElementNormal, VertexElementUV, și VertexElementVertexColor.

import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';

VertexElement (baza abstractă)

export abstract class VertexElement implements IIndexedVertexElement

Constructorul

constructor(
  elementType: VertexElementType,
  name: string = '',
  mappingMode: MappingMode | null = null,
  referenceMode: ReferenceMode | null = null,
)

Default mappingMode este: MappingMode.CONTROL_POINT; în mod implicit referenceMode este: ReferenceMode.DIRECT.

Proprietăți

ProprietateTipul de vehiculAccesulDescriere:
vertexElementTypeVertexElementTypeCiteşte.Tip semantic al acestui strat.
namestringCitire/scriereEtichetă opțională pentru acest strat.
mappingModeMappingModeCitire/scriereControlează cu care geometrie primitivă este asociată fiecare valoare.
referenceModeReferenceModeCitire/scriereControlează dacă valorile sunt adresate direct sau printr-un matrice de indice.
indicesnumber[]Citeşte.Aria de indice pentru: IndexToDirect modul de referință.

Metode de evaluare

setIndices(data)

NOT IMPLEMENTED. Pe bază. VertexElement clasa, această metodă aruncă Error('set_indices is not implemented') La momentul execuţiei. VertexElementFVector și de: VertexElementIntsTemplate să furnizeze implementări de lucru.

Înlocuiţi matricea de indice.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Pe bază. VertexElement clasa, această metodă aruncă Error('clear is not implemented') La momentul execuţiei. VertexElementFVector și de: VertexElementIntsTemplate să furnizeze implementări de lucru.

Îndepărtează toate datele şi indicii din strat.

clear(): void

VertexElementNormal

Stochează vectorii normali de suprafață. Datele normale sunt necesare pentru o iluminare corectă.

export class VertexElementNormal extends VertexElementFVector

Moștenire

VertexElementVertexElementFVectorVertexElementNormal

Constructorul

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 transporta mai multe straturi UV pentru canale diferite de textură. textureMapping proprietatea identifică scopul canalului.

export class VertexElementUV extends VertexElementFVector

Moștenire

VertexElementVertexElementFVectorVertexElementUV

Constructorul

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

Defaulturi la: TextureMapping.DIFFUSE când … textureMapping este: null.

Proprietate suplimentară

ProprietateTipul de vehiculAccesulDescriere:
textureMappingTextureMappingCiteşte.Canalul de textură cu care este asociat acest strat UV.
dataFVector4[]Citeşte.Valorile UV expuse ca FVector4 (z și w sunt: 0).
uvDataFVector2[]Citeşte.Valori UV ca: FVector2 intrări (numai x, y).

addData(data)

Se adaugă valorile UV. FVector2[], FVector3[], sau FVector4[].

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

VertexElementVertexColor

Stochează valorile de culoare RGBA pe vertex. Componentele sunt în intervalul 01.

export class VertexElementVertexColor extends VertexElementFVector

Moștenire

VertexElementVertexElementFVectorVertexElementVertexColor

Constructorul

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

vertexElementType este fixat la: VertexElementType.VERTEX_COLOR.


Exemple de astfel de măsuri

Adăugați normal la o rețea triunghială:

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ă coordonatele 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ă