-
Notifications
You must be signed in to change notification settings - Fork 1
/
shadowtest.html
98 lines (90 loc) · 3.87 KB
/
shadowtest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<html>
<head>
<script src="./vendor/three.js/Three.js"></script>
<script src="./vendor/jquery-1.7.js"></script>
<script>
$(function() {
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(document.body.clientWidth, document.body.clientHeight);
document.body.appendChild(renderer.domElement);
renderer.setClearColorHex(0xEEEEEE, 1.0);
renderer.clear();
//renderer.shadowCameraFov = 50;
//renderer.shadowMapWidth = 1024;;
//renderer.shadowMapHeight = 1024;
var fov = 45; // camera field-of-view in degrees
var width = renderer.domElement.width;
var height = renderer.domElement.height;
var aspect = width / height; // view aspect ratio
var near = 1; // near clip plane
var far = 10000; // far clip plane
var camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
camera.position.z = -90;
camera.position.x = 200;
camera.position.y = 50;
var scene = new THREE.Scene();
var plane = new THREE.Mesh(
new THREE.PlaneGeometry(400, 200, 10, 10),
new THREE.MeshLambertMaterial({color: 0xffffff}));
plane.rotation.x = -Math.PI/2;
plane.position.y = 0;
plane.receiveShadow = true;
scene.add(plane);
var light = new THREE.SpotLight();
light.castShadow = true;
light.position.set( 100, 200, 100 );
scene.add(light);
var litCube = new THREE.Mesh(
new THREE.CubeGeometry(50, 50, 50),
new THREE.MeshLambertMaterial({color: 0xffffff}));
litCube.position.y = 0;
litCube.position.x = 0;
litCube.position.z = 0;
litCube.castShadow = true;
scene.add(litCube);
renderer.shadowMapEnabled = true;
camera.lookAt(scene.position);
renderer.render(scene, camera);
/*
var paused = false;
var last = new Date().getTime();
var down = false;
var sx = 0, sy = 0;
window.onmousedown = function (ev){
down = true; sx = ev.clientX; sy = ev.clientY;
};
window.onmouseup = function(){ down = false; };
window.onmousemove = function(ev) {
if (down) {
var dx = ev.clientX - sx;
var dy = ev.clientY - sy;
camera.position.x += dx;
camera.position.y += dy;
sx += dx;
sy += dy;
}
}
function animate(t) {
if (!paused) {
last = t;
litCube.position.y = 60-Math.sin(t/900)*25;
litCube.position.x = Math.cos(t/600)*85;
litCube.position.z = Math.sin(t/600)*85;
litCube.rotation.x = t/500;
litCube.rotation.y = t/800;
renderer.clear();
camera.lookAt(scene.position);
renderer.render(scene, camera);
}
window.requestAnimationFrame(animate, renderer.domElement);
};
animate(new Date().getTime());
onmessage = function(ev) {
paused = (ev.data == 'pause');
};*/
});
</script>
</head>
<body>
</body>
</html>