# Extending Three.js

**URL:** <https://discourse.threejs.org/t/extending-three-js/19429>\
**Category:** Questions\
**Created:** [October 5, 2020, 3:17am UTC](https://discourse.threejs.org/t/extending-three-js/19429 "2020-10-05T03:17:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DefinitelyMaybe](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/definitelymaybe/32/8808_2.png) [@DefinitelyMaybe](https://discourse.threejs.org/u/DefinitelyMaybe)\
**Post date:** [October 5, 2020, 3:17am UTC](https://discourse.threejs.org/t/extending-three-js/19429/1 "2020-10-05T03:17:07Z")

</div>

Hey all!

So bits and pieces like: [https://github.com/mrdoob/three.js/issues/20455](https://github.com/mrdoob/three.js/issues/20455)  
show up from time to time and I myself am becoming more and more interested in reconfiguring parts of the library to suit my own preferences so naturally the question becomes “how do I do that?”

The current way that `build/three.js` is built is via rollup. I don’t know enough about that just yet but on face value it’s a bunch of regex’s parsing over the source scripts with file i/o form node.js to produce/write out a final script.

But that’s not exactly where I’m wanting to go. I’m playing around with cannon.js and creating new controls, and I feel like I’m in this weird development spot where I kind of want to fork the repo, change a bunch of things but not run it through rollup so I can work with changes I make directly, but then later on, when I might’ve nailed something down enough, I’d like to want to make a personal rollup build…

Did I not look hard enough through the doc’s/other related material?

See I feel like I’m might just be asking the wrong question because of seeing similar-ish question/answers like: [Extending PointLight uniforms](https://discourse.threejs.org/t/extending-pointlight-uniforms/10494/2)

---

<div class="post-metadata">

**Author:** ![mrdoob](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mrdoob/32/22417_2.png) [@mrdoob](https://discourse.threejs.org/u/mrdoob)\
**Post date:** [October 5, 2020, 12:47pm UTC](https://discourse.threejs.org/t/extending-three-js/19429/2 "2020-10-05T12:47:39Z")

</div>

There’s nothing wrong with forking the repo 🤓

---

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [October 6, 2020, 7:01am UTC](https://discourse.threejs.org/t/extending-three-js/19429/3 "2020-10-06T07:01:57Z")

</div>

Are you sure you will need to change anything in the core? Controls and physics can be implemented externally, like in the examples.

---

<div class="post-metadata">

**Author:** ![devingfx](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/devingfx/32/13661_2.png) [@devingfx](https://discourse.threejs.org/u/devingfx)\
**Post date:** [October 6, 2020, 11:03am UTC](https://discourse.threejs.org/t/extending-three-js/19429/4 "2020-10-06T11:03:50Z")

</div>

> [@DefinitelyMaybe](#):
>
> change a bunch of things but not run it through rollup so I can work with changes I make directly

Why do not run rollup? This is just a way of grouping everything in one file, but with confidence all dependencies are written in a good order…

You can make your changes and rollup every time a file is written to disk to be able to test! (See the rollup docs there should be a watch option)

If really the time consumed by rollup each time is a problem, you can add additional `<script>` after the one of `/build/three.js` to override some parts, but you have to be careful to not use `import xxx from xxx` in this file but replace it with the global object `let xxx = THREE.xxx` and then when you rollup, replace those lines with good module imports again…  
IMHO this is more work that using rollup…
