Всем привет,подскажите как можно
а дальше по коду использовать,а именно в switche и далее
var _loaders = {};
_loaders.loadCurrentObject = function (a) {
_loaders.object = a;
console.log(a);
function init() {
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 50000);
scene.add(camera);
var webGLRenderer = new THREE.WebGLRenderer();
webGLRenderer.setClearColor(new THREE.Color(0xffffff, 1.0));
webGLRenderer.setSize(window.innerWidth, window.innerHeight);
webGLRenderer.shadowMapEnabled = true;
camera.position.x = 5;
camera.position.y = 5;
camera.position.z = 5;
camera.lookAt(scene.position);
scene.add(camera);
var orbitControls = new THREE.OrbitControls(camera);
orbitControls.autoRotate = true;
var clock = new THREE.Clock();
var directionalLight = new THREE.DirectionalLight(0xffeedd);
directionalLight.position.set(100, 100, 150);
camera.add(directionalLight);
document.getElementById("WebGL-output").appendChild(webGLRenderer.domElement);
var step = 0;
var mesh;
switch (a.extension) {
case 'obj':
if (a.texture != "http://placehold.it/200x200") {
_loaders.loader = new THREE.OBJMTLLoader();
_loaders.loadObjMtl(_loaders.object);
} else {
_loaders.loader = new THREE.OBJLoader();
_loaders.loadObj(_loaders.object);
}
break;
case 'stl':
_loaders.loader = new THREE.STLLoader();
_loaders.loadStl(_loaders.object);
break;
}
_loaders.loadObj = function (a) {
_loaders.loader.load('/files/uploads/objects/'+ a.id + '/' + a.url, function (loadedMesh) {
loadedMesh.children.forEach(function (child) {
child.material = material;
child.geometry.computeFaceNormals();
child.geometry.computeVertexNormals();
});
mesh = loadedMesh;
loadedMesh.scale.set.x = 45;
loadedMesh.scale.set.y = 45;
loadedMesh.scale.set.z = 45;
loadedMesh.rotation.x = -0.3;
scene.add(loadedMesh);
});
};
render();
function render() {
var delta = clock.getDelta();
orbitControls.update(delta);
requestAnimationFrame(render);
webGLRenderer.render(scene, camera);
}
}
window.onload = init;
};