-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
173 lines (136 loc) · 5.42 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>CPS Post Dev Vector Visualiser</title>
<style>
body {
margin: 0;
}
canvas {
width: 100%;
height: 100%
}
</style>
</head>
<body>
<div id="app">
<form>
<!--<input v-model="euler1" value="">
<input v-model="euler2" value="">
<input v-model="euler3" value="">-->
</form>
<div id="container"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="src/three.js"></script>
<script src="src/TrackballControls.js"></script>
<script src="src/dat.gui.js"></script>
<script>
var camera, controls, scene, renderer;
var thing = {
message: 'dat.gui'
};
window.onload = function () {
var gui = new dat.GUI();
gui.add(thing, 'message');
};
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 3;
controls = new THREE.TrackballControls(camera);
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
controls.keys = [65, 83, 68];
controls.addEventListener('change', render);
scene = new THREE.Scene();
// lights
var light = new THREE.DirectionalLight(0xffffff);
light.position.set(1, 1, 1);
scene.add(light);
var light = new THREE.DirectionalLight(0x002288);
light.position.set(-1, -1, -1);
scene.add(light);
var light = new THREE.AmbientLight(0x222222);
scene.add(light);
//Geometry
var origin = new THREE.Vector3(0, 0, 0);
var origin2 = new THREE.Vector3(0, 0, 0);
var vectorX = new THREE.Vector3(1, 0, 0);
var vectorY = new THREE.Vector3(0, 1, 0);
var vectorZ = new THREE.Vector3(0, 0, 1);
var rot1 = THREE.Math.degToRad(10);
var rot2 = THREE.Math.degToRad(20);
var rot3 = THREE.Math.degToRad(30);
var vectorXdash = new THREE.Vector3(1, 0, 0);
var vectorYdash = new THREE.Vector3(0, 1, 0);
var vectorZdash = new THREE.Vector3(0, 0, 1);
rotation = new THREE.Euler(rot1, rot2, rot3, 'ZXZ');
vectorXdash.applyEuler(rotation);
vectorYdash.applyEuler(rotation);
vectorZdash.applyEuler(rotation);
var materialX = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(255, 0, 0)")
});
var materialY = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(0, 255, 0)")
});
var materialZ = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(0, 0, 255)")
});
var materialXdash = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(255, 150, 150)")
});
var materialYdash = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(150, 255, 150)")
});
var materialZdash = new THREE.LineBasicMaterial({
color: new THREE.Color("rgb(150, 150, 255)")
});
var geometryX = new THREE.Geometry();
var geometryY = new THREE.Geometry();
var geometryZ = new THREE.Geometry();
var geometryXdash = new THREE.Geometry();
var geometryYdash = new THREE.Geometry();
var geometryZdash = new THREE.Geometry();
geometryX.vertices.push(origin, vectorX);
geometryY.vertices.push(origin, vectorY);
geometryZ.vertices.push(origin, vectorZ);
geometryXdash.vertices.push(origin2, vectorXdash);
geometryYdash.vertices.push(origin2, vectorYdash);
geometryZdash.vertices.push(origin2, vectorZdash);
var axisX = new THREE.Line(geometryX, materialX);
var axisY = new THREE.Line(geometryY, materialY);
var axisZ = new THREE.Line(geometryZ, materialZ);
var axisXdash = new THREE.Line(geometryXdash, materialXdash);
var axisYdash = new THREE.Line(geometryYdash, materialYdash);
var axisZdash = new THREE.Line(geometryZdash, materialZdash);
scene.add(axisX, axisY, axisZ);
scene.add(axisXdash, axisYdash, axisZdash);
var axesHelper = new THREE.AxesHelper(5);
scene.add(axesHelper);
// renderer
renderer = new THREE.WebGLRenderer({ antialias: false });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
container = document.getElementById('container');
container.appendChild(renderer.domElement);
render();
}
function animate(time) {
requestAnimationFrame(animate);
controls.update();
}
function render() {
renderer.render(scene, camera);
}
</script>
</body>
</html>