Skip to content

Commit 85bef5d

Browse files
authored
Plugins: Add "TileFlatteningPlugin" (#1036)
* Add "setTileActive" plugin support * Add initial tile flattening plugin * Updates * Add dispose function * Add vertex iteration * comment * Add obb * Use circle bounding volume * fixes * Update docs * docs update * Clone the geometry * Use spheres rather than projected bounding spheres * Fix AABB construction * Update flattening plugin * One comment * lint fix * lint fix * Add force rerender * Fixes * Add d ts * Fixes
1 parent 7a237ec commit 85bef5d

5 files changed

Lines changed: 386 additions & 2 deletions

File tree

src/base/TilesRendererBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ export class TilesRendererBase {
444444

445445
if ( tile.__active ) {
446446

447-
this.setTileActive( tile, false );
447+
this.invokeOnePlugin( plugin => plugin.setTileActive && plugin.setTileActive( tile, false ) );
448448
tile.__active = false;
449449

450450
}

src/base/traverseFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export function toggleTiles( tile, renderer ) {
481481

482482
if ( tile.__wasSetActive !== setActive ) {
483483

484-
renderer.setTileActive( tile, setActive );
484+
renderer.invokeOnePlugin( plugin => plugin.setTileActive && plugin.setTileActive( tile, setActive ) );
485485

486486
}
487487

src/plugins/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,3 +723,47 @@ clearRegions(): void
723723
```
724724

725725
Remove all regions.
726+
727+
## TileFlatteningPlugin
728+
729+
A plugin that takes a shape as a mesh and direction along which to "flatten" vertices to the surface of the shape. Useful for shifting tile geometry to make room for new assets. Not compatible with other plugins that modify geometry such as `BatchedTilesPlugin`.
730+
731+
### hasShape
732+
733+
```js
734+
hasShape( shape: Object3D ): boolean
735+
```
736+
737+
Returns whether the given object has been passed in as a shape.
738+
739+
### addShape
740+
741+
```js
742+
addShape( shape: Object3D, direction: Vector3 ): void
743+
```
744+
745+
Adds the given object as a shape to flatten to in addition to the direction to flatten.
746+
747+
### updateShape
748+
749+
```js
750+
updateShape( shape: Object3D ): void
751+
```
752+
753+
Notifies the plugin that the given shape (geometry, position) has been changed and "tile flattening" needs to be regenerated.
754+
755+
### deleteShape
756+
757+
```js
758+
deleteShape( shape: Object3D ): void
759+
```
760+
761+
Deletes the given shape and regenerates the tile flattening.
762+
763+
### clearShapes
764+
765+
```js
766+
clearShapes(): void
767+
```
768+
769+
Deletes all shapes and resets the tiles.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Mesh } from 'three';
2+
3+
export class TileFatteningPlugin {
4+
5+
hasShape( mesh: Mesh ): boolean;
6+
addShape( mesh: Mesh, direction: Vector3 ): void;
7+
updateShape( mesh: Mesh ): void;
8+
deleteShape( mesh ): boolean;
9+
clearShapes(): void;
10+
11+
}

0 commit comments

Comments
 (0)