Skip to content

Instantly share code, notes, and snippets.

@tomlagier
Created October 23, 2015 21:36
Show Gist options
  • Save tomlagier/c951c601f516022240dd to your computer and use it in GitHub Desktop.
Save tomlagier/c951c601f516022240dd to your computer and use it in GitHub Desktop.
Basic snippet of code
this.currentlyRotating.addCubes(group);
let currentPosition,
pastPosition = ThreeHub.scene.mouse.raycaster.ray.intersectPlane(plane),
delta;
ThreeHub.$el.on('mousemove.cubeRotation', () => {
currentPosition = ThreeHub.scene.mouse.raycaster.ray.intersectPlane(plane);
delta = currentPosition[deltaAxis] - pastPosition[deltaAxis];
console.log({
delta,
deltaAxis,
rotationAxis,
plane
});
//PERFORM SOME TRANSLATION HERE DEPENDING ON THE PLANE, DELTA AXIS, AND ROTATION AXIS
this.currentlyRotating.rotation[rotationAxis] -= delta;
pastPosition.set(currentPosition.x, currentPosition.y, currentPosition.z);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment