Defining the models and images used in one place to make maintainance of

the mixer list easier.
10.3.x-maintenance
Dominic Clifton 2015-01-27 21:06:39 +01:00
parent a56c0eef40
commit b3424eadcb
2 changed files with 30 additions and 55 deletions

View File

@ -2,27 +2,27 @@
// generate mixer // generate mixer
var mixerList = [ var mixerList = [
{name: 'Tricopter', image: 'tri'}, {name: 'Tricopter', model: 'tricopter', image: 'tri'},
{name: 'Quad +', image: 'quad_p'}, {name: 'Quad +', model: 'quad_x', image: 'quad_p'},
{name: 'Quad X', image: 'quad_x'}, {name: 'Quad X', model: 'quad_x', image: 'quad_x'},
{name: 'Bicopter', image: 'bicopter'}, {name: 'Bicopter', model: 'custom', image: 'bicopter'},
{name: 'Gimbal', image: 'custom'}, {name: 'Gimbal', model: 'custom', image: 'custom'},
{name: 'Y6', image: 'y6'}, {name: 'Y6', model: 'y6', image: 'y6'},
{name: 'Hex +', image: 'hex_p'}, {name: 'Hex +', model: 'hex_plus', image: 'hex_p'},
{name: 'Flying Wing', image: 'flying_wing'}, {name: 'Flying Wing', model: 'custom', image: 'flying_wing'},
{name: 'Y4', image: 'y4'}, {name: 'Y4', model: 'y4', image: 'y4'},
{name: 'Hex X', image: 'hex_x'}, {name: 'Hex X', model: 'hex_x', image: 'hex_x'},
{name: 'Octo X8', image: 'octo_x8'}, {name: 'Octo X8', model: 'custom', image: 'octo_x8'},
{name: 'Octo Flat +', image: 'octo_flat_p'}, {name: 'Octo Flat +', model: 'custom', image: 'octo_flat_p'},
{name: 'Octo Flat X', image: 'octo_flat_x'}, {name: 'Octo Flat X', model: 'custom', image: 'octo_flat_x'},
{name: 'Airplane', image: 'airplane'}, {name: 'Airplane', model: 'custom', image: 'airplane'},
{name: 'Heli 120', image: 'custom'}, {name: 'Heli 120', model: 'custom', image: 'custom'},
{name: 'Heli 90', image: 'custom'}, {name: 'Heli 90', model: 'custom', image: 'custom'},
{name: 'V-tail Quad', image: 'vtail_quad'}, {name: 'V-tail Quad', model: 'quad_vtail', image: 'vtail_quad'},
{name: 'Hex H', image: 'custom'}, {name: 'Hex H', model: 'custom', image: 'custom'},
{name: 'PPM to SERVO', image: 'custom'}, {name: 'PPM to SERVO', model: 'custom', image: 'custom'},
{name: 'Dualcopter', image: 'custom'}, {name: 'Dualcopter', model: 'custom', image: 'custom'},
{name: 'Singlecopter', image: 'custom'}, {name: 'Singlecopter', model: 'custom', image: 'custom'},
{name: 'A-tail Quad', image: 'atail_quad'}, {name: 'A-tail Quad', model: 'quad_atail', image: 'atail_quad'},
{name: 'Custom', image: 'custom'} {name: 'Custom', model: 'custom', image: 'custom'}
]; ];

View File

@ -186,7 +186,7 @@ TABS.setup.initialize = function (callback) {
TABS.setup.initialize3D = function (compatibility) { TABS.setup.initialize3D = function (compatibility) {
var self = this, var self = this,
loader, canvas, wrapper, renderer, camera, scene, light, light2, modelWrapper, model, model_file, loader, canvas, wrapper, renderer, camera, scene, light, light2, modelWrapper, model, model_file,
fallback = false; useWebGlRenderer = false;
canvas = $('.model-and-info #canvas'); canvas = $('.model-and-info #canvas');
wrapper = $('.model-and-info #canvas_wrapper'); wrapper = $('.model-and-info #canvas_wrapper');
@ -197,50 +197,25 @@ TABS.setup.initialize3D = function (compatibility) {
var detector_canvas = document.createElement('canvas'); var detector_canvas = document.createElement('canvas');
if (window.WebGLRenderingContext && (detector_canvas.getContext('webgl') || detector_canvas.getContext('experimental-webgl'))) { if (window.WebGLRenderingContext && (detector_canvas.getContext('webgl') || detector_canvas.getContext('experimental-webgl'))) {
renderer = new THREE.WebGLRenderer({canvas: canvas.get(0), alpha: true, antialias: true}); renderer = new THREE.WebGLRenderer({canvas: canvas.get(0), alpha: true, antialias: true});
useWebGlRenderer = true;
} else { } else {
renderer = new THREE.CanvasRenderer({canvas: canvas.get(0), alpha: true}); 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 just adds an extra axis of rotation to avoid gimbal lock withe euler angles
modelWrapper = new THREE.Object3D() modelWrapper = new THREE.Object3D()
// load the model including materials // load the model including materials
var models = [ if (useWebGlRenderer) {
'tricopter', model_file = mixerList[CONFIG.multiType - 1].model;
'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];
} else { } else {
model_file = 'fallback'; model_file = 'fallback'
} }
loader = new THREE.JSONLoader(); loader = new THREE.JSONLoader();
loader.load('./resources/models/' + model_file + '.json', function (geometry, materials) { loader.load('./resources/models/' + model_file + '.json', function (geometry, materials) {
if (!fallback) { if (useWebGlRenderer) {
model = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials)); model = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
} else { } else {
materials = THREE.ImageUtils.loadTexture('./resources/textures/fallback_texture.png'); materials = THREE.ImageUtils.loadTexture('./resources/textures/fallback_texture.png');