-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
146 lines (95 loc) · 6.02 KB
/
index.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<script src="js/aframe-extras.js"></script>
<script src="js/aframe-text-geometry-component.min.js"></script>
<script>
var prevData = "clip: idle; crossFadeDuration: .3";;
var listenerAdded = false;
var scene = document.querySelector('a-scene');
var playOnce = false;
AFRAME.registerComponent('animation-control', {
schema: {default: ''},
init() {
const bot = document.querySelector('#bot');
var jumpBut = document.querySelector('#jump');
var runBut = document.querySelector('#run');
var walkBut = document.querySelector('#walk');
var idleBut = document.querySelector('#idle');
var scene = document.querySelector('a-scene');
this.el.addEventListener('click', () => {
if (this.el != jumpBut){
bot.setAttribute("animation-mixer",this.data);
scene.removeEventListener('animation-loop', jumpTrans);
prevData = this.data;
}
if (this.el == jumpBut) {
bot.setAttribute("animation-mixer",this.data);
var jumpTrans = function () {scene.removeEventListener('animation-loop',jumpTrans); bot.setAttribute("animation-mixer",prevData);console.log("scene ="+scene); console.log("fire")};
console.log("prev data from jump button = "+prevData);
setTimeout (function(){scene.addEventListener('animation-loop',jumpTrans);},500);
}
});
}
});
</script>
</head>
<body>
<a-scene>
<a-assets>
<img id="sky" src="tex/space.jpg">
<img id="grid" src="tex/gridPattern.png" >
<img id="pink" src="tex/pink.jpg">
<img id="chrome" src="tex/chrome.jpg">
<a-asset-item id="dawningFont" src="font/dawningOfANewDayRegular.typeface.json"></a-asset-item>
<a-asset-item id="exoFont" src="font/exo2Black.typeface.json"></a-asset-item>
<a-asset-item id="exoItalicFont" src="font/Fexo2BlackItalic.typeface.json"></a-asset-item>
</a-assets>
<a-entity id ="bot"
cursor-listener
scale="3.5 3.5 3.5"
position="0 1 -2.5"
rotation="0 0 0"
animation-mixer="clip: idle"
json-model="src: url(models/bot4.json);"
></a-entity>
<a-camera position="0 2 4">
<a-entity
raycaster="objects: .clickable"
cursor="fuse: true; fuseTimeout: 500"
position="0 0 -1"
geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03"
material="color: green; shader: flat">
<a-animation begin="click" easing="ease-in" attribute="scale"
fill="backwards" from="0.1 0.1 0.1" to="1 1 1"></a-animation>
<a-animation begin="cursor-fusing" easing="ease-in" attribute="scale"
fill="forwards" from="1 1 1" to="0.1 0.1 0.1"></a-animation>
</a-entity>
</a-camera>
<a-sky src="#sky" rotation="0 -90 0"></a-sky>
<a-entity position="-4 1 -6" rotation="5 0 0">
<a-entity
rotation="0 0 0"
position="-2 8 0"
text-geometry="value: Character Controls; font: #dawningFont; bevelEnabled: true; bevelSize: 0.05; bevelThickness: 0.05; curveSegments: 12; size: 1.2; height: 0;"
material="color:lavenderblush; metalness:1; roughness: 0; sphericalEnvMap: #pink;"
></a-entity>
<a-entity id= "run" class="clickable" animation-control="clip: run; crossFadeDuration: .3" position="1 3 4" rotation="0 0 0" scale="0.5 .6 .3" text-geometry="value: RUN; font: #exoFont; bevelEnabled: true; bevelSize: 0.1; bevelThickness: 0.1; curveSegments: 1; size: 1; height: 0.5;" material="color:pink; metalness:0.9; roughness: 0.05; sphericalEnvMap: #chrome;"></a-entity>
<a-entity id= "walk" class="clickable" animation-control="clip: walk; crossFadeDuration: .3" position="5.5 3 4" rotation="0 0 0" scale="0.5 .6 .3" text-geometry="value: WALK; font: #exoFont; bevelEnabled: true; bevelSize: 0.1; bevelThickness: 0.1; curveSegments: 1; size: 1; height: 0.5;" material="color:pink; metalness:0.9; roughness: 0.05; sphericalEnvMap: #chrome;"></a-entity>
<a-entity id= "jump" class="clickable" animation-control="clip: jump; crossFadeDuration: .3;" position="5.5 4 4" rotation="0 0 0" scale="0.5 .6 .3" text-geometry="value: JUMP; font: #exoFont; bevelEnabled: true; bevelSize: 0.1; bevelThickness: 0.1; curveSegments: 1; size: 1; height: 0.5;" material="color:pink; metalness:0.9; roughness: 0.05; sphericalEnvMap: #chrome;"></a-entity>
<a-entity id="idle" class="clickable" animation-control="clip: idle; crossFadeDuration: .3" position="1 4 4" rotation="0 0 0" scale="0.5 .6 .3" text-geometry="value: IDLE; font: #exoFont; bevelEnabled: true; bevelSize: 0.1; bevelThickness: 0.1; curveSegments: 1; size: 1; height: 0.5;" material="color:pink; metalness:0.9; roughness: 0.05; sphericalEnvMap: #chrome;"></a-entity>
</a-entity>
<a-entity
geometry="primitive: plane; width: 10000; height: 10000;" rotation="-90 0 0"
material="src: #grid; repeat: 10000 10000; transparent: true;metalness:0.6; roughness: 0.4; sphericalEnvMap: #sky;"></a-entity>
<a-entity light="color: #ccccff; intensity: 1; type: ambient;" visible=""></a-entity>
<a-entity light="color: #ffaaff; intensity: 1.5" position="5 5 5"></a-entity>
<a-entity light="color: #8498b2; intensity: 0.5" position="-5 5 15"></a-entity>
<a-entity light="color: white; type: ambient;"></a-entity>
</a-scene>
<script>
//setTimeout(function(){ document.querySelector('#bot').setAttribute("animation-mixer","clip: jump; crossFadeDuration: .3"); },5000);
</script>
<body>
</html>