Property — Aspose.3D FOSS for Java

Properties

Property đại diện cho một trường siêu dữ liệu có tên, có kiểu duy nhất được gắn vào bất kỳ A3DObject (bao gồm Node, Mesh, AnimationClip, v.v.). Các thuộc tính được truy cập thông qua PropertyCollection được trả về bởi obj.getProperties(). Bạn có thể đọc, ghi và liệt kê các thuộc tính để lưu trữ dữ liệu do người dùng định nghĩa cùng với các phần tử cảnh.

Properties: com.aspose.threed

import com.aspose.threed.Property;

Properties

Property các đối tượng thường không được tạo trực tiếp bởi mã ứng dụng. Chúng được tạo ra bằng cách gọi A3DObject.getProperty() hoặc được tìm thấy qua A3DObject.findProperty().

PropertiesPropertiesProperties
nameStringTên thuộc tính
valueObjectGiá trị khởi tạo (tùy chọn)

Properties

PropertiesPropertiesPropertiesPropertiesProperties
nameStringgetName()Tên thuộc tính chỉ đọc
valueObjectgetValue()setValue(Object)Giá trị hiện tại; có thể đọc và ghi
valueTypeClass<?>getValueType()Java Class của giá trị hiện tại

Properties

PropertiesKiểu trả vềProperties
getExtra(String name)ObjectLấy một trường siêu dữ liệu phụ có tên được lưu trên thuộc tính này
setExtra(String name, Object value)voidĐặt một trường siêu dữ liệu phụ có tên
getBindPoint(AnimationNode anim, boolean create)BindPointTrả về điểm ràng buộc hoạt hình cho thuộc tính này trong đối tượng đã cho AnimationNode; pass true để tạo một nếu chưa có
getKeyframeSequence(AnimationNode anim, boolean create)KeyframeSequenceTrả về chuỗi keyframe cho thuộc tính này trong đối tượng đã cho AnimationNode

Properties

import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.Property;
import com.aspose.threed.PropertyCollection;

Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("tagged_node");

// Access the property collection
PropertyCollection props = node.getProperties();

// Get a property by name (read raw value)
Object val = node.getProperty("name");
System.out.println(val);   // "tagged_node"

// Find a property object
Property prop = node.findProperty("name");
if (prop != null) {
    System.out.println(prop.getName());         // "name"
    System.out.println(prop.getValue());        // "tagged_node"
    System.out.println(prop.getValueType());    // class java.lang.String
}

// Enumerate all properties
for (Property p : props) {
    System.out.println("  " + p.getName() + " = " + p.getValue());
}

// Store a custom value on a property (extra metadata)
if (prop != null) {
    prop.setExtra("ui_label", "Scene Origin Node");
    Object label = prop.getExtra("ui_label");
    System.out.println(label);   // "Scene Origin Node"
}

Xem thêm

 Tiếng Việt