World
The world contains entities, in its most basic form an Entity is an invisible transform with children. An Entity with extra data can become a Model, Panel, Light, Camera or Environment.
getTime()
Get the time since the PlayScript started.
Return
float
getDeltaTime()
Get the time since the last frame was updated.
Return
float
isValid(entity)
Check if an entity is valid. An entity will become invalid if it gets destroyed but a variable still points to it.
Arguments
entity: Entity, a pointer to an entity in the world.
Return
bool
findByName(name)
Find an entity by name.
Arguments
name: string
Return
Entity , a pointer to an entity in the world, nil if the entity was not found.
findByUUID(uuid)
Find an entity by UUID.
Arguments
uuid: string
Return
Entity , a pointer to an entity in the world, nil if the entity was not found.
findById(id)
Find an entity by Id.
Arguments
id: int
Return
Entity , a pointer to an entity in the world, nil if the entity was not found.
findByTag(tag)
Find entities by tag.
Arguments
tag: string
Return
Table , a list of entities.
getUUID(entity)
Get the UUID of an entity. this is unique across all entities created in Unbound by using the system level UUID generators.
Arguments
entity: Entity, a pointer to an entity in the world.
Return
string
getType(entity)
Get the type of an entity. Available types are "Entity", "Model", "Camera", "Environment", "Light", "Panel", "Grid", "EditMarker".
Arguments
entity: Entity, a pointer to an entity in the world.
Return
string
findByType(type)
Find entities by type. Available types are "Entity", "Model", "Camera", "Environment", "Light", "Panel", "Grid", "EditMarker".
Arguments
type: string
Return
Table , a list of entities.
getScreenRay(screenPosition)
Get a 3D ray from a screen position.
Arguments
screenPosition: vec2, the screen position in pixels.
Return
ray , ray.origin and ray.direction.
findEntitiesInRectangle(camera, screenPoint1, screenPoint2, tag)
find entities enclosed in a screen space rectangle defined by two points
Arguments
camera: Entity, a pointer to a camera in the world.
screenPoint1: vec3
screenPoint2: vec3
tag: string
Return
table , entities found
findRaycastHit(rayOrigin, rayDirection, tag)
Faster way to find the closest intersection, comes at the cost of returning coarser results that will be imprecise with blocky distances.
Arguments
rayOrigin: vec3
rayDirection: vec3
tag:
Return
hit , hit.entity, hit.distance, hit.point.
getModelIntersection(model, rayOrigin, rayDirection, exclusion)
Shoot a ray and get a model's intersection against its edits.
Arguments
model: Entity, a pointer to a model in the world.
rayOrigin: vec3
rayDirection: vec3
exclusion: array
Return
hit , hit.success, hit.point, hit.normal.
getModelNormal(model, rayOrigin, rayDirection)
Shoot a ray and get a model's normal at the point of intersection.
Arguments
model: Entity, a pointer to a model in the world.
rayOrigin: vec3
rayDirection: vec3
Return
hit , hit.success, hit.point, hit.normal.
findClosestEditIndex(model, point)
Find the closest edit index in a model given a point in space.
Arguments
model: Entity, a pointer to a model in the world.
point: vec3
Return
edit index, number , The index of an edit inside a model.
findEditsInRectangle(model, camera, screenPoint1, screenPoint2)
Find edits enclosed in a screen space rectangle defined by two points
Arguments
model: Entity, a pointer to a model in the world.
camera: Entity, a pointer to a camera in the world.
screenPoint1:
screenPoint2:
Return
table , edits index list
getBounds(entity)
Get the bounds / dimensions of a model or entity in local space
Arguments
entity: Entity, a pointer to an entity in the world.
Return
aabb bounds
timerCallback(interval, cb)
creates a timer that calls a function every n seconds.
Arguments
interval: float
cb: callback
Return
a timer object that can be canceled with destroy