VertexElement Účel.Aspose.3D TypeScript Odkaz API

Balíček: @aspose/3d (v24.12.0)

VertexElement je abstraktní základní třída pro per-vertex attribute kanály připojené k Geometry.Každý kanál obsahuje typovaný datový soubor a mappingMode / referenceMode Metadata, která řídí vztah dat k geometrickým primitivům. Podtřídy jsou: VertexElementNormal, VertexElementUV,a) VertexElementVertexColor.

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

VertexElement (abstraktní základna)

export abstract class VertexElement implements IIndexedVertexElement

Konstruktor

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

Předvoleně mappingMode je: MappingMode.CONTROL_POINT; výchozí platba referenceMode je: ReferenceMode.DIRECT.

Vlastnosti

VlastnictvíTyp:PřístupPopis:
vertexElementTypeVertexElementTypeČtěte.Semantický typ této vrstvy.
namestringČtení/psaníNepovinná označení této vrstvy.
mappingModeMappingModeČtení/psaníOvládají, s jakou primitivní geometrii je každá hodnota spojená.
referenceModeReferenceModeČtení/psaníOvládá, zda jsou hodnoty adresovány přímo nebo prostřednictvím indexu.
indicesnumber[]Čtěte.Indexové pole pro: IndexToDirect referenční režim.

Metody

setIndices(data)

NOT IMPLEMENTED. Na základně. VertexElement třída, tato metoda vrhá Error('set_indices is not implemented') V běžném čase. Podtřídy VertexElementFVector a) VertexElementIntsTemplate poskytovat pracovní implementace.

Nahraďte index.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Na základně. VertexElement třída, tato metoda vrhá Error('clear is not implemented') V běžném čase. Podtřídy VertexElementFVector a) VertexElementIntsTemplate poskytovat pracovní implementace.

Odstraňte všechny údaje a indexy ze vrstvy.

clear(): void

VertexElementNormal

Většina rendererů vyžaduje normální data pro správné osvětlení.

export class VertexElementNormal extends VertexElementFVector

Dědictví

VertexElementVertexElementFVectorVertexElementNormal

Konstruktor

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

vertexElementType je pevně připevněn k: VertexElementType.NORMAL.


VertexElementUV

Skládá 2D texturní souřadnice. Mříž může mít pro různé kanály textury několik UV vrstev. textureMapping vlastnost identifikuje účel kanálu.

export class VertexElementUV extends VertexElementFVector

Dědictví

VertexElementVertexElementFVectorVertexElementUV

Konstruktor

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

Neplnění povinností TextureMapping.DIFFUSE kdy? textureMapping je: null.

Další majetek

VlastnictvíTyp:PřístupPopis:
textureMappingTextureMappingČtěte.Kanál textury, se kterým je tato UV vrstva spojená.
dataFVector4[]Čtěte.UV hodnoty vystavené jako: FVector4 položky (z a w jsou 0).
uvDataFVector2[]Čtěte.UV hodnoty jako: FVector2 položky (pouze x, y).

addData(data)

Přidání UV hodnot. FVector2[], FVector3[],nebo: FVector4[].

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

VertexElementVertexColor

Uložení barevných hodnot RGBA na vrchol. Komponenty jsou v rozmezí 01.

export class VertexElementVertexColor extends VertexElementFVector

Dědictví

VertexElementVertexElementFVectorVertexElementVertexColor

Konstruktor

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

vertexElementType je pevně připevněn k: VertexElementType.VERTEX_COLOR.


Příklady:

Přidání normálů do trojúhelníkového okruhu:

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

Přidejte UV souřadnice:

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

Viz také:

 Čeština