TextObjects - set default font family + make loading asynchronous
This commit is contained in:
@@ -4,6 +4,7 @@ import { assignParams } from "@/lib/MeshUtils";
|
||||
|
||||
class TextObject {
|
||||
constructor(engine, obj) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
const txt = new Text();
|
||||
// Set properties to configure:
|
||||
txt.text = obj.text;
|
||||
@@ -11,7 +12,7 @@ class TextObject {
|
||||
txt.lineHeight = 1.1;
|
||||
//txt.maxWidth = obj.width;
|
||||
txt.textAlign = 'center';
|
||||
txt.font = obj.fontPath;
|
||||
txt.font = obj.fontPath || '/static/fonts/Montserrat-Regular.ttf';
|
||||
txt.anchorX = 'center';
|
||||
txt.anchorY = 'bottom';
|
||||
txt.curveRadius = 0;
|
||||
@@ -29,9 +30,11 @@ class TextObject {
|
||||
txt.material = m;
|
||||
txt.sync(()=>{
|
||||
txt.material[1].opacity = 1;
|
||||
resolve(this);
|
||||
});
|
||||
this.txt = txt;
|
||||
this.object = txt;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user