123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <title>three.js - io - blender - vertex colors - webgl</title>
- <meta charset="utf-8">
- <style type="text/css">
- body {
- color: #eee;
- font-family:Monospace;
- font-size:13px;
- text-align:center;
- background-color: #000;
- margin: 0px;
- overflow: hidden;
- }
- #info {
- position: absolute;
- top: 0px; width: 100%;
- padding: 5px;
- }
- a {
- color: #0080ff;
- }
- </style>
- </head>
- <body>
- <div id="container"></div>
- <div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - vertex colors - blender export - webgl</div>
- <script type="text/javascript" src="../build/ThreeExtras.js"></script>
- <script type="text/javascript" src="js/Stats.js"></script>
-
- <script type="text/javascript">
- if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage();
- var container, stats;
- var camera, scene, renderer;
- var mesh, mesh2, mesh3, light;
- var mouseX = 0, mouseY = 0;
- var windowHalfX = window.innerWidth / 2;
- var windowHalfY = window.innerHeight / 2;
- init();
- setInterval( loop, 1000 / 60 );
- function init() {
- container = document.getElementById( 'container' );
- camera = new THREE.Camera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
- camera.position.z = 1800;
- scene = new THREE.Scene();
-
- //scene.addLight( new THREE.AmbientLight( 0x333333 ) );
-
- light = new THREE.DirectionalLight( 0xffffff );
- light.position.set( 0, 0, 1 );
- light.position.normalize();
- scene.addLight( light );
- var loader = new THREE.Loader();
- loader.loadAscii( { model: "obj/cubecolors/cubecolors.js", callback: createScene } );
-
- 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 );
- document.addEventListener( 'mousemove', onDocumentMouseMove, false );
- }
- function createScene( geometry ) {
-
- geometry.materials[0][0].shading = THREE.FlatShading;
-
- var material = [ new THREE.MeshFaceMaterial(),
- new THREE.MeshLambertMaterial( { color: 0xffffff, opacity:0.9, shading:THREE.FlatShading, wireframe: true, wireframe_linewidth: 2 } )
- ];
- mesh = SceneUtils.addMesh( scene, geometry, 250, 0, 0, 0, 0, 0, 0, material );
-
- }
-
- function onDocumentMouseMove( event ) {
- mouseX = ( event.clientX - windowHalfX );
- mouseY = ( event.clientY - windowHalfY );
- }
- function loop() {
- camera.position.x += ( mouseX - camera.position.x ) * 0.05;
- camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
- if ( mesh ) {
-
- mesh.rotation.x += 0.01;
- mesh.rotation.y += 0.01;
-
- }
-
- renderer.render( scene, camera );
- stats.update();
- }
- </script>
- </body>
- </html>
|