I have been working on customizing the code of a three.js example to load a .js file that was originally in .obj format. I am using BinaryLoader.js to load the object, however, the object is not appearing in my modified code. Here is what my code looks like so far:
<!DOCTYPE html>
<html lang="en">
<head>
<title>home</title>
<meta charset="utf-8>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background:#000;
color:#fff;
padding:0;
margin:0;
overflow:hidden;
font-family:georgia;
text-align:center;
}
</style>
</head>
<body>
<script src="js/three.min.js"></script>
<script src="loaders/BinaryLoader.js"></script>
<script src="Detector.js"></script>
<script>
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var CARS = {
"Porsche": {
name: "Bugatti Veyron",
url: "obj/car/Porsche_911_GT2.js",
init_rotation: [ 0, 0, 0 ],
scale: 5.5,
object: null,
buttons: null,
materials: null
}
};
var container, stats;
var camera, scene, renderer;
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
var loader = new THREE.BinaryLoader( true );
document.body.appendChild( loader.statusDomElement );
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 100000 );
scene = new THREE.Scene();
var ambient = new THREE.AmbientLight( 0x050505 );
scene.add( ambient );
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setFaceCulling( THREE.CullFaceNone );
renderer.autoClear = false;
container.appendChild( renderer.domElement );
loader.load( CARS[ "Porsche" ].url, function( geometry ) { createScene( geometry, "Porsche" ) } );
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
var timer = -0.0002 * Date.now();
camera.position.x = 1000 * Math.cos( timer );
camera.position.y += ( - mouseY - camera.position.y ) * .05;
camera.position.z = 1000 * Math.sin( timer );
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
</script>
</body>
</html>
Does anyone know how to solve this issue?