VertexElement — Aspose.3D TypeScript API Reference

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

VertexElement je abstraktní základní třída pro kanály atributů na vrcholu připojené k Geometry. Každý kanál obsahuje typové datové pole a mappingMode / referenceMode metadata, která řídí, jak data souvisejí s geometrickými primitivy. Podtřídy jsou: VertexElementNormal, VertexElementUV, a VertexElementVertexColor.

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

Properties

export abstract class VertexElement implements IIndexedVertexElement

Properties

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

Properties mappingMode je MappingMode.CONTROL_POINT; výchozí referenceMode je ReferenceMode.DIRECT.

Properties

PropertiesPropertiesPropertiesProperties
vertexElementTypeVertexElementTypečteníSémantický typ této vrstvy.
namestringčtení/zápisVolitelný štítek pro tuto vrstvu.
mappingModeMappingModečtení/zápisŘídí, ke kterému geometrickému primitivu je každá hodnota přiřazena.
referenceModeReferenceModečtení/zápisŘídí, zda jsou hodnoty adresovány přímo nebo prostřednictvím pole indexů.
indicesnumber[]čístIndexové pole pro IndexToDirect referenční režim.

Properties

setIndices(data)

NOT IMPLEMENTED. Na základní VertexElement třída, tato metoda vyhazuje Error('set_indices is not implemented') během běhu. Podtřídy VertexElementFVector a VertexElementIntsTemplate poskytují funkční implementace.

Nahradit pole indexů.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Na základní VertexElement třída, tato metoda vyhazuje Error('clear is not implemented') během běhu. Podtřídy VertexElementFVector a VertexElementIntsTemplate poskytují funkční implementace.

Odstranit všechna data a indexy z vrstvy.

clear(): void

VertexElementNormal

Ukládá vektory normál povrchu. Data o normálách jsou vyžadována většinou renderérů pro správné osvětlení.

export class VertexElementNormal extends VertexElementFVector

Properties

VertexElement → VertexElementFVector → VertexElementNormal

Properties

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

vertexElementType je nastaveno na VertexElementType.NORMAL.


ThreeMfLoadOptions / ThreeMfSaveOptions

Ukládá 2D texturové souřadnice. Mesh může nést více UV vrstev pro různé texturové kanály. The textureMapping vlastnost určuje účel kanálu.

export class VertexElementUV extends VertexElementFVector

Properties

VertexElement → VertexElementFVector → VertexElementUV

Properties

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

Výchozí je TextureMapping.DIFFUSE když textureMapping je null.

Vrací true, pokud se tato ohraničující krabice překrývá s jiným BoundingBox (dotýkající se hrany se počítají jako překrytí).

PropertiesPropertiesPropertiesProperties
textureMappingTextureMappingčístKanál textury, ke kterému je tato UV vrstva přiřazena.
dataFVector4[]čístUV hodnoty zveřejněny jako FVector4 položky (z a w jsou 0).
uvDataFVector2[]čtenyUV hodnoty jako FVector2 položky (pouze x, y).

addData(data)

Připojit UV hodnoty. Přijímá FVector2[], FVector3[], nebo FVector4[].

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

VertexElementVertexColor

Ukládá RGBA hodnoty barvy pro každý vrchol. Komponenty jsou v rozsahu 0–1.

export class VertexElementVertexColor extends VertexElementFVector

Properties

VertexElement → VertexElementFVector → VertexElementVertexColor

Properties

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

vertexElementType je nastaveno na VertexElementType.VERTEX_COLOR.


Properties

Přidejte normály do trojúhelníkové sítě:

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