You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
853 B
67 lines
853 B
class Selector {
|
|
|
|
constructor( editor ) {
|
|
|
|
const signals = editor.signals;
|
|
|
|
this.editor = editor;
|
|
this.signals = signals;
|
|
|
|
// signals
|
|
|
|
signals.intersectionsDetected.add( ( intersects ) => {
|
|
|
|
if ( intersects.length > 0 ) {
|
|
|
|
const object = intersects[ 0 ].object;
|
|
|
|
if ( object.userData.object !== undefined ) {
|
|
|
|
// helper
|
|
|
|
this.select( object.userData.object );
|
|
|
|
} else {
|
|
|
|
this.select( object );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.select( null );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
select( object ) {
|
|
|
|
if ( this.editor.selected === object ) return;
|
|
|
|
let uuid = null;
|
|
|
|
if ( object !== null ) {
|
|
|
|
uuid = object.uuid;
|
|
|
|
}
|
|
|
|
this.editor.selected = object;
|
|
this.editor.config.setKey( 'selected', uuid );
|
|
|
|
this.signals.objectSelected.dispatch( object );
|
|
|
|
}
|
|
|
|
deselect() {
|
|
|
|
this.select( null );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export { Selector };
|
|
|