diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-10-02 14:32:03 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-10-02 14:32:03 -0400 |
| commit | fa81420e382366ffd0d2262f1af6143399f7a91d (patch) | |
| tree | 245515f4b6a27098f83db206e0d4401a46e11c2d /public/assets/javascripts/rectangles/models/wall.js | |
| parent | b512bcdfe49e0bce336f848dcf620c3c533e1f8c (diff) | |
transform screen coordinates into a 3d point
Diffstat (limited to 'public/assets/javascripts/rectangles/models/wall.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/wall.js | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js index 07c3971..fdf54f0 100644 --- a/public/assets/javascripts/rectangles/models/wall.js +++ b/public/assets/javascripts/rectangles/models/wall.js @@ -50,16 +50,24 @@ index: index, }) }, +/* mousemove: function(e){ var offset = offsetFromPoint(e, mx.el) + var shouldFlip = base.side & (RIGHT | FRONT) if (offset) { - console.log([offset.left * mx.width + mx.face.x.a, (1-offset.top) * mx.height + mx.face.y.a].map(Math.round)) -// console.log(mx) - } - else { - console.log("NONE") + var pos = base.mxOffsetToPosition( offset, index ) + + var mx_pos = base.positionToMx(pos, new vec2(5,5)) + var mx_dot = new MX.Object3D + mx_dot.move(mx_pos) + mx_dot.width = 5 + mx_dot.height = 5 + mx_dot.rotationY = wall_rotation[base.side] + mx_dot.el.style.backgroundColor = "red" + scene.add(mx_dot) } }, +*/ mousedown: function(e){ if (Scenery.nextMedia) { var scenery = Scenery.addNextToWall({ @@ -184,7 +192,16 @@ } return position } - + Wall.prototype.mxOffsetToPosition = function( offset, index ) { + var face = this.surface.faces[index] + var shouldFlip = this.side & (RIGHT | FRONT) + var position = new vec2(0,0) + position.a = face.x.lerp(shouldFlip ? 1-offset.left : offset.left) + position.b = face.y.lerp(1-offset.top) + position.round() + return position + } + Wall.prototype.color = function(color){ this.$walls.css("background-color", color) } |
