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
|
define.class(function(require, $ui$button){
this.attributes = {
target: Config({type:string, value:""})
}
this.icon = "arrows"
this.justifycontent = "center"
this.alignitems = "center"
this.fontsize = 20;
this.onpointermove = function(event){
var t = this.find(this.target)
this.camera_start = vec3.sub(t._camera, t._lookat)
var M4 = mat4.invert(t.viewmatrix)
var screenup = vec3.normalize(vec3.vec3_mul_mat4(vec3(0,1,0), M4));
var M1 = mat4.identity()
var M2 = mat4.rotate(M1, event.movement[0] * 0.01, t._up)
var axis = vec3.normalize(vec3.cross(this.camera_start, t._up))
var M3 = mat4.rotate(M2, event.movement[1] * 0.01, axis)
var Rot = vec3.vec3_mul_mat4(this.camera_start, M3)
var Res = vec3.add(Rot, t._lookat)
t._camera = Res
t.redraw()
}
var rotator = this.constructor
this.constructor.examples = {
Usage:function(){
return [
rotator({target:"someview", width:100, height:100})
]
}
}
})
|