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 IIndexedVertexElementKonš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íctvo | Typ: | Prístup | Opis: |
|---|---|---|---|
vertexElementType | VertexElementType | Čítajte si . | Semantický typ tejto vrstvy. |
name | string | Čítanie/napísanie | Voliteľná štítka pre túto vrstvu. |
mappingMode | MappingMode | Čítanie/napísanie | Ovláda, s akou primitívnou geometriou je spojená každá hodnota. |
referenceMode | ReferenceMode | Čítanie/napísanie | Ovláda, či sa hodnoty adresujú priamo alebo prostredníctvom indexového súboru. |
indices | number[] | Čítajte si . | Indexové rozpätí pre: IndexToDirect referenčný režim. |
Metódy
setIndices(data)
NOT IMPLEMENTED. Na základni .
VertexElementtrieda, táto metóda vrháError('set_indices is not implemented')V priebehu prevádzky. PodtriedkyVertexElementFVectora)VertexElementIntsTemplateposkytovať pracovné implementácie.
Zmeňte indexový súbor.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Na základni .
VertexElementtrieda, táto metóda vrháError('clear is not implemented')V priebehu prevádzky. PodtriedkyVertexElementFVectora)VertexElementIntsTemplateposkytovať pracovné implementácie.
Odstráňte všetky údaje a indexy zo vrstvy.
clear(): voidVertexElementNormal
Uloží normálne vektory povrchu. Pre správne osvetlenie je potrebná väčšina renderov.
export class VertexElementNormal extends VertexElementFVectordedičstvo
VertexElement → VertexElementFVector → VertexElementNormal
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 VertexElementFVectordedičstvo
VertexElement → VertexElementFVector → VertexElementUV
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íctvo | Typ: | Prístup | Opis: |
|---|---|---|---|
textureMapping | TextureMapping | Čítajte si . | Kanál textúry, s ktorým je spojená táto UV vrstva. |
data | FVector4[] | Čítajte si . | UV hodnoty vystavené ako: FVector4 položky (z a w sú: 0). |
uvData | FVector2[] | Čí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[]): voidVertexElementVertexColor
Uloží sa na jednotlivé vrcholy RGBA farebné hodnoty. Komponenty sú v rozsahu 01.
export class VertexElementVertexColor extends VertexElementFVectordedičstvo
VertexElement → VertexElementFVector → VertexElementVertexColor
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');