Skip to main content

World3D

Struct World3D 

Source
pub struct World3D { /* private fields */ }
Expand description

Complete open-world 3D scene graph with mesh instancing library, chunk streaming, and BVH acceleration.

Implementations§

Source§

impl World3D

Open-world construction, model importing, BVH rebuild, and live vehicle/camera simulation for World3D.

Source

pub fn register_mesh(&mut self, chain: MeshLodChain) -> usize

Registers a MeshLodChain in the instancing library and returns its mesh_id.

§Arguments
  • &Self - Mutable world.
  • MeshLodChain - Multi-level LOD mesh chain.
§Returns
  • usize - Assigned mesh_id.
Source

pub fn spawn_object( &mut self, name: &str, mesh_id: usize, transform: Transform3D, material: PbrMaterial, ray_trace_caster: bool, ) -> usize

Spawns an instanced SceneObject3D referencing mesh_id into its spatial world chunk.

§Arguments
  • &Self - Mutable world.
  • &str - Object name.
  • usize - Registered mesh_id.
  • Transform3D - World transform.
  • PbrMaterial - Surface PBR material.
  • bool - Whether this object participates in BVH ray tracing.
§Returns
  • usize - Index of the spawned SceneObject3D.
Source

pub fn bump_world_revision(&mut self)

Increments the 3D world revision counter so 3D render caches invalidate independently of UI HUD updates.

§Arguments
  • &Self - Mutable world.
Source

pub fn set_object_dynamic(&mut self, obj_idx: usize, is_dynamic: bool) -> bool

Marks object obj_idx as static or dynamic, routing its triangles between the static BVH and incrementally refitted dynamic BVH.

§Arguments
  • &Self - Mutable world.
  • usize - Target object index in objects.
  • bool - true for dynamic BVH routing, false for static BVH routing.
§Returns
  • bool - true when obj_idx existed and was updated.
Source

pub fn teleport_object( &mut self, obj_idx: usize, transform: Transform3D, ) -> bool

Teleports object obj_idx to transform, incrementing teleport_epoch so snapshot interpolation snaps instead of sweeping.

§Arguments
  • &Self - Mutable world.
  • usize - Target object index in objects.
  • Transform3D - Destination world transform.
§Returns
  • bool - true when obj_idx existed and was teleported.
Source

pub fn import_model( &mut self, format: ModelFormat, source: &str, transform: Transform3D, fallback_material: PbrMaterial, spin_speed: f32, ) -> Result<ImportedModel3D, String>

Imports an external .obj or .gltf model directly into the live 3D world and returns import telemetry.

§Arguments
  • &Self - Mutable world.
  • ModelFormat - Source model format.
  • &str - Raw .obj or .gltf text content.
  • Transform3D - Placement transform in the 3D scene.
  • PbrMaterial - Fallback PBR material.
  • f32 - Optional continuous Y-spin speed in radians/sec.
§Returns
  • Result<ImportedModel3D, String> - Imported model summary or parse error.
Source

pub fn spawn_with(&mut self, desc: &SpawnObjectDesc) -> usize

Spawns an object from a fluent SpawnObjectDesc.

§Arguments
  • &Self - Mutable world.
  • &SpawnObjectDesc - Spawn descriptor.
§Returns
  • usize - Spawned object index.
Source

pub fn import_with( &mut self, desc: &ImportModelDesc, ) -> Result<ImportedModel3D, String>

Imports an external .obj or .gltf model using a fluent ImportModelDesc.

§Arguments
  • &Self - Mutable world.
  • &ImportModelDesc - Import descriptor.
§Returns
  • Result<ImportedModel3D, String> - Imported model telemetry or parse error.
Source

pub fn active_camera_mode(&self) -> CameraMode3D

Returns the typed CameraMode3D currently active in this world.

§Arguments
  • &Self - World reference.
§Returns
  • CameraMode3D - Active typed camera controller mode.
Source

pub fn set_camera_mode_enum(&mut self, mode: CameraMode3D)

Sets the active 3D camera controller using a typed CameraMode3D.

§Arguments
  • &Self - Mutable world.
  • CameraMode3D - Desired camera controller mode.
Source

pub fn ensure_bvh(&mut self)

Synchronizes the split static and dynamic BVH acceleration structures, refitting moving dynamic casters in O(N) without rebuilding static world geometry.

§Arguments
  • &Self - Mutable world.
Source

pub fn sync_dynamic_ray_instances(&mut self)

Lazily constructs local-space BVH4/BVH8 trees for dynamic meshes and updates dynamic_instances from current object transforms with zero BVH rebuilds.

§Arguments
  • &Self - Mutable world reference.
Source

pub fn trace_any_shadow_object_space( &self, ray: &Ray3D, t_min: f32, t_max: f32, ) -> bool

Traces a shadow ray using static BVH plus object-space inverse-interpolated dynamic instances.

§Arguments
  • &Self - World reference.
  • &Ray3D - World-space shadow ray.
  • f32 - Minimum hit distance.
  • f32 - Maximum hit distance.
§Returns
  • bool - true when occluded by static or dynamic geometry at its current/interpolated pose.
Source

pub fn trace_closest_packet4( &self, pkt: &RayPacket4, active_mask: u8, t_min: f32, t_max: f32, ) -> [Option<RayHit3D>; 4]

Traces a coherent 4-ray closest-hit packet against both the static BVH4 and object-space inverse-interpolated dynamic instances.

§Arguments
  • &Self - World reference.
  • &RayPacket4 - Coherent 4-ray query packet.
  • u8 - 4-bit mask of active rays (0..=15).
  • f32 - Minimum hit distance.
  • f32 - Maximum hit distance.
§Returns
  • [Option<RayHit3D>; 4] - Closest hit surface with world normal and material per active lane.
Source

pub fn trace_closest_object_space( &self, ray: &Ray3D, t_min: f32, t_max: f32, ) -> Option<RayHit3D>

Traces a closest-hit ray using static BVH plus object-space inverse-interpolated dynamic instances.

§Arguments
  • &Self - World reference.
  • &Ray3D - World-space query ray.
  • f32 - Minimum hit distance.
  • f32 - Maximum hit distance.
§Returns
  • Option<RayHit3D> - Closest hit surface with world-space normal and material.
Source

pub fn total_bvh_nodes(&self) -> usize

Returns the combined node count across both static and dynamic BVH acceleration trees.

§Arguments
  • &Self - World reference.
§Returns
  • usize - Total active BVH nodes.
Source

pub fn trace_any_shadow_split( bvhs: (&Bvh3D, &Bvh3D), ray: (Vec3, Vec3, Vec3), bounds: (f32, f32), caches: (&mut u32, &mut u32), ) -> bool

Traces a shadow/occlusion ray across both static and dynamic BVHs using 1-triangle occluder caches.

§Arguments
  • (&Bvh3D, &Bvh3D) - (static_bvh, dynamic_bvh) pair.
  • (Vec3, Vec3, Vec3) - (origin, dir, inv_dir) ray triple.
  • (f32, f32) - (t_min, t_max) distance bounds.
  • (&mut u32, &mut u32) - (static_cache, dynamic_cache) occluder triangle hints.
§Returns
  • bool - true if occluded by either static or dynamic geometry.
Source

pub fn trace_closest_split( bvhs: (&Bvh3D, &Bvh3D), ray: (Vec3, Vec3, Vec3), bounds: (f32, f32), ) -> Option<(f32, bool, usize)>

Traces a reflection/GI ray across both static and dynamic BVHs and returns (distance, is_dynamic, tri_index).

§Arguments
  • (&Bvh3D, &Bvh3D) - (static_bvh, dynamic_bvh) pair.
  • (Vec3, Vec3, Vec3) - (origin, dir, inv_dir) ray triple.
  • (f32, f32) - (t_min, t_max) distance bounds.
§Returns
  • Option<(f32, bool, usize)> - Closest (t, hit_in_dynamic_bvh, triangle_index).
Source

pub fn vehicle_index(&self) -> Option<usize>

Returns the optional player vehicle index.

§Arguments
  • &Self - World reference.
§Returns
  • Option<usize> - Vehicle index in objects.
Source

pub fn create_open_world_city() -> World3D

Builds a GTA-inspired open-world neon downtown city with reflective wet asphalt, glass towers, and a drivable sports car.

§Returns
  • Self - Populated open-world 3D city ready for real-time PBR + Ray Tracing.
Source

pub fn traffic_vehicle_count(&self) -> usize

Returns the number of autonomous cruising traffic vehicles registered in this world.

§Returns
  • usize - Active cruising traffic vehicle count.
Source

pub fn apply_atmosphere_preset(&mut self, preset: u8) -> f32

Applies an atmospheric mood preset (0=Sunset, 1=RainyNight, 2=Noon, 3=Midnight), updating sun lighting and ambient Niagara rain streaks.

§Arguments
  • u8 - Atmosphere preset index (0..=3).
§Returns
  • f32 - Corresponding time-of-day hour in [0.0, 24.0].
Source

pub fn add_point_light(&mut self, light: PointLight3D) -> usize

Registers a dynamic PointLight3D into this world for UE5 Clustered Deferred Lighting and returns its index.

§Arguments
  • PointLight3D - World-space point light descriptor.
§Returns
  • usize - Assigned point light index.
Source

pub fn add_spot_light(&mut self, light: SpotLight3D) -> usize

Registers a dynamic SpotLight3D into this world for UE5 Clustered Deferred Lighting and returns its index.

§Arguments
  • SpotLight3D - World-space spotlight descriptor.
§Returns
  • usize - Assigned spotlight index.
Source

pub fn clear_local_lights(&mut self)

Clears all dynamic local point and spot lights from this world.

Source

pub fn emit_particles_3d( &mut self, config: &NiagaraEmitterConfig3D, count: usize, ) -> usize

Emits count 3D particles into the world’s NiagaraSystem3D with zero heap allocations.

§Arguments
  • &NiagaraEmitterConfig3D - Emitter properties.
  • usize - Number of particles to emit.
§Returns
  • usize - Active particle count after emission.
Source

pub fn create_dense_open_world_city(blocks_radius: i32) -> World3D

Builds a dense UE5-scale multi-block cyberpunk metropolis with hundreds of occluding towers, local neon lights, and dynamic vehicles for scalability and occlusion benchmarking.

§Arguments
  • i32 - City block half-radius (1..=5, producing (2r+1)x(2r+1) multi-tower blocks).
§Returns
  • Self - Populated dense 3D open-world metropolis with built static/dynamic BVHs.
Source

pub fn cycle_camera_mode(&mut self) -> u8

Cycles the active 3D camera perspective (Chase -> Hood -> Orbit -> Aerial) safely without clipping.

§Arguments
  • &Self - Mutable world.
§Returns
  • u8 - New active camera mode index.
Source

pub fn ground_play_bounds(&self) -> Option<(f32, f32, f32, f32)>

Computes horizontal playable world bounds from non-solid ground meshes when present, preventing hardcoded invisible walls.

§Arguments
  • &Self - World reference.
§Returns
  • Option<(f32, f32, f32, f32)> - (min_x, max_x, min_z, max_z) horizontal ground limits.
Source

pub fn mesh_oriented_box_collision( &self, candidate: OrientedBox3D, ignore_idx: Option<usize>, ) -> Option<MeshCollisionHit3D>

Tests a world-space OrientedBox3D against every solid (ray_trace_caster == true) model’s real mesh triangles (excluding ignore_idx), returning the deepest penetration hit.

§Arguments
  • &Self - World reference.
  • OrientedBox3D - Candidate oriented bounding box in world space.
  • Option<usize> - Optional scene object index to exclude (self).
§Returns
  • Option<MeshCollisionHit3D> - Deepest real-mesh triangle collision contact, or None when clear.
Source

pub fn raycast_solid_meshes( &self, origin: Vec3, direction: Vec3, max_dist: f32, ignore_idx: Option<usize>, ) -> Option<RayHit3D>

Casts a world-space ray against every solid (ray_trace_caster == true) model’s real mesh triangles (excluding ignore_idx) up to max_dist.

§Arguments
  • &Self - World reference.
  • Vec3 - Ray origin in world space.
  • Vec3 - Unit ray direction in world space.
  • f32 - Maximum ray distance.
  • Option<usize> - Optional scene object index to exclude.
§Returns
  • Option<RayHit3D> - Closest real-mesh triangle intersection within (1e-4, max_dist].
Source

pub fn step_simulation( &mut self, dt: f32, input: &InputState, actions: &ActionMap, )

Advances drivable vehicle/camera controls with continuous real-mesh oriented bounding box-vs-triangle collision, wall sliding, raycast camera boom, and synchronized spinning bounds.

§Arguments
  • &Self - Mutable world.
  • f32 - Delta time in seconds.
  • &InputState - Real-time polled keyboard/pointer input.
  • &ActionMap - Action bindings for WASD/Arrows movement.
Source§

impl World3D

Source

pub fn get_mesh_library(&self) -> &Vec<MeshLodChain>

Source

pub fn get_mut_mesh_library(&mut self) -> &mut Vec<MeshLodChain>

Source

pub fn set_mesh_library(&mut self, val: Vec<MeshLodChain>) -> &mut World3D

Source

pub fn get_objects(&self) -> &Vec<SceneObject3D>

Source

pub fn get_mut_objects(&mut self) -> &mut Vec<SceneObject3D>

Source

pub fn set_objects(&mut self, val: Vec<SceneObject3D>) -> &mut World3D

Source

pub fn get_camera(&self) -> Camera3D

Source

pub fn get_mut_camera(&mut self) -> &mut Camera3D

Source

pub fn set_camera(&mut self, val: Camera3D) -> &mut World3D

Source

pub fn get_sun(&self) -> DirectionalLight3D

Source

pub fn get_mut_sun(&mut self) -> &mut DirectionalLight3D

Source

pub fn set_sun(&mut self, val: DirectionalLight3D) -> &mut World3D

Source

pub fn get_bvh(&self) -> &Bvh3D

Source

pub fn get_mut_bvh(&mut self) -> &mut Bvh3D

Source

pub fn set_bvh(&mut self, val: Bvh3D) -> &mut World3D

Source

pub fn get_dynamic_bvh(&self) -> &Bvh3D

Source

pub fn get_mut_dynamic_bvh(&mut self) -> &mut Bvh3D

Source

pub fn set_dynamic_bvh(&mut self, val: Bvh3D) -> &mut World3D

Source

pub fn get_bvh_dirty(&self) -> bool

Source

pub fn get_mut_bvh_dirty(&mut self) -> &mut bool

Source

pub fn set_bvh_dirty(&mut self, val: bool) -> &mut World3D

Source

pub fn get_dynamic_bvh_dirty(&self) -> bool

Source

pub fn get_mut_dynamic_bvh_dirty(&mut self) -> &mut bool

Source

pub fn set_dynamic_bvh_dirty(&mut self, val: bool) -> &mut World3D

Source

pub fn get_dynamic_topology_dirty(&self) -> bool

Source

pub fn get_mut_dynamic_topology_dirty(&mut self) -> &mut bool

Source

pub fn set_dynamic_topology_dirty(&mut self, val: bool) -> &mut World3D

Source

pub fn get_static_bvh_rebuilds(&self) -> u64

Source

pub fn get_mut_static_bvh_rebuilds(&mut self) -> &mut u64

Source

pub fn set_static_bvh_rebuilds(&mut self, val: u64) -> &mut World3D

Source

pub fn get_dynamic_bvh_refits(&self) -> u64

Source

pub fn get_mut_dynamic_bvh_refits(&mut self) -> &mut u64

Source

pub fn set_dynamic_bvh_refits(&mut self, val: u64) -> &mut World3D

Source

pub fn get_dynamic_bvh_rebuilds(&self) -> u64

Source

pub fn get_mut_dynamic_bvh_rebuilds(&mut self) -> &mut u64

Source

pub fn set_dynamic_bvh_rebuilds(&mut self, val: u64) -> &mut World3D

Source

pub fn get_world_revision(&self) -> u64

Source

pub fn get_mut_world_revision(&mut self) -> &mut u64

Source

pub fn set_world_revision(&mut self, val: u64) -> &mut World3D

Source

pub fn get_chunk_size(&self) -> f32

Source

pub fn get_mut_chunk_size(&mut self) -> &mut f32

Source

pub fn set_chunk_size(&mut self, val: f32) -> &mut World3D

Source

pub fn get_mut_player_vehicle_index(&mut self) -> &mut Option<usize>

Source

pub fn set_player_vehicle_index(&mut self, val: Option<usize>) -> &mut World3D

Source

pub fn get_imported_model_count(&self) -> usize

Source

pub fn get_mut_imported_model_count(&mut self) -> &mut usize

Source

pub fn set_imported_model_count(&mut self, val: usize) -> &mut World3D

Source

pub fn get_camera_mode(&self) -> u8

Source

pub fn get_mut_camera_mode(&mut self) -> &mut u8

Source

pub fn set_camera_mode(&mut self, val: u8) -> &mut World3D

Source

pub fn get_camera_orbit_rad(&self) -> f32

Source

pub fn get_mut_camera_orbit_rad(&mut self) -> &mut f32

Source

pub fn set_camera_orbit_rad(&mut self, val: f32) -> &mut World3D

Source

pub fn get_point_lights(&self) -> &Vec<PointLight3D>

Source

pub fn get_mut_point_lights(&mut self) -> &mut Vec<PointLight3D>

Source

pub fn set_point_lights(&mut self, val: Vec<PointLight3D>) -> &mut World3D

Source

pub fn get_spot_lights(&self) -> &Vec<SpotLight3D>

Source

pub fn get_mut_spot_lights(&mut self) -> &mut Vec<SpotLight3D>

Source

pub fn set_spot_lights(&mut self, val: Vec<SpotLight3D>) -> &mut World3D

Source

pub fn get_niagara(&self) -> &NiagaraSystem3D

Source

pub fn get_mut_niagara(&mut self) -> &mut NiagaraSystem3D

Source

pub fn set_niagara(&mut self, val: NiagaraSystem3D) -> &mut World3D

Source

pub fn get_atmosphere_preset(&self) -> u8

Source

pub fn get_mut_atmosphere_preset(&mut self) -> &mut u8

Source

pub fn set_atmosphere_preset(&mut self, val: u8) -> &mut World3D

Source

pub fn get_world_time_secs(&self) -> f32

Source

pub fn get_mut_world_time_secs(&mut self) -> &mut f32

Source

pub fn set_world_time_secs(&mut self, val: f32) -> &mut World3D

Trait Implementations§

Source§

impl Clone for World3D

Source§

fn clone(&self) -> World3D

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for World3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for World3D

Default empty 3D open world.

Source§

fn default() -> World3D

Creates an empty World3D with 64m chunk streaming enabled.

§Returns
  • Self - Empty World3D.

Auto Trait Implementations§

§

impl Forget for World3D

§

impl Freeze for World3D

§

impl Move for World3D

§

impl RefUnwindSafe for World3D

§

impl Send for World3D
where RawVecInner: Send,

§

impl Sync for World3D
where RawVecInner: Sync,

§

impl Unpin for World3D
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for World3D

§

impl UnwindSafe for World3D
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.