A3DObject, SceneObject, Entity — Aspose.3D TypeScript API Reference
Gói: @aspose/3d (v24.12.0)
Ba lớp này tạo thành nền tảng của @aspose/3d cây phân cấp lớp. Mỗi đối tượng công khai trong thư viện cuối cùng kế thừa A3DObject, cung cấp tên và hệ thống thuộc tính động. SceneObject thêm việc theo dõi thành viên trong cảnh. Entity là cơ sở cho tất cả các đối tượng có thể được gắn vào một Node như thực thể chính của nó (lưới, máy ảnh, đèn, v.v.).
import { A3DObject, SceneObject, Entity } from '@aspose/3d';A3DObject
Lớp cơ sở gốc cho tất cả @aspose/3d đối tượng. Thực hiện INamedObject.
export class A3DObject implements INamedObjectnew A3DObject(name?: string)name | string | đọc/ghi | Tên có thể đọc được bởi con người. Mặc định là ''. |
properties | PropertyCollection | đọc | Bộ sưu tập thuộc tính động. Duyệt với for...of hoặc truy vấn theo tên. |
findProperty(propertyName)
Trả về Property với tên đã cho, hoặc null nếu không có.
findProperty(propertyName: string): Property | nullgetProperty(property)
Trả về giá trị của thuộc tính có tên, hoặc null nếu thuộc tính không tồn tại.
getProperty(property: string): anysetProperty(property, value)
Đặt giá trị cho một thuộc tính có tên. Tạo thuộc tính nếu nó chưa tồn tại.
setProperty(property: string, value: any): voidremoveProperty(property)
Xóa một thuộc tính có tên hoặc một Property đối tượng khỏi bộ sưu tập.
removeProperty(property: string | Property): booleantoString()
"ClassName(name)".import { Scene } from '@aspose/3d';
const scene = new Scene();
const node = scene.rootNode.createChildNode('my_node');
node.setProperty('exportLayer', 2);
console.log(node.getProperty('exportLayer')); // 2
const prop = node.findProperty('name');
if (prop) {
console.log(prop.value); // my_node
console.log(prop.valueType); // string
}
for (const p of node.properties) {
console.log(`${p.name} = ${p.value}`);
}
node.removeProperty('exportLayer');
console.log(node.getProperty('exportLayer')); // null
SceneObject
A3DObject với một tham chiếu đến chủ sở hữu Scene.export class SceneObject extends A3DObjectA3DObject → SceneObject
Thuộc tính bổ sung
scene | `Scene | null` | đọc/ghi |
import { Scene } from '@aspose/3d';
const scene = new Scene();
const node = scene.rootNode.createChildNode('child');
console.log(node.scene === scene); // true
Lớp cơ sở trừu tượng cho tất cả các đối tượng có thể được gắn vào một Node như thực thể cảnh chính của nó. Các lớp con bao gồm Mesh, Camera, Light, và các loại hình học.
export class Entity extends SceneObjectA3DObject → SceneObject → Entity
parentNode | `Node | undefined` | đọc/ghi |
parentNodes | Node[] | đọc | Tất cả các nút cha tham chiếu đến thực thể này (bản sao chỉ đọc). Trong hầu hết các cảnh, một thực thể chỉ có đúng một nút cha. |
excluded | boolean | đọc/ghi | true, thực thể sẽ bị loại trừ khỏi việc render và xuất. Mặc định là false. |
getBoundingBox()
Trả về axis-aligned bounding box cho thực thể này. Ném ra trên lớp cơ sở; được triển khai bởi các lớp con cụ thể như Mesh.
getBoundingBox(): BoundingBoxgetEntityRendererKey()
Trả về một khóa renderer xác định đường render cho loại thực thể này. Ném ngoại lệ trong lớp cơ sở; được sử dụng nội bộ.
import { Scene, Mesh } from '@aspose/3d';
const scene = new Scene();
const mesh = new Mesh();
// Add control points and a polygon
// ...
const node = scene.rootNode.createChildNode('geo', mesh);
console.log(mesh.parentNode === node); // true
console.log(mesh.excluded); // false
// Exclude from next export
mesh.excluded = true;