tensorspace-team / tensorspace

Neural network 3D visualization framework, build interactive and intuitive model in browsers, support pre-trained deep learning models from TensorFlow, Keras, TensorFlow.js
https://tensorspace.org
Apache License 2.0
5.05k stars 445 forks source link

Support configure font style in scene #179

Open syt123450 opened 5 years ago

syt123450 commented 5 years ago

TensorSpace use fonts/helvetiker_regular.typeface.json as the basic font style for output1d layer text information. However, it does not support some text, for example, when input 中文, the fonts/helvetiker_regular.typeface.json will show ?? (this case can be reproduced in three.js docs's playground).

To handle this case, add a configuration in model, user can override the default fonts/helvetiker_regular.typeface.json with own fonts.

For example:

// user loadFont file through AJAX
let ownFont = loadFont();
let model = new TSP.models.Sequential({
    ...
    font: ownFont,
    ...
});
Truemedia commented 5 years ago

@syt123450 So I did a bit of digging on this after setting up a local instance of tensor (fixed a bug with missing dep aswell). I found the hard coded font and saw that there is an npm module for this specific font already (https://www.npmjs.com/package/three.regular.helvetiker). The rollup config didn't have common module and ES6 external resolver support so I added that into the build aswell. That at least trims down that giant line of json into one easy import. Still looking at the best way to pass through the option without rewriting too much function calls, but looks doable.

syt123450 commented 5 years ago

@Truemedia It's really a good news! I think this refactoring will highly improve the TensorSpace's source code readability. Could you send a PR related your refactoring?

syt123450 commented 5 years ago

@BoTime Could you give some suggestions about rollup configuration?

Truemedia commented 5 years ago

@syt123450 Sure, would you be able to open a feature branch/develop branch for me to do a new request on so it doesn't go into master just yet.

syt123450 commented 5 years ago

Hi @Truemedia , I created a new issue #192 and create a new branch refactorfont. We can work under the new issue for refactoring, separate the work of refactor and new feature ~

Truemedia commented 5 years ago

@syt123450 Ok cool, I won't have much time to commit any code during week but weekend can probably box off both those branches with the new features