Skip to content

Commit d95adf6

Browse files
author
Zhanarbek Osmonaliev
committed
Add animate-in feature
1 parent c49cc59 commit d95adf6

File tree

3 files changed

+44
-39
lines changed

3 files changed

+44
-39
lines changed

main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
DirectionalLight,
77
Color,
88
Fog,
9-
AxesHelper,
10-
DirectionalLightHelper,
11-
CameraHelper,
9+
// AxesHelper,
10+
// DirectionalLightHelper,
11+
// CameraHelper,
1212
PointLight,
1313
SphereGeometry,
1414
} from "three";
@@ -98,38 +98,10 @@ function init() {
9898
// SECTION Globe
9999
function initGlobe() {
100100
// Initialize the Globe
101-
Globe = new ThreeGlobe()
102-
// .globeImageUrl(EarthDarkSkin)
103-
.arcsData(travelHistory.flights)
104-
.arcColor((e) => {
105-
return e.status ? "#9cff00" : "#FF4000";
106-
})
107-
.arcAltitude((e) => {
108-
return e.arcAlt;
109-
})
110-
.arcStroke((e) => {
111-
return e.status ? 0.5 : 0.3;
112-
})
113-
.arcDashLength(0.9)
114-
.arcDashGap(4)
115-
.arcDashAnimateTime(1000)
116-
.arcsTransitionDuration(1000)
117-
.arcDashInitialGap((e) => e.order * 1)
118-
.labelsData(airportHistory.airports)
119-
.labelColor(() => "#ffcb21")
120-
.labelDotOrientation((e) => {
121-
return e.text === "ALA" ? "top" : "right";
122-
})
123-
.labelDotRadius(0.3)
124-
.labelSize((e) => e.size)
125-
.labelText("city")
126-
.labelResolution(6)
127-
.labelAltitude(0.01)
128-
.pointsData(airportHistory.airports)
129-
.pointColor(() => "#ffffff")
130-
.pointsMerge(true)
131-
.pointAltitude(0.07)
132-
.pointRadius(0.05)
101+
Globe = new ThreeGlobe({
102+
waitForGlobeReady: true,
103+
animateIn: true,
104+
})
133105
.hexPolygonsData(countries.features)
134106
.hexPolygonResolution(3)
135107
.hexPolygonMargin(0.7)
@@ -144,6 +116,39 @@ function initGlobe() {
144116
} else return "rgba(255,255,255, 0.7)";
145117
});
146118

119+
setTimeout(() => {
120+
Globe.arcsData(travelHistory.flights)
121+
.arcColor((e) => {
122+
return e.status ? "#9cff00" : "#FF4000";
123+
})
124+
.arcAltitude((e) => {
125+
return e.arcAlt;
126+
})
127+
.arcStroke((e) => {
128+
return e.status ? 0.5 : 0.3;
129+
})
130+
.arcDashLength(0.9)
131+
.arcDashGap(4)
132+
.arcDashAnimateTime(1000)
133+
.arcsTransitionDuration(1000)
134+
.arcDashInitialGap((e) => e.order * 1)
135+
.labelsData(airportHistory.airports)
136+
.labelColor(() => "#ffcb21")
137+
.labelDotOrientation((e) => {
138+
return e.text === "ALA" ? "top" : "right";
139+
})
140+
.labelDotRadius(0.3)
141+
.labelSize((e) => e.size)
142+
.labelText("city")
143+
.labelResolution(6)
144+
.labelAltitude(0.01)
145+
.pointsData(airportHistory.airports)
146+
.pointColor(() => "#ffffff")
147+
.pointsMerge(true)
148+
.pointAltitude(0.07)
149+
.pointRadius(0.05);
150+
}, 1000);
151+
147152
Globe.rotateY(-Math.PI * (5 / 9));
148153
Globe.rotateZ(-Math.PI / 6);
149154
const globeMaterial = Globe.globeMaterial();
@@ -180,8 +185,8 @@ function onMouseMove(event) {
180185
function onWindowResize() {
181186
camera.aspect = window.innerWidth / window.innerHeight;
182187
camera.updateProjectionMatrix();
183-
windowHalfX = window.innerWidth / 2;
184-
windowHalfY = window.innerHeight / 2;
188+
windowHalfX = window.innerWidth / 1.5;
189+
windowHalfY = window.innerHeight / 1.5;
185190
renderer.setSize(window.innerWidth, window.innerHeight);
186191
}
187192

0 commit comments

Comments
 (0)