Note that there are some explanatory texts on larger screens.

plurals
  1. POShadows dont work with three.js
    primarykey
    data
    text
    <p>Actually I'm new on <code>webGl</code> and specially with <code>three.js</code> and I'm trying to learn it while studying the examples from <a href="http://stemkoski.github.com/Three.js/" rel="nofollow">http://stemkoski.github.com/Three.js/</a>.</p> <p>Now my problem: I build up a little 3D Scene. A cube, a sphere, a floor and a pointlight. Now I want the pointlight to create shadows. I put this command "castShadow = true;" to cube, pointlight and sphere and then "receiveShadow = true;" to the floor. But no Shadow there.</p> <p>Hope someone could help me.</p> <p>other Question, Main Goal is to build up a house with windows and an animated light as the sun. That means that every mesh must cast shadows and also receive shadows. Is that possible?</p> <p>My Code:</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;style&gt; #container { background: #225; width: 400px; height: 300px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt; &lt;/div&gt; &lt;/body&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="js/Three.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // set the scene size var WIDTH = 400, HEIGHT = 400; // set some camera attributes var VIEW_ANGLE = 45, ASPECT = WIDTH / HEIGHT, NEAR = 0.1, FAR = 10000; var $container = $('#container'); // create a WebGL renderer, camera // and a scene var renderer = new THREE.WebGLRenderer(); var camera = new THREE.PerspectiveCamera( VIEW_ANGLE, ASPECT, NEAR, FAR); var scene = new THREE.Scene(); ///////////////////////// Camera ///////////////////// scene.add(camera); camera.position.set(180,-180,300); camera.lookAt(scene.position); ///////////////////////// Floor ///////////////////// var floorGeometry = new THREE.PlaneGeometry(200, 200); var floorMaterial = new THREE.MeshLambertMaterial( { color: 0x008800 } ); var floor = new THREE.Mesh(floorGeometry, floorMaterial); floor.position.set(0,0,-25); floor.rotation.set(0,0,0); floor.doubleSided = true; floor.receiveShadow = true; scene.add(floor); ///////////////////////// Cube ///////////////////// var cubeGeometry = new THREE.CubeGeometry( 50, 50, 50 ); var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x000088 } ); cube = new THREE.Mesh( cubeGeometry, cubeMaterial ); cube.position.set(0,0,0); cube.castShadow = true; scene.add(cube); ///////////////////////// Sphere ///////////////////// var sphereGeometry = new THREE.SphereGeometry(50, 16, 16); var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0xCC0000 }); sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); sphere.position.set(100,100,0); sphere.castShadow = true; scene.add(sphere); ///////////////////////// Point Light ///////////////////// var pointLight = new THREE.PointLight(0xFFFFFF); pointLight.position.set(50,50,130); pointLight.shadowCameraVisible = true; pointLight.shadowDarkness = 1; pointLight.intensity = 2; pointLight.castShadow = true; scene.add(pointLight); renderer.setSize(WIDTH, HEIGHT); $container.append(renderer.domElement); renderer.render(scene, camera); &lt;/script&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload