3dcitydb / 3dcitydb-web-map

Cesium-based 3D viewer and JavaScript API for the 3D City Database
Apache License 2.0
377 stars 125 forks source link

npm version and webpack build #34

Closed Tugark closed 1 month ago

Tugark commented 6 years ago

Hi there

(Beware, this could be a longer posting ;-)) As mentioned e.g. in https://github.com/3dcitydb/3dcitydb-web-map/pull/28#issuecomment-385880567, I worked on a webpack-friendly version of the library. The first version is done; however, I cannot easily open a pull-request since in order to have a working, clean library, we need to seperate the client from the library. See below for some thoughts about future developments.

What I've done is that I created a module of the library itself; this is prepared to be published as an npm package. As such, we would be able to use the 3dcitydb-web-map by using npm install 3dcitydb-web-map and develop it just like other libraries out there. You can find the module repository with a brief README here: https://github.com/Tugark/3dcitydb-npm

Since we also have the basic client (inside ./3dwebclient, mainly script.js), I also created this client as a webpack build. I exchanged the "official" script.js" with an index.js which includes all required node_modules as well as the above npm-version of the 3dcityb-library. This can then be compiled to app.js through webpack, while also copying the webworkers to the correct repositories. Please find the client and a README here: https://github.com/Tugark/3dcitydb-client

This is of course more a proof-of-concept and can certainly be optimized in various ways. I suggest that, should you find the time, checkout the repos, so we can work on this further. For getting ready, follow this approach:

Should you need assistance, I can help you out.


As for the advantages - using such an approach (npm module, webpack) has several advantages:

Of course, there are also disadvantages, such as


I hope that my posting wasn't too long :-) Please let me know what you think of the approach and whether you think that we could change the library to be npm-module based (perhaps something like webclient 2.0 to avoid breaking changes or so). I do hope that we can develop this approach further since I think it would help the amazing work you've put in so far to be even more widely used and also be more future-oriented.

Should you find bugs and issues, please report them to me.

Happy coding and best, Lukas

Tugark commented 6 years ago

By the way, here is a screenshot that shows custom terrain and 3dcitydb-layers, provided by the webpack build (see the repo for known issues ;)): 17-05-_2018_10-43-32