Jelajahi Sumber

getBoundsTransform -> getOrientedBounds

Garrett Johnson 4 tahun lalu
induk
melakukan
ef604dba16
4 mengubah file dengan 19 tambahan dan 11 penghapusan
  1. 4 4
      README.md
  2. 2 2
      example/FlyOrbitControls.js
  3. 4 2
      example/ionExample.js
  4. 9 3
      src/three/TilesRenderer.js

+ 4 - 4
README.md

@@ -381,15 +381,15 @@ Both `group.matrixWorld` and all cameras world matrices are expected to be up to
 getBounds( box : Box3 ) : boolean
 ```
 
-Sets `box` to the root bounding box of the tile set in the [group](#group) frame. Returns `false` if the tile root was not loaded.
+Sets `box` to the axis aligned root bounding box of the tile set in the [group](#group) frame. Returns `false` if the tile root was not loaded.
 
-### .getBoundsTransform
+### .getOrientedBounds
 
 ```js
-getBoundsTransform(target: Matrix4) : boolean;
+getOrientedBounds( box : Box3, boxTransform : Matrix4) : boolean;
 ```
 
-Sets `target` from the transformation matrix of the [group](#group). Returns `false` if the tile root was not loaded.
+Sets `box` and `boxTransform` to the bounds and matrix that describe the oriented bounding box that encapsulates the root of the tile set. Returns `false` if the tile root was not loaded.
 
 ### .hasCamera
 

+ 2 - 2
example/FlyOrbitControls.js

@@ -165,7 +165,7 @@ export class FlyOrbitControls extends OrbitControls {
 
 			}
 
-			if ( forwardHeld || backHeld || leftHeld || rightHeld || upHeld || downHeld ) {
+			if ( forwardHeld || backHeld || leftHeld || rightHeld || upHeld || downHeld || fastHeld ) {
 
 				this.minDistance = 0.01;
 				this.maxDistance = 0.01;
@@ -236,7 +236,7 @@ export class FlyOrbitControls extends OrbitControls {
 
 			}
 
-			if ( ! ( forwardHeld || backHeld || leftHeld || rightHeld || upHeld || downHeld ) ) {
+			if ( ! ( forwardHeld || backHeld || leftHeld || rightHeld || upHeld || downHeld || fastHeld ) ) {
 
 				endFlight();
 

+ 4 - 2
example/ionExample.js

@@ -27,7 +27,8 @@ import {
 	TorusBufferGeometry,
 	OrthographicCamera,
 	sRGBEncoding,
-	Matrix4
+	Matrix4,
+	Box3,
 } from 'three';
 import { FlyOrbitControls } from './FlyOrbitControls.js';
 import { BufferGeometryUtils } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
@@ -185,8 +186,9 @@ function reinstantiateTiles() {
 
 				tiles.onLoadTileSet = () => {
 
+					const box = new Box3();
 					const matrix = new Matrix4();
-					tiles.getBoundsTransform( matrix );
+					tiles.getBoundsTransform( box, matrix );
 					const position = new Vector3().setFromMatrixPosition( matrix );
 					const distanceToEllipsoidCenter = position.length();
 

+ 9 - 3
src/three/TilesRenderer.js

@@ -114,7 +114,7 @@ export class TilesRenderer extends TilesRendererBase {
 
 	}
 
-	getBoundsTransform( target ) {
+	getOrientedBounds( box, matrix ) {
 
 		if ( ! this.root ) {
 
@@ -122,9 +122,15 @@ export class TilesRenderer extends TilesRendererBase {
 
 		}
 
-		if ( this.root.cached.boxTransform ) {
+		const cached = this.root.cached;
+		const boundingBox = cached.box;
+		const obbMat = cached.boxTransform;
+
+		if ( box ) {
+
+			box.copy( boundingBox );
+			matrix.copy( obbMat );
 
-			target.copy( this.root.cached.boxTransform );
 			return true;
 
 		} else {