Просмотр исходного кода

Editor: Cycle through overlapping objects on click.

Mr.doob 1 месяц назад
Родитель
Сommit
c745aee7c0
1 измененных файлов с 27 добавлено и 5 удалено
  1. 27 5
      editor/js/Selector.js

+ 27 - 5
editor/js/Selector.js

@@ -18,17 +18,39 @@ class Selector {
 
 			if ( intersects.length > 0 ) {
 
-				const object = intersects[ 0 ].object;
+				// Resolve helpers to their actual objects
 
-				if ( object.userData.object !== undefined ) {
+				const objects = [];
 
-					// helper
+				for ( let i = 0; i < intersects.length; i ++ ) {
 
-					this.select( object.userData.object );
+					let object = intersects[ i ].object;
+
+					if ( object.userData.object !== undefined ) {
+
+						object = object.userData.object;
+
+					}
+
+					if ( objects.indexOf( object ) === - 1 ) {
+
+						objects.push( object );
+
+					}
+
+				}
+
+				// Cycle through objects if the first one is already selected
+
+				let index = objects.indexOf( editor.selected );
+
+				if ( index !== - 1 && index < objects.length - 1 ) {
+
+					this.select( objects[ index + 1 ] );
 
 				} else {
 
-					this.select( object );
+					this.select( objects[ 0 ] );
 
 				}
 

粤ICP备19079148号