Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1bb5937
Add BatchedTilesPlugin
gkjohnson Oct 10, 2024
5255743
Add start to expanding batched mesh
gkjohnson Oct 10, 2024
a1fc5fc
Split out ExpandingBatchedMesh
gkjohnson Oct 10, 2024
9e1cb7a
Clean up
gkjohnson Oct 10, 2024
92ad3b8
small fixes
gkjohnson Oct 10, 2024
eab6bcc
Progress on getting things working
gkjohnson Oct 10, 2024
fded441
Check revision
gkjohnson Oct 10, 2024
797bfcc
Texture fixes
gkjohnson Oct 10, 2024
8a7e0dd
Small fixes
gkjohnson Oct 10, 2024
fcafc43
Some fixes to geometry expansion
gkjohnson Oct 10, 2024
d81b2f3
remove extra count
gkjohnson Oct 11, 2024
88dad5f
Fix rendering
gkjohnson Oct 11, 2024
a28d095
Fix instance deletion
gkjohnson Oct 11, 2024
4ac26cc
Remove frustum culling
gkjohnson Oct 11, 2024
44cfdd8
Get everything working
gkjohnson Oct 11, 2024
c33b658
Fix score
gkjohnson Oct 11, 2024
2c18e0d
Update raycasting logic
gkjohnson Oct 11, 2024
edcc005
Add raycasting support
gkjohnson Oct 11, 2024
efde47d
Update material support
gkjohnson Oct 11, 2024
b3b647e
Add docs
gkjohnson Oct 11, 2024
b4d4a9b
updates
gkjohnson Oct 11, 2024
232d1e8
Fix disposal
gkjohnson Oct 11, 2024
612df8b
Handle all already loaded models
gkjohnson Oct 11, 2024
86adb9f
Add comments
gkjohnson Oct 11, 2024
ca31d9f
more comments
gkjohnson Oct 11, 2024
9c634c2
fix disposal
gkjohnson Oct 11, 2024
6dc7812
some fixes
gkjohnson Oct 11, 2024
ed22dd5
Remove unused fields
gkjohnson Oct 11, 2024
f853086
Add model view batched mesh
gkjohnson Oct 11, 2024
e9fc014
Adjust the model view batched mesh to use camera offset
gkjohnson Oct 12, 2024
a60b171
Temporarily remove mipmaps
gkjohnson Oct 12, 2024
302bb01
Handle cases where tiles have multiple geometries
gkjohnson Oct 12, 2024
db0a89e
Remove override
gkjohnson Oct 12, 2024
3b4bdb0
fix use of free ids
gkjohnson Oct 12, 2024
4a4b302
Limit the amount of instances to the size of a 3d texture
gkjohnson Oct 12, 2024
6f8ce37
Add stand in options
gkjohnson Oct 12, 2024
4ee5101
Adjust instance count check
gkjohnson Oct 12, 2024
9813045
Support multiple geometries per tile
gkjohnson Oct 12, 2024
add90b6
Handle incongruent attributes, texturs
gkjohnson Oct 12, 2024
e1cae9a
Update plugin
gkjohnson Oct 12, 2024
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
39 changes: 39 additions & 0 deletions PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,45 @@ transformLatLonHeightToOrigin( lat, lon, height = 0 ) : void

Transforms the centers the tile set such that the given coordinates and height are positioned at the origin with "X" facing west and "Z" facing north.

## 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]
> All tile geometry rendered with BatchedMesh will use the same material and only a single material "map" is supported. Only tiles geometry containing a single mesh are supported. Not compatible with other plugins that modify mesh materials or rely on other bespoke mesh data (eg TilesFadePlugin, DebugTilesPlugin, GLTF Metadata extensions).

### .constructor


```js
constructor( options : Object )
```

Available options are as follows:

```js
{
// WebGLRenderer used for generating a WebGLArrayRenderTarget
renderer,

// The initial number of instances to use for rendering
instanceCount: 500,

// The minimum amount of vertex and index space to save per tile geometry added. If adequate tile space is already allocated
// when a new tile geometry is added then it can prevent more expensive geometry resizing and optimization.
vertexCount: 1000,
indexCount: 1000,

// The amount to increase the geometry and instance allocation when the operations must occur
expandPercent: 0.25,

// The material to use for the BatchedMesh. The material of the first tile rendered with be used if not set.
material: null,
}
```

# Controls

## EnvironmentControls
Expand Down
3 changes: 3 additions & 0 deletions example/fadingTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ function reinstantiateTiles() {
if ( groundTiles ) {

groundTiles.dispose();
groundTiles.group.removeFromParent();

skyTiles.dispose();
skyTiles.group.removeFromParent();

}

Expand Down
1 change: 0 additions & 1 deletion example/googleMapsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function reinstantiateTiles() {
tiles.registerPlugin( new UpdateOnChangePlugin() );
tiles.registerPlugin( new TilesFadePlugin() );
tiles.group.rotation.x = - Math.PI / 2;
tiles.errorTarget = 50;

// Note the DRACO compression files need to be supplied via an explicit source.
// We use unpkg here but in practice should be provided by the application.
Expand Down
51 changes: 51 additions & 0 deletions example/src/plugins/batched/ArrayTextureCopyMaterial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MeshBasicMaterial } from 'three';

// A MeshBasicMaterial that supports taking a TextureArray and a layer to render
export class ArrayTextureCopyMaterial extends MeshBasicMaterial {

set layer( v ) {

this._layerUniform.value = v;

}

get layer() {

return this._layerUniform.value;

}

constructor( ...args ) {

super( ...args );
this._layerUniform = { value: 0 };

}

onBeforeCompile( shader ) {

shader.uniforms.layer = this._layerUniform;

shader.fragmentShader = shader.fragmentShader
.replace(
'#include <map_pars_fragment>',
/* glsl */`
#ifdef USE_MAP
precision highp sampler2DArray;
uniform sampler2DArray map;
uniform int layer;
#endif
`,
)
.replace(
'#include <map_fragment>',
/* glsl */`
#ifdef USE_MAP
diffuseColor *= texture( map, vec3( vMapUv, layer ) );
#endif
`
);

}

}
Loading
Loading