-
Notifications
You must be signed in to change notification settings - Fork 70
/
ambient-occlusion-test.html
72 lines (52 loc) · 1.39 KB
/
ambient-occlusion-test.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
<!DOCTYPE html>
<html>
<head>
<title>A-Frame - ambient occulusion</title>
<script src="js/aframe-master-v1.3.0.min.js"></script>
</head>
<body>
<script>
AFRAME.registerComponent("ambient-occulusion", {
schema: {
},
init: function()
{
let geometry = this.el.object3D.children[0].geometry;
// used by ambient occlusion texture
let uv2 = new Float32Array( [0,1, 1,1, 0,0, 1,0] );
// itemSize = 2 because there are 2 values (components) per vertex
geometry.setAttribute( 'uv2', new THREE.BufferAttribute( uv2, 2 ) );
},
play: function()
{
// setting "ambientOcclusionTextureRepeat" seems to have no effect,
// and can not run the code in init (too early?)
this.el.object3D.children[0].material.aoMap.repeat.set(1,1);
}
});
</script>
<a-scene>
<a-assets>
<img id="wallDiffuse" src="images/stone-wall-diffuse-256.jpg" />
<img id="wallNormal" src="images/stone-wall-normal-256.jpg" />
<img id="wallAO" src="images/ao-map.png" />
</a-assets>
<a-sky
color = "#001337">
</a-sky>
<a-plane
width="100" height="100"
position=" 0.00 0.00 0.00"
rotation="-90 0 0"
color="#666666">
</a-plane>
<a-plane
id="wall"
position="0 1.5 -2"
material="src: #wallDiffuse; normalMap: #wallNormal; repeat: 2 3;
ambientOcclusionMap: #wallAO; ambientOcclusionTextureRepeat: 1 1;"
ambient-occulusion>
</a-plane>
</a-scene>
</body>
</html>