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 cycle_camera_mode(&mut self) -> u8
pub fn cycle_camera_mode(&mut self) -> u8
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, AABB collision resolution, and spinning models by dt seconds.
§Arguments
&Self- Mutable world.f32- Delta time in seconds.&InputState- Real-time polled keyboard/pointer input.&ActionMap- Action bindings for WASD/Arrows movement.