Skip to content

Commit

Permalink
fix(PaintWidget): blocked event w/o intersection
Browse files Browse the repository at this point in the history
Events were being aborted even when the manipulator returns no world
coordinates.
  • Loading branch information
floryst committed Jan 23, 2024
1 parent 8234507 commit 8a48a47
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions Sources/Widgets/Widgets3D/PaintWidget/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,39 @@ export default function widgetBehavior(publicAPI, model) {
publicAPI.handleEvent = (callData) => {
const manipulator =
model.activeState?.getManipulator?.() ?? model.manipulator;
if (manipulator && model.activeState && model.activeState.getActive()) {
const normal = model._camera.getDirectionOfProjection();
const up = model._camera.getViewUp();
const right = [];
vec3.cross(right, up, normal);
model.activeState.setUp(...up);
model.activeState.setRight(...right);
model.activeState.setDirection(...normal);

const { worldCoords } = manipulator.handleEvent(
callData,
model._apiSpecificRenderWindow
);
if (!(manipulator && model.activeState && model.activeState.getActive())) {
return macro.VOID;
}

if (worldCoords.length) {
model.widgetState.setTrueOrigin(...worldCoords);
model.activeState.setOrigin(...worldCoords);

if (model.painting) {
const trailCircle = model.widgetState.addTrail();
trailCircle.set(
model.activeState.get(
'origin',
'up',
'right',
'direction',
'scale1'
)
);
}
}
const normal = model._camera.getDirectionOfProjection();
const up = model._camera.getViewUp();
const right = [];
vec3.cross(right, up, normal);
model.activeState.setUp(...up);
model.activeState.setRight(...right);
model.activeState.setDirection(...normal);

const { worldCoords } = manipulator.handleEvent(
callData,
model._apiSpecificRenderWindow
);

if (!worldCoords.length) {
return macro.VOID;
}

publicAPI.invokeInteractionEvent();
return macro.EVENT_ABORT;
model.widgetState.setTrueOrigin(...worldCoords);
model.activeState.setOrigin(...worldCoords);

if (model.painting) {
const trailCircle = model.widgetState.addTrail();
trailCircle.set(
model.activeState.get('origin', 'up', 'right', 'direction', 'scale1')
);
}
return macro.VOID;

publicAPI.invokeInteractionEvent();
return macro.EVENT_ABORT;
};

publicAPI.grabFocus = () => {
Expand Down

0 comments on commit 8a48a47

Please sign in to comment.