แพคเกจ: @aspose/3d (v24.12.0) ภาษา: TypeScript / Node.js 18+ สัญญาอนุญาต: MIT
@aspose/3d เป็นไลบรารีที่มีสัญญาอนุญาต MIT สำหรับการอ่าน, สร้าง, และส่งออกฉาก 3D ใน Node.js มาพร้อมกับการกำหนดประเภท TypeScript ที่สมบูรณ์, ขึ้นอยู่กับ runtime เพียงหนึ่งตัว ( «<SEG_7»> )xmldom), รองรับไฟล์ฟอร์แมต 3D หลักเจ็ดรูปแบบ การทำ I/O ทั้งหมดเป็นแบบ synchronous ไม่ต้องใช้ native addons.
Properties
Properties tsconfig.json การตั้งค่าสำหรับการแก้ไขเส้นทางย่อยอย่างถูกต้อง:
คลาสหลัก
Properties
คอนเทนเนอร์รากสำหรับฉาก 3D เนื้อหาทั้งหมด; โหนด, เรขาคณิต, วัสดุ, และแอนิเมชัน; จะถูกจัดเก็บในต้นไม้ที่มีรากที่ scene.rootNode.ใช้ open() / openFromBuffer() เพื่อโหลดไฟล์และ save() / saveToBuffer() เพื่อส่งออก.
| Properties | Properties | Properties |
|---|
rootNode | Node | รากของกราฟฉาก |
assetInfo | AssetInfo | เมตาดาต้าไฟล์ (ผู้สร้าง, หน่วย, ระบบพิกัด) |
animationClips | AnimationClip[] | คลิปแอนิเมชันทั้งหมดในฉาก |
open(path, opts?) | (string, LoadOptions?) → void | โหลดไฟล์จากดิสก์ |
openFromBuffer(buf, opts?) | (Buffer, LoadOptions?) → void | โหลดจากบัฟเฟอร์ในหน่วยความจำ |
save(path, opts?) | (string, SaveOptions?) → void | บันทึกลงดิสก์ (รูปแบบสรุปจากส่วนขยาย) |
saveToBuffer(ext, opts?) | (string, SaveOptions?) → Buffer | บันทึกลงบัฟเฟอร์ในหน่วยความจำ |
createAnimationClip(name) | (string) → AnimationClip | สร้างและลงทะเบียนคลิปแอนิเมชันใหม่ |
Properties
โหนดต้นไม้ที่มีชื่อในกราฟฉาก โหนดบรรจุตัวเลือกเสริม Entity (mesh, camera, light) และ Transform ที่กำหนดตำแหน่งของโหนดสัมพันธ์กับโหนดแม่ของมัน.
| Properties | Properties | Properties |
|---|
name | string | ชื่อโหนด |
childNodes | Node[] | โหนดลูกโดยตรง |
entity | `Entity | null` |
transform | Transform | การแปล, การหมุน, การสเกล |
materials | Material[] | วัสดุที่กำหนดให้กับโหนดนี้ |
createChildNode(name) | (string) → Node | เพิ่มโหนดลูก |
getChildNode(name) | `(string) → Node | null` |
Properties
Polygon mesh; ประเภทเรขาคณิตหลัก ขยายจาก Geometry.
| Properties | Properties | Properties |
|---|
controlPoints | Vector4[] | ตำแหน่งเวอร์เท็กซ์ (w=1 สำหรับตำแหน่ง) |
polygonCount | number | จำนวนโพลิกอน |
createPolygon(indices) | (number[]) → void | เพิ่มโพลิกอน (สามเหลี่ยมหรือสี่เหลี่ยม) |
getElement(type) | `(VertexElementType) → VertexElement | null` |
createElement(type) | (VertexElementType) → VertexElement | สร้างองค์ประกอบเวอร์เท็กซ์ |
Properties
การแปลงเชิงพื้นที่แบบโลคัลที่ใช้กับโหนด.
| Properties | Properties | Properties |
|---|
translation | Vector3 | ตำแหน่งท้องถิ่น |
eulerAngles | Vector3 | การหมุนออยเลอร์เป็นองศา (ลำดับ XYZ) |
rotation | Quaternion | การหมุนเป็นควอเทอร์เนียน |
scaling | Vector3 | สเกลท้องถิ่น |
คลาสวัสดุ
| Properties | Properties | คุณสมบัติหลัก |
|---|
LambertMaterial | การเชดดิ้งแบบกระจาย + แสงรอบด้าน | diffuseColor, ambientColor, transparency |
PhongMaterial | เพิ่ม specular + emissive ให้กับ Lambert | specularColor, shininess, emissiveColor |
PbrMaterial | อิงฟิสิกส์สำหรับ glTF 2.0 | albedo, metallicFactor, roughnessFactor, emissiveColor |
คลาสคณิตศาสตร์
| Properties | Properties |
|---|
Vector3 | 3-component double-precision vector (x, y, z) |
Vector4 | 4-component vector for homogeneous math (x, y, z, w) |
FVector3 | เวอร์ชันความแม่นยำเดี่ยวที่ใช้ในข้อมูลเวอร์เท็กซ์ |
Matrix4 | 4×4 transformation matrix; multiply, invert, decompose |
Quaternion | ควอเทอร์เนียนการหมุน; fromEulerAngle, toEulerAngles, slerp |
BoundingBox | กล่องขอบเขตที่จัดแนวตามแกน; minimum, maximum, center, size, merge |
คลาสแอนิเมชัน
| Properties | Properties |
|---|
AnimationClip | คลิปที่ตั้งชื่อ; มี AnimationNode รายการ; เข้าถึงผ่าน scene.animationClips |
AnimationNode | ผูกคลิปกับโหนดซีนที่ตั้งชื่อ; มี AnimationChannel รายการ |
AnimationChannel | เป้าหมายเป็นคุณสมบัติเดียว (เช่น translation X); เก็บ KeyframeSequence |
KeyframeSequence | รายการที่เรียงลำดับของ KeyFrame อ็อบเจกต์ที่มี interpolation และ extrapolation |
KeyFrame | คู่เวลา/ค่าเดียว |
Properties
| Properties | Properties | Properties |
|---|
VertexElementType | NORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENT | ความหมายขององค์ประกอบเวอร์เท็กซ์ |
MappingMode | CONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAME | วิธีที่ข้อมูลแมปกับเรขาคณิต |
ReferenceMode | DIRECT, INDEX, INDEX_TO_DIRECT | กลยุทธ์การทำดัชนีสำหรับข้อมูลองค์ประกอบเวอร์เท็กซ์ |
Interpolation | CONSTANT, LINEAR, BEZIER | การอินเทอร์โพเลชันของคีย์เฟรม |
Extrapolation | CONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATE | พฤติกรรมนอกช่วงคีย์เฟรม |
โมดูลฟอร์แมต
คลาสตัวเลือกเฉพาะฟอร์แมตจะถูกส่งออกจากโมดูลย่อยของเส้นทาง แยกนำเข้าแต่ละคลาสตามต้องการ:
โมดูล OBJ (@aspose/3d/formats/obj)
| Properties | ตัวเลือกคีย์ |
|---|
ObjLoadOptions | enableMaterials, flipCoordinateSystem, scale, normalizeNormal |
โมดูล glTF/GLB (@aspose/3d/formats/gltf)
| Properties | ตัวเลือกคีย์ |
|---|
GltfSaveOptions | binaryMode (true → .glb), flipTexCoordV |
GltfFormat | GltfFormat.getInstance(): อินสแตนซ์รูปแบบสำหรับ scene.save() |
โมดูล STL (@aspose/3d/formats/stl)
| Properties | ตัวเลือกสำคัญ |
|---|
StlLoadOptions | N/A |
StlSaveOptions | binaryMode (false → ASCII, true → binary) |
โมดูล FBX (@aspose/3d/formats/fbx)
| Properties | ตัวเลือกสำคัญ |
|---|
FbxLoadOptions | N/A |
FbxSaveOptions | embedTextures |
รูปแบบที่รองรับ
| Properties | Properties | Properties | Properties |
|---|
| Properties | .obj | Properties | Properties |
| glTF 2.0 | .gltf | Properties | Properties |
| Properties | .glb | Properties | Properties |
| STL | .stl | Properties | Properties |
| FBX | .fbx | ไม่* | ไม่* |
| COLLADA | .dae | Properties | Properties |
| 3MF | .3mf | Properties | Properties |
ตัวอย่างอ้างอิงอย่างรวดเร็ว
ดูเพิ่มเติม