savoiardi/object

Scene graph objects, transforms, and model loading.

This module wraps Three.js objects with helpers for hierarchy management, transforms, traversal, and loading common 3D formats.

Types

Data returned from an FBX load operation.

pub type FBXData

Data returned from a GLTF load operation.

pub type GLTFData

A scene graph object.

pub type Object3D

Values

pub fn add_child(
  parent parent: Object3D,
  child child: Object3D,
) -> Object3D

Adds a child object to a parent.

pub fn attach_child(
  parent parent: Object3D,
  child child: Object3D,
) -> Object3D

Reparents a child while preserving world transform.

pub fn children(object: Object3D) -> List(Object3D)

Returns the direct children of an object.

pub fn clear(object: Object3D) -> Object3D

Removes all children from an object.

pub fn clone(object: Object3D, recursive: Bool) -> Object3D

Clones an object, optionally including its descendants.

pub fn copy(
  object: Object3D,
  source: Object3D,
  recursive: Bool,
) -> Object3D

Copies properties from a source object into a target object.

pub fn dispose(object: Object3D) -> Nil

Disposes an object and its owned resources.

pub fn get_all_by_property(
  object: Object3D,
  property_name: String,
  value: String,
) -> List(Object3D)

Finds all descendants with the given property value.

pub fn get_by_id(
  object: Object3D,
  id: Int,
) -> Result(Object3D, Nil)

Finds the first descendant with the given object id.

pub fn get_by_name(
  object: Object3D,
  name: String,
) -> Result(Object3D, Nil)

Finds the first descendant with the given name.

pub fn get_by_property(
  object: Object3D,
  property_name: String,
  value: String,
) -> Result(Object3D, Nil)

Finds the first descendant with the given property value.

pub fn get_fbx_scene(data: FBXData) -> Object3D

Extracts the root scene object from FBX data.

pub fn get_gltf_scene(data: GLTFData) -> Object3D

Extracts the root scene object from GLTF data.

pub fn get_material(object: Object3D) -> material.Material

Reads the material assigned to an object.

pub fn get_name(object: Object3D) -> String

Reads the name of an object.

pub fn get_parent(object: Object3D) -> Result(Object3D, Nil)

Returns the parent of an object when present.

pub fn get_position(object: Object3D) -> vec3.Vec3(Float)

Reads the local position of an object.

pub fn get_quaternion(object: Object3D) -> quaternion.Quaternion

Reads the local quaternion of an object.

pub fn get_rotation(object: Object3D) -> vec3.Vec3(Float)

Reads the local Euler rotation of an object.

pub fn get_scale(object: Object3D) -> vec3.Vec3(Float)

Reads the local scale of an object.

pub fn get_world_direction(object: Object3D) -> vec3.Vec3(Float)

Reads the forward world direction of an object.

pub fn get_world_position(object: Object3D) -> vec3.Vec3(Float)

Reads the world position of an object.

pub fn get_world_quaternion(
  object: Object3D,
) -> quaternion.Quaternion

Reads the world quaternion of an object.

pub fn get_world_scale(object: Object3D) -> vec3.Vec3(Float)

Reads the world scale of an object.

pub fn group() -> Object3D

Creates an empty group object.

pub fn id(object: Object3D) -> Int

Reads the numeric object identifier.

pub fn is_visible(object: Object3D) -> Bool

Returns whether an object is visible.

pub fn line_segments(
  geometry: geometry.Geometry,
  material: material.Material,
) -> Object3D

Creates a line segments object from geometry and material.

pub fn load_fbx(
  loader: loader.FBXLoader,
  url: String,
  on_result: fn(Result(FBXData, loader.LoadError)) -> Nil,
) -> Nil

Loads FBX data and reports the result through a callback.

pub fn load_fbx_async(
  loader: loader.FBXLoader,
  url: String,
) -> promise.Promise(Result(FBXData, loader.LoadError))

Loads FBX data asynchronously.

pub fn load_gltf(
  loader: loader.GLTFLoader,
  url: String,
  on_result: fn(Result(GLTFData, loader.LoadError)) -> Nil,
) -> Nil

Loads GLTF data and reports the result through a callback.

pub fn load_gltf_async(
  loader: loader.GLTFLoader,
  url: String,
) -> promise.Promise(Result(GLTFData, loader.LoadError))

Loads GLTF data asynchronously.

pub fn load_obj(
  loader: loader.OBJLoader,
  url: String,
  on_result: fn(Result(Object3D, loader.LoadError)) -> Nil,
) -> Nil

Loads an OBJ model and reports the result through a callback.

pub fn load_obj_async(
  loader: loader.OBJLoader,
  url: String,
) -> promise.Promise(Result(Object3D, loader.LoadError))

Loads an OBJ model asynchronously.

pub fn look_at(
  object: Object3D,
  target: vec3.Vec3(Float),
) -> Object3D

Rotates an object so it faces a target point.

pub fn mesh(
  geometry: geometry.Geometry,
  material: material.Material,
) -> Object3D

Creates a mesh from geometry and material.

pub fn remove_child(
  parent parent: Object3D,
  child child: Object3D,
) -> Object3D

Removes a child object from a parent.

pub fn remove_from_parent(object: Object3D) -> Object3D

Removes an object from its parent.

pub fn replace_model(
  old_object: Object3D,
  new_object: Object3D,
  name: String,
) -> Object3D

Replaces an existing object’s model while preserving the logical slot name.

pub fn rotate_x(object: Object3D, angle: Float) -> Object3D

Rotates an object around the x axis.

pub fn rotate_y(object: Object3D, angle: Float) -> Object3D

Rotates an object around the y axis.

pub fn rotate_z(object: Object3D, angle: Float) -> Object3D

Rotates an object around the z axis.

pub fn set_cast_shadow(
  object: Object3D,
  cast_shadow: Bool,
) -> Object3D

Enables or disables shadow casting for an object.

pub fn set_frustum_culled(
  object: Object3D,
  frustum_culled: Bool,
) -> Object3D

Enables or disables frustum culling for an object.

pub fn set_geometry(
  object: Object3D,
  geometry: geometry.Geometry,
) -> Object3D

Sets the geometry assigned to an object.

pub fn set_material(
  object: Object3D,
  material: material.Material,
) -> Object3D

Sets the material assigned to an object.

pub fn set_matrix_auto_update(
  object: Object3D,
  matrix_auto_update: Bool,
) -> Object3D

Enables or disables local matrix auto-updates.

pub fn set_matrix_world_auto_update(
  object: Object3D,
  matrix_world_auto_update: Bool,
) -> Object3D

Enables or disables world matrix auto-updates.

pub fn set_name(object: Object3D, name: String) -> Object3D

Sets the name of an object.

pub fn set_position(
  object: Object3D,
  position: vec3.Vec3(Float),
) -> Object3D

Sets the local position of an object.

pub fn set_quaternion(
  object: Object3D,
  quaternion: quaternion.Quaternion,
) -> Object3D

Sets the local quaternion of an object.

pub fn set_receive_shadow(
  object: Object3D,
  receive_shadow: Bool,
) -> Object3D

Enables or disables shadow receiving for an object.

pub fn set_render_order(
  object: Object3D,
  render_order: Int,
) -> Object3D

Sets the render order of an object.

pub fn set_rotation(
  object: Object3D,
  rotation: vec3.Vec3(Float),
) -> Object3D

Sets the local Euler rotation of an object.

pub fn set_scale(
  object: Object3D,
  scale: vec3.Vec3(Float),
) -> Object3D

Sets the local scale of an object.

pub fn set_visible(object: Object3D, visible: Bool) -> Object3D

Sets whether an object is visible.

pub fn translate_x(object: Object3D, distance: Float) -> Object3D

Translates an object along its local x axis.

pub fn translate_y(object: Object3D, distance: Float) -> Object3D

Translates an object along its local y axis.

pub fn translate_z(object: Object3D, distance: Float) -> Object3D

Translates an object along its local z axis.

pub fn traverse(
  object: Object3D,
  visit: fn(Object3D) -> Nil,
) -> Nil

Traverses an object and all of its descendants.

pub fn traverse_ancestors(
  object: Object3D,
  visit: fn(Object3D) -> Nil,
) -> Nil

Traverses the ancestors of an object.

pub fn traverse_visible(
  object: Object3D,
  visit: fn(Object3D) -> Nil,
) -> Nil

Traverses only visible objects in a hierarchy.

pub fn update_matrix(object: Object3D) -> Object3D

Recomputes the local transformation matrix.

pub fn update_matrix_world(
  object: Object3D,
  force: Bool,
) -> Object3D

Recomputes the world transformation matrix.

pub fn update_world_matrix(
  object: Object3D,
  update_parents: Bool,
  update_children: Bool,
) -> Object3D

Recomputes selected portions of the world matrix hierarchy.

pub fn uuid(object: Object3D) -> String

Reads the stable UUID of an object.

Search Document