VertexElement Scopul.3D TypeScript Referință API
Ambalaj: @aspose/3d (v24.12.0)
VertexElement este clasa de bază abstractă pentru canalele atributive per-vertex atașate unui Geometry.Fiecare canal conţine o matrice de date tipate şi un sistem de informaţii. mappingMode / referenceMode Metadatele care controlează modul în care datele se referă la primitive de geometrie. Subclasele sunt: VertexElementNormal, VertexElementUV, și VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';VertexElement (baza abstractă)
export abstract class VertexElement implements IIndexedVertexElementConstructorul
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Default mappingMode este: MappingMode.CONTROL_POINT; în mod implicit referenceMode este: ReferenceMode.DIRECT.
Proprietăți
| Proprietate | Tipul de vehicul | Accesul | Descriere: |
|---|---|---|---|
vertexElementType | VertexElementType | Citeşte. | Tip semantic al acestui strat. |
name | string | Citire/scriere | Etichetă opțională pentru acest strat. |
mappingMode | MappingMode | Citire/scriere | Controlează cu care geometrie primitivă este asociată fiecare valoare. |
referenceMode | ReferenceMode | Citire/scriere | Controlează dacă valorile sunt adresate direct sau printr-un matrice de indice. |
indices | number[] | Citeşte. | Aria de indice pentru: IndexToDirect modul de referință. |
Metode de evaluare
setIndices(data)
NOT IMPLEMENTED. Pe bază.
VertexElementclasa, această metodă aruncăError('set_indices is not implemented')La momentul execuţiei.VertexElementFVectorși de:VertexElementIntsTemplatesă furnizeze implementări de lucru.
Înlocuiţi matricea de indice.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Pe bază.
VertexElementclasa, această metodă aruncăError('clear is not implemented')La momentul execuţiei.VertexElementFVectorși de:VertexElementIntsTemplatesă furnizeze implementări de lucru.
Îndepărtează toate datele şi indicii din strat.
clear(): voidVertexElementNormal
Stochează vectorii normali de suprafață. Datele normale sunt necesare pentru o iluminare corectă.
export class VertexElementNormal extends VertexElementFVectorMoștenire
VertexElement → VertexElementFVector → VertexElementNormal
Constructorul
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 transporta mai multe straturi UV pentru canale diferite de textură. textureMapping proprietatea identifică scopul canalului.
export class VertexElementUV extends VertexElementFVectorMoștenire
VertexElement → VertexElementFVector → VertexElementUV
Constructorul
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Defaulturi la: TextureMapping.DIFFUSE când … textureMapping este: null.
Proprietate suplimentară
| Proprietate | Tipul de vehicul | Accesul | Descriere: |
|---|---|---|---|
textureMapping | TextureMapping | Citeşte. | Canalul de textură cu care este asociat acest strat UV. |
data | FVector4[] | Citeşte. | Valorile UV expuse ca FVector4 (z și w sunt: 0). |
uvData | FVector2[] | Citeşte. | Valori UV ca: FVector2 intrări (numai x, y). |
addData(data)
Se adaugă valorile UV. FVector2[], FVector3[], sau FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Stochează valorile de culoare RGBA pe vertex. Componentele sunt în intervalul 01.
export class VertexElementVertexColor extends VertexElementFVectorMoștenire
VertexElement → VertexElementFVector → VertexElementVertexColor
Constructorul
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType este fixat la: VertexElementType.VERTEX_COLOR.
Exemple de astfel de măsuri
Adăugați normal la o rețea triunghială:
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ă coordonatele 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');