forked from tentone/potree-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
138 lines (114 loc) · 4.12 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Potree-Core Example</title>
</head>
<body style="background-color: #000000">
<script src="lib/threejs/three.min.js"></script>
<script src="lib/threejs/OrbitControls.js"></script>
<script src="build/potree.min.js"></script>
<script>
document.body.onload = function()
{
//three.js
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, 1, 0.1, 1000);
var canvas = document.createElement("canvas");
canvas.style.position = "absolute";
canvas.style.top = "0px";
canvas.style.left = "0px";
canvas.style.width = "100%";
canvas.style.height = "100%";
document.body.appendChild(canvas);
var renderer = new THREE.WebGLRenderer(
{
canvas: canvas,
alpha: true,
logarithmicDepthBuffer: true,
context: null,
precision: "highp",
premultipliedAlpha: true,
antialias: true,
preserveDrawingBuffer: false,
powerPreference: "high-performance"
});
var geometry = new THREE.BoxBufferGeometry(25, 1, 25);
var material = new THREE.MeshBasicMaterial({color: 0x44AA44});
var cube = new THREE.Mesh(geometry, material);
cube.position.y = -2;
scene.add(cube);
scene.add(new THREE.AmbientLight(0xffffff));
var controls = new THREE.OrbitControls(camera, canvas);
camera.position.z = 10;
var raycaster = new THREE.Raycaster();
raycaster.params.Points.threshold = 1e-2;
var normalized = new THREE.Vector2();
canvas.onmousemove = function(event)
{
normalized.set((event.clientX / canvas.width) * 2 - 1, -(event.clientY / canvas.height) * 2 + 1);
raycaster.setFromCamera(normalized, camera);
}
canvas.ondblclick = function(event)
{
var intesects = raycaster.intersectObject(scene, true);
if(intesects.length > 0)
{
var geometry = new THREE.SphereBufferGeometry(0.1, 32, 32);
var material = new THREE.MeshBasicMaterial({color: 0xAA4444});
var sphere = new THREE.Mesh(geometry, material);
sphere.position.copy(intesects[0].point);
scene.add(sphere);
}
}
Potree.Global.workerPath = "./source";
loadPointCloud("data/lion_takanawa_ept_laz/ept.json", new THREE.Vector3(-4, -4, 3.0));
loadPointCloud("data/lion_takanawa_ept_bin/ept.json", new THREE.Vector3(-11, -4, 3.0));
loadPointCloud("data/lion_takanawa/cloud.js", new THREE.Vector3(-2, -3, 0.0));
loadPointCloud("data/lion_takanawa_las/cloud.js", new THREE.Vector3(3, -3, 0.0));
loadPointCloud("data/lion_takanawa_laz/cloud.js", new THREE.Vector3(8, -3, 0.0));
//loadPointCloud("http://arena4d.uksouth.cloudapp.azure.com:8080/4e5059c4-f701-4a8f-8830-59e78a2c0816/BLK360 Sample.vpc");
//"http://5.9.65.151/mschuetz/potree/resources/pointclouds/faro/skatepark/cloud.js"
//"http://5.9.65.151/mschuetz/potree/resources/pointclouds/weiss/subseamanifold2/cloud.js"
function loadPointCloud(url, position)
{
Potree.loadPointCloud(url, "pointcloud", function(e)
{
var points = new Potree.Group();
points.material.opacity = 1.0;
points.material.wireframe = true;
scene.add(points);
var pointcloud = e.pointcloud;
if(position !== undefined)
{
pointcloud.position.copy(position);
}
var material = pointcloud.material;
material.size = 2;
material.pointColorType = Potree.PointColorType.RGB; //RGB | DEPTH | HEIGHT | POINT_INDEX | LOD | CLASSIFICATION
material.pointSizeType = Potree.PointSizeType.ADAPTIVE; //ADAPTIVE | FIXED
material.shape = Potree.PointShape.CIRCLE; //CIRCLE | SQUARE
points.add(pointcloud);
});
}
function loop()
{
cube.rotation.y += 0.01;
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(loop);
};
loop();
document.body.onresize = function()
{
var width = window.innerWidth;
var height = window.innerHeight;
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
document.body.onresize();
};
</script>
</body>
</html>