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";
|
||||
|
||||
class ImageObject {
|
||||
@@ -28,6 +28,25 @@ class ImageObject {
|
||||
}
|
||||
}
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user