pub struct Object3D {Show 32 fields
pub id: u32,
pub name: String,
pub object_type: &'static str,
pub parent: Option<WeakObjectRef>,
pub children: Vec<ObjectRef>,
pub visible: bool,
pub layers: Layers,
pub render_order: f64,
pub frustum_culled: bool,
pub matrix_auto_update: bool,
pub matrix_world_auto_update: bool,
pub matrix_world_needs_update: bool,
pub matrix_alias: Option<WeakObjectRef>,
pub is_camera: bool,
pub is_light: bool,
pub cast_shadow: bool,
pub receive_shadow: bool,
pub occlusion_test: bool,
pub is_group: bool,
pub is_scene: bool,
pub position: Vector3,
pub rotation: Euler,
pub quaternion: Quaternion,
pub scale: Vector3,
pub up: Vector3,
pub matrix: Matrix4,
pub matrix_world: Matrix4,
pub user_data: Map<String, Value>,
pub payload: Payload,
pub listeners: SceneEventListeners,
pub on_before_render: Option<ObjectRenderHook>,
pub on_after_render: Option<ObjectRenderHook>,
}Expand description
three.js’ Object3D: the transform and the drawable state every scene node
carries. The parent/children tree lives on ObjectRef, the handle that wraps
this in an Rc<RefCell<..>> — see docs/scene-graph.md.
Debug is written out by hand because the render hooks are closures: it
prints whether each is set.
Fields§
§id: u32Object3D.id — a per-thread counter, three.js’ _object3DId ++.
name: StringObject3D.name.
object_type: &'static strObject3D.type. 'Object3D' unless a subclass overrides it (Group
sets 'Group').
parent: Option<WeakObjectRef>Object3D.parent, weak: see docs/scene-graph.md.
children: Vec<ObjectRef>Object3D.children.
visible: boolObject3D.visible.
layers: LayersObject3D.layers — tested against the camera’s in _projectObject.
render_order: f64Object3D.renderOrder. On a Group it becomes the groupOrder of
everything below it; on a drawable it is the second render-list sort key.
frustum_culled: boolObject3D.frustumCulled.
matrix_auto_update: boolObject3D.matrixAutoUpdate (Object3D.DEFAULT_MATRIX_AUTO_UPDATE).
matrix_world_auto_update: boolObject3D.matrixWorldAutoUpdate (DEFAULT_MATRIX_WORLD_AUTO_UPDATE).
matrix_world_needs_update: boolObject3D.matrixWorldNeedsUpdate.
matrix_alias: Option<WeakObjectRef>this.matrix = other.matrixWorld — CameraHelper’s sharing of its
camera’s world matrix object. JS aliases the two; the port copies the
other node’s matrix_world into matrix at the moment
updateMatrixWorld() reads matrix, which is when the alias would be
observed. None for everything else, and for a clone (copy() copies
the matrix’s values, not the object).
is_camera: boolObject3D.isCamera — lookAt() points a camera the other way round.
is_light: boolObject3D.isLight — as is_camera.
cast_shadow: boolObject3D.castShadow — whether the shadow pass draws this object.
receive_shadow: boolObject3D.receiveShadow — whether the object’s material samples the
shadow maps, which makes it a different program from the same material
on a non-receiving object.
occlusion_test: boolobject.occlusionTest — not a declared Object3D property in three
but an ad-hoc one the renderer reads (RenderList.push(),
WebGPUBackend.draw()): when true the object’s draws are wrapped in
an occlusion query, and renderer.isOccluded( object ) answers from its
result. Being ad hoc, Object3D.copy() does not carry it, so neither
does Clone.
is_group: boolObject3D.isGroup.
is_scene: boolObject3D.isScene.
position: Vector3Object3D.position.
rotation: EulerKept in sync with quaternion by Object3D::set_rotation, the same way
three.js’ Euler/Quaternion onChange callbacks keep them in sync.
quaternion: QuaternionObject3D.quaternion.
scale: Vector3Object3D.scale.
up: Vector3Object3D.up.
matrix: Matrix4Object3D.matrix, composed from position/quaternion/scale by
update_matrix.
matrix_world: Matrix4Object3D.matrixWorld.
user_data: Map<String, Value>Object3D.userData — the application’s own data on the object, an
open JSON object as in three.js. The node system reads it through
user_data, once per draw, as
UserDataNode does.
payload: PayloadWhat three.js would get from subclassing: the Mesh/InstancedMesh
state that makes this node drawable. See Payload.
listeners: SceneEventListenersobject._listeners — the SceneEvent
listeners, added and dispatched through
ObjectRef::add_event_listener and its siblings.
on_before_render: Option<ObjectRenderHook>object.onBeforeRender( renderer, scene, camera, geometry, material, group ) — called by the renderer once per draw of this object in a
scene render, after the scene’s matrices are updated and before
anything of the pass is drawn. None is three’s empty default. See
ObjectRenderHook for the arguments and docs/api.md decision 12
for where the port calls it.
on_after_render: Option<ObjectRenderHook>object.onAfterRender( renderer, scene, camera, geometry, material, group ) — called once per draw of this object after the scene’s pass
(and its output pass, if any) has been recorded.
Implementations§
Source§impl Object3D
impl Object3D
Sourcepub fn set_on_before_render(
&mut self,
hook: impl FnMut(&ObjectRef, &Renderer, &Scene, &dyn RenderCamera, Option<&Group>) + 'static,
)
pub fn set_on_before_render( &mut self, hook: impl FnMut(&ObjectRef, &Renderer, &Scene, &dyn RenderCamera, Option<&Group>) + 'static, )
object.onBeforeRender = function ( renderer, scene, camera, geometry, material, group ) { ... } — sets
on_before_render. Assigning the field
works too; this spares spelling out the closure’s argument types.
Sourcepub fn set_on_after_render(
&mut self,
hook: impl FnMut(&ObjectRef, &Renderer, &Scene, &dyn RenderCamera, Option<&Group>) + 'static,
)
pub fn set_on_after_render( &mut self, hook: impl FnMut(&ObjectRef, &Renderer, &Scene, &dyn RenderCamera, Option<&Group>) + 'static, )
object.onAfterRender = function ( ... ) { ... } — sets
on_after_render, as
set_on_before_render does.
Sourcepub fn is_mesh(&self) -> bool
pub fn is_mesh(&self) -> bool
object.isMesh — see Payload::is_mesh.
Sourcepub fn is_skinned_mesh(&self) -> bool
pub fn is_skinned_mesh(&self) -> bool
object.isSkinnedMesh.
Sourcepub fn skinned_mesh(&self) -> Option<&SkinnedMesh>
pub fn skinned_mesh(&self) -> Option<&SkinnedMesh>
The SkinnedMesh this object is, if it is one.
Sourcepub fn skinned_mesh_mut(&mut self) -> Option<&mut SkinnedMesh>
pub fn skinned_mesh_mut(&mut self) -> Option<&mut SkinnedMesh>
object.isSkinnedMesh’s SkinnedMesh state, mutably.
Sourcepub fn is_instanced_mesh(&self) -> bool
pub fn is_instanced_mesh(&self) -> bool
object.isInstancedMesh.
Sourcepub fn is_line(&self) -> bool
pub fn is_line(&self) -> bool
object.isLine — see Payload::is_line.
Sourcepub fn is_points(&self) -> bool
pub fn is_points(&self) -> bool
object.isPoints — see Payload::is_points.
Sourcepub fn is_line_segments(&self) -> bool
pub fn is_line_segments(&self) -> bool
object.isLineSegments.
Sourcepub fn line_mut(&mut self) -> Option<&mut Line>
pub fn line_mut(&mut self) -> Option<&mut Line>
Line.geometry / Line.material, mutably, when this node is a line.
Sourcepub fn geometry(&self) -> Option<&Rc<BufferGeometry>>
pub fn geometry(&self) -> Option<&Rc<BufferGeometry>>
object.geometry for a mesh or a line.
Sourcepub fn material(&self) -> Option<&MeshBasicNodeMaterial>
pub fn material(&self) -> Option<&MeshBasicNodeMaterial>
object.material for a mesh or a line.
Sourcepub fn mesh_mut(&mut self) -> Option<&mut Mesh>
pub fn mesh_mut(&mut self) -> Option<&mut Mesh>
Mesh.geometry / Mesh.material, mutably, when this node is a mesh.
Sourcepub fn light(&self) -> Option<&LightObject>
pub fn light(&self) -> Option<&LightObject>
The light state when is_light is true — Light.color,
Light.intensity, PointLight.distance, PointLight.decay.
Sourcepub fn light_mut(&mut self) -> Option<&mut LightObject>
pub fn light_mut(&mut self) -> Option<&mut LightObject>
The light state, mutably; see light.
Sourcepub fn instance_matrix(&self) -> Option<&InstancedBufferAttribute>
pub fn instance_matrix(&self) -> Option<&InstancedBufferAttribute>
InstancedMesh.instanceMatrix.
Sourcepub fn instance_color(&self) -> Option<&InstancedBufferAttribute>
pub fn instance_color(&self) -> Option<&InstancedBufferAttribute>
InstancedMesh.instanceColor, None until setColorAt() is called.
Sourcepub fn set_matrix_at(&mut self, index: usize, matrix: &Matrix4)
pub fn set_matrix_at(&mut self, index: usize, matrix: &Matrix4)
InstancedMesh.setMatrixAt( index, matrix ), reached through the payload.
Panics if this node is not an InstancedMesh, the way the JS would throw.
Sourcepub fn set_color_at(&mut self, index: usize, color: &Color)
pub fn set_color_at(&mut self, index: usize, color: &Color)
InstancedMesh.setColorAt( index, color ), reached through the payload.
Panics if this node is not an InstancedMesh, the way the JS would throw.
Sourcepub fn set_rotation(&mut self, x: f64, y: f64, z: f64)
pub fn set_rotation(&mut self, x: f64, y: f64, z: f64)
object.rotation.set( x, y, z ) — the Euler onChange callback then
refreshes the quaternion, which is what updateMatrix() composes from.
Sourcepub fn apply_matrix4(&mut self, m: &Matrix4)
pub fn apply_matrix4(&mut self, m: &Matrix4)
Object3D.applyMatrix4().
Sourcepub fn apply_quaternion(&mut self, q: &Quaternion)
pub fn apply_quaternion(&mut self, q: &Quaternion)
Object3D.applyQuaternion().
Sourcepub fn set_rotation_from_axis_angle(&mut self, axis: &Vector3, angle: f64)
pub fn set_rotation_from_axis_angle(&mut self, axis: &Vector3, angle: f64)
Object3D.setRotationFromAxisAngle().
Sourcepub fn set_rotation_from_euler(&mut self, euler: &Euler)
pub fn set_rotation_from_euler(&mut self, euler: &Euler)
Object3D.setRotationFromEuler().
Sourcepub fn set_rotation_from_matrix(&mut self, m: &Matrix4)
pub fn set_rotation_from_matrix(&mut self, m: &Matrix4)
Object3D.setRotationFromMatrix() — the upper 3x3 of m must be a pure
rotation (unscaled).
Sourcepub fn set_rotation_from_quaternion(&mut self, q: &Quaternion)
pub fn set_rotation_from_quaternion(&mut self, q: &Quaternion)
Object3D.setRotationFromQuaternion() — q is assumed normalized.
Sourcepub fn rotate_on_axis(&mut self, axis: &Vector3, angle: f64)
pub fn rotate_on_axis(&mut self, axis: &Vector3, angle: f64)
Object3D.rotateOnAxis() — rotates about an axis in object space.
Sourcepub fn rotate_on_world_axis(&mut self, axis: &Vector3, angle: f64)
pub fn rotate_on_world_axis(&mut self, axis: &Vector3, angle: f64)
Object3D.rotateOnWorldAxis() — rotates about an axis in world space.
Assumes the object has no rotated parent.
Sourcepub fn translate_on_axis(&mut self, axis: &Vector3, distance: f64)
pub fn translate_on_axis(&mut self, axis: &Vector3, distance: f64)
Object3D.translateOnAxis() — translates along an axis in object space.
Sourcepub fn translate_x(&mut self, distance: f64)
pub fn translate_x(&mut self, distance: f64)
Object3D.translateX().
Sourcepub fn translate_y(&mut self, distance: f64)
pub fn translate_y(&mut self, distance: f64)
Object3D.translateY().
Sourcepub fn translate_z(&mut self, distance: f64)
pub fn translate_z(&mut self, distance: f64)
Object3D.translateZ().
Sourcepub fn local_to_world(&mut self, vector: &mut Vector3)
pub fn local_to_world(&mut self, vector: &mut Vector3)
Object3D.localToWorld().
Sourcepub fn world_to_local(&mut self, vector: &mut Vector3)
pub fn world_to_local(&mut self, vector: &mut Vector3)
Object3D.worldToLocal().
Sourcepub fn look_at(&mut self, target: &Vector3)
pub fn look_at(&mut self, target: &Vector3)
Object3D.lookAt() for a plain object: the object’s +Z is pointed away
from target (a camera or light points at it instead — see
PerspectiveCamera::look_at).
Sourcepub fn get_world_position(&mut self) -> Vector3
pub fn get_world_position(&mut self) -> Vector3
Object3D.getWorldPosition().
Sourcepub fn get_world_quaternion(&mut self) -> Quaternion
pub fn get_world_quaternion(&mut self) -> Quaternion
Object3D.getWorldQuaternion().
Sourcepub fn get_world_scale(&mut self) -> Vector3
pub fn get_world_scale(&mut self) -> Vector3
Object3D.getWorldScale().
Sourcepub fn get_world_direction(&mut self) -> Vector3
pub fn get_world_direction(&mut self) -> Vector3
Object3D.getWorldDirection() — the object’s +Z axis in world space.
Sourcepub fn update_matrix(&mut self)
pub fn update_matrix(&mut self)
Object3D.updateMatrix().
Sourcepub fn update_matrix_world(&mut self, parent_matrix_world: Option<&Matrix4>)
pub fn update_matrix_world(&mut self, parent_matrix_world: Option<&Matrix4>)
Object3D.updateMatrixWorld() for an object whose parent’s world matrix
is parent_matrix_world (None for a root).
Trait Implementations§
Source§impl Clone for Object3D
Object3D.copy( source, recursive = false ), minus the tree: a clone gets a
fresh id and no parent or children, because a Clone that shared the
Rcs would give two objects the same child list. Nor does it get the
listeners or the render hooks: copy() does not copy _listeners, and a
boxed closure cannot be cloned.
impl Clone for Object3D
Object3D.copy( source, recursive = false ), minus the tree: a clone gets a
fresh id and no parent or children, because a Clone that shared the
Rcs would give two objects the same child list. Nor does it get the
listeners or the render hooks: copy() does not copy _listeners, and a
boxed closure cannot be cloned.