This commit is contained in:
@@ -91,19 +91,20 @@ class InteractiveObject extends EventManager{
|
||||
}
|
||||
|
||||
if (obj.distance) {
|
||||
const o = this.object;
|
||||
let dstm = obj.distance;
|
||||
let v = new Vector3();
|
||||
o.visible = false;
|
||||
engine.addEventListener('beforeRender', function () {
|
||||
o.getWorldPosition(v);
|
||||
var dst = engine.cameraWorld.position.distanceTo(v);
|
||||
if (dst <= dstm && !o.visible) {
|
||||
o.visible = true;
|
||||
}else if (dst > dstm && o.visible){
|
||||
o.visible = false;
|
||||
}
|
||||
});
|
||||
engine.hideIfFar(this.object, obj.distance)
|
||||
// const o = this.object;
|
||||
// let dstm = obj.distance;
|
||||
// let v = new Vector3();
|
||||
// o.visible = false;
|
||||
// engine.addEventListener('beforeRender', function () {
|
||||
// o.getWorldPosition(v);
|
||||
// var dst = engine.cameraWorld.position.distanceTo(v);
|
||||
// if (dst <= dstm && !o.visible) {
|
||||
// o.visible = true;
|
||||
// }else if (dst > dstm && o.visible){
|
||||
// o.visible = false;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
resolve(this);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Group, Vector3, Matrix4, Mesh, Quaternion, PlaneGeometry, MeshStandardMaterial, DoubleSide, RepeatWrapping, Vector2} from 'three';
|
||||
import { Group, Vector3, Matrix4, Quaternion, RepeatWrapping, Vector2} from 'three';
|
||||
import { InteractiveObject } from '../InteractiveObject';
|
||||
import { getBoundingBox, getBoundingBoxSize } from '@/lib/MeshUtils';
|
||||
|
||||
@@ -79,6 +79,9 @@ class MazeObject {
|
||||
bbox.l = Math.min(g.position.x, bbox.l)
|
||||
bbox.r = Math.max(g.position.x, bbox.r)
|
||||
bbox.f = Math.max(g.position.z, bbox.f)
|
||||
if (g.userData?.['io.maxDistance']){
|
||||
engine.hideIfFar(g, g.userData?.['io.maxDistance']);
|
||||
}
|
||||
});
|
||||
|
||||
//the floor:
|
||||
@@ -101,6 +104,9 @@ class MazeObject {
|
||||
let t = o.tunnel.clone();
|
||||
t.position.set(0, 0, i * tubeSize);
|
||||
def.matrix && t.applyMatrix4(def.matrix);
|
||||
if (t.userData?.['io.maxDistance']){
|
||||
engine.hideIfFar(t, t.userData?.['io.maxDistance']);
|
||||
}
|
||||
root.add(t);
|
||||
}
|
||||
offsetZ = def.len * tubeSize;
|
||||
|
||||
Reference in New Issue
Block a user