How to make a class structure of three.js in a clean way

I have been working with three.js for a couple of months. However I always find that it is really messy. So I want to make my three.js codes clean. Anyone knows about this?

1 answer

  • answered 2020-06-27 05:42 manthrax

    depends what you're doing. for a simple singlepage one off effect.. just pile everything into the index.html

    For slightly larger apps I usually make a Viewer or App class that has the renderer, scene, camera, lights, etc, and pass that to some Component classes.

    For larger projects, you may benefit from decoupling rendering from data, maybe using an ECS like ECSY.