Skip to content

Instantly share code, notes, and snippets.

@magicleon94
Last active January 31, 2018 21:56
Show Gist options
  • Save magicleon94/51400aeb7d277036d09f400cd281f507 to your computer and use it in GitHub Desktop.
Save magicleon94/51400aeb7d277036d09f400cd281f507 to your computer and use it in GitHub Desktop.
Experimenting with THREE.js
<html>
<script src="three.js-master/build/three.js"></script>
<body>
</body>
<script>
var renderer;
var scene;
var camera;
var altair;
function update() {
altair.rotateY(0.05);
renderer.render(scene, camera);
requestAnimationFrame(update);
}
window.onload = function () {
const WIDTH = 800;
const HEIGHT = 600;
const VIEW_ANGLE = 45;
const ASPECT_RATIO = WIDTH / HEIGHT;
const NEAR = 0.1;
const FAR = 1000;
container = document.createElement('div');
document.body.appendChild(container);
renderer = new THREE.WebGLRenderer();
camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT_RATIO, NEAR, FAR);
camera.position.set(0, 0, 100);
camera.lookAt(new THREE.Vector3(0, 0, 0));
scene = new THREE.Scene();
scene.add(camera);
renderer.setSize(WIDTH, HEIGHT);
container.appendChild(renderer.domElement);
const pointLight = new THREE.PointLight(0xFFFFFF);
scene.add(pointLight);
var loader = new THREE.ObjectLoader();
loader.load('assassins-creed-altair-threejs/assassins-creed-altair.json', function (obj) {
altair = obj;
altair.scale.set(0.5, 0.5, 0.5)
altair.position.z = 0;
altair.position.y = -30;
altair.rotateY(3.14);
scene.add(altair);
update();
})
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment