-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviewer.php
executable file
·83 lines (60 loc) · 2.09 KB
/
viewer.php
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
<html>
<head>
<script src="js/three.min.js"></script>
<script src="js/STLLoader.js"></script>
<script src="js/OrbitControls.js"></script>
</head>
<body>
<script>
var container, camera, scene, renderer;
var orbitControls;
init();
animate();
function init(){
container=document.createElement('div');
document.body.appendChild(container);
camera=new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.set(3, 0.5, 3);
scene=new THREE.Scene();
// object
var loader=new THREE.STLLoader();
loader.addEventListener('load', function (event){
var geometry=event.content;
var material=new THREE.MeshLambertMaterial({ ambient: 0xFBB917,color: 0xfdd017 });
var mesh=new THREE.Mesh(geometry, material);
scene.add(mesh);});
//http://10.11.12.146/models/Aarakocra_body.stl
// STL file to be loaded
loader.load('models/Arakocra_body.stl');
controls = new THREE.OrbitControls(camera, container);
controls.autoRotate = true;
// lights
scene.add(new THREE.AmbientLight(0x736F6E));
var directionalLight=new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position=camera.position;
scene.add(directionalLight);
// renderer
renderer=new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);}
function addLight(x, y, z, color, intensity){
var directionalLight=new THREE.DirectionalLight(color, intensity);
directionalLight.position.set(x, y, z)
scene.add(directionalLight);}
function onWindowResize(){
camera.aspect=window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);}
function animate(){
requestAnimationFrame(animate);
render();
}
function render(){
var timer=Date.now() * 0.0005;
renderer.render(scene, camera);
renderer.setClearColor(0xf5f5f5, 1);
}
</script>
</body>
</html>