This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { TextureLoader, MeshStandardMaterial, MeshBasicMaterial, PlaneGeometry, Mesh, DoubleSide } from "three";
|
import { TextureLoader, MeshStandardMaterial, MeshBasicMaterial, PlaneGeometry, Mesh, DoubleSide, Vector3 } from "three";
|
||||||
import { assignParams } from "@/lib/MeshUtils";
|
import { assignParams } from "@/lib/MeshUtils";
|
||||||
|
|
||||||
class ImageObject {
|
class ImageObject {
|
||||||
@@ -28,6 +28,25 @@ class ImageObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.object = new Mesh(geo, mp.metalness ? new MeshStandardMaterial(mp) : new MeshBasicMaterial(mp));
|
this.object = new Mesh(geo, mp.metalness ? new MeshStandardMaterial(mp) : new MeshBasicMaterial(mp));
|
||||||
|
|
||||||
|
if (obj.distance) {
|
||||||
|
const o = this.object;
|
||||||
|
let dstm = obj.distance;
|
||||||
|
var oldBR = o.onBeforeRender;
|
||||||
|
o.material.opacity = 0.01;
|
||||||
|
o.onBeforeRender = function (renderer, scene, camera) {
|
||||||
|
oldBR && oldBR.apply(this, arguments);
|
||||||
|
var v = new Vector3();
|
||||||
|
o.getWorldPosition(v);
|
||||||
|
var dst = camera.position.distanceTo(v);
|
||||||
|
if (dst < dstm * 2 && dst > dstm * 1) {
|
||||||
|
o.material.opacity = dstm * 1 - (dst - dstm * 1);
|
||||||
|
}
|
||||||
|
if (dst < .5 * dstm) {
|
||||||
|
o.material.opacity = dstm * dst * 2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
resolve(this)
|
resolve(this)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,23 +30,23 @@ class TextObject {
|
|||||||
txt.sync();
|
txt.sync();
|
||||||
this.txt = txt;
|
this.txt = txt;
|
||||||
this.object = txt;
|
this.object = txt;
|
||||||
// if (obj.effect == 'distance') {
|
if (obj.distance) {
|
||||||
// let dstm = .8;
|
let dstm = obj.distance;
|
||||||
// var oldBR = txt.onBeforeRender;
|
var oldBR = txt.onBeforeRender;
|
||||||
// txt.material[1].opacity = 0.01;
|
txt.material[1].opacity = 0.01;
|
||||||
// txt.onBeforeRender = function (renderer, scene, camera) {
|
txt.onBeforeRender = function (renderer, scene, camera) {
|
||||||
// oldBR && oldBR.apply(this, arguments);
|
oldBR && oldBR.apply(this, arguments);
|
||||||
// var v = new Vector3();
|
var v = new Vector3();
|
||||||
// txt.getWorldPosition(v);
|
txt.getWorldPosition(v);
|
||||||
// var dst = camera.position.distanceTo(v);
|
var dst = camera.position.distanceTo(v);
|
||||||
// if (dst < dstm * 2 && dst > dstm * 1) {
|
if (dst < dstm * 2 && dst > dstm * 1) {
|
||||||
// txt.material[1].opacity = dstm * 1 - (dst - dstm * 1);
|
txt.material[1].opacity = dstm * 1 - (dst - dstm * 1);
|
||||||
// }
|
}
|
||||||
// if (dst < .5 * dstm) {
|
if (dst < .5 * dstm) {
|
||||||
// txt.material[1].opacity = dstm * dst * 2;
|
txt.material[1].opacity = dstm * dst * 2;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user