-
Notifications
You must be signed in to change notification settings - Fork 106
/
surfaceClosestPoint.html
70 lines (52 loc) · 2.14 KB
/
surfaceClosestPoint.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
<!DOCTYPE html>
<html>
<head>
<title>Closest Point to a Surface</title>
<script src="js/verb.min.js"></script>
<script src="js/three.min.js"></script>
<script src="js/verbToThreeConversion.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/codemirror.js"></script>
<script src="js/javascript.js"></script>
<script src="js/threeBasic.js"></script>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/codemirror.css">
<link rel="stylesheet" href="css/example.css">
<link rel="stylesheet" href="css/colorforth.css">
</head>
<body>
<div id="button">Show/Hide Code</div>
<div id="viewer" class="col">
<div id="title"></div>
</div>
<div id="code-container" class="col scroll-y"></div>
</body>
<script id="script">
setupScene();
var degree = 3
, knots = [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1]
, pts = [ [ [0, 0, -5], [10, 0, 0], [20, 0, 0], [30, 0, 0] , [40, 0, 0], [50, 0, 0] ],
[ [0, -10, 0], [10, -10, 10], [20, -10, 10], [30, -10, 0] , [40, -10, 0], [50, -10, 0] ],
[ [0, -20, 0], [10, -20, 10], [20, -20, 10], [30, -20, 0] , [40, -20, -2], [50, -20, -12] ],
[ [0, -30, 0], [10, -30, 0], [20, -30, -23], [30, -30, 0] , [40, -30, 0], [50, -30, 0] ],
[ [0, -40, 0], [10, -40, 0], [20, -40, 0], [30, -40, 4] , [40, -40, -20], [50, -40, 0] ],
[ [0, -50, 12], [10, -50, 0], [20, -50, 10], [30, -50, 0] , [50, -50, -3], [50, -50, -5] ], ];
var srf = verb.geom.NurbsSurface.byKnotsControlPointsWeights( degree, degree, knots, knots, pts );
var lineMat = new THREE.LineBasicMaterial();
var pts = [];
var c = 5;
for (var i = 0; i < c; i++){
for (var j = 0; j < c; j++){
var p0 = [60 * i / (c-1) - 10, -60 * j / (c-1) + 10, 7 ];
pts.push( p0 );
var p = srf.closestPoint( p0 );
var l = new verb.geom.Line(p, p0);
addCurveToScene( l.toThreeGeometry(), lineMat );
}
}
addPointsToScene( pts );
addMeshToScene( srf.toThreeGeometry() );
renderScene();
</script>
<script src="js/example.js"></script>
</html>