mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 18:02:50 +01:00
enter sketch mode on sketch object double click
This commit is contained in:
parent
17e4527329
commit
3bb0e51802
7 changed files with 50 additions and 7 deletions
|
|
@ -11,6 +11,7 @@ export function activate(ctx) {
|
|||
domElement.addEventListener('mousedown', mousedown, false);
|
||||
domElement.addEventListener('mouseup', mouseup, false);
|
||||
domElement.addEventListener('mousemove', mousemove, false);
|
||||
domElement.addEventListener('dblclick', dblclick, false);
|
||||
|
||||
|
||||
let performRaycast = e => {
|
||||
|
|
@ -149,8 +150,31 @@ export function activate(ctx) {
|
|||
valid.clear();
|
||||
}
|
||||
|
||||
function dblclick(e) {
|
||||
let hits = performRaycast(e);
|
||||
dispatchDblclick(e, hits);
|
||||
}
|
||||
|
||||
function dispatchDblclick(e, hits) {
|
||||
event.mouseEvent = e;
|
||||
event.hits = hits;
|
||||
for (let hit of hits) {
|
||||
if (LOG_FLAGS.PICK) {
|
||||
printRaycastDebugInfo('dblclick', hit);
|
||||
}
|
||||
let obj = hit.object;
|
||||
if (obj && obj.onDblclick) {
|
||||
obj.onDblclick(event);
|
||||
}
|
||||
if (!hit.object.passMouseEvent || !hit.object.passMouseEvent(event)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctx.services.modelMouseEventSystem = {
|
||||
dispatchMousedown, dispatchMouseup, dispatchMousemove
|
||||
dispatchMousedown, dispatchMouseup, dispatchMousemove, dispatchDblclick
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export function activate(context) {
|
|||
let TOL = 1;
|
||||
if (dx < TOL && dy < TOL) {
|
||||
if (e.button !== 0) {
|
||||
handleSolidPick(e);
|
||||
// handleSolidPick(e);
|
||||
} else {
|
||||
handlePick(e);
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ export function activate(context) {
|
|||
}
|
||||
|
||||
function mousedblclick(e) {
|
||||
handleSolidPick(e);
|
||||
// handleSolidPick(e);
|
||||
}
|
||||
|
||||
function clickaway() {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,14 @@ export class CurveBasedView extends View {
|
|||
this.rootGroup.add(this.marker);
|
||||
this.rootGroup.add(this.picker);
|
||||
this.picker.onMouseEnter = () => {
|
||||
this.ctx.highlightService.highlight(this.model.id);
|
||||
if (!this.isDisposed) {
|
||||
this.ctx.highlightService.highlight(this.model.id);
|
||||
}
|
||||
}
|
||||
this.picker.onMouseLeave = () => {
|
||||
this.ctx.highlightService.unHighlight(this.model.id);
|
||||
if (!this.isDisposed) {
|
||||
this.ctx.highlightService.unHighlight(this.model.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,12 +65,19 @@ export class SketchLoopView extends View {
|
|||
|
||||
this.rootGroup.add(this.mesh);
|
||||
this.mesh.onMouseEnter = () => {
|
||||
this.ctx.highlightService.highlight(this.model.id);
|
||||
if (!this.isDisposed) {
|
||||
this.ctx.highlightService.highlight(this.model.id);
|
||||
}
|
||||
}
|
||||
this.mesh.onMouseLeave = () => {
|
||||
this.ctx.highlightService.unHighlight(this.model.id);
|
||||
if (!this.isDisposed) {
|
||||
this.ctx.highlightService.unHighlight(this.model.id);
|
||||
}
|
||||
}
|
||||
this.mesh.raycastPriority = 10;
|
||||
this.mesh.onDblclick = () => {
|
||||
ctx.sketcherService.sketchFace(this.model.face);
|
||||
}
|
||||
}
|
||||
|
||||
updateVisuals() {
|
||||
|
|
|
|||
|
|
@ -6,5 +6,8 @@ export class SketchObjectView extends CurveBasedView {
|
|||
const color = mSketchObject.construction ? 0x777777 : 0x0000FF;
|
||||
const tess = mSketchObject.sketchPrimitive.tessellate(10).map(sketchToWorldTransformation.apply).map(v => v.data());
|
||||
super(ctx, mSketchObject, tess, 3, 4, color, 0x49FFA5, true);
|
||||
this.picker.onDblclick = () => {
|
||||
ctx.sketcherService.sketchFace(this.model.face);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,10 @@ export class View {
|
|||
this.model.ext.view = null;
|
||||
this.model = null;
|
||||
};
|
||||
|
||||
get isDisposed() {
|
||||
return this.model === null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ export function activate(ctx) {
|
|||
if (inPlaceEditor.inEditMode) {
|
||||
inPlaceEditor.exit();
|
||||
}
|
||||
ctx.pickControlService.deselectAll();
|
||||
inPlaceEditor.enter(face);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue