-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonClickerTest.html
More file actions
132 lines (105 loc) · 4.56 KB
/
CommonClickerTest.html
File metadata and controls
132 lines (105 loc) · 4.56 KB
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
<!-- Copyright 2019 Bhautik J Joshi bjoshi@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Common Clicker Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #fff;
color: #000;
margin: 0px;
overflow: hidden;
}
#info {
color: #000;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
display:block;
}
#info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
</style>
</head>
<body>
<div id="info">
Shared Engine Test
</div>
<!-- common -->
<script src="https://cdn.rawgit.com/mrdoob/three.js/r95/build/three.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/r95/examples/js/vr/WebVR.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/r95/examples/js/controls/OrbitControls.js"></script>
<!-- <script src="https://raw.githubusercontent.com/bhautikj/THREE.VRController/master/VRController.js"></script> -->
<script src="../THREE.VRController/VRController.js"></script>
<script src="VRCommonClicker.js"></script>
<script src="VRTextPanel.js"></script>
<script src="VRSceneStager.js"></script>
<script>
var container = document.createElement( 'div' );
document.body.appendChild( container );
var supportsVR = false;
if (navigator.getVRDisplays)
supportsVR = true;
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 500 );
var scene = new THREE.Scene();
if (!supportsVR)
scene.background = new THREE.Color( 0xffffff );
else
scene.background = new THREE.Color( 0xffdddd );
var ambient = new THREE.AmbientLight( 0x666666 );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0x887766 );
directionalLight.position.set( - 1, 1, 1 ).normalize();
scene.add( this.directionalLight );
var renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( this.renderer.domElement );
var onWindowResize = function() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
window.addEventListener( 'resize', onWindowResize, false );
var populateInteractionTargetsRandomly = function(num, scene) {
var scope = THREE.CommonClicker;
var MeshStandardMaterial = new THREE.MeshStandardMaterial({color: 0xFFEEEE});
for ( var i = 0; i < num; i++ ) {
var cubeMesh = new THREE.Mesh(
new THREE.BoxGeometry( 0.5, 0.5, 0.5 ),
new THREE.MeshStandardMaterial({color: 0xFFEEEE})
);
cubeMesh.position.x = Math.random() * 10 - 5;
cubeMesh.position.y = Math.random() * 10 - 5;
cubeMesh.position.z = Math.random() * 10 - 5;
scope.InteractionTargets.push(cubeMesh);
scene.add(cubeMesh);
cubeMesh.userData.clickCallback = function(obj) {
obj.material.color.setHex( 0x99FF99 );
};
}
}
populateInteractionTargetsRandomly (40, scene);
THREE.CommonClicker.Init(scene, camera, renderer);
var render = function () {
THREE.CommonClicker.UpdateText([Date.now()]);
THREE.CommonClicker.Update();
renderer.render( scene, camera );
}
renderer.setAnimationLoop( render );
</script>
</body>
</html>