diff options
author | James Graham <james@hoppipolla.co.uk> | 2015-03-27 09:18:12 +0000 |
---|---|---|
committer | James Graham <james@hoppipolla.co.uk> | 2015-04-03 23:29:19 +0100 |
commit | 2c9faf5363be229498578bdeca55c0c52730f0fa (patch) | |
tree | e070d5d12a587f1e1939410b2cd88450543d7534 /tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js | |
parent | 1a81b18b9f22d7bc1a967d08fcc7fbcf2ee200f5 (diff) | |
download | servo-2c9faf5363be229498578bdeca55c0c52730f0fa.tar.gz servo-2c9faf5363be229498578bdeca55c0c52730f0fa.zip |
Update CSS tests to revision 31d63cc79bd4c929ed582229e936d7b389f3e6ab
Diffstat (limited to 'tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js')
-rw-r--r-- | tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js b/tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js new file mode 100644 index 00000000000..10b045301c4 --- /dev/null +++ b/tests/wpt/css-tests/css-transforms-1_dev/xhtml1/support/static-cube.js @@ -0,0 +1,52 @@ +// This source is the javascript needed to build a simple moving +// cube in **three.js** based on this +// [example](https://raw.github.com/mrdoob/three.js/r44/examples/canvas_geometry_cube.html) +// It is the source about this [blog post](/blog/2011/08/06/lets-do-a-cube/). + +// ## Now lets start + +// declare a bunch of variable we will need later +var container; +var camera, scene, renderer; +var cube; + +// ## Initialize everything +function init() { + // create the camera + camera = new THREE.Camera( 70, 4/3, 100, 1000 ); + camera.position.z = 350; + + // create the Scene + scene = new THREE.Scene(); + + // create the Cube + cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200 ), new THREE.MeshNormalMaterial() ); + + // add the object to the scene + scene.addObject( cube ); + + // create the container element + container = document.querySelector("#container"); + + // init the WebGL renderer and append it to the Dom + renderer = new THREE.WebGLRenderer(); + renderer.setSize( container.getBoundingClientRect().width, container.getBoundingClientRect().height ); + container.appendChild( renderer.domElement ); +} + + +// ## Render the 3D Scene +function render() { + // animate the cube + cube.rotation.x = 0.5; + cube.rotation.y = 0.8; + cube.rotation.z = 0.2; + + // actually display the scene in the DOM element + renderer.render( scene, camera ); +} + +document.addEventListener("DOMContentLoaded", function() { + init(); + render(); +})
\ No newline at end of file |