Defining the models and images used in one place to make maintainance of
the mixer list easier.10.3.x-maintenance
parent
a56c0eef40
commit
b3424eadcb
46
js/model.js
46
js/model.js
|
@ -2,27 +2,27 @@
|
|||
|
||||
// generate mixer
|
||||
var mixerList = [
|
||||
{name: 'Tricopter', image: 'tri'},
|
||||
{name: 'Quad +', image: 'quad_p'},
|
||||
{name: 'Quad X', image: 'quad_x'},
|
||||
{name: 'Bicopter', image: 'bicopter'},
|
||||
{name: 'Gimbal', image: 'custom'},
|
||||
{name: 'Y6', image: 'y6'},
|
||||
{name: 'Hex +', image: 'hex_p'},
|
||||
{name: 'Flying Wing', image: 'flying_wing'},
|
||||
{name: 'Y4', image: 'y4'},
|
||||
{name: 'Hex X', image: 'hex_x'},
|
||||
{name: 'Octo X8', image: 'octo_x8'},
|
||||
{name: 'Octo Flat +', image: 'octo_flat_p'},
|
||||
{name: 'Octo Flat X', image: 'octo_flat_x'},
|
||||
{name: 'Airplane', image: 'airplane'},
|
||||
{name: 'Heli 120', image: 'custom'},
|
||||
{name: 'Heli 90', image: 'custom'},
|
||||
{name: 'V-tail Quad', image: 'vtail_quad'},
|
||||
{name: 'Hex H', image: 'custom'},
|
||||
{name: 'PPM to SERVO', image: 'custom'},
|
||||
{name: 'Dualcopter', image: 'custom'},
|
||||
{name: 'Singlecopter', image: 'custom'},
|
||||
{name: 'A-tail Quad', image: 'atail_quad'},
|
||||
{name: 'Custom', image: 'custom'}
|
||||
{name: 'Tricopter', model: 'tricopter', image: 'tri'},
|
||||
{name: 'Quad +', model: 'quad_x', image: 'quad_p'},
|
||||
{name: 'Quad X', model: 'quad_x', image: 'quad_x'},
|
||||
{name: 'Bicopter', model: 'custom', image: 'bicopter'},
|
||||
{name: 'Gimbal', model: 'custom', image: 'custom'},
|
||||
{name: 'Y6', model: 'y6', image: 'y6'},
|
||||
{name: 'Hex +', model: 'hex_plus', image: 'hex_p'},
|
||||
{name: 'Flying Wing', model: 'custom', image: 'flying_wing'},
|
||||
{name: 'Y4', model: 'y4', image: 'y4'},
|
||||
{name: 'Hex X', model: 'hex_x', image: 'hex_x'},
|
||||
{name: 'Octo X8', model: 'custom', image: 'octo_x8'},
|
||||
{name: 'Octo Flat +', model: 'custom', image: 'octo_flat_p'},
|
||||
{name: 'Octo Flat X', model: 'custom', image: 'octo_flat_x'},
|
||||
{name: 'Airplane', model: 'custom', image: 'airplane'},
|
||||
{name: 'Heli 120', model: 'custom', image: 'custom'},
|
||||
{name: 'Heli 90', model: 'custom', image: 'custom'},
|
||||
{name: 'V-tail Quad', model: 'quad_vtail', image: 'vtail_quad'},
|
||||
{name: 'Hex H', model: 'custom', image: 'custom'},
|
||||
{name: 'PPM to SERVO', model: 'custom', image: 'custom'},
|
||||
{name: 'Dualcopter', model: 'custom', image: 'custom'},
|
||||
{name: 'Singlecopter', model: 'custom', image: 'custom'},
|
||||
{name: 'A-tail Quad', model: 'quad_atail', image: 'atail_quad'},
|
||||
{name: 'Custom', model: 'custom', image: 'custom'}
|
||||
];
|
||||
|
|
|
@ -186,7 +186,7 @@ TABS.setup.initialize = function (callback) {
|
|||
TABS.setup.initialize3D = function (compatibility) {
|
||||
var self = this,
|
||||
loader, canvas, wrapper, renderer, camera, scene, light, light2, modelWrapper, model, model_file,
|
||||
fallback = false;
|
||||
useWebGlRenderer = false;
|
||||
|
||||
canvas = $('.model-and-info #canvas');
|
||||
wrapper = $('.model-and-info #canvas_wrapper');
|
||||
|
@ -197,50 +197,25 @@ TABS.setup.initialize3D = function (compatibility) {
|
|||
var detector_canvas = document.createElement('canvas');
|
||||
if (window.WebGLRenderingContext && (detector_canvas.getContext('webgl') || detector_canvas.getContext('experimental-webgl'))) {
|
||||
renderer = new THREE.WebGLRenderer({canvas: canvas.get(0), alpha: true, antialias: true});
|
||||
useWebGlRenderer = true;
|
||||
} else {
|
||||
|
||||
renderer = new THREE.CanvasRenderer({canvas: canvas.get(0), alpha: true});
|
||||
fallback = true;
|
||||
}
|
||||
|
||||
// modelWrapper just adds an extra axis of rotation to avoid gimbal lock withe euler angles
|
||||
modelWrapper = new THREE.Object3D()
|
||||
|
||||
// load the model including materials
|
||||
var models = [
|
||||
'tricopter',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'y6',
|
||||
'hex_plus',
|
||||
'quad_x',
|
||||
'y4',
|
||||
'hex_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_vtail',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_x',
|
||||
'quad_atail',
|
||||
'quad_x'
|
||||
];
|
||||
|
||||
if (!fallback) {
|
||||
model_file = models[CONFIG.multiType - 1];
|
||||
if (useWebGlRenderer) {
|
||||
model_file = mixerList[CONFIG.multiType - 1].model;
|
||||
} else {
|
||||
model_file = 'fallback';
|
||||
model_file = 'fallback'
|
||||
}
|
||||
|
||||
loader = new THREE.JSONLoader();
|
||||
loader.load('./resources/models/' + model_file + '.json', function (geometry, materials) {
|
||||
if (!fallback) {
|
||||
if (useWebGlRenderer) {
|
||||
model = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
|
||||
} else {
|
||||
materials = THREE.ImageUtils.loadTexture('./resources/textures/fallback_texture.png');
|
||||
|
|
Loading…
Reference in New Issue