Skip to content

Commit

Permalink
Move BatchedTilesPlugin to core plugins (#899)
Browse files Browse the repository at this point in the history
* Rearrange functions

* clean up

* More cleanup

* rearrangement

* batch tiles plugin rename

* Updates

* comment

* Add display for batched mesh instances

* Fix frustum addition

* Small updates

* Move batched tiles plugin
  • Loading branch information
gkjohnson authored Dec 25, 2024
1 parent dae7c32 commit b4e47ed
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 8 deletions.
11 changes: 5 additions & 6 deletions example/googleMapsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TileCompressionPlugin,
UnloadTilesPlugin,
GLTFExtensionsPlugin,
BatchedTilesPlugin,
} from '3d-tiles-renderer/plugins';
import {
Scene,
Expand All @@ -24,7 +25,6 @@ import {
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import Stats from 'three/examples/jsm/libs/stats.module.js';
import { BatchedTilesPlugin } from './src/plugins/batched/BatchedTilesPlugin.js';

let controls, scene, renderer, tiles, transition;
let statsContainer, stats;
Expand Down Expand Up @@ -354,20 +354,19 @@ function updateHtml() {
if ( batchPlugin ) {

let tot = 0;
let totFade = 0;
batchPlugin.batchedMesh._instanceInfo.forEach( info => {
batchPlugin.batchedMesh?._instanceInfo.forEach( info => {

if ( info.visible && info.active ) tot ++;

} );

fadePlugin.batchedMesh._instanceInfo.forEach( info => {
fadePlugin.batchedMesh?._instanceInfo.forEach( info => {

if ( info.visible && info.active ) totFade ++;
if ( info.visible && info.active ) tot ++;

} );

str += ', Batched: ' + tot + ', Fade Batched: ' + totFade;
str += ', Batched: ' + tot;

}

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,6 @@ Available options are as follows:

## BatchedTilesPlugin

_available in the examples directory_

Plugin that uses three.js' BatchedMesh to limit the number of draw calls required and improve performance. The BatchedMesh geometry and instance size are automatically resized and optimized as new geometry is added and removed. The max number of instances to generate is limited by the max size of a 3d texture.

> [!WARNING]
Expand Down
1 change: 1 addition & 0 deletions src/plugins/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { GLTFExtensionsPlugin } from './three/GLTFExtensionsPlugin';
export { ReorientationPlugin } from './three/ReorientationPlugin';
export { UnloadTilesPlugin } from './three/UnloadTilesPlugin';
export { TilesFadePlugin } from './three/fade/TilesFadePlugin';
export { BatchedTilesPlugin } from './three/batched/BatchedTilesPlugin';
export * from './three/DebugTilesPlugin';

// common plugins
Expand Down
1 change: 1 addition & 0 deletions src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { GLTFExtensionsPlugin } from './three/GLTFExtensionsPlugin.js';
export { ReorientationPlugin } from './three/ReorientationPlugin.js';
export { UnloadTilesPlugin } from './three/UnloadTilesPlugin.js';
export { TilesFadePlugin } from './three/fade/TilesFadePlugin.js';
export { BatchedTilesPlugin } from './three/batched/BatchedTilesPlugin.js';
export * from './three/DebugTilesPlugin.js';

// common plugins
Expand Down
17 changes: 17 additions & 0 deletions src/plugins/three/batched/BatchedTilesPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Material, WebGLRenderer } from 'three';

export class BatchedTilesPlugin {

constructor( options : {
instanceCount: number,
vertexCount: number,
indexCount: number,
expandPercent: number,
maxInstanceCount: number,
discardOriginalContent: boolean,

material: Material | null,
renderer: WebGLRenderer | null,
} );

}
File renamed without changes.

0 comments on commit b4e47ed

Please sign in to comment.