Skip to content

Commit

Permalink
Load images in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Nov 16, 2024
1 parent 7e83600 commit be861e7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions resources/js/globe.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import * as THREE from 'three';
import ThreeGlobe from 'three-globe';
import WebGL from 'three/addons/capabilities/WebGL.js';
import earthNight from '../../public/world/earth-night.jpg';
import earthTopology from '../../public/world/earth-topology.png';
// import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js';

if (! WebGL.isWebGL2Available()) {
const warning = THREE.WEBGL.getWebGLErrorMessage();
throw new Error(warning);
}

const node = document.getElementById('globe-visualization');
const data = JSON.parse(node.dataset.points);

const colorInterpolator = t => `rgba(255, 100, 50, ${ 1 - t })`;

const Globe = new ThreeGlobe()
.globeImageUrl('/world/earth-night.jpg')
.bumpImageUrl('/world/earth-topology.png')
// .globeImageUrl('/world/earth-night.jpg')
// .bumpImageUrl('/world/earth-topology.png')
.globeImageUrl(earthNight)
.bumpImageUrl(earthTopology)
.ringsData(data)
.ringColor(() => colorInterpolator)
.ringMaxRadius(() => 5)
Expand All @@ -23,7 +33,7 @@ const Globe = new ThreeGlobe()

// Setup renderer
const renderer = new THREE.WebGLRenderer({
// alpha: true,
alpha: true,
antialias: true,
});
renderer.setPixelRatio(window.devicePixelRatio);
Expand Down Expand Up @@ -88,7 +98,6 @@ function tick(timestamp) {
tick_count = Math.ceil(fps * seconds);
point_index = data.length <= (point_index + 1) ? 0 : point_index + 1;
current_step = 0;
// console.log({ item: data[point_index], fps });
}
}

Expand Down

0 comments on commit be861e7

Please sign in to comment.