diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-04-20 16:45:09 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-04-20 16:45:09 -0400 |
| commit | 6ce9d713a9ffdbf27155718ca8c9a3a4645389f2 (patch) | |
| tree | 75d982f2ff1dd09ce5f38b97d0e7344458c5db76 | |
| parent | 06fc629e2be66d79e94a02b169e12bc0918d0881 (diff) | |
alt to rotate a non-billboard scenery obj
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/sculpture/move.js | 11 | ||||
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/sculpture/types/_object.js | 8 |
2 files changed, 13 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/engine/sculpture/move.js b/public/assets/javascripts/rectangles/engine/sculpture/move.js index 4f6d176..e571c3b 100644 --- a/public/assets/javascripts/rectangles/engine/sculpture/move.js +++ b/public/assets/javascripts/rectangles/engine/sculpture/move.js @@ -2,7 +2,8 @@ Sculpture.move = function(base){ var x, y, z, position, dimension, bounds - var dragging = false, shiftPressed = false, moved = false + var rotationY + var dragging = false, altPressed = false, shiftPressed = false, moved = false var oldState var height, width @@ -40,12 +41,14 @@ Sculpture.move = function(base){ e.clickAccepted = false return } + altPressed = (e.altKey && ! base.billboard) shiftPressed = e.shiftKey dragging = true moved = false x = base.mx.x y = base.mx.y z = base.mx.z + rotationY = base.mx.rotationY height = base.mx.height * base.mx.scale bounds = base.bounds @@ -66,9 +69,13 @@ Sculpture.move = function(base){ // here we need to move the element based on the XY coords, as // base.mx.y = position.b + delta.b + dimension.b / 2 - if (e.shiftKey) { + if (shiftPressed) { base.mx.y = clamp( y + delta.b, height/2 + sculpture_distance_from_floor, Infinity ) } + else if (altPressed) { + base.mx.rotationY = mod( rotationY + delta.a / (window.innerWidth / 2) , TWO_PI ) + Sculpture.resize.move_dots() + } else { base.mx.x = x + delta.a * cos(cam.rotationY) - delta.b * sin(cam.rotationY) base.mx.z = z + delta.a * sin(cam.rotationY) + delta.b * cos(cam.rotationY) diff --git a/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js b/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js index 390c42e..a9c1669 100644 --- a/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js +++ b/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js @@ -54,13 +54,13 @@ Sculpture.types.base = Fiber.extend(function(base){ setBillboard: function(val){ this.billboard = val if (this.billboard) { - this.mx.el.classList.add("backface-visible") - this.mx.el.classList.remove("backface-hidden") + this.mx.el.classList.add("backface-hidden") + this.mx.el.classList.remove("backface-visible") this.mx.rotationY = cam.rotationY } else { - this.mx.el.classList.add("backface-hidden") - this.mx.el.classList.remove("backface-visible") + this.mx.el.classList.add("backface-visible") + this.mx.el.classList.remove("backface-hidden") this.mx.rotationY = PI/2 } }, |
