Skip to content

Commit c745aee

Browse files
committed
Editor: Cycle through overlapping objects on click.
1 parent b7c9099 commit c745aee

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

editor/js/Selector.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,39 @@ class Selector {
1818

1919
if ( intersects.length > 0 ) {
2020

21-
const object = intersects[ 0 ].object;
21+
// Resolve helpers to their actual objects
2222

23-
if ( object.userData.object !== undefined ) {
23+
const objects = [];
2424

25-
// helper
25+
for ( let i = 0; i < intersects.length; i ++ ) {
2626

27-
this.select( object.userData.object );
27+
let object = intersects[ i ].object;
28+
29+
if ( object.userData.object !== undefined ) {
30+
31+
object = object.userData.object;
32+
33+
}
34+
35+
if ( objects.indexOf( object ) === - 1 ) {
36+
37+
objects.push( object );
38+
39+
}
40+
41+
}
42+
43+
// Cycle through objects if the first one is already selected
44+
45+
let index = objects.indexOf( editor.selected );
46+
47+
if ( index !== - 1 && index < objects.length - 1 ) {
48+
49+
this.select( objects[ index + 1 ] );
2850

2951
} else {
3052

31-
this.select( object );
53+
this.select( objects[ 0 ] );
3254

3355
}
3456

0 commit comments

Comments
 (0)