refactoring
This commit is contained in:
@@ -9,11 +9,11 @@ class TextObject {
|
||||
txt.text = obj.text;
|
||||
txt.fontSize = 0.033;
|
||||
txt.lineHeight = 1.1;
|
||||
txt.maxWidth = obj.width;
|
||||
//txt.maxWidth = obj.width;
|
||||
txt.textAlign = 'center';
|
||||
txt.font = obj.fontPath;
|
||||
txt.anchorX = obj.anchorX || 'center';
|
||||
txt.anchorY = obj.anchorY || 'bottom';
|
||||
txt.anchorX = 'center';
|
||||
txt.anchorY = 'bottom';
|
||||
txt.curveRadius = 0;
|
||||
txt.outlineColor = 0xffffff;
|
||||
txt.outlineWidth = '15%';
|
||||
@@ -27,26 +27,11 @@ class TextObject {
|
||||
side: DoubleSide
|
||||
});
|
||||
txt.material = m;
|
||||
txt.sync();
|
||||
txt.sync(()=>{
|
||||
txt.material[1].opacity = 1;
|
||||
});
|
||||
this.txt = txt;
|
||||
this.object = txt;
|
||||
if (obj.distance) {
|
||||
let dstm = obj.distance;
|
||||
var oldBR = txt.onBeforeRender;
|
||||
txt.material[1].opacity = 0.01;
|
||||
txt.onBeforeRender = function (renderer, scene, camera) {
|
||||
oldBR && oldBR.apply(this, arguments);
|
||||
var v = new Vector3();
|
||||
txt.getWorldPosition(v);
|
||||
var dst = camera.position.distanceTo(v);
|
||||
if (dst < dstm * 2 && dst > dstm * 1) {
|
||||
txt.material[1].opacity = dstm * 1 - (dst - dstm * 1);
|
||||
}
|
||||
if (dst < .5 * dstm) {
|
||||
txt.material[1].opacity = dstm * dst * 2;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user