SceneObject¶
Reference¶
- class SceneObject¶
- module:
- findByName(name)¶
Find an object by name and return it
- findByTag(tag)¶
Find a list of objects by their tag and return it
- create(objectType, options, parent)¶
Create a new object in the scenegraph. This is a generic function, for specialized versions, see below.
- Parameters:¶
objectType (
str
) – Type of object. Possible types are “Sphere”, “”.options (
table
) – The options to use. For information about the possible options, see the specialized functions below.parent (
Object
) – the parent object to add the new one to or nil to put it at root level
- Returns:¶
a promise resolving to a SceneObject
- Return type:¶
Promise
- fromHandle(handle)¶
Create a scene object by handle number. Used internally
- Parameters:¶
handle (
number
)
- getName()¶
Return the name of the scene object. The name is the user given name.
- getDisplayName()¶
Return the display name of the scene object. In case the object has no user given name, a name will be generated
in the format “type <id>”
- setFieldValue(name, value)¶
Set a field of the scene object to a new value
- Parameters:¶
name (
str
)value (
str
)
- setFieldColorValue(name, value)¶
Set a field of the scene object to a new color value
- setFieldNumberValue(name, value)¶
Set a field of the scene object to a new number value
- Parameters:¶
name (
str
)value (
number
)
- setFieldEnumValue(name, value)¶
Set a field of the scene object to a new enum value
- Parameters:¶
name (
str
)value (
number
)
- setFieldBooleanValue(name, value)¶
Set a field of the scene object to a new boolean value
- Parameters:¶
name (
str
)value (
boolean
)
- getFieldColorValue()¶
Get the value of a scene object’s field as color value
- getFieldNumberValue()¶
Get the value of a scene object’s field as number value
- getFieldEnumValue()¶
Get the value of a scene object’s field as string value
- getFieldEnumOptions()¶
Get the value of a scene object’s field as string value
- getFieldBooleanValue()¶
Get the value of a scene object’s field as boolean value
- getLinkItem(name)¶
Get a link of the scene object to a new value
- setLinkItem(name, item)¶
Set a link from the scene object
- Parameters:¶
name (
str
) – name of the link fielditem (
str
) – value can be either an item ID or an Item object
- setField(name, value)¶
Set a field of the scene bject to a new value
- Parameters:¶
name (
str
)value (
str
)
- getTransform()¶
Get local transform of a scene object
- getWorldTransform()¶
Get world transform of a scene object
- setTransform(transform)¶
Set local transform of a scene object
- getLinearVelocity()¶
Return the linear velocity of the object. This only works for objects added to the physics engine and
with watchLinearVelocity set to true, otherwise it will return a zero vector
- setLinearVelocity(velocity)¶
Set the linear velocity of the object. This only works for objects added to the physics engine.
- getAngularVelocity()¶
Return the angular velocity of the object. This only works for objects added to the physics engine and
with watchAngularVelocity set to true, otherwise it will return a zero vector
- setAngularVelocity(velocity)¶
Set the angular velocity of the object. This only works for objects added to the physics engine
- clone(x, y, z, parent)¶
Clone a scene object to a new position and return it
- Parameters:¶
x (
number
) – optional position transform parameter. Defaults to the cloned position xy (
number
) – optional position transform parameter. Defaults to the cloned position yz (
number
) – optional position transform parameter. Defaults to the cloned position zparent (
Object
) – the parent object to add the new one to or nil to clone it where it currently is
- Returns:¶
a promise resolving to a SceneObject
- Return type:¶
Promise
- delete()¶
Delete scene object
- getActive()¶
- getTags()¶
- takeSnapshot(recursive)¶
Take a snapshot of this object and its children if specified. Taking a snapshot will allow to reset it’s complete
state back to this moment at a later point. This will rollback any changes on the objects. This includes recreating deleted child objects or deleting newly created ones.
- rollbackSnapshot(snapshot)¶
Rollback a snapshot. Any changes made to this object will be rolled back. This includes recreating deleted child objects
or deleting newly created ones.
- Parameters:¶
snapshot (
any
)
- isEnabled()¶
Check if the object is enabled. Disabled objects are not drawn and their scripts are not executed
- enable()¶
Enable the object
- disable()¶
Disable the object
- getEntities()¶
Get the list of Entity objects attached to the scene object. One for each script
- getEntityByScriptName(name)¶
Get a reference to an Entity object attached to the scene object based on the script’s name. If multiple scripts of the same name
are attached to the scene object, the first one is returned
- getParent()¶