123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- class SelectionHelper {
- constructor( editor ) {
- const signals = editor.signals;
- this.editor = editor;
- this.config = editor.config;
- this.signals = signals;
- this.selected = null;
- // 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.selected === object ) return;
- let uuid = null;
- if ( object !== null ) {
- uuid = object.uuid;
- }
- this.selected = object;
- this.config.setKey( 'selected', uuid );
- this.signals.objectSelected.dispatch( object );
- }
- deselect() {
- this.select( null );
- }
- }
- export { SelectionHelper };
|