VertexElement — Aspose.3D TypeScript API Reference
แพคเกจ: @aspose/3d (v24.12.0)
VertexElement เป็นคลาสฐานเชิงนามธรรมสำหรับช่องแอตทริบิวต์ต่อจุด (per-vertex) ที่แนบกับ 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 จำเป็นสำหรับเรนเดอร์หลายตัวเพื่อการแสงที่ถูกต้อง.
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
เก็บพิกัดเทกซ์เจอร์ 2 มิติ. เมชอาจมีหลายชั้น 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.
คุณสมบัติเพิ่มเติม
| 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');