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.
impl World3D
Open-world construction, model importing, BVH rebuild, and live vehicle/camera simulation for World3D.
Sourcepub fn register_mesh(&mut self, chain: MeshLodChain) -> usize
pub fn register_mesh(&mut self, chain: MeshLodChain) -> usize
Sourcepub fn spawn_object(
&mut self,
name: &str,
mesh_id: usize,
transform: Transform3D,
material: PbrMaterial,
ray_trace_caster: bool,
) -> usize
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- Registeredmesh_id.Transform3D- World transform.PbrMaterial- Surface PBR material.bool- Whether this object participates in BVH ray tracing.
§Returns
usize- Index of the spawnedSceneObject3D.
Sourcepub fn bump_world_revision(&mut self)
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.
Sourcepub fn set_object_dynamic(&mut self, obj_idx: usize, is_dynamic: bool) -> bool
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 inobjects.bool-truefor dynamic BVH routing,falsefor static BVH routing.
§Returns
bool-truewhenobj_idxexisted and was updated.
Sourcepub fn teleport_object(
&mut self,
obj_idx: usize,
transform: Transform3D,
) -> bool
pub fn teleport_object( &mut self, obj_idx: usize, transform: Transform3D, ) -> bool
Sourcepub fn import_model(
&mut self,
format: ModelFormat,
source: &str,
transform: Transform3D,
fallback_material: PbrMaterial,
spin_speed: f32,
) -> Result<ImportedModel3D, String>
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.objor.gltftext 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.
Sourcepub fn spawn_with(&mut self, desc: &SpawnObjectDesc) -> usize
pub fn spawn_with(&mut self, desc: &SpawnObjectDesc) -> usize
Sourcepub fn import_with(
&mut self,
desc: &ImportModelDesc,
) -> Result<ImportedModel3D, String>
pub fn import_with( &mut self, desc: &ImportModelDesc, ) -> Result<ImportedModel3D, String>
Sourcepub fn active_camera_mode(&self) -> CameraMode3D
pub fn active_camera_mode(&self) -> CameraMode3D
Sourcepub fn set_camera_mode_enum(&mut self, mode: CameraMode3D)
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.
Sourcepub fn ensure_bvh(&mut self)
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.
Sourcepub fn sync_dynamic_ray_instances(&mut self)
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.
Sourcepub fn trace_any_shadow_object_space(
&self,
ray: &Ray3D,
t_min: f32,
t_max: f32,
) -> bool
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-truewhen occluded by static or dynamic geometry at its current/interpolated pose.
Sourcepub fn trace_closest_packet4(
&self,
pkt: &RayPacket4,
active_mask: u8,
t_min: f32,
t_max: f32,
) -> [Option<RayHit3D>; 4]
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.
Sourcepub fn trace_closest_object_space(
&self,
ray: &Ray3D,
t_min: f32,
t_max: f32,
) -> Option<RayHit3D>
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.
Sourcepub fn total_bvh_nodes(&self) -> usize
pub fn total_bvh_nodes(&self) -> usize
Sourcepub fn trace_any_shadow_split(
bvhs: (&Bvh3D, &Bvh3D),
ray: (Vec3, Vec3, Vec3),
bounds: (f32, f32),
caches: (&mut u32, &mut u32),
) -> bool
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-trueif occluded by either static or dynamic geometry.
Sourcepub fn trace_closest_split(
bvhs: (&Bvh3D, &Bvh3D),
ray: (Vec3, Vec3, Vec3),
bounds: (f32, f32),
) -> Option<(f32, bool, usize)>
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).
Sourcepub fn vehicle_index(&self) -> Option<usize>
pub fn vehicle_index(&self) -> Option<usize>
Sourcepub fn create_open_world_city() -> Self
pub fn create_open_world_city() -> Self
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.
Sourcepub fn traffic_vehicle_count(&self) -> usize
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.
Sourcepub fn apply_atmosphere_preset(&mut self, preset: u8) -> f32
pub fn apply_atmosphere_preset(&mut self, preset: u8) -> f32
Sourcepub fn add_point_light(&mut self, light: PointLight3D) -> usize
pub fn add_point_light(&mut self, light: PointLight3D) -> usize
Sourcepub fn add_spot_light(&mut self, light: SpotLight3D) -> usize
pub fn add_spot_light(&mut self, light: SpotLight3D) -> usize
Sourcepub fn clear_local_lights(&mut self)
pub fn clear_local_lights(&mut self)
Clears all dynamic local point and spot lights from this world.
Sourcepub fn emit_particles_3d(
&mut self,
config: &NiagaraEmitterConfig3D,
count: usize,
) -> usize
pub fn emit_particles_3d( &mut self, config: &NiagaraEmitterConfig3D, count: usize, ) -> usize
Sourcepub fn create_dense_open_world_city(blocks_radius: i32) -> Self
pub fn create_dense_open_world_city(blocks_radius: i32) -> Self
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.
Sourcepub fn cycle_camera_mode(&mut self) -> u8
pub fn cycle_camera_mode(&mut self) -> u8
Sourcepub fn mesh_oriented_box_collision(
&self,
candidate: OrientedBox3D,
ignore_idx: Option<usize>,
) -> Option<MeshCollisionHit3D>
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, orNonewhen clear.
Sourcepub fn raycast_solid_meshes(
&self,
origin: Vec3,
direction: Vec3,
max_dist: f32,
ignore_idx: Option<usize>,
) -> Option<RayHit3D>
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].
Sourcepub fn step_simulation(
&mut self,
dt: f32,
input: &InputState,
actions: &ActionMap,
)
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.