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

PropertyTypeAccessDescription
vertexElementTypeVertexElementTypeReadประเภทเชิงความหมายของชั้นนี้.
namestringอ่าน/เขียนการติดป้ายที่ไม่จําเป็นสําหรับชั้นนี้.
mappingModeMappingModeอ่าน/เขียนการควบคุมที่เจอมิทรี ปริมิตี้แต่ละค่าที่เกี่ยวข้องกับ.
referenceModeReferenceModeอ่าน/เขียนการควบคุมว่าค่าจะถูกอัดตรงหรือผ่านการวัดอินเด็กซ์หรือไม่.
indicesnumber[]Readอัตราการแสดงอัคทัศน์สําหรับ IndexToDirect รูปแบบการอ้างอิง.

Methods

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 จำเป็นสำหรับเรนเดอร์หลายตัวเพื่อการแสงที่ถูกต้อง.

export class VertexElementNormal extends VertexElementFVector { }

Inheritance

VertexElementVertexElementFVectorVertexElementNormal

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

VertexElementVertexElementFVectorVertexElementUV

Constructor

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

การผิดพลาดในการทําการ TextureMapping.DIFFUSE เมื่อไหร่ textureMapping คือ null.

คุณสมบัติเพิ่มเติม

PropertyTypeAccessDescription
textureMappingTextureMappingReadช่องทางของเนื้อผิวที่ชั้น UV นี้เกี่ยวข้องกับ.
dataFVector4[]Readค่า UV ที่ถูกเผยแพร่ในช่วงเวลา FVector4 รายการ (z และ w เป็น 0).
uvDataFVector2[]Readค่า 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 { }

Inheritance

VertexElementVertexElementFVectorVertexElementVertexColor

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

See Also

 ภาษาไทย