PropertyCollection{/PLANKER:}Vyzerá to ako...

VertexElement Aspose.3D TypeScript Odkaz API

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

VertexElement je abstraktná základná trieda pre per-vertexové atribútové kanály pripojené k Geometry.Každý kanál obsahuje typovaný súbor údajov a mappingMode / referenceMode Metadata, ktoré kontrolujú ako sa údaje vzťahujú k geometrickým primitívom. Podtriedky sú: VertexElementNormal, VertexElementUV,a) VertexElementVertexColor.

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

VertexElement (abstraktná základňa)

export abstract class VertexElement implements IIndexedVertexElement

Konštruktor

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

Predvolené: mappingMode je: MappingMode.CONTROL_POINT; predvolené referenceMode je: ReferenceMode.DIRECT.

Vlastnosti

VlastníctvoTyp:PrístupOpis:
vertexElementTypeVertexElementTypeČítajte si .Semantický typ tejto vrstvy.
namestringČítanie/napísanieVoliteľná štítka pre túto vrstvu.
mappingModeMappingModeČítanie/napísanieOvláda, s akou primitívnou geometriou je spojená každá hodnota.
referenceModeReferenceModeČítanie/napísanieOvláda, či sa hodnoty adresujú priamo alebo prostredníctvom indexového súboru.
indicesnumber[]Čítajte si .Indexové rozpätí pre: IndexToDirect referenčný režim.

Metódy

setIndices(data)

NOT IMPLEMENTED. Na základni . VertexElement trieda, táto metóda vrhá Error('set_indices is not implemented') V priebehu prevádzky. Podtriedky VertexElementFVector a) VertexElementIntsTemplate poskytovať pracovné implementácie.

Zmeňte indexový súbor.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Na základni . VertexElement trieda, táto metóda vrhá Error('clear is not implemented') V priebehu prevádzky. Podtriedky VertexElementFVector a) VertexElementIntsTemplate poskytovať pracovné implementácie.

Odstráňte všetky údaje a indexy zo vrstvy.

clear(): void

VertexElementNormal

Uloží normálne vektory povrchu. Pre správne osvetlenie je potrebná väčšina renderov.

export class VertexElementNormal extends VertexElementFVector

dedičstvo

VertexElementVertexElementFVectorVertexElementNormal

Konštruktor

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

vertexElementType je fixný na: VertexElementType.NORMAL.


VertexElementUV

Uloží 2D textúrne koordináty. Mriežka môže niesť viac UV vrstiev pre rôzne textúra kanály. textureMapping vlastnosť identifikuje účel kanála.

export class VertexElementUV extends VertexElementFVector

dedičstvo

VertexElementVertexElementFVectorVertexElementUV

Konštruktor

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

Zlyhania v prípade: TextureMapping.DIFFUSE kedy textureMapping je: null.

Dodatočné majetok

VlastníctvoTyp:PrístupOpis:
textureMappingTextureMappingČítajte si .Kanál textúry, s ktorým je spojená táto UV vrstva.
dataFVector4[]Čítajte si .UV hodnoty vystavené ako: FVector4 položky (z a w sú: 0).
uvDataFVector2[]Čítajte si .UV hodnoty ako: FVector2 položky (len x, y).

addData(data)

Pridať hodnoty UV. Prijme sa: FVector2[], FVector3[],alebo FVector4[].

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

VertexElementVertexColor

Uloží sa na jednotlivé vrcholy RGBA farebné hodnoty. Komponenty sú v rozsahu 01.

export class VertexElementVertexColor extends VertexElementFVector

dedičstvo

VertexElementVertexElementFVectorVertexElementVertexColor

Konštruktor

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

vertexElementType je fixný na: VertexElementType.VERTEX_COLOR.


Príklady:

Pridať normály do trojuholníkového sieťového pásu:

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

Pridať UV súradnice:

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

Pozri tiež:

 Slovenčina