This commit is contained in:
2025-11-29 16:40:17 +02:00
parent 2078cef20b
commit f383d9d548
2 changed files with 37 additions and 18 deletions
+17 -17
View File
@@ -30,23 +30,23 @@ class TextObject {
txt.sync();
this.txt = txt;
this.object = txt;
// if (obj.effect == 'distance') {
// let dstm = .8;
// 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;
// }
// };
// }
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;
}
};
}
}
}