Three.js loading obj


#1

Hey… hope you guys can help. I’m basically trying to do the three.js “getting started” example but instead of loading a cube I want to load an obj.

<html>
<head>
	<title>My first Three.js app</title>
	<style>
		body { margin: 0; }
		canvas { width: 100%; height: 100% }
	</style>
</head>
<body>
	<script src="js/three.min.js"></script>
	<script>
		var scene = new THREE.Scene();
		var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );

		var renderer = new THREE.WebGLRenderer();
		renderer.setSize( window.innerWidth, window.innerHeight );
		document.body.appendChild( renderer.domElement );

		var geometry = new THREE.BoxGeometry( 1, 1, 1 );
		var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
		var cube = new THREE.Mesh( geometry, material );
		scene.add( cube );

		camera.position.z = 5;

		var render = function () {
			requestAnimationFrame( render );

			cube.rotation.x += 0.1;
			cube.rotation.y += 0.1;

			renderer.render(scene, camera);
		};

		render();
	</script>
</body>

#5

heyhey, signing on here for the first time in a while, is this still a question @violetforest? if so i can lend some advice re:three.js && 3d object files : )


#6

hey! i actually figured it out but I have other questions regarding 123dcatch models and putting them in threejs @nickbriz


#7

sure, what’s the issue?

sidenote << re: 3dObject files in three.js, while there are all kinds of loaders + techniques for loading 3d stuffs into a three.js project i ( && others ) generally think its best to use Mr.Doob’s blender plugin ( which converts any 3d file u can load into blender into a .js file ) to create .js files that can be loaded in useing the JSONLoader …that might answer ur 123dcatch question + other re:questions, but if not just ask : )