From 4c7cad2ebfc44244ba845c1574271e48b9f2b740 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 4 Feb 2015 13:30:39 -0500 Subject: orbit camera --- public/assets/javascripts/rectangles/util/mouse.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'public/assets/javascripts/rectangles/util/mouse.js') diff --git a/public/assets/javascripts/rectangles/util/mouse.js b/public/assets/javascripts/rectangles/util/mouse.js index cb36038..86edf6c 100644 --- a/public/assets/javascripts/rectangles/util/mouse.js +++ b/public/assets/javascripts/rectangles/util/mouse.js @@ -76,6 +76,14 @@ function mouse (opt) { window.addEventListener("mousemove", base.mousemove) window.addEventListener("mouseup", base.mouseup) } + base.unbind = function(){ + if (opt.el) { + opt.el.removeEventListener("mousedown", base.mousedown) + opt.el.removeEventListener("contextmenu", base.contextmenu) + } + window.removeEventListener("mousemove", base.mousemove) + window.removeEventListener("mouseup", base.mouseup) + } base.bind_el = function(el){ el.addEventListener("mousedown", base.mousedown) -- cgit v1.2.3-70-g09d2 From 00614373ad41e679dc7e06aca950d7167bd1c68f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 31 Mar 2015 16:31:54 -0400 Subject: test with image url --- public/assets/javascripts/rectangles/util/mouse.js | 2 +- public/assets/test/ortho2.html | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'public/assets/javascripts/rectangles/util/mouse.js') diff --git a/public/assets/javascripts/rectangles/util/mouse.js b/public/assets/javascripts/rectangles/util/mouse.js index 86edf6c..2b98cee 100644 --- a/public/assets/javascripts/rectangles/util/mouse.js +++ b/public/assets/javascripts/rectangles/util/mouse.js @@ -134,7 +134,7 @@ function mouse (opt) { } var x = pos.a, y = pos.b - + if (base.down) { base.cursor.x.b = x base.cursor.y.b = y diff --git a/public/assets/test/ortho2.html b/public/assets/test/ortho2.html index 5609ec3..89a5688 100644 --- a/public/assets/test/ortho2.html +++ b/public/assets/test/ortho2.html @@ -69,6 +69,8 @@ Map.UI.Ortho = function(map){ if (e.ctrlKey || e.which === 3) { if (placing) { // close polyline or cancel + placing = false + add_mx_polyline(points) return } cursor.quantize(1/map.zoom) @@ -153,6 +155,7 @@ $(window).resize(function(){ }) +var wall_height = 100 var placing = false var points, mx_points = [] var shapes = [] @@ -166,7 +169,7 @@ function polyline (points, finished) { map.draw.dot_at(points[0].a, points[0].b, 5) } if (points.length > 1) { - ctx.fillStyle = "#ff0" + ctx.fillStyle = "rgba(255,255,0,0.1)" ctx.strokeStyle = "#f80" ctx.lineWidth = 2 / map.zoom ctx.beginPath() @@ -204,10 +207,10 @@ function add_mx_polyline_face(head, tail){ var angle = atan2( head.b - tail.b, head.a - tail.a ) mx.move({ x: mid_x / 2, - y: 25 + 1, + y: wall_height/2 + 1, z: mid_z / 2, width: ceil(len), - height: 50, + height: wall_height, rotationY: angle }) var hue = abs(round( angle / PI * 90 + 300)) -- cgit v1.2.3-70-g09d2 From 7f443264d1c30b48cc3923ee6e700facdf0f7214 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Jun 2016 16:32:37 -0400 Subject: fix resize issues --- .../javascripts/rectangles/engine/map/_map.js | 29 +++++++++++++--------- public/assets/javascripts/rectangles/util/mouse.js | 15 ++++++++++- .../assets/javascripts/ui/editor/EditorSettings.js | 2 +- public/assets/stylesheets/app.css | 2 ++ views/home.ejs | 1 + 5 files changed, 35 insertions(+), 14 deletions(-) (limited to 'public/assets/javascripts/rectangles/util/mouse.js') diff --git a/public/assets/javascripts/rectangles/engine/map/_map.js b/public/assets/javascripts/rectangles/engine/map/_map.js index 6492db6..ba3ec92 100644 --- a/public/assets/javascripts/rectangles/engine/map/_map.js +++ b/public/assets/javascripts/rectangles/engine/map/_map.js @@ -41,12 +41,28 @@ var Map = function(opt){ } base.set_zoom(opt.zoom) + base.resize = function(w, h){ + if (w && h) { + canvas.width = base.dimensions.a = w + canvas.height = base.dimensions.b = h + } + else { + // resize here - esp if 2d-hires + canvas.width = base.dimensions.a = base.el.parentNode.offsetWidth + canvas.height = base.dimensions.b = base.el.parentNode.offsetHeight + } + } + + base.toggle = function(state){ + return $(base.el).toggle(state).is(':visible') + } + var canvas = base.canvas = document.createElement("canvas") canvas.width = base.dimensions.a canvas.height = base.dimensions.b base.el.appendChild(canvas) - + switch (opt.type) { case "ortho": base.draw = new Map.Draw (base, { ortho: true }) @@ -71,17 +87,6 @@ var Map = function(opt){ base.sides = base.sides_for_camera break } - - base.resize = function(w, h){ - canvas.width = base.dimensions.a = w || window.innerWidth - canvas.height = base.dimensions.b = h || window.innerHeight - // resize here - esp if 2d-hires - } - - base.toggle = function(state){ - return $(base.el).toggle(state).is(':visible') - } - } Map.prototype.update = function(){ diff --git a/public/assets/javascripts/rectangles/util/mouse.js b/public/assets/javascripts/rectangles/util/mouse.js index 2b98cee..6d9862c 100644 --- a/public/assets/javascripts/rectangles/util/mouse.js +++ b/public/assets/javascripts/rectangles/util/mouse.js @@ -54,10 +54,20 @@ function mouse (opt) { opt.up && base.tube.on("up", opt.up) opt.rightclick && base.tube.on("rightclick", opt.rightclick) - var offset = (opt.use_offset && opt.el) ? opt.el.getBoundingClientRect() : null + var offset; base.init = function (){ base.bind() + base.set_offset() + } + + base.set_offset = function(){ + if (opt.use_offset && opt.el) { + offset = opt.el.getBoundingClientRect() + } + else { + offset = null + } } base.on = function(){ @@ -73,6 +83,9 @@ function mouse (opt) { opt.el.addEventListener("mousedown", base.mousedown) opt.el.addEventListener("contextmenu", base.contextmenu) } + if (opt.use_offset) { + window.addEventListener("resize", base.set_offset) + } window.addEventListener("mousemove", base.mousemove) window.addEventListener("mouseup", base.mouseup) } diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index d8cfca6..5aa88e9 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -41,7 +41,7 @@ var EditorSettings = FormView.extend({ this.action = data.isNew ? this.createAction : this.updateAction this.parent.data = data - if (data.shapes.length) { + if (data.shapes && data.shapes.length) { Rooms.deserializeFromShapes(data, data.walls) } else if (data.rooms) { diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 1154fde..fdf7c12 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1331,6 +1331,8 @@ form .paidPlan label { float: none; font-size: 16px; margin: 0 10px; } #hud { position: fixed; top:0;left:0; + width: 100%; + height: 100%; z-index: 2; } #palette { diff --git a/views/home.ejs b/views/home.ejs index af43f0b..36dad83 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -60,6 +60,7 @@

Sign Up

Room Showcase

-- cgit v1.2.3-70-g09d2