-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathareaLight.html
89 lines (79 loc) · 2.85 KB
/
areaLight.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Hilo3d AreaLight example</title>
<link rel="stylesheet" type="text/css" href="./example.css">
</head>
<body>
<div id="container"></div>
<script src="../build/Hilo3d.js"></script>
<script src="./js/stats.js"></script>
<script src="./js/OrbitControls.js"></script>
<script src="./js/init.js"></script>
<script>
var box = new Hilo3d.Mesh({
geometry:new Hilo3d.BoxGeometry(),
material:new Hilo3d.PBRMaterial({
baseColor:new Hilo3d.Color(1, 1, 1)
}),
rotationY:30,
rotationX:30,
onUpdate:function(){
this.rotationY ++;
}
}).addTo(stage).setScale(10);
var plane = new Hilo3d.Mesh({
geometry: new Hilo3d.PlaneGeometry(),
material:new Hilo3d.PBRMaterial({
baseColor:new Hilo3d.Color(1, 1, 1),
side:Hilo3d.constants.FRONT_AND_BACK
}),
rotationX:90
}).addTo(stage).setScale(2000, 2000, 1);
var num = 6;
while(num --) {
var areaLight = new Hilo3d.AreaLight({
color: new Hilo3d.Color(Math.random(), Math.random(), Math.random()),
x: 5,
y: 5,
z: 0,
amount:10,
rotationX:90,
startAngle:num * Math.PI * 2 / 6,
width:5 + Math.random() * 2,
height:5,
onUpdate:function(){
var t = ( Date.now() / 2000 + this.startAngle);
var r = 12.0;
var lx = r * Math.cos( t );
var lz = r * Math.sin( t );
var ly = (5.0 + 5.0 * Math.sin( t * 5 )) * 0.5 + this.height * 0.5;
this.setPosition( lx, ly, lz );
this.lookAt( box );
}
}).addTo(stage)
var areaLightMesh = new Hilo3d.Mesh({
geometry:new Hilo3d.PlaneGeometry(),
material:new Hilo3d.BasicMaterial({
diffuse:areaLight.color,
lightType:'NONE',
side:Hilo3d.constants.FRONT_AND_BACK
})
});
areaLightMesh.scaleX = areaLight.width;
areaLightMesh.scaleY = areaLight.height;
areaLight.addChild( areaLightMesh );
}
camera.fov = 45;
camera.near = 1;
camera.far = 1000;
camera.setPosition(0, 20, 35);
camera.lookAt(box);
stage.clearColor.set(1, 1, 1, 1);
directionLight.amount = 0;
ambientLight.amount = 0;
</script>
</body>
</html>