You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
742 B
JavaScript

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 100 );
var canvas = document.getElementById('torusKnot');
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth/2, window.innerHeight/2 );
document.body.appendChild(renderer.domElement);
var geometry = new THREE.TorusKnotGeometry( 10, 3, 100, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
var torusKnot = new THREE.Mesh( geometry, material );
scene.add( torusKnot );
camera.position.z = 20;
var animate = function () {
requestAnimationFrame( animate );
torusKnot.rotation.x += 0.01;
torusKnot.rotation.y += 0.01;
renderer.render( scene, camera );
};
animate();