diff options
| author | Julie Lala <jules@okfoc.us> | 2014-08-22 13:57:23 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-08-22 13:57:23 -0400 |
| commit | 335232556d74ec37774b504ad8c8af29c34788bb (patch) | |
| tree | bfbcc6541ad1d505fe013265d69016ccc618e2e9 | |
| parent | 41349226e763751311d3b0135086505a77f5472a (diff) | |
switch wall
3 files changed, 22 insertions, 26 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 diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/image.js b/public/assets/javascripts/rectangles/engine/scenery/types/image.js index cab6a94..2b50cbf 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/image.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/image.js @@ -12,13 +12,9 @@ Scenery.types.image = Scenery.types.base.extend(function(base){ this.bind() if (opt.data) { - // console.log(opt.wall) - // console.log(opt.data.position) if (opt.wall) { var position = opt.wall.mxToPosition(opt.data.position) - // console.log(position.a) opt.index = opt.wall.surface.index_for_x( position.a, 0 ) - // console.log(opt.index) } this.set_wall(opt) this.deserialize(opt.data) diff --git a/public/assets/javascripts/rectangles/models/surface.js b/public/assets/javascripts/rectangles/models/surface.js index 5b411c0..53977c8 100644 --- a/public/assets/javascripts/rectangles/models/surface.js +++ b/public/assets/javascripts/rectangles/models/surface.js @@ -25,6 +25,7 @@ this.bounds.y.b = rect.y.a } this.bounds.x.b += rect.width() + this.bounds.y.a = Math.min(this.bounds.y.a, rect.y.a) this.bounds.y.b = Math.max(this.bounds.y.b, rect.y.b) this.faces.push(rect) } @@ -90,7 +91,6 @@ if (right_edge > 0) { delta.a -= right_edge } - var bottom_edge = position.b + delta.b - bounds.y.a if (bottom_edge < 0) { delta.b -= bottom_edge @@ -105,7 +105,6 @@ } Surface.prototype.translate = function (old_bounds, dimension, position, delta) { - this.clamp_delta( this.bounds, dimension, position, delta ) var new_delta = delta.clone() |
