소스 검색

DragControls: Add `recursive` property. (#26747)

* add recursive property to DragControls

* Update DragControls.js

Clean up.

---------

Co-authored-by: Michael Herzog <[email protected]>
Sachin S 1 년 전
부모
커밋
15e4656ca9
2개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 0
      docs/examples/en/controls/DragControls.html
  2. 3 2
      examples/jsm/controls/DragControls.js

+ 5 - 0
docs/examples/en/controls/DragControls.html

@@ -100,6 +100,11 @@
 			Whether or not the controls are enabled.
 		</p>
 
+		<h3>[property:Boolean recursive]</h3>
+		<p>
+			Whether children of draggable objects can be dragged independently from their parent. Default is `true`.
+		</p>
+
 		<h3>[property:Boolean transformGroup]</h3>
 		<p>
 			This option only works if the [page:DragControls.objects] array contains a single draggable group object.

+ 3 - 2
examples/jsm/controls/DragControls.js

@@ -99,7 +99,7 @@ class DragControls extends EventDispatcher {
 				_intersections.length = 0;
 
 				_raycaster.setFromCamera( _pointer, _camera );
-				_raycaster.intersectObjects( _objects, true, _intersections );
+				_raycaster.intersectObjects( _objects, scope.recursive, _intersections );
 
 				if ( _intersections.length > 0 ) {
 
@@ -151,7 +151,7 @@ class DragControls extends EventDispatcher {
 			_intersections.length = 0;
 
 			_raycaster.setFromCamera( _pointer, _camera );
-			_raycaster.intersectObjects( _objects, true, _intersections );
+			_raycaster.intersectObjects( _objects, scope.recursive, _intersections );
 
 			if ( _intersections.length > 0 ) {
 
@@ -205,6 +205,7 @@ class DragControls extends EventDispatcher {
 		// API
 
 		this.enabled = true;
+		this.recursive = true;
 		this.transformGroup = false;
 
 		this.activate = activate;