Three.js r125 generates a warning in Observable

If it’s safe to ignore the warnings, then you could probably just mess with window.__THREE__ after you imported the library.

Otherwise my first choice would probably be 3), passing in THREE. I’m not sure why you’d need to get the version number in this scenario:

  • If you pass in THREE, you’re already in control.
  • If you want to see the required version, you can inspect the notebook and optionally pin its version.

As for modules from examples, you’ll certainly have to restore any interface additions to the THREE object which are expected by the notebook (i.e., make sure all object types are available).

I’ve used the following format to deal with example modules:

function importExample(path, module = path.split('/').pop(), version = VERSION) {
  return import(`https://unpkg.com/three@${version}/examples/jsm/${path}.js`)
    .then(m => module ? m[module] : m);
}
OrbitControls = importExample('controls/OrbitControls')
Line2 = importExample('lines/Line2')
LineMaterial = importExample('lines/LineMaterial')
LineGeometry = importExample('lines/LineGeometry')