Files
three.js/examples/webgl_geometries.html
T
Mr.doob 7c7d4428f2 Moved src/materials/Mappings.js inside src/materials/Texture.js
Moved `src/materials/*Texture.js` to `src/textures/*Texture.js`
2011-08-29 05:18:25 +02:00

160 lines
4.1 KiB
HTML

<!DOCTYPE HTML>
<html lang="en">
<head>
<title>three.js webgl - geometries</title>
<meta charset="utf-8">
<style type="text/css">
body {
font-family: Monospace;
background-color: #000;
margin: 0px;
overflow: hidden;
}
#log { color:#fff; position:absolute; top:50px; text-align:left; display:block; z-index:100; pointer-events:none; }
</style>
</head>
<body>
<pre id="log"></pre>
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="js/Detector.js"></script>
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
<script type="text/javascript">
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container, stats;
var camera, scene, renderer;
var objects = [];
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.y = 200;
camera.position.z = 800;
scene = new THREE.Scene();
var light, object, material;
scene.addLight( new THREE.AmbientLight( 0x404040 ) );
light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.z = 1;
scene.addLight( light );
material = [
new THREE.MeshLambertMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/UV.jpg' ) } ),
new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true, transparent: true, opacity: 0.1 } )
];
objects[ 0 ] = object = new THREE.Mesh( new THREE.CubeGeometry( 100, 100, 100, 4, 4, 4 ), material );
object.position.x = - 200;
object.position.z = 200;
scene.addObject( object );
objects[ 1 ] = object = new THREE.Mesh( new THREE.CylinderGeometry( 50, 25, 75, 100 ), material );
object.position.z = 200;
scene.addObject( object );
objects[ 2 ] = object = new THREE.Mesh( new THREE.IcosahedronGeometry( 2 ), material );
object.position.x = 200;
object.position.z = 200;
object.scale.x = object.scale.y = object.scale.z = 75;
scene.addObject( object );
objects[ 3 ] = object = new THREE.Mesh( new THREE.PlaneGeometry( 100, 100, 4, 4 ), material );
object.position.x = - 200;
scene.addObject( object );
objects[ 4 ] = object = new THREE.Mesh( new THREE.SphereGeometry( 75, 20, 10 ), material );
scene.addObject( object );
var points = [];
for ( var i = 0; i < 50; i ++ ) {
points.push( new THREE.Vector3( Math.sin( i * 0.2 ) * 15 + 50, 0, ( i - 5 ) * 2 ) );
}
objects[ 5 ] = object = new THREE.Mesh( new THREE.LatheGeometry( points, 20 ), material );
object.position.x = 200;
scene.addObject( object );
objects[ 6 ] = object = new THREE.Mesh( new THREE.TorusGeometry( 50, 20, 20, 20 ), material );
object.position.x = - 200;
object.position.z = - 200;
scene.addObject( object );
objects[ 7 ] = object = new THREE.Mesh( new THREE.TorusKnotGeometry( 50, 10, 50, 20 ), material );
object.position.z = - 200;
scene.addObject( object );
objects[ 8 ] = object = new THREE.Trident();
object.position.x = 200;
object.position.z = - 200;
object.scale.x = object.scale.y = object.scale.z = 0.5;
scene.addObject( object );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
}
//
function animate() {
requestAnimationFrame( animate );
render();
stats.update();
}
function render() {
var timer = new Date().getTime() * 0.0001;
camera.position.x = Math.cos( timer ) * 800;
camera.position.z = Math.sin( timer ) * 800;
for ( var i = 0, l = objects.length; i < l; i++ ) {
var object = objects[ i ];
object.rotation.x += 0.01;
object.rotation.y += 0.005;
}
renderer.render( scene, camera );
}
</script>
</body>
</html>