Analog Instruments/Functions analog instruments.js
Jump to navigation
Jump to search
1 'use strict';
2 // Clock
3 function instrument_analog_clock(input){
4 var time_hours = input.input_ms/((3600000*12)/360),
5 time_minutes = input.input_ms/((60000*60)/360),
6 time_seconds = input.input_ms/((1000*60)/360),
7 unit;
8 if (input.units === 'hours') unit = time_hours;
9 else if (input.units === 'minutes') unit = time_minutes;
10 else if (input.units === 'seconds') unit = time_seconds;
11 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(unit), input.axis);
12 }
13
14 // Oil Temperature Indicator
15 function instrument_analog_oil_tmp(input){
16 var property = 'propulsion/engine[0]/oil-temperature-degF';
17 if (input.units === 'F') var val = jsb[property.replace('0', input.engine)]/input.factor;
18 else if (input.units === 'C') val = f2c(jsb[property.replace('0', input.engine)])/input.factor;
19 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(clamp(intrpl_tbl(val, input.table), input.min, input.max)), input.axis);
20 }
21
22 // Airspeed Indicator
23 function instrument_analog_asi(input){
24 if (input.units === 'kts') var val = jsb['velocities/vc-kts']/input.factor;
25 else if (input.units === 'kph') val = (jsb['velocities/vc-kts']*1.85200)/input.factor;
26 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(clamp(intrpl_tbl(val, input.table), input.min, input.max)), input.axis);
27 }
28
29 // Altitude Indicator
30 function instrument_analog_alt(input){
31 if (input.units === 'ft') var val = jsb['position/h-sl-ft']/input.factor;
32 else if (input.units === 'km') val = (jsb['position/h-sl-ft']*0.0003048)/input.factor;
33 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(clamp(intrpl_tbl(val, input.table), input.min, input.max)), input.axis);
34 }
35
36 // VSI Indicator
37 function instrument_analog_vsi(input){
38 if (input.units === 'fps') var val = jsb['velocities/v-down-fps']/input.factor;
39 else if (input.units === 'mps') val = (jsb['velocities/v-down-fps']*0.3048)/input.factor;
40 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(clamp(intrpl_tbl(val, input.table), input.min, input.max)), input.axis);
41 }
42
43 // RPM Indicator
44 function instrument_analog_rpm(input){
45 var property = 'propulsion/engine[0]/engine-rpm';
46 geom.rotate_joint_orig(geom.get_joint(input.bone), deg2rad(clamp(intrpl_tbl(jsb[property.replace('0', input.engine)]/input.factor, input.table), input.min, input.max)), input.axis);
47 }
48
49 // Compass
50 function instrument_analog_compass(input){
51 geom.rotate_joint_orig(geom.get_joint(input.bone), jsb['attitude/heading-true-rad'], input.axis);
52 }
53
54 // Turn Indicator
55 function instrument_analog_turn(input){
56 geom.rotate_joint_orig(geom.get_joint(input.bone), clamp(input.property, deg2rad(input.min), deg2rad(input.max)), input.axis);
57 }
58
59 // Slip/Bank Indicator
60 function instrument_analog_slip(input){
61 geom.rotate_joint_orig(geom.get_joint(input.bone), clamp(input.property, deg2rad(input.min), deg2rad(input.max)), input.axis);
62 }