TextObjects - set default font family + make loading asynchronous
This commit is contained in:
@@ -4,34 +4,37 @@ import { assignParams } from "@/lib/MeshUtils";
|
|||||||
|
|
||||||
class TextObject {
|
class TextObject {
|
||||||
constructor(engine, obj) {
|
constructor(engine, obj) {
|
||||||
const txt = new Text();
|
return new Promise((resolve, reject)=>{
|
||||||
// Set properties to configure:
|
const txt = new Text();
|
||||||
txt.text = obj.text;
|
// Set properties to configure:
|
||||||
txt.fontSize = 0.033;
|
txt.text = obj.text;
|
||||||
txt.lineHeight = 1.1;
|
txt.fontSize = 0.033;
|
||||||
//txt.maxWidth = obj.width;
|
txt.lineHeight = 1.1;
|
||||||
txt.textAlign = 'center';
|
//txt.maxWidth = obj.width;
|
||||||
txt.font = obj.fontPath;
|
txt.textAlign = 'center';
|
||||||
txt.anchorX = 'center';
|
txt.font = obj.fontPath || '/static/fonts/Montserrat-Regular.ttf';
|
||||||
txt.anchorY = 'bottom';
|
txt.anchorX = 'center';
|
||||||
txt.curveRadius = 0;
|
txt.anchorY = 'bottom';
|
||||||
txt.outlineColor = 0xffffff;
|
txt.curveRadius = 0;
|
||||||
txt.outlineWidth = '15%';
|
txt.outlineColor = 0xffffff;
|
||||||
txt.depthOffset = 0.1;
|
txt.outlineWidth = '15%';
|
||||||
//txt.outlineBlur = '50%';
|
txt.depthOffset = 0.1;
|
||||||
txt.color = new Color(0x0);
|
//txt.outlineBlur = '50%';
|
||||||
assignParams(txt, obj)
|
txt.color = new Color(0x0);
|
||||||
let m = new MeshBasicMaterial({
|
assignParams(txt, obj)
|
||||||
// roughness: .73,
|
let m = new MeshBasicMaterial({
|
||||||
// metalness: .37,
|
// roughness: .73,
|
||||||
side: DoubleSide
|
// metalness: .37,
|
||||||
});
|
side: DoubleSide
|
||||||
txt.material = m;
|
});
|
||||||
txt.sync(()=>{
|
txt.material = m;
|
||||||
txt.material[1].opacity = 1;
|
txt.sync(()=>{
|
||||||
});
|
txt.material[1].opacity = 1;
|
||||||
this.txt = txt;
|
resolve(this);
|
||||||
this.object = txt;
|
});
|
||||||
|
this.txt = txt;
|
||||||
|
this.object = txt;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user