Scene

Thuộc tính

Properties Scene class trong Aspose.3D đóng vai trò là container gốc cho nội dung 3D, quản lý các đối tượng cấp cao nhất và cho phép quản lý quan hệ cha/con cho cấu trúc cây cảnh. Nó cung cấp quyền truy cập vào các nút gốc và các cảnh phụ, tạo thành điểm vào để tải, xây dựng và lưu các cảnh 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();

Thuộc tính

Properties Scene class có thể được khởi tạo không có đối số nào để tạo một cảnh trống, hoặc với các tham số tùy chọn.

NameTypeAccessDescription
rootNodeNodeReadGets the root node.
assetInfoAssetInfoReadGets the asset info.
subScenesList<Scene>ReadGets the sub scenes.
libraryList<A3DObject>ReadGets the library.
animationClipsList<AnimationClip>ReadGets the animation clips.
currentAnimationClipAnimationClipReadGets the current animation clip.
posesCollection<Pose>ReadGets the poses.
VERSIONStringReadGets the version.
sceneSceneReadGets the scene.
nameStringReadGets the name.
propertiesPropertyCollectionReadGets the properties.

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


## Các phương thức lớp

| Signature                                                                                               | Description                                                                                                                    |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `Scene()`                                                                                               | Calls Scene on this Scene instance.                                                                                            |
| `Scene(entity: Entity)`                                                                                 | Calls Scene(entity) on this Scene instance.                                                                                    |
| `Scene(scene: Scene, name: String)`                                                                     | Calls Scene(scene, name) on this Scene instance.                                                                               |
| `getRootNode()`  →  `Node`                                                                              | Returns the root node.                                                                                                         |
| `getAssetInfo()`  →  `AssetInfo`                                                                        | Returns the asset info.                                                                                                        |
| `setAssetInfo(value: AssetInfo)`                                                                        | Sets the asset info value.                                                                                                     |
| `getSubScenes()`  →  `List<Scene>`                                                                      | Returns the sub scenes.                                                                                                        |
| `getLibrary()`  →  `List<A3DObject>`                                                                    | Returns the library.                                                                                                           |
| `getAnimationClips()`  →  `List<AnimationClip>`                                                         | Returns the animation clips.                                                                                                   |
| `getCurrentAnimationClip()`  →  `AnimationClip`                                                         | Returns the current animation clip.                                                                                            |
| `setCurrentAnimationClip(value: AnimationClip)`                                                         | Sets the current animation clip value.                                                                                         |
| `getAnimationClip(name: String)`  →  `AnimationClip`                                                    | Calls getAnimationClip(name) on this Scene instance.                                                                           |
| `createAnimationClip(name: String)`  →  `AnimationClip`                                                 | Calls createAnimationClip(name) on this Scene instance.                                                                        |
| `getPoses()`  →  `Collection<Pose>`                                                                     | Returns the poses.                                                                                                             |
| `clear()`                                                                                               | Calls clear on this Scene instance.                                                                                            |
| `open(filePath: String)`                                                                                | Calls open(filePath) on this Scene instance.                                                                                   |
| `open(filePath: String, cancellationToken: Cancellation)`                                               | Calls open(filePath, cancellationToken) on this Scene instance.                                                                |
| `open(filePath: String, format: FileFormat)`                                                            | Calls open(filePath, format) on this Scene instance.                                                                           |
| `open(filePath: String, format: FileFormat, cancellationToken: Cancellation)`                           | Calls open(filePath, format, cancellationToken) on this Scene instance.                                                        |
| `open(filePath: String, options: LoadOptions)`                                                          | Calls open(filePath, options) on this Scene instance.                                                                          |
| `open(filePath: String, options: LoadOptions, cancellationToken: Cancellation)`                         | Calls open(filePath, options, cancellationToken) on this Scene instance.                                                       |
| `open(stream: InputStream)`                                                                             | Calls open(stream) on this Scene instance.                                                                                     |
| `open(stream: InputStream, cancellationToken: Cancellation)`                                            | Calls open(stream, cancellationToken) on this Scene instance.                                                                  |
| `open(stream: InputStream, format: FileFormat)`                                                         | Calls open(stream, format) on this Scene instance.                                                                             |
| `open(stream: InputStream, format: FileFormat, cancellationToken: Cancellation)`                        | Calls open(stream, format, cancellationToken) on this Scene instance.                                                          |
| `open(stream: InputStream, options: LoadOptions)`                                                       | Calls open(stream, options) on this Scene instance.                                                                            |
| `open(stream: InputStream, options: LoadOptions, cancellationToken: Cancellation)`                      | Calls open(stream, options, cancellationToken) on this Scene instance.                                                         |
| `open(stream: Stream, format: FileFormat, options: LoadOptions)`                                        | Calls open(stream, format, options) on this Scene instance.                                                                    |
| `open(stream: Stream, format: FileFormat, options: LoadOptions, cancellationToken: Cancellation)`       | Calls open(stream, format, options, cancellationToken) on this Scene instance.                                                 |
| `open(stream: Stream)`                                                                                  | Calls open(stream) on this Scene instance.                                                                                     |
| `open(stream: Stream, cancellationToken: Cancellation)`                                                 | Calls open(stream, cancellationToken) on this Scene instance.                                                                  |
| `open(stream: Stream, format: FileFormat)`                                                              | Calls open(stream, format) on this Scene instance.                                                                             |
| `open(stream: Stream, format: FileFormat, cancellationToken: Cancellation)`                             | Calls open(stream, format, cancellationToken) on this Scene instance.                                                          |
| `open(stream: Stream, options: LoadOptions)`                                                            | Calls open(stream, options) on this Scene instance.                                                                            |
| `open(stream: Stream, options: LoadOptions, cancellationToken: Cancellation)`                           | Calls open(stream, options, cancellationToken) on this Scene instance.                                                         |
| `fromFile(filePath: String)`  →  `Scene`                                                                | Calls fromFile(filePath) on this Scene instance.                                                                               |
| `fromFile(filePath: String, cancellationToken: Cancellation)`  →  `Scene`                               | Calls fromFile(filePath, cancellationToken) on this Scene instance.                                                            |
| `fromFile(filePath: String, format: FileFormat)`  →  `Scene`                                            | Calls fromFile(filePath, format) on this Scene instance.                                                                       |
| `fromFile(filePath: String, format: FileFormat, cancellationToken: Cancellation)`  →  `Scene`           | Calls fromFile(filePath, format, cancellationToken) on this Scene instance.                                                    |
| `fromFile(filePath: String, options: LoadOptions)`  →  `Scene`                                          | Calls fromFile(filePath, options) on this Scene instance.                                                                      |
| `fromFile(filePath: String, options: LoadOptions, cancellationToken: Cancellation)`  →  `Scene`         | Calls fromFile(filePath, options, cancellationToken) on this Scene instance.                                                   |
| `fromStream(stream: InputStream)`  →  `Scene`                                                           | Calls fromStream(stream) on this Scene instance.                                                                               |
| `fromStream(stream: InputStream, cancellationToken: Cancellation)`  →  `Scene`                          | Calls fromStream(stream, cancellationToken) on this Scene instance.                                                            |
| `fromStream(stream: InputStream, format: FileFormat)`  →  `Scene`                                       | Calls fromStream(stream, format) on this Scene instance.                                                                       |
| `fromStream(stream: InputStream, format: FileFormat, cancellationToken: Cancellation)`  →  `Scene`      | Calls fromStream(stream, format, cancellationToken) on this Scene instance.                                                    |
| `fromStream(stream: InputStream, options: LoadOptions)`  →  `Scene`                                     | Calls fromStream(stream, options) on this Scene instance.                                                                      |
| `fromStream(stream: InputStream, options: LoadOptions, cancellationToken: Cancellation)`  →  `Scene`    | Calls fromStream(stream, options, cancellationToken) on this Scene instance.                                                   |
| `fromStream(stream: Stream)`  →  `Scene`                                                                | Calls fromStream(stream) on this Scene instance.                                                                               |
| `fromStream(stream: Stream, cancellationToken: Cancellation)`  →  `Scene`                               | Calls fromStream(stream, cancellationToken) on this Scene instance.                                                            |
| `fromStream(stream: Stream, format: FileFormat)`  →  `Scene`                                            | Calls fromStream(stream, format) on this Scene instance.                                                                       |
| `fromStream(stream: Stream, format: FileFormat, cancellationToken: Cancellation)`  →  `Scene`           | Calls fromStream(stream, format, cancellationToken) on this Scene instance.                                                    |
| `fromStream(stream: Stream, options: LoadOptions)`  →  `Scene`                                          | Calls fromStream(stream, options) on this Scene instance.                                                                      |
| `fromStream(stream: Stream, options: LoadOptions, cancellationToken: Cancellation)`  →  `Scene`         | Calls fromStream(stream, options, cancellationToken) on this Scene instance.                                                   |
| `save(filePath: String)`                                                                                | Calls save(filePath) on this Scene instance.                                                                                   |
| `save(filePath: String, format: FileFormat)`                                                            | Calls save(filePath, format) on this Scene instance.                                                                           |
| `save(filePath: String, format: FileFormat, cancellationToken: Cancellation)`                           | Calls save(filePath, format, cancellationToken) on this Scene instance.                                                        |
| `save(filePath: String, options: SaveOptions)`                                                          | Calls save(filePath, options) on this Scene instance.                                                                          |
| `save(filePath: String, options: SaveOptions, cancellationToken: Cancellation)`                         | Calls save(filePath, options, cancellationToken) on this Scene instance.                                                       |
| `save(stream: OutputStream, format: FileFormat)`                                                        | Calls save(stream, format) on this Scene instance.                                                                             |
| `save(stream: OutputStream, format: FileFormat, cancellationToken: Cancellation)`                       | Calls save(stream, format, cancellationToken) on this Scene instance.                                                          |
| `save(stream: OutputStream, options: SaveOptions)`                                                      | Calls save(stream, options) on this Scene instance.                                                                            |
| `save(stream: OutputStream, options: SaveOptions, cancellationToken: Cancellation)`                     | Calls save(stream, options, cancellationToken) on this Scene instance.                                                         |
| `save(stream: OutputStream, format: FileFormat, options: SaveOptions)`                                  | Calls save(stream, format, options) on this Scene instance.                                                                    |
| `save(stream: OutputStream, format: FileFormat, options: SaveOptions, cancellationToken: Cancellation)` | Calls save(stream, format, options, cancellationToken) on this Scene instance.                                                 |
| `save(stream: Stream, format: FileFormat)`                                                              | Calls save(stream, format) on this Scene instance.                                                                             |
| `save(stream: Stream, format: FileFormat, cancellationToken: Cancellation)`                             | Calls save(stream, format, cancellationToken) on this Scene instance.                                                          |
| `save(stream: Stream, options: SaveOptions)`                                                            | Calls save(stream, options) on this Scene instance.                                                                            |
| `save(stream: Stream, options: SaveOptions, cancellationToken: Cancellation)`                           | Calls save(stream, options, cancellationToken) on this Scene instance.                                                         |
| `render(camera: Camera, fileName: String)`                                                              | Not implemented in the FOSS edition — throws at runtime.  Calls render(camera, fileName) on this Scene instance.               |
| `render(camera: Camera, fileName: String, size: Vector2, format: String)`                               | Not implemented in the FOSS edition — throws at runtime.  Calls render(camera, fileName, size, format) on this Scene instance. |
| `render(camera: Camera, texture: TextureData)`                                                          | Not implemented in the FOSS edition — throws at runtime.  Calls render(camera, texture) on this Scene instance.                |
| `SceneObject()`                                                                                         | Boolean operator allows you to apply Boolean operation on two IMeshConvertible instances.                                      |
| `getScene()`  →  `Scene`                                                                                | Constructor of BooleanOperator.                                                                                                |
| `A3DObject()`                                                                                           | Parameterized Cylinder. It can also be used to represent a cone when one of radiusTop/radiusBottom is zero.                    |
| `getName()`  →  `String`                                                                                | The segments of the curve.                                                                                                     |
| `setName(name: String)`                                                                                 | Constructs a CircleShape profile with specified radius.                                                                        |
| `getProperties()`  →  `PropertyCollection`                                                              | Initializes a new instance of Cylinder class.                                                                                  |
| `findProperty(name: String)`  →  `Property`                                                             | Initializes a new instance of the Bone class.                                                                                  |
| `getProperty(name: String)`  →  `Object`                                                                | Gets the transform matrix of the node in current pose.                                                                         |
| `setProperty(name: String, value: Object)`                                                              | Gets the width segments.                                                                                                       |
| `removeProperty(name: String)`  →  `boolean`                                                            | Gets flip coordinate system of control points/normal during importing/exporting.                                               |




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

Thuộc tính

Tất cả các thuộc tính được truy cập thông qua các phương thức getter/setter.

Thuộc tính

Thuộc tính

Tạo một cảnh, thêm một nút mesh, và lưu dưới dạng 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);

Xem thêm

 Tiếng Việt