-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
69 lines (62 loc) · 1.45 KB
/
main.js
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
var geometryList = [
"BoxGeometry",
"CapsuleGeometry",
"CircleGeometry",
"ConeGeometry",
"CylinderGeometry",
//"EdgesGeometry",
"ExtrudeGeometry",
"IcosahedronGeometry",
"LatheGeometry",
"OctahedronGeometry",
"PlaneGeometry",
//"PolyhedronGeometry",
"DodecahedronGeometry",
"RingGeometry",
"ShapeGeometry",
"SphereGeometry",
"TetrahedronGeometry",
"TorusGeometry",
"TorusKnotGeometry",
"TubeGeometry"
];
var url = 'https://threejs.org/docs/scenes/geometry-browser.html#'
function isVisible(ele) {
var rect = ele.getBoundingClientRect();
return rect.top > -rect.height && rect.top < window.innerHeight;
}
window.onload = function() {
geometryList.map(type => {
var child = document.createElement("iframe");
container.appendChild(child);
if (!isVisible(child))
child.src = "";
else {
child.src = url + type;
}
child.id = type;
})
container.onscroll = function() {
geometryList.map(type => {
var child = document.getElementById(type);
if (!isVisible(child))
child.src = "";
else {
child.src = url + type;
}
})
}
document.getElementById("search").oninput = function() {
var filters = geometryList.filter(type => type.indexOf(this.value) >= 0);
if (filters.length < 1) {
this.style.color = "red";
return;
} else {
this.style.color = "black"
}
var elmnt = document.getElementById(filters[0]);
elmnt.scrollIntoView(true);
container.onscroll();
//window.scrollTo(0, elmnt.offsetTop);
}
}