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 ניתן ליצור מופע של המחלקה ללא ארגומנטים כדי ליצור סצנה ריקה, או עם פרמטרים אופציונליים.

ExampleExampleExample
entityEntityישות אופציונלית לצירוף לצומת השורש בעת היצירה
parentSceneSceneסצנת הורה אופציונלית (לתתי‑סצנות); דורשת שם
nameStringשם הסצנה (משמש רק עם הבונה בעל שני הארגומנטים 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.

ExampleExampleExampleExampleExample
rootNodeNodegetRootNode()צומת השורש של היררכיית הסצנה
subScenesList<Scene>getSubScenes()תתי‑סצנות מקוננות בתוך סצנה זו
assetInfoAssetInfogetAssetInfo()setAssetInfo(AssetInfo)מטא‑נתוני נכס כגון מחבר, תאריך יצירה ויחידות
animationClipsList<AnimationClip>getAnimationClips()קלאפים של אנימציה המוגדרים בסצנה
currentAnimationClipAnimationClipgetCurrentAnimationClip()setCurrentAnimationClip(AnimationClip)קלאף האנימציה הפעיל כעת
libraryList<A3DObject>getLibrary()אובייקטי מטא‑נתונים שהוגדרו על ידי המשתמש וצורפו לסצנה
nameStringgetName()setName(String)שם אובייקט הסצנה
propertiesPropertyCollectiongetProperties()מאפיינים מותאמים אישית המחוברים לסצנה

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

ראה גם

 עברית