summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/scenery/move.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery/move.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/move.js41
1 files changed, 21 insertions, 20 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js
index 991d1d4..93bccb0 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/move.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/move.js
@@ -63,7 +63,7 @@ Scenery.move = function(base){
var flipX = base.wall.side & (FRONT | RIGHT)
var delta = cursor.delta()
- delta.mul( cursor_amp ) // this should be proportional to your distance from the wall
+ delta.mul( cursor_amp ) // TODO: this should be proportional to your distance from the wall
if (flipX) { delta.a *= -1 }
delta.b *= -1
@@ -108,46 +108,47 @@ Scenery.move = function(base){
function switch_wall (e, target, cursor){
if (! dragging) return
if (target.wall.id == base.wall.id) return
- if (! target.wall.fits(base.media, base.scale)) return
-
+
var old_wall_side = base.wall.side
var wall_group = old_wall_side | target.wall.side
+ var new_bounds = target.wall.surface.bounds_at_index_with_dimensions(target.index || 0, dimension)
- base.set_wall(target)
+ if (! new_bounds) return
+
+ base.wall = target.wall
+ base.bounds = bounds = new_bounds
+
+ position.a = bounds.x.midpoint() - dimension.a / 2
- bounds = base.bounds
- x = base.center.a
- z = base.center.b
-
if (old_wall_side !== target.wall.side && wall_group !== FRONT_BACK && wall_group !== LEFT_RIGHT) {
switch (old_wall_side) {
case FRONT:
- z = bounds.x.a
+ position.a = bounds.x.a + dimension.a / 2
break
case BACK:
- z = bounds.x.b
+ position.a = bounds.x.b - dimension.a / 2
break
case LEFT:
- x = bounds.x.a
+ position.a = bounds.x.a + dimension.a / 2
break
case RIGHT:
- x = bounds.x.b
+ position.a = bounds.x.b - dimension.a / 2
break
}
}
- cursor.x.a = cursor.x.b
-
- base.mx.move({
- x: x,
- z: z,
- rotationY: wall_rotation[ target.wall.side ]
- })
+ var mx_delta = base.wall.positionToMx( position, dimension )
+ base.mx.move(mx_delta)
if (editor.permissions.resize) {
Scenery.resize.rotate_dots()
- Scenery.resize.move_dots()
+// Scenery.resize.move_dots()
}
+
+ cursor.x.a = cursor.x.b
+ //var delta = cursor.delta()
+ drag(e, cursor)
+
}
return this