Property — Aspose.3D FOSS for Java
Example
Property 表示附加到任何对象的单个具名、类型化的元数据字段 A3DObject (包括 Node, Mesh, AnimationClip,,等等)。属性可通过 PropertyCollection 由…返回的 obj.getProperties().。您可以读取、写入和枚举属性,以在场景元素旁存储用户定义的数据。.
Example: com.aspose.threed
import com.aspose.threed.Property;Example
Property 对象通常不会由应用程序代码直接构造。它们是通过调用 A3DObject.getProperty() 或通过 A3DObject.findProperty().
| Example | Example | Example |
|---|---|---|
name | String | 属性名称 |
value | Object | 初始值(可选) |
Example
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
name | String | getName() | – | 属性的只读名称 |
value | Object | getValue() | setValue(Object) | 当前值;可读写 |
valueType | Class<?> | getValueType() | – | Java Class 当前值的 |
Example
| Example | 返回类型 | Example |
|---|---|---|
getExtra(String name) | Object | 获取此属性上存储的具名额外元数据字段 |
setExtra(String name, Object value) | void | 设置具名额外元数据字段 |
getBindPoint(AnimationNode anim, boolean create) | BindPoint | 返回在给定情况下此属性的动画绑定点 AnimationNode; pass true 如果不存在则创建一个 |
getKeyframeSequence(AnimationNode anim, boolean create) | KeyframeSequence | 返回在给定的上下文中此属性的关键帧序列 AnimationNode |
Example
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"
}