Replace require() used to load 3D font with THREE.FontLoader()
Currently, there is a require() in a middle of this script to load the 3D font:
https://github.com/edf-hpc/slurm-web/blob/master/js/draw/3d-draw.js#L487
This is not very clean, it is not a common pattern, and it must be considered as a technical debt. The three.js approach is to use THREE.FontLoader() instead.
We should study the feasibility to use it in place.
(translated in english by @rezib)
I tried several things: move the font require in the shim, the config or in the require packages but unfortunately the dynamic loading of require needs the font to be declared in the require path previously. This feature is useful for template dynamic loading. We cannot load a js file from a path specified in the config which is itself already loaded.
I tried to workaround this with a plugin, but the issue is that I get a plain JS file and I have to exec this file to properly load it, which I don't recommend. It isn't only ugly, this should also be considered a bad practice.
My last test was to extract the FontLoader() from three.js r74, to check if it could work with r72. But no, it not only requires some new core features but it also requires the font to be exported in json (new feature from march 3rd in facetype, see PR #8).
I think that in term of code style, the current situation is better. Event if it's not usual, it perfectly valid though.
three.js r73 has problems with displaying the rackname in 3d-view. Switched to three.js r74 and replacing the require() with FontLoader and one of the three.js font files (helvetiker_bold.typeface.js) likes to work with the following changes in 3d-draw.js L488 :
var loader = new THREE.FontLoader();
loader.load(config.RACKNAME.FONT.PATH, function(font) {
var geometry = new THREE.TextGeometry(rack.name, {
font: font,
size: config.UNITSIZE * config.RACKNAME.SIZE,
height: config.UNITSIZE * config.RACKNAME.DEPTH
}); // TextGeometry
var material, mesh;
This issue concerns Slurm-web v2 which is not maintained anymore. You are highly encouraged to test the new version v3.0.0 that is not impacted by this issue. The quick start guide for v3.0.0 is available online: https://docs.rackslab.io/slurm-web/install/quickstart.html
Unless someone is motivated to maintain the old version of Slurm-web or you have a justified reason to keep this issue open, it will be closed in a few weeks.
For the reasons explained in the previous comment, I finally close this issue.