VertexElement — Aspose.3D TypeScript API Reference
חבילה : תגית: 3D / 3d (הופנה מהדף 24.0)
VertexElement הוא הכיתה הבסיסית אבסטרטית עבור ערוצי אקריפטים per-vertex הקשורים ל Geometry.כל ערוץ מחזיק מעמד נתונים מסוג ו mappingMode / referenceMode נתונים מטאוגרפיים שמשלבים כיצד הנתונים קשורים לגיאומטריה פרימיטיביות.התכונות הבאות הן: VertexElementNormal, VertexElementUV, ו VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';מבנה אובססיבי (abstract base)
export abstract class VertexElement implements IIndexedVertexElement { }מבנה
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)דוגמנית mappingMode הוא MappingMode.CONTROL_POINT;• דפדפן referenceMode הוא ReferenceMode.DIRECT.
נכסים
| נכסים | סוג | גישה | תיאור |
|---|---|---|---|
vertexElementType | VertexElementType | קראו | סוג סמנטי של שכבה זו. |
name | string | קרא / כתיבה | תווית אופציונלית עבור שכבה זו. |
mappingMode | MappingMode | קרא / כתיבה | בקרת איזה גיאומטריה פרימיטיבית כל ערך קשור. |
referenceMode | ReferenceMode | קרא / כתיבה | הוא בודק אם ערכים נוגעים ישירות או באמצעות רצועת אינדיקטורים. |
indices | number[] | קראו | מדד ארכיון עבור IndexToDirect מצב התייחסות. |
שיטות
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
מאחסן וקטורי נורמל של פני השטח. נתוני נורמל נדרשים ברוב הרנדררים לתאורה נכונה.
export class VertexElementNormal extends VertexElementFVector { }מורשת
VertexElement → VertexElementFVector → VertexElementNormal
מבנה
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType קבועים ל VertexElementType.NORMAL.
VertexElementUV
מסך 2D יכול לשאת שכבות UV מרובות עבור ערוצי טקסטור שונים. textureMapping המשמעות היא שהמטרה של הערוץ.
export class VertexElementUV extends VertexElementFVector { }מורשת
VertexElement → VertexElementFVector → VertexElementUV
מבנה
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)חסרונות ל TextureMapping.DIFFUSE כאשר textureMapping הוא null.
מאפיין נוסף
| נכסים | סוג | גישה | תיאור |
|---|---|---|---|
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 VertexElementFVector { }מורשת
VertexElement → VertexElementFVector → VertexElementVertexColor
מבנה
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType קבועים ל VertexElementType.VERTEX_COLOR.
דוגמאות
הוסף נורמליים לרשת משולשים:
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');