-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera-rot.js
More file actions
80 lines (67 loc) · 2.36 KB
/
camera-rot.js
File metadata and controls
80 lines (67 loc) · 2.36 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// camera rotation around axis
// uses orbitControl@treejs tied with Viewlang
// todo: manipulate camera object from player.
export default function setup(mv) {
var intervalDur=15;
var timer_rm = ()=>{};
function make(opts) {
var obj = mv.create_obj( {}, opts );
obj.feature("enabled timers");
obj.setParam("enabled",false);
obj.trackParam("enabled",aval)
// neet to get it by function every time - because control might be changed externally
var getcontrol = () => qmlEngine.rootObject.scene3d.cameraControlC.sceneControl;
var sl1 = obj.addSlider("teta-angle",0,-1,360,0.01,function(value) {
var orbitControl = getcontrol();
orbitControl.manualTheta = value < 0 || value == null || isNaN(value) ? undefined : 2*Math.PI * value / 360.0;
orbitControl.theta = orbitControl.manualTheta;
orbitControl.update();
if (!obj.params.enabled) {
orbitControl.manualTheta = undefined;
orbitControl.update();
}
});
// синхронизирует процесс таймера и потребность на него, что определяется ненулевым значением value
function aval() {
if (obj.params.enabled) {
var orbitControl = getcontrol();
orbitControl.update();
timer_rm();
timer_rm = obj.setInterval( function() {
var dt = aps.value;
if (isNaN(dt)) dt = 0;
var newangle = ((sl1.value + dt)%360 + 360)%360;
if (isNaN(newangle)) newangle = 0;
sl1.setValue( newangle );
}, intervalDur );
}
else
{
timer_rm(); timer_rm = () => {};
var orbitControl = getcontrol();
orbitControl.manualTheta = undefined;
orbitControl.update();
}
}
var aps = obj.addSlider("auto-rotate",0.01,-0.1,+0.1,0.01,function(value) {
aval();
});
obj.addCmd( "start",function() {
obj.setParam("enabled",true);
});
obj.addCmd( "stop",function() {
obj.setParam("enabled",false);
});
obj.on("remove",() => {
var orbitControl = getcontrol();
orbitControl.manualTheta = undefined;
orbitControl.update();
})
return obj; // ну то есть я пока не понял, хочу я вообще что-то возвращать или нет
}
mv.addItemType( "cameraZ","Animation: Camera rotate",make, {
label:"extra",
guionce:true,
title_ru: "Поворот камеры"
} );
}