diff options
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery')
3 files changed, 21 insertions, 9 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js index 58592d4..119391d 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js +++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js @@ -35,8 +35,14 @@ var Scenery = new function(){ var scene_media = base.add(opt) // test if scenery was placed here - base.nextMedia = null - return scene_media + if (! scene_media.bounds) { + base.remove( scene_media.id ) + return null + } + else { + base.nextMedia = null + return scene_media + } } base.find = function(id){ @@ -44,9 +50,9 @@ var Scenery = new function(){ } base.remove = function(id){ - var media = base.list[id] + var scene_media = base.list[id] delete base.list[id] - media && media.destroy() + scene_media && scene_media.destroy() } base.uid = new UidGenerator(base.list) diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js index 7b716f6..effee2a 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js @@ -28,14 +28,11 @@ Scenery.types.base = Fiber.extend(function(base){ }, recenter: function () { + if (! this.bounds) return var center = this.bounds.center() center.a -= this.dimensions.a / 2 center.b -= this.dimensions.b / 2 - console.log(center+"") var mx_position = this.wall.positionToMx( center, this.dimensions ) - console.log(mx_position) - console.log(this.wall.surface.faces.join("\n")) - // also supply scale? this.mx.move(mx_position) this.position.assign(center) }, diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/image.js b/public/assets/javascripts/rectangles/engine/scenery/types/image.js index 1582e0f..3bee827 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/image.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/image.js @@ -12,11 +12,20 @@ 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) } else { this.set_wall(opt) - this.recenter() + this.bounds && this.recenter() } }, |
