Browse Source

Fix raycast point scale

Garrett Johnson 5 years ago
parent
commit
b8f0f8b939
1 changed files with 12 additions and 2 deletions
  1. 12 2
      example/index.js

+ 12 - 2
example/index.js

@@ -137,9 +137,9 @@ function init() {
 	rayIntersect = new Group();
 
 	const rayIntersectMat = new MeshBasicMaterial( { color: 0xe91e63 } );
-	const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 10 ), rayIntersectMat );
+	const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 6 ), rayIntersectMat );
 	rayMesh.rotation.x = Math.PI / 2;
-	rayMesh.position.z += 5;
+	rayMesh.position.z += 3;
 	rayIntersect.add( rayMesh );
 
 	const rayRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), rayIntersectMat );
@@ -278,6 +278,16 @@ function animate() {
 
 		}
 
+		if ( params.orthographic ) {
+
+			rayIntersect.scale.setScalar( closestHit.distance / 150 );
+
+		} else {
+
+			rayIntersect.scale.setScalar( closestHit.distance * camera.fov / 6000 );
+
+		}
+
 		rayIntersect.visible = true;
 
 	} else {