New API for Text component
sasha240100 opened this issue · 2 comments
sasha240100 commented
Concept:
new Text({
font: Text.load('path/to/font.js'),
geometry: {
size: 80,
height: 5,
curveSegments: 12,
bevelEnabled: true,
bevelThickness: 10,
bevelSize: 8,
bevelSegments: 5
},
// ...
}).addTo(app);
Text.load()
- wrapsFontLoader
in a promise. returns a Promise which is resolved with aTHREE.Font
.font
parameter in Text can accept both:THREE.Font
or Promise that resolves it.
P.s.: It can be implemented simply in API by just keeping async way and wrappingTHREE.Font
inPromise.resolve(font)
if such is passed
Version:
- v2.x.x
- v1.x.x
Issue type:
- Bug
- Proposal/Enhancement
- Question
- Discussion
Tested on:
Desktop
- Chrome
- Chrome Canary
- Chrome dev-channel
- Firefox
- Opera
- Microsoft IE
- Microsoft Edge
Android
- Chrome
- Firefox
- Opera
IOS
- Chrome
- Firefox
- Opera
tomriddle1234 commented
This is fine for now. However in some frameworks, as pointed by Hirako, loading external json files can cause issue, like Ionic, it can be solved with customized webpack config file.
So maybe, the better way is to leave the loading file/data part to the framework it self that works with WHS.js, this means, the new text API or other similar API should accept a data object as input parameter as well as the existing file-loading scheme.
For example, in Ionic/Angular, the loading becomes subscription to an http request observable, and then whis.js just take the loaded data.
sasha240100 commented
@tomriddle1234 The API will still support async because of promise passed. Ok, working on implementation now.