เริ่มต้นใช้งาน
เริ่มต้นกับ Aspose.3D FOSS สำหรับ Java
ยินดีต้อนรับสู่ aspose-3d-foss, ไลบรารี Java ฟรีและโอเพนซอร์สสำหรับการโหลด, สร้าง, และส่งออกฉาก 3D. คู่มือนี้จะพาคุณจากโครงการใหม่ไปสู่ฉากที่ทำงานได้ในไม่กี่นาที.
ข้อกำหนดเบื้องต้น
| ข้อกำหนด | รายละเอียด |
|---|---|
| Java | JDK 21 หรือใหม่กว่า |
| เครื่องมือสร้าง | Maven หรือ Gradle |
| OS | Windows, macOS หรือ Linux |
การติดตั้ง
เพิ่มการพึ่งพา Maven ไปยังโปรเจกต์ของคุณ pom.xml:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-3d-foss</artifactId>
<version>26.1.0</version>
</dependency>ตรวจสอบ:
import com.aspose.threed.Scene;
public class Main {
public static void main(String[] args) {
Scene scene = new Scene();
System.out.println("aspose-3d-foss loaded successfully.");
}
}ดูที่ คู่มือการติดตั้ง สำหรับขั้นตอนการตั้งค่า Gradle และการตรวจสอบ.
สิ่งที่คุณทำได้
เมื่อติดตั้งแล้วคุณสามารถทำได้ทันที:
- โหลด ไฟล์ OBJ, STL, glTF 2.0 / GLB, และ FBX ผ่าน
scene.open() - ตรวจสอบ ลำดับชั้นของฉาก: สำรวจ
Nodeต้นไม้, อ่านMeshเรขาคณิต, เข้าถึงนอร์มของเวอร์เท็กซ์และ UV - การแปลง nodes: ตั้งค่า translation, rotation, และ scale ผ่าน
Transformคลาส - ใช้วัสดุ: กำหนด
MaterialหรือPbrMaterialให้กับ nodes - ส่งออก ไปยังรูปแบบที่รองรับใด ๆ ด้วย
scene.save() - สร้างเรขาคณิต: สร้าง
Meshวัตถุโดยโปรแกรมด้วยจุดควบคุมและโพลิกอน
เริ่มต้นอย่างรวดเร็ว
โหลดไฟล์ 3D, พิมพ์ลำดับชั้นของฉาก, และบันทึกใหม่ในรูปแบบ GLB:
import com.aspose.threed.Scene;
import com.aspose.threed.Node;
public class QuickStart {
public static void main(String[] args) throws Exception {
Scene scene = new Scene();
scene.open("input.obj");
System.out.println("Root children: " + scene.getRootNode().getChildNodes().size());
for (Node node : scene.getRootNode().getChildNodes()) {
String entityType = node.getEntity() != null
? node.getEntity().getClass().getSimpleName()
: "no entity";
System.out.println(" " + node.getName() + " [" + entityType + "]");
}
scene.save("output.glb");
System.out.println("Saved output.glb");
}
}ขั้นตอนต่อไป
- คู่มือการติดตั้ง: การตั้งค่า Maven/Gradle และการตรวจสอบ
- คู่มือผู้พัฒนา: การสนับสนุนรูปแบบ, การดำเนินการ mesh, วัสดุ, และการแปลง
- คุณลักษณะและฟังก์ชัน: การสำรวจเชิงลึกในทุกด้านของฟีเจอร์ด้วยตัวอย่าง Java