JavaScript三维模型库 Three.js
openkk
13年前
<p>Three.js 是一款运行在浏览器中的 3D 引擎,你可以用它创建各种三维场景,包括了摄影机、光影、材质等各种对象。你可以在它的主页上看到许多精采的演示。不过,这款引擎目前还处在比较不成熟的 开发阶段,其不够丰富的 API 以及匮乏的文档增加了初学者的学习难度(尤其是文档的匮乏)</p> <pre class="brush:javascript; toolbar: true; auto-links: false;"> var camera, scene, renderer, geometry, material, mesh; init(); animate(); function init() { scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 ); camera.position.z = 1000; scene.add( camera ); geometry = new THREE.CubeGeometry( 200, 200, 200 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); renderer = new THREE.CanvasRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); } function animate() { // Include examples/js/RequestAnimationFrame.js for cross-browser compatibility. requestAnimationFrame( animate ); render(); } function render() { mesh.rotation.x += 0.01; mesh.rotation.y += 0.02; renderer.render( scene, camera ); }</pre> <p></p> <p><a href="/misc/goto?guid=4959499270657509897"><img alt="equirectangular" src="https://a248.e.akamai.net/assets.github.com/img/0c4e6cea178ab2c375ae6ff9a06e6002bb756996/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f34345f6571756972656374616e67756c61722e706e67" width="109" height="82" /></a> <a href="/misc/goto?guid=4959499270738670397"><img alt="scissors" src="https://a248.e.akamai.net/assets.github.com/img/f39ff878ca4cad0ca35bab6eae1f80eb8c59667a/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f34325f73636973736f72732e706e67" width="109" height="82" /></a> <a href="/misc/goto?guid=4959499270824601272"><img alt="lookat" src="https://a248.e.akamai.net/assets.github.com/img/a6e81c613c79670e60a188528ecf73bc46362c4f/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f34315f6c6f6f6b61742e706e67" width="109" height="82" /></a> <a href="/misc/goto?guid=4959499270916216734"><img alt="video" src="https://a248.e.akamai.net/assets.github.com/img/cc9f9c9c4573307fa819ce7f0474dc42f43e8e40/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f34305f766964656f2e706e67" width="109" height="82" /></a> <a href="/misc/goto?guid=4959499271002332260"><img alt="dof" src="https://a248.e.akamai.net/assets.github.com/img/dccedf0c2ab4bdb84735ec30212b793eea35b9f5/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f33395f646f662e706e67" width="109" height="82" /></a> <a href="/misc/goto?guid=4959499271074323145"><img alt="ribbon" src="https://a248.e.akamai.net/assets.github.com/img/6775feb4216ba98d31a244171ec0886fa9b36e8f/687474703a2f2f6d72646f6f622e6769746875622e636f6d2f74687265652e6a732f6173736574732f6578616d706c65732f33385f726962626f6e2e706e67" width="109" height="82" /></a> <br /> 演示:http://mrdoob.github.com/three.js/<br /> <br /> </p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1323911983359" target="_blank">http://www.open-open.com/lib/view/home/1323911983359</a></p>