1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <!doctype html> <html lang="en"> <head> <title>Test</title> <meta charset="utf-8"> </head> <body style="margin: 0;"> <script src="three.min.js"></script> <script src="ColladaLoader.js"></script> <script src="OrbitControls.js"></script> <script> var scene, camera, renderer; init(); animate(); function init() { scene = new THREE.Scene(); var WIDTH = window.innerWidth, HEIGHT = window.innerHeight; renderer = new THREE.WebGLRenderer({antialias:true}); renderer.setSize(WIDTH, HEIGHT); document.body.appendChild(renderer.domElement); camera = new THREE.PerspectiveCamera(45, WIDTH / HEIGHT, 0.1, 10000); camera.position.set(50,150,100); scene.add(camera); window.addEventListener('resize', function() { var WIDTH = window.innerWidth, HEIGHT = window.innerHeight; renderer.setSize(WIDTH, HEIGHT); camera.aspect = WIDTH / HEIGHT; camera.updateProjectionMatrix(); }); var light = new THREE.PointLight(0xfffff3, 0.8); light.position.set(-100,200,100); scene.add(light); var sphereSize = 1; var pointLightHelper = new THREE.PointLightHelper( light, sphereSize ); scene.add( pointLightHelper ); var light2 = new THREE.PointLight(0xd7f0ff, 0.2); light2.position.set(200,200,100); scene.add(light2); var sphereSize = 1; var pointLightHelper2 = new THREE.PointLightHelper( light2, sphereSize ); scene.add( pointLightHelper2 ); var light3 = new THREE.PointLight(0xFFFFFF, 0.5); light3.position.set(150,200,-100); scene.add(light3); var sphereSize = 1; var pointLightHelper3 = new THREE.PointLightHelper( light3, sphereSize ); scene.add( pointLightHelper3 ); var loader = new THREE.ColladaLoader(); loader.options.convertUpAxis = true; loader.load( 'a.dae', function ( collada ) { var dae = collada.scene; var skin = collada.skins[ 0 ]; dae.position.set(0,0,0); dae.scale.set(1.5,1.5,1.5); scene.add(dae); var axes = new THREE.AxisHelper(50); axes.position = dae.position; scene.add(axes); var gridXZ = new THREE.GridHelper(100, 10); gridXZ.setColors( new THREE.Color(0x8f8f8f), new THREE.Color(0x8f8f8f) ); gridXZ.position.set(0,0,0 ); scene.add(gridXZ); }); controls = new THREE.OrbitControls(camera, renderer.domElement); } function animate() { requestAnimationFrame(animate); renderer.render(scene, camera); controls.update(); } </script> </body> </html>
|