VertexElement — Aspose.3D TypeScript API Reference
Pachet: @aspose/3d (v24.12.0)
VertexElement este clasa de bază abstractă pentru canalele de atribute per-vertex atașate la un Geometry. Fiecare canal deține un tablou de date tipizat și mappingMode / referenceMode metadate care controlează modul în care datele se raportează la primitivele geometrice. Subclasele sunt: VertexElementNormal, VertexElementUV, și VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';ImageRenderOptions
export abstract class VertexElement implements IIndexedVertexElementImageRenderOptions
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)ImageRenderOptions mappingMode este MappingMode.CONTROL_POINT; implicit referenceMode este ReferenceMode.DIRECT.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
vertexElementType | VertexElementType | citire | Tip semantic al acestui strat. |
name | string | citire/scriere | Etichetă opțională pentru acest strat. |
mappingMode | MappingMode | citire/scriere | Controlează cu ce primitivă geometrică este asociată fiecare valoare. |
referenceMode | ReferenceMode | citire/scriere | Controlează dacă valorile sunt adresate direct sau printr-un tablou de indici. |
indices | number[] | citire | Tablou de indici pentru IndexToDirect modul de referință. |
ImageRenderOptions
setIndices(data)
NOT IMPLEMENTED. Pe baza VertexElement clasă, această metodă aruncă Error('set_indices is not implemented') în timpul execuției. Subclasele VertexElementFVector și VertexElementIntsTemplate furnizează implementări funcționale.
Înlocuiește tabloul de indici.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Pe clasa de bază VertexElement clasă, această metodă aruncă Error('clear is not implemented') în timpul execuției. Subclasele VertexElementFVector și VertexElementIntsTemplate furnizează implementări funcționale.
Elimină toate datele și indicii din strat.
clear(): voidVertexElementNormal
Stochează vectorii normali ai suprafeței. Datele de normale sunt necesare majorității rendererelor pentru iluminare corectă.
export class VertexElementNormal extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementNormal
ImageRenderOptions
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType este fixat la VertexElementType.NORMAL.
VertexElementUV
Stochează coordonate de textură 2D. O plasă poate conține mai multe straturi UV pentru diferite canale de textură. The textureMapping proprietatea identifică scopul canalului.
export class VertexElementUV extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementUV
ImageRenderOptions
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Valoarea implicită este TextureMapping.DIFFUSE când textureMapping este null.
Proprietate suplimentară
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
textureMapping | TextureMapping | citește | Canalul de textură cu care este asociat acest strat UV. |
data | FVector4[] | citește | Valorile UV expuse ca FVector4 intrări (z și w sunt 0). |
uvData | FVector2[] | citește | Valorile UV ca FVector2 intrări (doar x, y). |
addData(data)
Adaugă valorile UV. Acceptă FVector2[], FVector3[], sau FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Stochează valori de culoare RGBA per vertex. Componentele sunt în intervalul 0–1.
export class VertexElementVertexColor extends VertexElementFVectorImageRenderOptions
VertexElement → VertexElementFVector → VertexElementVertexColor
ImageRenderOptions
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType este fixat la VertexElementType.VERTEX_COLOR.
ImageRenderOptions
Adaugă normale la o rețea triunghiulară:
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');Adaugă coordonate UV:
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');