-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (54 loc) · 2.05 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Three.js PLY Viewer</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/PLYLoader.js"></script>
<script src='ThreeCSG.js'></script>
<script>
let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
let renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
let controls = new THREE.OrbitControls(camera, renderer.domElement);
let ambientLight = new THREE.AmbientLight(0x404040, 2);
scene.add(ambientLight);
let directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
let plyLoader = new THREE.PLYLoader();
// Load 38.ply
plyLoader.load('38.ply', function(geometry) {
let mesh1Material = new THREE.MeshLambertMaterial({ color: 0xff0000 });
let mesh1 = new THREE.Mesh(geometry, mesh1Material);
mesh1.scale.set(0.01, 0.01, 0.01);
scene.add(mesh1);
});
// Load 73.ply
plyLoader.load('73.ply', function(geometry) {
let mesh2Material = new THREE.MeshLambertMaterial({ color: 0x00ff00 });
let mesh2 = new THREE.Mesh(geometry, mesh2Material);
mesh2.scale.set(0.01, 0.01, 0.01);
scene.add(mesh2);
});
camera.position.set(0, 0, 3);
camera.lookAt(0, 0, 0);
function animate() {
requestAnimationFrame(animate);
controls.update();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>