summaryrefslogtreecommitdiff
path: root/client/assets/javascripts/rectangles/engine/scenery/image/_image.js
blob: dadb2d21984ae158b74755b853bded52277b0a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Scenery.image = function (wall, img) {

	var base = this
	
	base.wall = wall
	base.img = img
	base.dimensions = new vec2(img.width, img.height)
	base.center = wall.center()
	base.bounds = wall.bounds_for(img)

	// should be proportional to distance from wall
	var cursor_amp = 1.5
	
	base.init = function(){
		base.build()
		base.bind()
	}
	
	base.build = function(){
		base.mx_img = new MX.Image({
			src: img.src,
			x: base.center.a,
			y: Rooms.list[wall.room].height/2 - img.height/2 - 20,
			z: base.center.b,
			scale: 300/img.naturalWidth,
			rotationY: wall_rotation[ wall.side ],
			backface: false,
		})
		scene.add( base.mx_img )
		base.move = new Scenery.image.move (base)
	}
	
	base.bind = function(){
		base.move.bind()
// 		base.resize.bind()
		$(base.mx_img.el).bind({
			mouseenter: function(e){
// 				console.log('entered an image')
				// show the resize points for this image
				Scenery.resize.show(base)
				Scenery.image.hovering = true
			},
			mouseleave: function(e){
// 				console.log('left an image')
				Scenery.resize.defer_hide(base)
				Scenery.image.hovering = false
			}
		})
	}
	
	return base
}