pub struct BatchedMesh {
pub mesh: Mesh,
pub per_object_frustum_culled: bool,
pub sort_objects: bool,
pub custom_sort: Option<CustomSort>,
/* private fields */
}Expand description
BatchedMesh extends Mesh.
Fields§
§mesh: MeshThe Mesh half: geometry, material and morph state.
per_object_frustum_culled: bool_perObjectFrustumCulled — whether each instance is culled by its own
bounding sphere.
sort_objects: bool_sortObjects — whether instances are depth-sorted before drawing.
custom_sort: Option<CustomSort>customSort, set by set_custom_sort.
Implementations§
Source§impl BatchedMesh
impl BatchedMesh
Sourcepub fn new(
max_instance_count: usize,
max_vertex_count: usize,
max_index_count: usize,
material: MeshBasicNodeMaterial,
) -> ObjectRef
pub fn new( max_instance_count: usize, max_vertex_count: usize, max_index_count: usize, material: MeshBasicNodeMaterial, ) -> ObjectRef
new BatchedMesh( maxInstanceCount, maxVertexCount, maxIndexCount, material ),
as a scene-graph ObjectRef.
Sourcepub fn max_instance_count(&self) -> usize
pub fn max_instance_count(&self) -> usize
maxInstanceCount.
Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
instanceCount — the number of active instances.
Sourcepub fn geometry(&self) -> &Rc<BufferGeometry>
pub fn geometry(&self) -> &Rc<BufferGeometry>
The packed geometry every instance draws a range of.
Sourcepub fn geometry_range_at(&self, geometry_id: usize) -> Option<&GeometryInfo>
pub fn geometry_range_at(&self, geometry_id: usize) -> Option<&GeometryInfo>
getGeometryRangeAt( geometryId ) — the packed range this geometry
owns inside the shared BufferGeometry.
Sourcepub fn set_custom_sort(&mut self, func: Option<CustomSort>) -> &mut Self
pub fn set_custom_sort(&mut self, func: Option<CustomSort>) -> &mut Self
setCustomSort( func ).
Sourcepub fn add_geometry(&mut self, geometry: &BufferGeometry) -> usize
pub fn add_geometry(&mut self, geometry: &BufferGeometry) -> usize
addGeometry( geometry ) with the default reserved counts.
Sourcepub fn set_geometry_at(
&mut self,
geometry_id: usize,
geometry: &BufferGeometry,
) -> usize
pub fn set_geometry_at( &mut self, geometry_id: usize, geometry: &BufferGeometry, ) -> usize
setGeometryAt( geometryId, geometry ).
Sourcepub fn add_instance(&mut self, geometry_id: usize) -> usize
pub fn add_instance(&mut self, geometry_id: usize) -> usize
addInstance( geometryId ).
Sourcepub fn set_matrix_at(
&mut self,
instance_id: usize,
matrix: &Matrix4,
) -> &mut Self
pub fn set_matrix_at( &mut self, instance_id: usize, matrix: &Matrix4, ) -> &mut Self
setMatrixAt( instanceId, matrix ).
Sourcepub fn set_color_at(&mut self, instance_id: usize, color: &Color) -> &mut Self
pub fn set_color_at(&mut self, instance_id: usize, color: &Color) -> &mut Self
setColorAt( instanceId, color ). Color.toArray() writes rgb only,
so the alpha stays at the texture’s initial 1.
Sourcepub fn bounding_box_at(&mut self, geometry_id: usize) -> Option<Box3>
pub fn bounding_box_at(&mut self, geometry_id: usize) -> Option<Box3>
getBoundingBoxAt( geometryId, target ) — computed from the packed
geometry’s own index range, so it costs nothing until the first cull.
Sourcepub fn bounding_sphere_at(&mut self, geometry_id: usize) -> Option<Sphere>
pub fn bounding_sphere_at(&mut self, geometry_id: usize) -> Option<Sphere>
getBoundingSphereAt( geometryId, target ).
Sourcepub fn raycast(
&mut self,
matrix_world: &Matrix4,
object: &ObjectRef,
raycaster: &Raycaster,
intersects: &mut Vec<Intersection>,
)
pub fn raycast( &mut self, matrix_world: &Matrix4, object: &ObjectRef, raycaster: &Raycaster, intersects: &mut Vec<Intersection>, )
BatchedMesh.raycast( raycaster, intersects ) — Mesh.raycast() once
per active, visible instance, over that instance’s geometry range with
its per-geometry bounds and matrixWorld × instanceMatrix, each hit
tagged with its batchId.
three.js points a scratch Mesh (no morph targets) at the batch
geometry’s attributes for this; the port passes the same pieces to the
shared mesh raycast directly.
Sourcepub fn on_before_render(&mut self, matrix_world: &Matrix4, camera: &BatchCamera)
pub fn on_before_render(&mut self, matrix_world: &Matrix4, camera: &BatchCamera)
onBeforeRender( renderer, scene, camera, geometry, material ).