D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jbeuckm
Full window
Github gist
Hello, Three.js
<html> <head> <title>My first Three.js app</title> <style> body { margin: 0; } canvas { width: 100%; height: 100% } </style> </head> <body> <script src="https://rawgithub.com/mrdoob/three.js/master/build/three.js"></script> <script> var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); var renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); var tet = new THREE.Mesh( new THREE.TetrahedronGeometry(1), new THREE.MeshPhongMaterial({ ambient: 0xff0000, color: 0xdddddd, specular: 0x999999, shininess: 0, shading: THREE.FlatShading }) ); tet.position.set(-3, 0, 0); scene.add(tet); var cube = new THREE.Mesh( new THREE.CubeGeometry(1, 1, 1), new THREE.MeshPhongMaterial({ ambient: 0x00ff00, color: 0xdddddd, specular: 0x999999, shininess: 30, shading: THREE.FlatShading }) ); scene.add(cube); var oct = new THREE.Mesh( new THREE.OctahedronGeometry(1), new THREE.MeshPhongMaterial({ ambient: 0x0000ff, color: 0xdddddd, specular: 0x999999, shininess: 60, shading: THREE.FlatShading }) ); oct.position.set(3, 0, 0); scene.add(oct); var light = new THREE.PointLight(0xffffff, 1, 100); light.position.set(10, 10, 10); scene.add(light); var light = new THREE.AmbientLight(0x404040); // soft white light scene.add(light); camera.position.z = 5; var render = function () { requestAnimationFrame(render); cube.rotation.x += 0.02; cube.rotation.y += 0.02; tet.rotation.x -= .02; oct.rotation.x += .02; renderer.render(scene, camera); }; render(); </script> </body> </html>
https://rawgithub.com/mrdoob/three.js/master/build/three.js