-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (85 loc) · 3.7 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
<!DOCTYPE html>
<html>
<head>
<title>sup</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script type="text/javascript" src="http://www.midijs.net/lib/midi.js"></script>
<script type="text/javascript" src="audio.js"></script>
<script type="text/javascript" src="sentiment.js"></script>
<script type="text/javascript" src="text.js"></script>
<a href="#" onClick="MIDIjs.play('test.mid');">Play Book</a>
<a href="#" onClick="MIDIjs.stop();">Stop</a>
<script src="THREE/three.js"></script>
<script src="THREE/textGeometry.js"></script>
<script src="THREE/fontUtils.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/fonts/optimer_regular.typeface.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/fonts/optimer_bold.typeface.js"></script>
<script>
// This is where stuff in our game will happen:
var screenW = window.innerWidth/2;
var screenH = window.innerHeight/2;
var spdx = 0,
spdy = 0;
mouseX = 0, mouseY = 0, mouseDown = false;
document.addEventListener('mousemove', function(event) {
mouseX = event.clientX;
mouseY = event.clientY;
}, false);
document.body.addEventListener("mousedown", function(event) {
mouseDown = true
}, false);
document.body.addEventListener("mouseup", function(event) {
mouseDown = false
}, false);
var scene = new THREE.Scene();
// This is what sees the stuff:
var camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 1, 2000);
camera.position.set (350, 0, 1000);
// This will draw what the camera sees onto the screen:
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var txt = "CHAPTER I. Down the Rabbit-Hole Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversations?' So she was considering in her own mind (as "
console.log(txt);
var textGeom = new THREE.TextGeometry(txt, {
font: 'optimer',
weight: 'bold',
size:200
});
var material2 = new THREE.MeshNormalMaterial();
var textMesh = new THREE.Mesh( textGeom, material2 );
console.log(textMesh.position.y);
textGeom.computeBoundingBox();
var textWidth = textGeom.boundingBox.max.x - textGeom.boundingBox.min.x;
textMesh.position.set( -0.5 * textWidth, 0, 60 );//left-rt/high/far
scene.add( textMesh );
pivot = new THREE.Object3D();
pivot.add( textMesh );
scene.add( pivot );
// Now, show what the camera sees on the screen:
renderer.render(scene, camera);
function animate() {
spdy = (screenH / 50 + mouseY) / 2000;
spdx = (screenW / 50 + mouseX) / 1000;
// rotate on mousedown
if (mouseDown) {
// textMesh.rotation.x = spdy;
pivot.rotation.x = spdy;
pivot.rotation.y = spdx;
}
camera.position.y -= 4;
requestAnimationFrame(animate);
render();
}
function render() {
// render
renderer.render(scene, camera);
}
animate();
</script>
</html>