awv3
Version:
⚡ AWV3 embedded CAD
41 lines (36 loc) • 1.53 kB
JavaScript
import * as THREE from 'three';
import MaterialStore from '../../../misc/materialstore';
import Object3 from '../../../three/object3';
import BaseHandler from './base';
export default class HoverHandler extends BaseHandler {
constructor(sketcher, name) {
super(sketcher, name);
this.sketcher.selector.activate(this.sketcher.namedElements.selection);
}
destroy() {
this.sketcher.selector.removeAll();
for (let obj of this.sketcher.graphics.values())
this.sketcher.selector.unhover(obj.localMesh || obj);
this.sketcher.selector.deactivate();
super.destroy();
}
[Object3.Events.Interaction.Hovered](object, hitObject) {
this.sketcher.constraintVisualizer.hover(object, hitObject.first);
if (!hitObject.first) return;
this.sketcher.selector.hover(hitObject);
if (object.isConstraint()) {
for (let entity of object.entities)
if (entity.graphics)
this.sketcher.selector.hover({ material: entity.graphics.localMesh.material });
}
}
[Object3.Events.Interaction.Unhovered](object, hitObject) {
this.sketcher.constraintVisualizer.unhover(object, hitObject.first);
this.sketcher.selector.unhover(hitObject);
if (object.isConstraint()) {
for (let entity of object.entities)
if (entity.graphics)
this.sketcher.selector.unhover({ material: entity.graphics.localMesh.material });
}
}
}