Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchedMesh: cleanup, add maxGeometryCount member #691

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions types/three/src/objects/BatchedMesh.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ import { Camera } from '../cameras/Camera.js';
* usage of {@link BatchedMesh} will help you to reduce the number of draw calls and thus improve the overall rendering
* performance in your application.
*
* Requires platform support for the {@link https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_multi_draw WEBGL_multi_draw extension}.
* If the {@link https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_multi_draw WEBGL_multi_draw extension} is not
* supported then a less performant callback is used.
*
* Example: {@link https://threejs.org/examples/#webgl_mesh_batch WebGL / mesh / batch}
* @example
* const box = new THREE.BoxGeometry( 1, 1, 1 );
* const sphere = new THREE.BoxGeometry( 1, 1, 1 );
* const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
*
* // initialize and add geometries into the batched mesh
* const batchedMesh = new BatchedMesh( 10, 5000, 10000, material );
* const boxId = batchedMesh.addGeometry( box );
* const sphereId = batchedMesh.addGeometry( sphere );
*
* // position the geometries
* batchedMesh.setMatrixAt( boxId, boxMatrix );
* batchedMesh.setMatrixAt( sphereId, sphereMatrix );
*
* scene.add( batchedMesh );
*
* @also Example: {@link https://threejs.org/examples/#webgl_mesh_batch WebGL / mesh / batch}
*/
declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
/**
Expand Down Expand Up @@ -47,6 +64,11 @@ declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
*/
sortObjects: boolean;

/**
* The maximum number of individual geometries that can be stored in the {@link BatchedMesh}. Read only.
*/
get maxGeometryCount(): number;

/**
* Read-only flag to check if a given object is of type {@link BatchedMesh}.
*/
Expand Down Expand Up @@ -140,10 +162,6 @@ declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
*/
deleteGeometry(index: number): this;

getGeometryCount(): number;
getVertexCount(): number;
getIndexCount(): number;

getBoundingBoxAt(index: number, target: Box3): Box3;
getBoundingSphereAt(index: number, target: Sphere): Sphere;
}
Expand Down