This is my final for threejsplaygnd. I started off by making an interesting shape using the torus knot. I experimented with the swinging camera and mesh position. I have attempted to make the torus knot look like it is coming out at you. I experimented with also making the knot rotate but decided against it because if felt like to much was going on. I like this composition because it looks as if the torus knot is creating a curved tunnel.
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
background-color: #ffffff;
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="http://brangerbriz.net/labs/threejs_playGnd/js/three.min.js"></script>
<script src="http://brangerbriz.net/labs/threejs_playGnd/js/Detector.js"></script>
<script>
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var camera, scene, renderer;
var geometry, material, mesh;
function setup() {
var W = window.innerWidth, H = window.innerHeight;
renderer = new THREE.WebGLRenderer( { preserveDrawingBuffer: true } );
renderer.autoClearColor = false;
renderer.setSize( W, H );
document.body.appendChild( renderer.domElement );
camera = new THREE.PerspectiveCamera( 50, W/H, 1, 10000 );
camera.position.z = 500;
scene = new THREE.Scene();
// paste your code from the geometryGUI here
geometry = new THREE.TorusKnotGeometry(171.39, 11.78, 100, 100, 11.01, 15, 1);
material = new THREE.MeshNormalMaterial({shading: THREE.FlatShading});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
}
function draw() {
requestAnimationFrame( draw );
// experiment with code from the snippets menu here
mesh.position.x = Math.sin( Date.now() * 0.01 ) * 50;
mesh.rotation.z = Date.now() * 0.000;
//swinging camera
mesh.position.z = Math.sin( Date.now() * 0.003 ) * 600;
renderer.render( scene, camera );
}
setup();
draw();
</script>
</body>
</html>