Scene — Aspose.3D FOSS for Java
Example
Example Scene class in Aspose.3D משמשת כמכולה השורש לתוכן תלת‑ממדי, מנהלת אובייקטים ברמת העל ומאפשרת ניהול יחסי הורה/ילד עבור היררכיית הסצנה. היא מספקת גישה לצמתים השורש ולתתי‑סצנות, ומהווה נקודת כניסה לטעינה, בנייה ושמירת סצנות תלת‑ממד.
import com.aspose.threed.Scene;
// Create an empty scene
Scene scene = new Scene();
// Access the root node via getter method
Node root = scene.getRootNode();Example
Example Scene ניתן ליצור מופע של המחלקה ללא ארגומנטים כדי ליצור סצנה ריקה, או עם פרמטרים אופציונליים.
| Example | Example | Example |
|---|---|---|
entity | Entity | ישות אופציונלית לצירוף לצומת השורש בעת היצירה |
parentScene | Scene | סצנת הורה אופציונלית (לתתי‑סצנות); דורשת שם |
name | String | שם הסצנה (משמש רק עם הבונה בעל שני הארגומנטים Scene(Scene, String) בונה) |
import com.aspose.threed.Scene;
// Empty scene
Scene scene = new Scene();
// Scene with an initial entity
Scene scene = new Scene(new Mesh());
// Access the root node (getter method)
Node root = scene.getRootNode();מתודות מחלקה
| Example | סוג החזרה | Example |
|---|---|---|
Scene.fromFile(String filePath) | Scene | טוען סצנה מהנתיב הקובץ שצוין, ומזהה את הפורמט אוטומטית. |
Scene.fromFile(String filePath, LoadOptions options) | Scene | טוען סצנה עם אפשרויות טעינה ספציפיות לפורמט. |
import com.aspose.threed.Scene;
// Load from file (format detected from extension)
Scene scene = Scene.fromFile("model.obj");
// Load with options
ObjLoadOptions opts = new ObjLoadOptions();
Scene scene = Scene.fromFile("model.obj", opts);Example
כל המאפיינים נגישים דרך מתודות getter/setter.
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
rootNode | Node | getRootNode() | – | צומת השורש של היררכיית הסצנה |
subScenes | List<Scene> | getSubScenes() | – | תתי‑סצנות מקוננות בתוך סצנה זו |
assetInfo | AssetInfo | getAssetInfo() | setAssetInfo(AssetInfo) | מטא‑נתוני נכס כגון מחבר, תאריך יצירה ויחידות |
animationClips | List<AnimationClip> | getAnimationClips() | – | קלאפים של אנימציה המוגדרים בסצנה |
currentAnimationClip | AnimationClip | getCurrentAnimationClip() | setCurrentAnimationClip(AnimationClip) | קלאף האנימציה הפעיל כעת |
library | List<A3DObject> | getLibrary() | – | אובייקטי מטא‑נתונים שהוגדרו על ידי המשתמש וצורפו לסצנה |
name | String | getName() | setName(String) | שם אובייקט הסצנה |
properties | PropertyCollection | getProperties() | – | מאפיינים מותאמים אישית המחוברים לסצנה |
Example
| Example | סוג החזרה | Example |
|---|---|---|
save(String filePath) | void | שומר את הסצנה לקובץ; הפורמט נובע מההרחבה |
save(String filePath, FileFormat format) | void | שומר את הסצנה לקובץ במצוין FileFormat |
save(String filePath, SaveOptions options) | void | שומר את הסצנה באמצעות אפשרויות שמירה ספציפיות לפורמט |
open(String filePath) | void | פותח קובץ לתוך הסצנה הזו; הפורמט נובע מההרחבה |
open(String filePath, LoadOptions options) | void | פותח קובץ עם אפשרויות טעינה ספציפיות לפורמט |
getProperty(String name) | Object | מקבל ערך של מאפיין לפי שם |
findProperty(String name) | Property | מוצא מאפיין לפי שם |
createAnimationClip(String name) | AnimationClip | יוצר animation clip חדש בעל שם ומוסיף אותו לסצנה |
getAnimationClip(String name) | AnimationClip | מוצא animation clip קיים לפי שם, או null אם לא נמצא |
clear() | void | מוחק את כל התוכן מהסצנה |
Example
צור סצנה, הוסף צומת רשת, ושמור ל‑GLB:
import com.aspose.threed.Scene;
import com.aspose.threed.FileFormat;
// Create scene and mesh
Scene scene = new Scene();
Mesh mesh = new Mesh();
mesh.getControlPoints().add(new Vector4(0, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(1, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);
// Add node to root
Node node = scene.getRootNode().createChildNode("triangle", mesh);
// Save as GLB
GltfSaveOptions glbOpts = new GltfSaveOptions();
glbOpts.setContentType(FileContentType.BINARY);
scene.save("triangle.glb", glbOpts);