Quellcode durchsuchen

Raycaster: Set recursive default value to true (#22460)

* Set recursive default value to true

* Update for new recursive flag default
WestLangley vor 3 Jahren
Ursprung
Commit
147ded28ca
3 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
  1. 2 2
      docs/api/en/core/Raycaster.html
  2. 2 2
      src/core/Raycaster.js
  3. 6 6
      test/unit/src/core/Raycaster.tests.js

+ 2 - 2
docs/api/en/core/Raycaster.html

@@ -160,7 +160,7 @@
 		<h3>[method:Array intersectObject]( [param:Object3D object], [param:Boolean recursive], [param:Array optionalTarget] )</h3>
 		<h3>[method:Array intersectObject]( [param:Object3D object], [param:Boolean recursive], [param:Array optionalTarget] )</h3>
 		<p>
 		<p>
 		[page:Object3D object] — The object to check for intersection with the ray.<br />
 		[page:Object3D object] — The object to check for intersection with the ray.<br />
-		[page:Boolean recursive] — If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default is false.<br />
+		[page:Boolean recursive] — If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default is true.<br />
 		[page:Array optionalTarget] — (optional) target to set the result. Otherwise a new [page:Array] is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
 		[page:Array optionalTarget] — (optional) target to set the result. Otherwise a new [page:Array] is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
 		</p>
 		</p>
 		<p>
 		<p>
@@ -189,7 +189,7 @@
 		<h3>[method:Array intersectObjects]( [param:Array objects], [param:Boolean recursive], [param:Array optionalTarget] )</h3>
 		<h3>[method:Array intersectObjects]( [param:Array objects], [param:Boolean recursive], [param:Array optionalTarget] )</h3>
 		<p>
 		<p>
 		[page:Array objects] — The objects to check for intersection with the ray.<br />
 		[page:Array objects] — The objects to check for intersection with the ray.<br />
-		[page:Boolean recursive] — If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. Default is false.<br />
+		[page:Boolean recursive] — If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. Default is true.<br />
 		[page:Array optionalTarget] — (optional) target to set the result. Otherwise a new [page:Array] is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
 		[page:Array optionalTarget] — (optional) target to set the result. Otherwise a new [page:Array] is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
 		</p>
 		</p>
 		<p>
 		<p>

+ 2 - 2
src/core/Raycaster.js

@@ -53,7 +53,7 @@ class Raycaster {
 
 
 	}
 	}
 
 
-	intersectObject( object, recursive = false, intersects = [] ) {
+	intersectObject( object, recursive = true, intersects = [] ) {
 
 
 		intersectObject( object, this, intersects, recursive );
 		intersectObject( object, this, intersects, recursive );
 
 
@@ -63,7 +63,7 @@ class Raycaster {
 
 
 	}
 	}
 
 
-	intersectObjects( objects, recursive = false, intersects = [] ) {
+	intersectObjects( objects, recursive = true, intersects = [] ) {
 
 
 		for ( let i = 0, l = objects.length; i < l; i ++ ) {
 		for ( let i = 0, l = objects.length; i < l; i ++ ) {
 
 

+ 6 - 6
test/unit/src/core/Raycaster.tests.js

@@ -155,13 +155,13 @@ export default QUnit.module( 'Core', () => {
 			var raycaster = getRaycaster();
 			var raycaster = getRaycaster();
 			var objectsToCheck = getObjectsToCheck();
 			var objectsToCheck = getObjectsToCheck();
 
 
-			assert.ok( raycaster.intersectObject( objectsToCheck[ 0 ] ).length === 1,
+			assert.ok( raycaster.intersectObject( objectsToCheck[ 0 ], false ).length === 1,
 				"no recursive search should lead to one hit" );
 				"no recursive search should lead to one hit" );
 
 
-			assert.ok( raycaster.intersectObject( objectsToCheck[ 0 ], true ).length === 3,
+			assert.ok( raycaster.intersectObject( objectsToCheck[ 0 ] ).length === 3,
 				"recursive search should lead to three hits" );
 				"recursive search should lead to three hits" );
 
 
-			var intersections = raycaster.intersectObject( objectsToCheck[ 0 ], true );
+			var intersections = raycaster.intersectObject( objectsToCheck[ 0 ] );
 			for ( var i = 0; i < intersections.length - 1; i ++ ) {
 			for ( var i = 0; i < intersections.length - 1; i ++ ) {
 
 
 				assert.ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );
 				assert.ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );
@@ -175,13 +175,13 @@ export default QUnit.module( 'Core', () => {
 			var raycaster = getRaycaster();
 			var raycaster = getRaycaster();
 			var objectsToCheck = getObjectsToCheck();
 			var objectsToCheck = getObjectsToCheck();
 
 
-			assert.ok( raycaster.intersectObjects( objectsToCheck ).length === 1,
+			assert.ok( raycaster.intersectObjects( objectsToCheck, false ).length === 1,
 				"no recursive search should lead to one hit" );
 				"no recursive search should lead to one hit" );
 
 
-			assert.ok( raycaster.intersectObjects( objectsToCheck, true ).length === 3,
+			assert.ok( raycaster.intersectObjects( objectsToCheck ).length === 3,
 				"recursive search should lead to three hits" );
 				"recursive search should lead to three hits" );
 
 
-			var intersections = raycaster.intersectObjects( objectsToCheck, true );
+			var intersections = raycaster.intersectObjects( objectsToCheck );
 			for ( var i = 0; i < intersections.length - 1; i ++ ) {
 			for ( var i = 0; i < intersections.length - 1; i ++ ) {
 
 
 				assert.ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );
 				assert.ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );