my code is:
var camera, scene, renderer;
var mesh;
var x, y, z;
function init() {
"use strict";
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 100);
camera.position.z = 400;
scene = new THREE.scene();
function createplanet() {
var colorget, geometry;
function randomcolor() {
var letters, color, i;
color = '#';
letters = '0123456789ABCDEF'.split('');
i = 1;
if (i === true) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
geometry = new window.THREE.SphereGeometry(x, y, z);
x = Math.random() * 3;
y = Math.random() * 10;
z = y;
colorget = new window.THREE.LineBasicMaterial({color: randomcolor()
});
}
}
init();
animate();
Note: I'll add an animate function later.
My question is that whenever I try to use the live preview ability of Brackets, nothing shows up and I think it's because THREE.something isn't recognized in Brackets. I have downloaded three.js so should I use a JSON file or what? Also, any other help with any issues that you notice would be extremely appreciated.
In your HTML file (the one that calls this JavaScript code or has it embedded within), you should reference your three.js file.
For example if it is located in a scripts
folder, you would type <script src="scripts/three.js"></script>
.
Important: This line must go above the line(s) that call your JavaScript code that you quoted above.