joeb joeb - 8 months ago 48
Javascript Question

Three js sample scene not working

Sorry for the total noob question but Im just starting in three.js. This will probably be a simple answer for the pros. Im trying to start with the most basic scene and build my knowledge from there. So i started with the example scene straight from the docs. All i get when i run it, both locally, and on my server is just a white screen, no canvas or scene. The examples i downloaded work both locally and on my server so im not quite sure why this doesn't work. Here's my code.

<!DOCTYPE html>
<title>My first Three.js app</title>
<style>canvas { width: 100%; height: 100% }</style>
<script src="threejs/three.js"></script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 10000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
var geometry = new THREE.BoxGeometry(700, 700, 700, 10, 10, 10);
var material = new THREE.MeshBasicMaterial({color: 0xfffff, wireframe: true});
var cube = new THREE.Mesh(geometry, material);
camera.position.z = 1000;
function render() {
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render(scene, camera);

Thanks in advance for any help.



Check your three.js file location. This src worked for me , my html file is in the home folder (three.js-master)

<script src="build/three.js"></script>