Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>JSFiddle Problem</title>
- </head>
- <style>
- body
- {
- position:absolute;
- left: 25%;
- margin: 0px;
- padding: 0px;
- }
- </style>
- <script src="http://stemkoski.github.io/Three.js/js/Three.js"></script>
- <body>
- <div id="container" style = "text-align: center;width: 100%;">
- </div>
- <script>
- // this function is executed on each animation frame
- function animate() {
- // render
- renderer.render(scene, camera);
- // request new frame
- requestAnimationFrame(function () {
- animate();
- });
- }
- // renderer
- var renderer = new THREE.WebGLRenderer({
- antialias: true
- }); //antialiasing on! :)
- renderer.setClearColor(0xADD8E6, 1); //made the colour for the sky blue
- renderer.setSize(720, 600);
- document.body.appendChild(renderer.domElement);
- // camera
- var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 800);
- camera.position.set(0, 150, 400);
- // scene
- var scene = new THREE.Scene();
- //CODE HERE
- var ashTexture = THREE.ImageUtils.loadTexture('http://www.mediafire.com/convkey/7344/ra2l3kgscpvjflafg.jpg');
- var ashMaterial = new THREE.SpriteMaterial({
- map: ashTexture
- });
- var imageWidth = ashMaterial.map.image.width;
- var imageHeight = ashMaterial.map.image.height;
- var Ash = new THREE.Sprite(ashMaterial);
- Ash.scale.set(2 * imageWidth, 2 * imageHeight, 1.0);
- Ash.position.set(100, 100, 0);
- scene.add(Ash);
- //CODE ENDS HERE
- // add subtle ambient lighting
- var ambientLight = new THREE.AmbientLight(0xbbbbbb);
- scene.add(ambientLight);
- // directional lighting
- var directionalLight = new THREE.DirectionalLight(0xffffff);
- directionalLight.position.set(1, 1, 1).normalize();
- scene.add(directionalLight);
- // start animation
- animate();
- </script>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement