protectwise / troika

A JavaScript framework for interactive 3D and 2D visualizations
MIT License
1.64k stars 124 forks source link

troika-3d-text available via a content delivery network #48

Closed theo-armour closed 4 years ago

theo-armour commented 4 years ago

Is troika-3d-text available via a content delivery network such as jsdelivr.net?

I build very simple plain-vanilla JavaScript cookbook examples - such as this one:

https://www.ladybug.tools/spider-covid-19-viz-3d/cookbook/globe-population-cities/

I am very interested in building examples that include troika-3d-text. Is there some way this could be possible?

lojjic commented 4 years ago

It's published in the public npm repository so yes, a CDN like jsdelivr.net or unpkg.com that proxies npm modules should work.

lojjic commented 4 years ago

More specifically, for usage with globals, you'll probably want the textmesh-standalone umd file with its two dependencies:

https://cdn.jsdelivr.net/npm/troika-three-utils@0.26.0 https://cdn.jsdelivr.net/npm/troika-worker-utils@0.26.0 https://cdn.jsdelivr.net/npm/troika-3d-text@0.26.0/dist/textmesh-standalone.umd.min.js

You should then be able to access the global troika_3d_text.TextMesh I haven't tried this personally so lemme know if it doesn't work.

theo-armour commented 4 years ago

@lojjic

Thanks for speedy holiday reply. looking now.

theo-armour commented 4 years ago

@lojjic

https://ta-troika-3d-text.glitch.me/

source: https://glitch.com/edit/#!/ta-troika-3d-text?path=index.html%3A1%3A0

see line 228

error Uncaught Reference Error: TextMesh is not defined

lojjic commented 4 years ago

Yeah, like I wrote above if you're using globals then it's going to be at troika_3d_text.TextMesh not just TextMesh. Your glitch seems to work when you fix that and the missing argument to zoomObjectBoundingSphere.

Also keep in mind that the text layout is asynchronous, so the bounding sphere won't be accurate until after the sync completes.

theo-armour commented 4 years ago

Again. @lojjic, thank you for speedy holiday response.

My doh. Troika 3D Text rules!

Your project looks like it is going to be fun to investigate