summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/environments/tableaux/columns_split.js
blob: b9981d62e011d80972312378d7bd0c0f96c173ed (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
53
54
55
56
57
58
59
60
61
62
63
MX.Tableaux.ColumnsSplit = MX.Tableau.extend({

	init: function (opt) {

		this.opt = opt = defaults(opt, {
			width: 100,
			height: 100,
			depth: 100,
			norm: 0.5,
			gap: 5,
			x: 0,
			y: 0,
			z: 0,
			rotationY: 0,
			scale: 1,
			count: 1,
		})
		
		opt.colorBottom = opt.colorBottom || opt.color
		
		if ( ! (opt.norm instanceof Array) ) {
			opt.norm = [ opt.norm, opt.norm ]
		}
		
		var norm, spacingX, spacingZ, scalebox
		
		for (var i = 0; i < opt.count; i++) {

			norm = lerp( i/(opt.count-1), opt.norm[0], opt.norm[1] )

			spacingX = opt.spacingX * i
			spacingZ = opt.spacingZ * i

			scalebox = new MX.ScaleBox({
				"width": opt.width,
				"height": opt.height * norm,
				"depth": opt.depth,
				"x": opt.x + spacingX,
				"y": opt.y + opt.gap,
				"z": opt.z + spacingZ,
				"color": opt.color,
				"sides": "top bottom left right front back",
				"rotationY": opt.rotationY,
			});
			scene.add(scalebox)

			scalebox = new MX.ScaleBox({
				"width": opt.width,
				"height": opt.height * (1 - norm),
				"depth": opt.depth,
				"x": opt.x + spacingX,
				"y": opt.y - opt.height * (1 - norm) - opt.gap,
				"z": opt.z + spacingZ,
				"color": opt.colorBottom,
				"sides": "top bottom left right front back",
				"rotationY": opt.rotationY,
			});
			scene.add(scalebox)
		}

	}
	
})