VertexElement — Aspose.3D TypeScript API Reference
แพ็คเกจ: @aspose/3d (v24.12.0)
VertexElement คือคลาสฐานแบบสรุปสําหรับช่องทางอภิสิทธิ์ที่ติดต่อกับ a Geometry. แต่ละช่องมีอาร์เรย์ข้อมูลที่ถูกตีพิมพ์ และ mappingMode / referenceMode เมตาเดทที่ควบคุมการสัมพันธ์ข้อมูลกับพริมิติเวสทางกณฑศาสตร์ กลุ่มล่างคือ: VertexElementNormal, VertexElementUV,และ VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';VertexElement (ฐานสรุป)
export abstract class VertexElement implements IIndexedVertexElement { }Constructor
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Default mappingMode คือ MappingMode.CONTROL_POINT; การกําหนดโดยอัตราถัดไป referenceMode คือ ReferenceMode.DIRECT.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
vertexElementType | VertexElementType | Read | ประเภทเชิงความหมายของชั้นนี้. |
name | string | อ่าน/เขียน | การติดป้ายที่ไม่จําเป็นสําหรับชั้นนี้. |
mappingMode | MappingMode | อ่าน/เขียน | การควบคุมที่เจอมิทรี ปริมิตี้แต่ละค่าที่เกี่ยวข้องกับ. |
referenceMode | ReferenceMode | อ่าน/เขียน | การควบคุมว่าค่าจะถูกอัดตรงหรือผ่านการวัดอินเด็กซ์หรือไม่. |
indices | number[] | Read | อัตราการแสดงอัคทัศน์สําหรับ IndexToDirect รูปแบบการอ้างอิง. |
Methods
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 VertexElementFVector { }Inheritance
VertexElement → VertexElementFVector → VertexElementNormal
Constructor
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType ติดตั้งไว้ที่ VertexElementType.NORMAL.
VertexElementUV
ส่งความหมาย 2D. mesh อาจมีหลายชั้น UV สําหรับช่องทางความรู้ที่แตกต่างกัน textureMapping คุณสมบัติระบุวัตถุประสงค์ของช่องทาง.
export class VertexElementUV extends VertexElementFVector { }Inheritance
VertexElement → VertexElementFVector → VertexElementUV
Constructor
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)การผิดพลาดในการทําการ TextureMapping.DIFFUSE เมื่อไหร่ textureMapping คือ null.
คุณสมบัติเพิ่มเติม
| Property | Type | Access | Description |
|---|---|---|---|
textureMapping | TextureMapping | Read | ช่องทางของเนื้อผิวที่ชั้น UV นี้เกี่ยวข้องกับ. |
data | FVector4[] | Read | ค่า UV ที่ถูกเผยแพร่ในช่วงเวลา FVector4 รายการ (z และ w เป็น 0). |
uvData | FVector2[] | Read | ค่า UV ในรูปแบบ FVector2 รายการ (x, y เท่านั้น). |
addData(data)
ใส่ค่า UV ยอมรับ FVector2[], FVector3[],หรือ FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
เก็บค่าความสี RGBA ต่อเวอร์เท็กซ์. ส่วนประกอบอยู่ในช่วง 0–1.
export class VertexElementVertexColor extends VertexElementFVector { }Inheritance
VertexElement → VertexElementFVector → VertexElementVertexColor
Constructor
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType ติดตั้งไว้ที่ VertexElementType.VERTEX_COLOR.
Examples
เพิ่มเวกเตอร์ปกติให้กับเมชสามเหลี่ยม:
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');