summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-03-31 12:44:28 -0400
committerJules Laplace <jules@okfoc.us>2015-03-31 12:44:28 -0400
commit4b794104e86b74c531e35443cf23ce8cf144d505 (patch)
treeae2557a2de7a213a2eb002365ea0203e5b186e79
parent835fbcd8b47715d34d17b784409db1d45f992c29 (diff)
etc
-rw-r--r--public/assets/javascripts/app.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/map/ui_ortho.js82
-rw-r--r--public/assets/test/ortho.html9
-rw-r--r--public/assets/test/ortho2.html83
4 files changed, 92 insertions, 84 deletions
diff --git a/public/assets/javascripts/app.js b/public/assets/javascripts/app.js
index 6ff062e..6ebcda5 100644
--- a/public/assets/javascripts/app.js
+++ b/public/assets/javascripts/app.js
@@ -21,8 +21,6 @@ app.init = function () {
app.launch = function () {
if ($.browser.msie || ! has3d()) { return app.fallback() }
- var movements
-
scene = new MX.Scene().addTo('#scene')
scene.width = window.innerWidth
scene.height = window.innerHeight
diff --git a/public/assets/javascripts/rectangles/engine/map/ui_ortho.js b/public/assets/javascripts/rectangles/engine/map/ui_ortho.js
index adcc078..e69de29 100644
--- a/public/assets/javascripts/rectangles/engine/map/ui_ortho.js
+++ b/public/assets/javascripts/rectangles/engine/map/ui_ortho.js
@@ -1,82 +0,0 @@
-Map.UI = Map.UI || {}
-Map.UI.Ortho = function(map){
-
- var base = this
-
- base.creating = base.dragging = base.resizing = false
-
- base.mouse = new mouse({
- el: map.el,
- down: function(e, cursor){
- cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
- cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
-
- if (e.ctrlKey || e.which === 3) {
- if (placing) {
- // close polyline or cancel
- return
- }
- cursor.quantize(1/map.zoom)
- map.center.a = cursor.x.a
- map.center.b = -cursor.y.a
- cursor.x.b = cursor.x.a
- cursor.y.b = cursor.y.a
- base.mouse.down = false
- e.preventDefault()
- e.stopPropagation()
- return
- }
-
- // compare to initial point
- var p = new vec2( cursor.x.a, cursor.y.a )
- if (placing) {
- if (points.length > 2 && points[0].distanceTo( p ) < 10/map.zoom) {
- points.push( points[0].clone() )
- placing = false
- add_mx_polyline(points)
- }
- else {
- points.push( p )
- mx_points.push( add_mx_point(p) )
- }
- }
- else {
- placing = true
- points = []
- points.push( p )
- mx_points.push( add_mx_point(p) )
- }
- },
- move: function(e, cursor){
- cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
- cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
- last_point = new vec2( cursor.x.a, cursor.y.a )
- if (placing && points.length > 1 && points[0].distanceTo( last_point ) < 10/map.zoom) {
- document.body.style.cursor = "pointer"
- last_point.assign(points[0])
- cursor.x.a = cursor.x.b = last_point.a
- cursor.y.a = cursor.y.b =last_point.b
- }
- else {
- document.body.style.cursor = "crosshair"
- }
- },
- drag: function(e, cursor){
- cursor.x.b = ((cursor.x.b/map.dimensions.a)+0.5) * map.dimensions.a / map.zoom + map.center.a
- cursor.y.b = ((cursor.y.b/map.dimensions.b)-0.5) * map.dimensions.b / map.zoom - map.center.b
- },
- up: function(e, cursor, new_cursor){
- new_cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
- new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
- }
- })
-
- base.wheel = new wheel({
- el: map.el,
- update: mousewheel,
- })
-
- function mousewheel (e, deltaY, deltaX){
- map.set_zoom(map.zoom_exponent - deltaY/20)
- }
-} \ No newline at end of file
diff --git a/public/assets/test/ortho.html b/public/assets/test/ortho.html
index 1ca7e06..2257006 100644
--- a/public/assets/test/ortho.html
+++ b/public/assets/test/ortho.html
@@ -99,6 +99,15 @@ Map.UI.Ortho = function(map){
new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
}
})
+
+ base.wheel = new wheel({
+ el: map.el,
+ update: mousewheel,
+ })
+
+ function mousewheel (e, deltaY, deltaX){
+ map.set_zoom(map.zoom_exponent - deltaY/20)
+ }
}
var scene, map, controls
diff --git a/public/assets/test/ortho2.html b/public/assets/test/ortho2.html
index 733c90c..17acead 100644
--- a/public/assets/test/ortho2.html
+++ b/public/assets/test/ortho2.html
@@ -46,6 +46,89 @@ body {
<script src="/assets/javascripts/rectangles/engine/map/draw.js"></script>
<script>
+Map.UI = Map.UI || {}
+Map.UI.Ortho = function(map){
+
+ var base = this
+
+ base.creating = base.dragging = base.resizing = false
+
+ base.mouse = new mouse({
+ el: map.el,
+ down: function(e, cursor){
+ cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
+ cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
+
+ if (e.ctrlKey || e.which === 3) {
+ if (placing) {
+ // close polyline or cancel
+ return
+ }
+ cursor.quantize(1/map.zoom)
+ map.center.a = cursor.x.a
+ map.center.b = -cursor.y.a
+ cursor.x.b = cursor.x.a
+ cursor.y.b = cursor.y.a
+ base.mouse.down = false
+ e.preventDefault()
+ e.stopPropagation()
+ return
+ }
+
+ // compare to initial point
+ var p = new vec2( cursor.x.a, cursor.y.a )
+ if (placing) {
+ if (points.length > 2 && points[0].distanceTo( p ) < 10/map.zoom) {
+ points.push( points[0].clone() )
+ placing = false
+ add_mx_polyline(points)
+ }
+ else {
+ points.push( p )
+ mx_points.push( add_mx_point(p) )
+ }
+ }
+ else {
+ placing = true
+ points = []
+ points.push( p )
+ mx_points.push( add_mx_point(p) )
+ }
+ },
+ move: function(e, cursor){
+ cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
+ cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
+ last_point = new vec2( cursor.x.a, cursor.y.a )
+ if (placing && points.length > 1 && points[0].distanceTo( last_point ) < 10/map.zoom) {
+ document.body.style.cursor = "pointer"
+ last_point.assign(points[0])
+ cursor.x.a = cursor.x.b = last_point.a
+ cursor.y.a = cursor.y.b =last_point.b
+ }
+ else {
+ document.body.style.cursor = "crosshair"
+ }
+ },
+ drag: function(e, cursor){
+ cursor.x.b = ((cursor.x.b/map.dimensions.a)+0.5) * map.dimensions.a / map.zoom + map.center.a
+ cursor.y.b = ((cursor.y.b/map.dimensions.b)-0.5) * map.dimensions.b / map.zoom - map.center.b
+ },
+ up: function(e, cursor, new_cursor){
+ new_cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
+ new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
+ }
+ })
+
+ base.wheel = new wheel({
+ el: map.el,
+ update: mousewheel,
+ })
+
+ function mousewheel (e, deltaY, deltaX){
+ map.set_zoom(map.zoom_exponent - deltaY/20)
+ }
+}
+
var scene, map, controls