JSM: Documentation for importable examples

It’d be great to have ‘how to import this’ near the top of documentation for example files, as we add support for them. Like:

import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

We get enough questions here and in the forums where people are surprised something isn’t part of the core library, and this might help with some of that.

Author: Fantashit

3 thoughts on “JSM: Documentation for importable examples

  1. You know what… I think we should start converting all examples to <script type="module"> 😁

    Compatibility seems to be there: https://caniuse.com/#feat=es6-module

    We just lose IE11. But we kind of lost it already when using promises in GLTFLoader and using the loader in many of the examples.

    We may want to have a couple of examples using nomodule for testing IE11 though.

  2. Not that my opinion necessarily carries any weight, but as a new three.js user, I’m writing 100%% typescript and ES modules. I expect most new projects are at this point. Webpack and other tools can transpile back and add some polyfills for older browsers when needed (I think a lot of people care less & less — YMMV).

  3. As far as I can tell, ‘polyfilling’ modules for IE11 is not so simple and would result in code that doesn’t demonstrate real-world use.

    That being the case, do we still want to convert example HTML files to use ES modules?

    I think so. Yes.

Comments are closed.