forked from liuli4016/plumeviz_webgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
computetri.html
60 lines (42 loc) · 1.98 KB
/
computetri.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
<html lang="en">
<head>
<title>triangulate</title>
<meta charset="utf-8">
<script type="text/javascript" src="../eddyview/three.js"></script>
<script type="text/javascript" src="../eddyview/delaunay.js"></script>
</head>
<body>
<p id="demo"></p>
<script type= "text/javascript">
var xhttp = new XMLHttpRequest();
var vertices = [];
var printstring = "";
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
var pattern, result;
// float float float
pattern = /([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)/g;
while ( ( result = pattern.exec( this.responseText ) ) != null )
{
vertices.push( new THREE.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])) );
}
var triangles = triangulate(vertices);
//console.log(triangles);
for (var i=0; i<triangles.length; i++)
{
var currentline = triangles[i].v2.x + ' ' + triangles[i].v2.y + ' ' + triangles[i].v2.z + ' ' + triangles[i].v1.x + ' ' + triangles[i].v1.y + ' ' + triangles[i].v1.z + ' ' + triangles[i].v0.x + ' ' + triangles[i].v0.y + ' ' + triangles[i].v0.z + "<br />";
printstring = printstring + currentline;
}
document.getElementById("demo").innerHTML = printstring;
//console.log(printstring);
}
};
xhttp.open("GET", "covisbathy.txt", true);
xhttp.send();
//document.getElementById("demo").innerHTML = printstring;
</script>
<body>
</body>
</html>