forked from erichlof/THREE.js-PathTracing-Renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Planet_Rendering.html
86 lines (77 loc) · 2.86 KB
/
Planet_Rendering.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js PathTracing Renderer - Planet Rendering (preview - WIP)</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<link href="css/default.css" rel="stylesheet"/>
</head>
<body>
<div id="container"> </div>
<div id="info">three.js PathTracing Renderer - Planet Rendering (preview - WIP)</div>
<button id="cameraPosButton" class="toggleButton" onclick="toggleCameraPos()">Teleport to Surface</button>
<button id="timePauseButton" class="toggleButton" onclick="toggleTimePause()">Pause Time</button>
<div id="cameraInfo"> </div>
<script src="js/three.min.js"> </script>
<!-- <script src="js/FirstPersonCameraControls.js"> </script> -->
<script>
// this demo's camera code requires a slight change to yawObject.rotation, as seen below
var FirstPersonCameraControls = function ( camera ) {
camera.rotation.set( 0, 0, 0 );
var pitchObject = new THREE.Object3D();
pitchObject.add( camera );
var yawObject = new THREE.Object3D();
yawObject.add( pitchObject );
var movementX = 0;
var movementY = 0;
var onMouseMove = function ( event ) {
if (isPaused)
return;
movementX = event.movementX || event.mozMovementX || 0;
movementY = event.movementY || event.mozMovementY || 0;
/// yawObject.rotation.y -= movementX * 0.002;
yawObject.rotateOnWorldAxis(yawObject.up, -movementX * 0.002);
pitchObject.rotation.x -= movementY * 0.002;
// clamp the camera's vertical movement (around the x-axis) to the scene's 'ceiling' and 'floor'
pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
};
document.addEventListener( 'mousemove', onMouseMove, false );
this.getObject = function () {
return yawObject;
};
this.getYawObject = function () {
return yawObject;
};
this.getPitchObject = function () {
return pitchObject;
};
this.getDirection = function() {
var te = pitchObject.matrixWorld.elements;
return function( v ) {
v.set( te[ 8 ], te[ 9 ], te[ 10 ] ).negate();
return v;
};
}();
this.getUpVector = function() {
var te = pitchObject.matrixWorld.elements;
return function( v ) {
v.set( te[ 4 ], te[ 5 ], te[ 6 ] );
return v;
};
}();
this.getRightVector = function() {
var te = pitchObject.matrixWorld.elements;
return function( v ) {
v.set( te[ 0 ], te[ 1 ], te[ 2 ] );
return v;
};
}();
};
</script>
<script src="js/MobileJoystickControls.js"> </script>
<script src="js/stats.min.js"> </script>
<script src="js/PathTracingCommon.js"> </script>
<script src="js/InitCommon.js"> </script>
<script src="js/Planet_Rendering.js"> </script>
</body>
</html>