vasturiano / three-globe

WebGL Globe Data Visualization as a ThreeJS reusable 3D object
https://vasturiano.github.io/three-globe/example/links/
MIT License
1.26k stars 149 forks source link

Unable to load three-globe in ObservableHQ #96

Open emileaben opened 3 months ago

emileaben commented 3 months ago

Describe the bug I'm unable to load three-globe in an ObservableHQ notebook

To Reproduce Steps to reproduce the behavior:

  1. Goto the observableHQ require-debugger Create a notebook on ObservableHQ
  2. Enter 'three-globe' in the search box there
  3. This shows that none of the module loading techniques tried there work

Expected behavior

When putting this javascript code in an ObservableHQ notebook cell, I would expect three-globe to load: ThreeGlobe = require('three-globe')

Desktop (please complete the following information):

Additional context I'm unsure to what extent this is an ObservableHQ or three-globe problem, but since ObservableHQ has this module-require debugger, which recommends asking module authors, I think it's reasonable to enquire here first on what the issue might be.

vasturiano commented 3 months ago

Emile!!! Fancy seeing you here. 😄

Ok, so I don't know for sure why Observable is choking on this pkg, but I highly suspect it's because it needs ThreeJS as peer dependency.

This means in order to get it to work inside Observable you need to somehow import the core of ThreeJS itself and then load this package. Normally in an app that's easily done via imports, but in the Observable env, I don't know. Maybe by loading it all into globals via UMDs but sounds tricky.

However, you might not need to bother with any of that, if you require instead the package globe.gl it comes already pre-packaged with its own version of ThreeJS, and you don't need to bother with scene / camera /renderer scaffoldings either.

Observable loads that pkg just fine, here's a notebook example that uses it: https://observablehq.com/@vasturiano/solar-terminator