VertexElement — Aspose.3D TypeScript API Reference
Paketti: @aspose/3d (v24.12.0)
VertexElement on abstrakti perusluokka per-vertex-ominaisuuskanaville, jotka on liitetty kohteeseen Geometry. Jokainen kanava sisältää tyypitetyn data-taulukon ja mappingMode / referenceMode metadata, joka ohjaa, miten data liittyy geometrisia primitiivejä. Aliluokat ovat: VertexElementNormal, VertexElementUV, ja VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';Properties
export abstract class VertexElement implements IIndexedVertexElementProperties
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Properties mappingMode on MappingMode.CONTROL_POINT; oletus referenceMode on ReferenceMode.DIRECT.
Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
vertexElementType | VertexElementType | luku | Tämän kerroksen semanttinen tyyppi. |
name | string | luku/kirjoitus | Valinnainen nimi tälle kerrokselle. |
mappingMode | MappingMode | luku/kirjoitus | Ohjaa, mihin geometriseen primitiiviin kukin arvo on liitetty. |
referenceMode | ReferenceMode | luku/kirjoitus | Ohjaa, käsitelläänkö arvot suoraan vai indeksitaulukon kautta. |
indices | number[] | luku | Indeksitaulukko kohteelle IndexToDirect viitemoodi. |
Properties
setIndices(data)
NOT IMPLEMENTED. Perusluokassa VertexElement luokassa, tämä metodi heittää Error('set_indices is not implemented') suoritusaikana. Aliluokat VertexElementFVector ja VertexElementIntsTemplate tarjoavat toimivat toteutukset.
Korvaa indeksitaulukko.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Perusluokassa VertexElement luokassa, tämä metodi heittää Error('clear is not implemented') suoritusaikana. Aliluokat VertexElementFVector ja VertexElementIntsTemplate tarjoavat toimivat toteutukset.
Poista kaikki data ja indeksit kerroksesta.
clear(): voidVertexElementNormal
Tallentaa pinnan normaalivektorit. Normaali‑data on useimpien renderöijien vaatima oikean valaistuksen saavuttamiseksi.
export class VertexElementNormal extends VertexElementFVectorProperties
VertexElement → VertexElementFVector → VertexElementNormal
Properties
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType on asetettu arvoon VertexElementType.NORMAL.
Returns: VertexElementUV
Tallentaa 2D-tekstuurikoordinaatit. Verkkorakenne voi sisältää useita UV-kerroksia eri tekstuurikanaville. Tämä textureMapping ominaisuus tunnistaa kanavan tarkoituksen.
export class VertexElementUV extends VertexElementFVectorProperties
VertexElement → VertexElementFVector → VertexElementUV
Properties
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Oletusarvo on TextureMapping.DIFFUSE kun textureMapping on null.
Lisäominaisuus
| Properties | Properties | Properties | Properties |
|---|---|---|---|
textureMapping | TextureMapping | lue | Tekstuurikanava, johon tämä UV-kerros on liitetty. |
data | FVector4[] | lue | UV-arvot esitetty FVector4 merkinnät (z ja w ovat 0). |
uvData | FVector2[] | luettu | UV-arvot muodossa FVector2 merkinnät (vain x, y). |
addData(data)
Lisää UV-arvot. Hyväksyy FVector2[], FVector3[], tai FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Tallentaa per-vertex RGBA -väriarvot. Komponentit ovat välillä 0–1.
export class VertexElementVertexColor extends VertexElementFVectorProperties
VertexElement → VertexElementFVector → VertexElementVertexColor
Properties
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType on kiinnitetty VertexElementType.VERTEX_COLOR.
Properties
Lisää normaalit kolmioverkkoon:
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');Lisää UV-koordinaatit:
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');