VertexElement — Aspose.3D TypeScript API Reference
Πακέτο: @aspose/3d (v24.12.0)
VertexElement είναι η αφηρημένη βασική κλάση για κανάλια χαρακτηριστικών ανά κορυφή που συνδέονται με ένα Geometry. Κάθε κανάλι διατηρεί έναν πίνακα δεδομένων με τύπο και mappingMode / referenceMode μεταδεδομένα που ελέγχουν πώς τα δεδομένα σχετίζονται με τα γεωμετρικά πρωτότυπα. Οι υποκλάσεις είναι: VertexElementNormal, VertexElementUV, και 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 είναι MappingMode.CONTROL_POINT; προεπιλογή referenceMode είναι ReferenceMode.DIRECT.
Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
vertexElementType | VertexElementType | ανάγνωση | Σημασιολογικός τύπος αυτού του επιπέδου. |
name | string | ανάγνωση/εγγραφή | Προαιρετική ετικέτα για αυτό το επίπεδο. |
mappingMode | MappingMode | ανάγνωση/εγγραφή | Ελέγχει ποιο γεωμετρικό πρωτότυπο συνδέεται με κάθε τιμή. |
referenceMode | ReferenceMode | ανάγνωση/εγγραφή | Ελέγχει εάν οι τιμές προσεγγίζονται άμεσα ή μέσω ενός πίνακα δεικτών. |
indices | number[] | ανάγνωση | Πίνακας δεικτών για IndexToDirect λειτουργία αναφοράς. |
Properties
setIndices(data)
NOT IMPLEMENTED. Στην βάση VertexElement κλάση, αυτή η μέθοδος ρίχνει Error('set_indices is not implemented') κατά την εκτέλεση. Οι υποκλάσεις VertexElementFVector και VertexElementIntsTemplate παρέχουν λειτουργικές υλοποιήσεις.
Αντικαθιστά τον πίνακα δεικτών.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Στην βάση VertexElement κλάση, αυτή η μέθοδος ρίχνει Error('clear is not implemented') κατά την εκτέλεση. Οι υποκλάσεις VertexElementFVector και VertexElementIntsTemplate παρέχουν λειτουργικές υλοποιήσεις.
Αφαιρεί όλα τα δεδομένα και τους δείκτες από το επίπεδο.
clear(): voidVertexElementNormal
Αποθηκεύει διανύσματα κανονικών επιφάνειας. Τα δεδομένα normal απαιτούνται από τους περισσότερους renderers για σωστό φωτισμό.
export class VertexElementNormal extends VertexElementFVectorProperties
VertexElement → VertexElementFVector → VertexElementNormal
Properties
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType είναι ορισμένο σε VertexElementType.NORMAL.
Επιστρέφει: VertexElementUV
Αποθηκεύει 2D συντεταγμένες υφής. Ένα πλέγμα μπορεί να περιέχει πολλαπλά επίπεδα UV για διαφορετικά κανάλια υφής. Το textureMapping ιδιότητα προσδιορίζει τον σκοπό του καναλιού.
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,
)Προεπιλογή είναι TextureMapping.DIFFUSE όταν textureMapping είναι null.
A3DObject → Material → LambertMaterial
| Properties | Properties | Properties | Properties |
|---|---|---|---|
textureMapping | TextureMapping | διάβασε | Το κανάλι υφής με το οποίο συνδέεται αυτό το στρώμα UV. |
data | FVector4[] | διάβασε | Τιμές UV εκτεθειμένες ως FVector4 καταχωρήσεις (z και w είναι 0). |
uvData | FVector2[] | αναγνώμενες | Τιμές UV ως FVector2 καταχωρήσεις (μόνο x, y). |
addData(data)
Προσθήκη τιμών UV. Δέχεται FVector2[], FVector3[], ή FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Αποθηκεύει τιμές χρώματος RGBA ανά κορυφή. Τα συστατικά είναι στο εύρος 0–1.
export class VertexElementVertexColor extends VertexElementFVectorProperties
VertexElement → VertexElementFVector → VertexElementVertexColor
Properties
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType είναι σταθερό σε VertexElementType.VERTEX_COLOR.
Properties
Προσθήκη κανονικών σε ένα τριγωνικό πλέγμα:
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');Προσθήκη συντεταγμένων 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');