Browse Source

raycast update

Garrett Johnson 5 years ago
parent
commit
a2bb68a17d
3 changed files with 26 additions and 16 deletions
  1. 12 8
      example/bundle/example.e31bb0bc.js
  2. 1 1
      example/bundle/example.e31bb0bc.js.map
  3. 13 7
      example/index.js

+ 12 - 8
example/bundle/example.e31bb0bc.js

@@ -1418,15 +1418,15 @@ class B3DMLoader {
 
     const featureTableStart = 28;
     const jsonFeatureTableData = new Uint8Array(buffer, featureTableStart, featureTableJSONByteLength);
-    const jsonFeatureTable = featureTableJSONByteLength === 0 ? {} : JSON.parse(arrayToString(jsonFeatureTableData));
-    const binFeatureTableData = new Uint8Array(buffer, featureTableStart + featureTableJSONByteLength, featureTableBinaryByteLength); // TODO: dereference the json feature table data in to the binary array.
+    const jsonFeatureTable = featureTableJSONByteLength === 0 ? {} : JSON.parse(arrayToString(jsonFeatureTableData)); // const binFeatureTableData = new Uint8Array( buffer, featureTableStart + featureTableJSONByteLength, featureTableBinaryByteLength );
+    // TODO: dereference the json feature table data in to the binary array.
     // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/FeatureTable/README.md#json-header
     // Batch Table
 
     const batchTableStart = featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength;
     const jsonBatchTableData = new Uint8Array(buffer, batchTableStart, batchTableJSONByteLength);
-    const jsonBatchTable = batchTableJSONByteLength === 0 ? {} : JSON.parse(arrayToString(jsonBatchTableData));
-    const binBatchTableData = new Uint8Array(buffer, batchTableStart + batchTableJSONByteLength, batchTableBinaryByteLength); // TODO: dereference the json batch table data in to the binary array.
+    const jsonBatchTable = batchTableJSONByteLength === 0 ? {} : JSON.parse(arrayToString(jsonBatchTableData)); // const binBatchTableData = new Uint8Array( buffer, batchTableStart + batchTableJSONByteLength, batchTableBinaryByteLength );
+    // TODO: dereference the json batch table data in to the binary array.
     // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/FeatureTable/README.md#json-header
 
     const glbStart = batchTableStart + batchTableJSONByteLength + batchTableBinaryByteLength;
@@ -38527,7 +38527,7 @@ class ThreeTilesRenderer extends _TilesRenderer.TilesRenderer {
 
       return minError;
     } else if ('sphere' in boundingVolume) {
-      const sphere = cached.sphere;
+      // const sphere = cached.sphere;
       console.warn('ThreeTilesRenderer : Sphere bounds not supported.');
     } else if ('region' in boundingVolume) {
       // unsupported
@@ -42626,9 +42626,13 @@ function animate() {
   if (results.length) {
     const closestHit = results[0];
     const point = closestHit.point;
-    const normal = closestHit.face.normal;
-    rayIntersect.position.copy(point);
-    rayIntersect.lookAt(point.x + normal.x, point.y + normal.y, point.z + normal.z);
+    rayIntersect.position.copy(point); // If the display bounds are visible they get intersected
+
+    if (closestHit.face) {
+      const normal = closestHit.face.normal;
+      rayIntersect.lookAt(point.x + normal.x, point.y + normal.y, point.z + normal.z);
+    }
+
     rayIntersect.visible = true;
   } else {
     rayIntersect.visible = false;

File diff suppressed because it is too large
+ 1 - 1
example/bundle/example.e31bb0bc.js.map


+ 13 - 7
example/index.js

@@ -227,14 +227,20 @@ function animate() {
 
 		const closestHit = results[ 0 ];
 		const point = closestHit.point;
-		const normal = closestHit.face.normal;
-
 		rayIntersect.position.copy( point );
-		rayIntersect.lookAt(
-			point.x + normal.x,
-			point.y + normal.y,
-			point.z + normal.z
-		);
+
+		// If the display bounds are visible they get intersected
+		if ( closestHit.face ) {
+
+			const normal = closestHit.face.normal;
+			rayIntersect.lookAt(
+				point.x + normal.x,
+				point.y + normal.y,
+				point.z + normal.z
+			);
+
+		}
+
 		rayIntersect.visible = true;
 
 	} else {