summaryrefslogtreecommitdiff
path: root/public/assets
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/_map.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/map/draw.js19
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/ortho.js9
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/polyline.js9
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/regionlist.js11
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/shapelist.js13
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js2
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js7
8 files changed, 61 insertions, 12 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/_map.js b/public/assets/javascripts/rectangles/engine/map/_map.js
index e27346d..6492db6 100644
--- a/public/assets/javascripts/rectangles/engine/map/_map.js
+++ b/public/assets/javascripts/rectangles/engine/map/_map.js
@@ -50,6 +50,7 @@ var Map = function(opt){
switch (opt.type) {
case "ortho":
base.draw = new Map.Draw (base, { ortho: true })
+ base.draw.grid_size = MAP_GRID_SIZE
base.ui = new Map.UI.Ortho (base)
base.sides = base.sides_for_center
$(window).resize(base.resize)
@@ -57,6 +58,7 @@ var Map = function(opt){
case "editor":
base.draw = new Map.Draw (base)
+ base.draw.grid_size = MAP_GRID_SIZE
base.ui = new Map.UI.Editor (base)
base.sides = base.sides_for_center
$(window).resize(base.resize)
@@ -64,6 +66,7 @@ var Map = function(opt){
case "minimap":
base.draw = new Map.Draw (base, { center: scene.camera, minimap: true })
+ base.draw.grid_size = MAP_GRID_SIZE * 10
base.ui = new Map.UI.Minimap (base)
base.sides = base.sides_for_camera
break
diff --git a/public/assets/javascripts/rectangles/engine/map/draw.js b/public/assets/javascripts/rectangles/engine/map/draw.js
index fd05f86..4f4759f 100644
--- a/public/assets/javascripts/rectangles/engine/map/draw.js
+++ b/public/assets/javascripts/rectangles/engine/map/draw.js
@@ -179,8 +179,8 @@ Map.Draw = function(map, opt){
ctx.lineWidth = 1/map.zoom
var sides = map.sides()
- var quant = sides.clone().quantize(MAP_GRID_SIZE)
- for (var x = quant.x.a - MAP_GRID_SIZE; x <= quant.x.b; x += MAP_GRID_SIZE) {
+ var quant = sides.clone().quantize(draw.grid_size)
+ for (var x = quant.x.a - draw.grid_size; x <= quant.x.b; x += draw.grid_size) {
if (Math.round(x) % 360 == 0) {
ctx.strokeStyle = "rgba(0,0,0,0.3)"
ctx.lineWidth = 1/map.zoom
@@ -191,17 +191,18 @@ Map.Draw = function(map, opt){
}
line(x, sides.y.a, x, sides.y.b)
}
- for (var y = quant.y.a - MAP_GRID_SIZE; y <= quant.y.b; y += MAP_GRID_SIZE) {
- if (Math.round(y) % 360 == 0) {
+
+ for (var y = quant.y.a - draw.grid_size; y <= quant.y.b; y += draw.grid_size) {
+ if (Math.round(y) % 360 == 0) {
ctx.strokeStyle = "rgba(0,0,0,0.3)"
ctx.lineWidth = 1/map.zoom
- }
- else {
+ }
+ else {
ctx.strokeStyle = "rgba(0,0,0,0.05)"
ctx.lineWidth = 1/map.zoom
- }
- line(sides.x.a, y, sides.x.b, y)
- }
+ }
+ line(sides.x.a, y, sides.x.b, y)
+ }
}
//
diff --git a/public/assets/javascripts/rectangles/engine/shapes/ortho.js b/public/assets/javascripts/rectangles/engine/shapes/ortho.js
index c1acae5..163f646 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/ortho.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/ortho.js
@@ -1,5 +1,9 @@
// An OrthoPolyline is a Polyline where all angles are 90 degrees.
+if (! ('window' in this) ) {
+ var Polyline = require("./polyline.js")
+}
+
var OrthoPolyline = Polyline.extend(function(base){
var exports = {}
exports.type = function(){
@@ -55,3 +59,8 @@ var OrthoPolyline = Polyline.extend(function(base){
}
return exports
})
+
+
+if (! ('window' in this) ) {
+ module.exports = OrthoPolyline
+}
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
index 579d0ea..b2cd92f 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
@@ -2,6 +2,11 @@
// Additionally, it manages a set of MX objects which correspond to the walls in 3D.
// In this way, it attempts to bridge the 2D (canvas, imperative) and 3D (css, declarative) views.
+if (! ('window' in this) ) {
+ var Fiber = require("../../../vendor/bower_components/fiber/src/fiber.js")
+ var vec2 = require("../../models/vec2")
+}
+
var Polyline = Fiber.extend(function(base){
var exports = {}
exports.init = function(){
@@ -201,3 +206,7 @@ var Polyline = Fiber.extend(function(base){
}
return exports
})
+
+if (! ('window' in this) ) {
+ module.exports = Polyline
+}
diff --git a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
index 0dd4a1e..8c9e732 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
@@ -5,6 +5,13 @@
// 1) all angles are orthogonal
// 2) all polylines are closed
+if (! ('window' in this) ) {
+ var Fiber = require("../../../vendor/bower_components/fiber/src/fiber.js")
+ var vec2 = require("../../models/vec2")
+ var Rect = require("../../models/rect")
+ var sort = require("../../util/sort")
+}
+
var RegionList = (function(){
var RegionList = {}
@@ -223,6 +230,10 @@ var RegionList = (function(){
}
return new Rect( segment[0].a, segment[0].b, segment[1].a, segment[1].b )
}
+
+ if (! ('window' in this) ) {
+ module.exports = RegionList
+ }
return RegionList
diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
index 2d33af2..21beb76 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
@@ -1,5 +1,11 @@
// The ShapeList manages the list of polylines which form a V2 layout.
+if (! ('window' in this) ) {
+ var Fiber = require("../../../vendor/bower_components/fiber/src/fiber.js")
+ var Polyline = require("./polyline.js")
+ var OrthoPolyline = require("./ortho.js")
+}
+
var ShapeList = Fiber.extend(function(base){
var exports = {}
exports.init = function(){
@@ -110,4 +116,9 @@ var ShapeList = Fiber.extend(function(base){
})
}
return exports
-}) \ No newline at end of file
+})
+
+if (! ('window' in this) ) {
+ shapes = new ShapeList
+ module.exports = shapes
+}
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 83bc8b7..d8cfca6 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) {
+ if (data.shapes.length) {
Rooms.deserializeFromShapes(data, data.walls)
}
else if (data.rooms) {
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js
index 1ba97cf..43e81d8 100644
--- a/public/assets/javascripts/ui/reader/ReaderView.js
+++ b/public/assets/javascripts/ui/reader/ReaderView.js
@@ -76,7 +76,12 @@ var ReaderView = View.extend({
},
build: function(data){
- data.rooms && Rooms.deserialize(data.rooms)
+ if (data.shapes.length) {
+ Rooms.deserializeFromShapes(data)
+ }
+ else {
+ Rooms.deserialize(data.rooms)
+ }
data.walls && Walls.deserialize(data.walls)
data.media && Scenery.deserialize(data.media)
data.sculpture && Sculpture.deserialize(data.sculpture)