run
stop
save file
clear code
// // THREE.js playground // =================== // // Write code in this box, out comes 3D WebGL! // Also, this code is auto-saved onto your device when you leave. // Pick right up from where you left! // Cool stuff: // Use Ctrl+B or Ctrl+Enter to run. Or click the buttons on the bottom left. // Click the bar with line numbers on it to toggle this box. // Suggestions? Mail boxmein at (domain). // // This function runs once before anything else. // Use it to do setup, performance intensive tasks, whatever! // // Arguments: // state :: Object -- store anything here, it'll surely be available in draw() // // Return true to never call draw() at all. // function setup(THREE, scene, camera, renderer, state) { // Set up a Scene! // Add a yellow point light state.light = new THREE.PointLight(0xFFFF00); state.light.position.set(10, 10, 10); scene.add(state.light); // Add a neutral kinda-white ambient light state.ambi = new THREE.AmbientLight(0x404040); scene.add(state.ambi); // Add a green cube state.geo = new THREE.BoxGeometry(1, 1, 1); state.material = new THREE.MeshLambertMaterial({color: 0x00FF00}); state.cube = new THREE.Mesh(state.geo, state.material); scene.add(state.cube); // Move the camera away camera.position.z = 5; // Movement magicks state.angspeed = 1; } // // This function runs once every frame. // Use it to do things that aren't as intense performance-wise. // // Arguments: // state :: Object (it's persistent-ish!) // dt :: Number (seconds since last invocation) // st :: Number (start time's javascript timestamp (unix * 1000)) // // Return true to stop ticking! // function draw(THREE, scene, camera, renderer, state, dt, st) { state.cube.rotation.y += state.angspeed * dt; }