Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREE included from npm #9

Closed
wants to merge 4 commits into from
Closed

THREE included from npm #9

wants to merge 4 commits into from

Conversation

atnartur
Copy link
Contributor

@atnartur atnartur commented Aug 5, 2016

I added requiring THREE.js from npm. I think it will be easier to connect the library. A lot of developers builds projects with build tools such as webpack. And this tools works very good with npm modules.

@mattdesl
Copy link
Contributor

mattdesl commented Aug 9, 2016

Directly depending on three is not a very good thing right now. ThreeJS does not yet follow semantic versioning and cannot support multiple versions in the same bundle (not that you would want it, since it's a huge library!). Its updates and changes are so frequent and widespread that I will have to constantly update this module to keep up. And because so many projects require forks of the ThreeJS code, it is better to place the burden on the user. This is a bit like how React is doing it, forcing a peer dependency, the only difference is we aren't using a real peerDependency because ThreeJS isn't following semver and because peerDependencies are just a pain in the ass to deal with.

Instead, my preferred approach is to have this in your root index.js script for browserify/webpack:

global.THREE = require('three');

This gives you the flexibility to later replace it with script tags, e.g. if you have a custom build of ThreeJS or need to attach some plugins to the THREE instance before running your bundled code.

<script src="three.js"></script>
<script src="three-extensions-and-plugins.js"></script>
<script src="bundle.js"></script>

Also see:
mattdesl/three-orbit-controls#17 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants