Garrett Johnson 5 gadi atpakaļ
vecāks
revīzija
da0ed16c61
1 mainītis faili ar 7 papildinājumiem un 5 dzēšanām
  1. 7 5
      example/index.js

+ 7 - 5
example/index.js

@@ -114,23 +114,25 @@ function init() {
 
 	box = new Box3();
 
+	offsetParent = new Group();
+	scene.add( offsetParent );
+
+	// Raycasting init
 	raycaster = new Raycaster();
 	mouse = new Vector2();
 
 	rayIntersect = new Group();
 
-	const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 10 ), new MeshBasicMaterial( { color: 0xe91e63 } ) );
+	const rayIntersectMat = new MeshBasicMaterial( { color: 0xe91e63 } );
+	const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 10 ), rayIntersectMat );
 	rayMesh.rotation.x = Math.PI / 2;
 	rayMesh.position.z += 5;
 	rayIntersect.add( rayMesh );
 
-	const rayRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), new MeshBasicMaterial( { color: 0xe91e63 } ) );
+	const rayRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), rayIntersectMat );
 	rayIntersect.add( rayRing );
 	scene.add( rayIntersect );
 
-	offsetParent = new Group();
-	scene.add( offsetParent );
-
 	reinstantiateTiles();
 
 	onWindowResize();