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 IIndexedVertexElement

Properties

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

Properties mappingMode είναι MappingMode.CONTROL_POINT; προεπιλογή referenceMode είναι ReferenceMode.DIRECT.

Properties

PropertiesPropertiesPropertiesProperties
vertexElementTypeVertexElementTypeανάγνωσηΣημασιολογικός τύπος αυτού του επιπέδου.
namestringανάγνωση/εγγραφήΠροαιρετική ετικέτα για αυτό το επίπεδο.
mappingModeMappingModeανάγνωση/εγγραφήΕλέγχει ποιο γεωμετρικό πρωτότυπο συνδέεται με κάθε τιμή.
referenceModeReferenceModeανάγνωση/εγγραφήΕλέγχει εάν οι τιμές προσεγγίζονται άμεσα ή μέσω ενός πίνακα δεικτών.
indicesnumber[]ανάγνωσηΠίνακας δεικτών για IndexToDirect λειτουργία αναφοράς.

Properties

setIndices(data)

NOT IMPLEMENTED. Στην βάση VertexElement κλάση, αυτή η μέθοδος ρίχνει Error('set_indices is not implemented') κατά την εκτέλεση. Οι υποκλάσεις VertexElementFVector και VertexElementIntsTemplate παρέχουν λειτουργικές υλοποιήσεις.

Αντικαθιστά τον πίνακα δεικτών.

setIndices(data: number[]): void

clear()

NOT IMPLEMENTED. Στην βάση VertexElement κλάση, αυτή η μέθοδος ρίχνει Error('clear is not implemented') κατά την εκτέλεση. Οι υποκλάσεις VertexElementFVector και VertexElementIntsTemplate παρέχουν λειτουργικές υλοποιήσεις.

Αφαιρεί όλα τα δεδομένα και τους δείκτες από το επίπεδο.

clear(): void

VertexElementNormal

Αποθηκεύει διανύσματα κανονικών επιφάνειας. Τα δεδομένα normal απαιτούνται από τους περισσότερους renderers για σωστό φωτισμό.

export class VertexElementNormal extends VertexElementFVector

Properties

VertexElementVertexElementFVectorVertexElementNormal

Properties

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

vertexElementType είναι ορισμένο σε VertexElementType.NORMAL.


Επιστρέφει: VertexElementUV

Αποθηκεύει 2D συντεταγμένες υφής. Ένα πλέγμα μπορεί να περιέχει πολλαπλά επίπεδα UV για διαφορετικά κανάλια υφής. Το textureMapping ιδιότητα προσδιορίζει τον σκοπό του καναλιού.

export class VertexElementUV extends VertexElementFVector

Properties

VertexElementVertexElementFVectorVertexElementUV

Properties

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

Προεπιλογή είναι TextureMapping.DIFFUSE όταν textureMapping είναι null.

A3DObjectMaterialLambertMaterial

PropertiesPropertiesPropertiesProperties
textureMappingTextureMappingδιάβασεΤο κανάλι υφής με το οποίο συνδέεται αυτό το στρώμα UV.
dataFVector4[]διάβασεΤιμές UV εκτεθειμένες ως FVector4 καταχωρήσεις (z και w είναι 0).
uvDataFVector2[]αναγνώμενεςΤιμές UV ως FVector2 καταχωρήσεις (μόνο x, y).

addData(data)

Προσθήκη τιμών UV. Δέχεται FVector2[], FVector3[], ή FVector4[].

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

VertexElementVertexColor

Αποθηκεύει τιμές χρώματος RGBA ανά κορυφή. Τα συστατικά είναι στο εύρος 0–1.

export class VertexElementVertexColor extends VertexElementFVector

Properties

VertexElementVertexElementFVectorVertexElementVertexColor

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');

Δείτε επίσης

 Ελληνικά