Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions examples/webgl_shadowmap_pointlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
var camera, scene, renderer, stats;
var pointLight, pointLight2;
var torusKnot;
var cubeMaterial;
var torusKnotMaterial;
var wallMaterial;
var ground;

Expand All @@ -59,7 +59,7 @@
function initScene() {

camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set( 0, 10, 40 );
camera.position.set( 0, 10, 60 );

scene = new THREE.Scene();
scene.add( new THREE.AmbientLight( 0x222233 ) );
Expand All @@ -70,12 +70,12 @@

var pointLight = new THREE.PointLight( color, 1, 30 );
pointLight.castShadow = true;
pointLight.shadowCameraNear = 1;
pointLight.shadowCameraFar = 30;
pointLight.shadow.camera.near = 1;
pointLight.shadow.camera.far = 30;
// pointLight.shadowCameraVisible = true;
pointLight.shadowBias = 0.01;
pointLight.shadow.bias = 0.01;

var geometry = new THREE.SphereGeometry( 0.3, 32, 32 );
var geometry = new THREE.SphereGeometry( 0.3, 12, 6 );
var material = new THREE.MeshBasicMaterial( { color: color } );
var sphere = new THREE.Mesh( geometry, material );
pointLight.add( sphere );
Expand All @@ -84,35 +84,37 @@

}

pointLight = createLight( 0xffffff );
pointLight = createLight( 0xaaffaa );
scene.add( pointLight );

pointLight2 = createLight( 0xff0000 );
pointLight2 = createLight( 0xaaaaff );
scene.add( pointLight2 );

cubeMaterial = new THREE.MeshPhongMaterial( {
torusKnotMaterial = new THREE.MeshPhongMaterial( {
color: 0xff0000,
shininess: 50,
shininess: 100,
//wireframe: true,
//wireframeLinewidth: 2,
specular: 0x222222
} );

var torusGeometry = new THREE.TorusKnotGeometry( 14, 1, 150, 20 );
torusKnot = new THREE.Mesh( torusGeometry, cubeMaterial );
torusKnot.position.set( 0, 5, 0 );
var torusKnotGeometry = new THREE.TorusKnotGeometry( 8, 1, 150, 20 );
torusKnot = new THREE.Mesh( torusKnotGeometry, torusKnotMaterial );
torusKnot.position.set( 0, 9, 0 );
torusKnot.castShadow = true;
torusKnot.receiveShadow = true;
scene.add( torusKnot );

wallMaterial = new THREE.MeshPhongMaterial( {
color: 0xa0adaf,
color: 0xffffff,
shininess: 10,
specular: 0x111111,
shading: THREE.SmoothShading
} );

var wallGeometry = new THREE.BoxGeometry( 10, 0.15, 10 );
ground = new THREE.Mesh( wallGeometry, wallMaterial );
ground.position.set( 0, -5, 0 );
ground.position.set( 0, - 5, 0 );
ground.scale.multiplyScalar( 3 );
ground.receiveShadow = true;
scene.add( ground );
Expand All @@ -124,7 +126,7 @@
scene.add( ceiling );

var wall = new THREE.Mesh( wallGeometry, wallMaterial );
wall.position.set( -14, 10, 0 );
wall.position.set( - 14, 10, 0 );
wall.rotation.z = Math.PI / 2;
wall.scale.multiplyScalar( 3 );
wall.receiveShadow = true;
Expand All @@ -138,29 +140,18 @@
scene.add( wall );

wall = new THREE.Mesh( wallGeometry, wallMaterial );
wall.position.set( 0, 10, -14 );
wall.position.set( 0, 10, - 14 );
wall.rotation.y = Math.PI / 2;
wall.rotation.z = Math.PI / 2;
wall.scale.multiplyScalar( 3 );
wall.receiveShadow = true;
scene.add( wall );

/*
wall = new THREE.Mesh( wallGeometry, wallMaterial );
wall.scale.multiplyScalar( 3 );
wall.castShadow = false;
wall.receiveShadow = true;
scene.add( wall );
wall.position.set( 0, 10, 14 );
wall.rotation.y = Math.PI / 2;
wall.rotation.z = Math.PI / 2;
*/

}

function initMisc() {

renderer = new THREE.WebGLRenderer();
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setClearColor( 0x000000 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
Expand All @@ -169,6 +160,9 @@

// Mouse control
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.minDistance = 12;
controls.maxDistance = 60;
controls.enablePan = false;
controls.target.set( 0, 10, 0 );
controls.update();

Expand Down