浏览代码

Merge pull request #233 from ligaofeng0901/master

Add tile visibility callback
Garrett Johnson 3 年之前
父节点
当前提交
8799560a0e
共有 3 个文件被更改,包括 16 次插入0 次删除
  1. 8 0
      README.md
  2. 1 0
      src/three/TilesRenderer.d.ts
  3. 7 0
      src/three/TilesRenderer.js

+ 8 - 0
README.md

@@ -478,6 +478,14 @@ onDisposeModel = null : ( scene : Object3D, tile : Tile ) => void
 
 
 Callback that is called every time a model is disposed of. This should be used in conjunction with [.onLoadModel](#onLoadModel) to dispose of any custom materials created for a tile. Note that the textures, materials, and geometries that a tile loaded in with are all automatically disposed of even if they have been removed from the tile meshes.
 Callback that is called every time a model is disposed of. This should be used in conjunction with [.onLoadModel](#onLoadModel) to dispose of any custom materials created for a tile. Note that the textures, materials, and geometries that a tile loaded in with are all automatically disposed of even if they have been removed from the tile meshes.
 
 
+### .onTileVisibilityChange
+
+```js
+onTileVisibilityChange = null : ( scene : Object3D, tile : Tile, visible : boolean ) => void
+```
+
+Callback that is called when a tile's visibility changed. The parameter `visible` is `true` when the tile is visible
+
 ### .dispose
 ### .dispose
 
 
 ```js
 ```js

+ 1 - 0
src/three/TilesRenderer.d.ts

@@ -30,6 +30,7 @@ export class TilesRenderer extends TilesRendererBase {
 	onLoadTileSet : ( ( tileSet : Tileset ) => void ) | null;
 	onLoadTileSet : ( ( tileSet : Tileset ) => void ) | null;
 	onLoadModel : ( ( scene : Object3D, tile : Tile ) => void ) | null;
 	onLoadModel : ( ( scene : Object3D, tile : Tile ) => void ) | null;
 	onDisposeModel : ( ( scene : Object3D, tile : Tile ) => void ) | null;
 	onDisposeModel : ( ( scene : Object3D, tile : Tile ) => void ) | null;
+	onTileVisibilityChange : ( ( scene : Object3D, tile : Tile, visible : boolean ) => void ) | null;
 
 
 
 
 }
 }

+ 7 - 0
src/three/TilesRenderer.js

@@ -74,6 +74,7 @@ export class TilesRenderer extends TilesRendererBase {
 		this.onLoadTileSet = null;
 		this.onLoadTileSet = null;
 		this.onLoadModel = null;
 		this.onLoadModel = null;
 		this.onDisposeModel = null;
 		this.onDisposeModel = null;
+		this.onTileVisibilityChange = null;
 
 
 		const manager = new LoadingManager();
 		const manager = new LoadingManager();
 		manager.setURLModifier( url => {
 		manager.setURLModifier( url => {
@@ -796,6 +797,12 @@ export class TilesRenderer extends TilesRendererBase {
 
 
 		}
 		}
 
 
+		if ( this.onTileVisibilityChange ) {
+
+			this.onTileVisibilityChange( scene, tile, visible );
+
+		}
+
 	}
 	}
 
 
 	setTileActive( tile, active ) {
 	setTileActive( tile, active ) {