diff --git a/src/components/InteractiveObjects/TextObject.js b/src/components/InteractiveObjects/TextObject.js index cf240d4..252c47e 100644 --- a/src/components/InteractiveObjects/TextObject.js +++ b/src/components/InteractiveObjects/TextObject.js @@ -4,34 +4,37 @@ import { assignParams } from "@/lib/MeshUtils"; class TextObject { constructor(engine, obj) { - const txt = new Text(); - // Set properties to configure: - txt.text = obj.text; - txt.fontSize = 0.033; - txt.lineHeight = 1.1; - //txt.maxWidth = obj.width; - txt.textAlign = 'center'; - txt.font = obj.fontPath; - txt.anchorX = 'center'; - txt.anchorY = 'bottom'; - txt.curveRadius = 0; - txt.outlineColor = 0xffffff; - txt.outlineWidth = '15%'; - txt.depthOffset = 0.1; - //txt.outlineBlur = '50%'; - txt.color = new Color(0x0); - assignParams(txt, obj) - let m = new MeshBasicMaterial({ - // roughness: .73, - // metalness: .37, - side: DoubleSide - }); - txt.material = m; - txt.sync(()=>{ - txt.material[1].opacity = 1; - }); - this.txt = txt; - this.object = txt; + return new Promise((resolve, reject)=>{ + const txt = new Text(); + // Set properties to configure: + txt.text = obj.text; + txt.fontSize = 0.033; + txt.lineHeight = 1.1; + //txt.maxWidth = obj.width; + txt.textAlign = 'center'; + txt.font = obj.fontPath || '/static/fonts/Montserrat-Regular.ttf'; + txt.anchorX = 'center'; + txt.anchorY = 'bottom'; + txt.curveRadius = 0; + txt.outlineColor = 0xffffff; + txt.outlineWidth = '15%'; + txt.depthOffset = 0.1; + //txt.outlineBlur = '50%'; + txt.color = new Color(0x0); + assignParams(txt, obj) + let m = new MeshBasicMaterial({ + // roughness: .73, + // metalness: .37, + side: DoubleSide + }); + txt.material = m; + txt.sync(()=>{ + txt.material[1].opacity = 1; + resolve(this); + }); + this.txt = txt; + this.object = txt; + }) } }