amazing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Group, Vector3, Matrix4, Mesh, Quaternion, BoxGeometry } from 'three';
|
||||
import { Group, Vector3, Matrix4, Mesh, Quaternion, PlaneGeometry, MeshStandardMaterial, DoubleSide } from 'three';
|
||||
import { InteractiveObject } from '../InteractiveObject';
|
||||
|
||||
class MazeObject {
|
||||
@@ -8,6 +8,8 @@ class MazeObject {
|
||||
this.object = room;
|
||||
let context = {};
|
||||
|
||||
const bbox = {l:0, r:0, f:0}
|
||||
|
||||
const scale = 5;
|
||||
|
||||
context.wallSize = params.wallSize || 1.2*scale; //half
|
||||
@@ -19,11 +21,11 @@ class MazeObject {
|
||||
this.context = context;
|
||||
let _tf = {
|
||||
rotation: {
|
||||
r: 3 * Math.PI / 2, f: 0, l: Math.PI / 2, b: Math.PI
|
||||
r: 3 * Math.PI / 2, f: 0, l: Math.PI / 2, b: 0
|
||||
},
|
||||
pNext: {
|
||||
r: [-context.wallSize/2, context.wallSize/2],
|
||||
f: [0, context.wallSize / 2],
|
||||
f: [0, context.wallSize],
|
||||
l: [context.wallSize/2, context.wallSize/2]
|
||||
}
|
||||
};
|
||||
@@ -62,7 +64,6 @@ class MazeObject {
|
||||
e[4].rotateY(_tf.rotation.l);
|
||||
|
||||
e[1].position.set(0, 0, offsetZ + 0);
|
||||
|
||||
e[2].position.set(-context.wallSize/2, 0, offsetZ + context.wallSize/2);
|
||||
e[3].position.set(0, 0, offsetZ + context.wallSize);
|
||||
e[4].position.set(context.wallSize/2, 0, offsetZ + context.wallSize/2);
|
||||
@@ -86,6 +87,9 @@ class MazeObject {
|
||||
e.forEach(g => {
|
||||
g.applyMatrix4(def.matrix);
|
||||
root.add(g);
|
||||
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)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,7 +171,14 @@ class MazeObject {
|
||||
// //engine.phy.add(mesh, 'fixed')
|
||||
// })
|
||||
|
||||
console.log(o.tunnel)
|
||||
console.log(bbox, 'bbox')
|
||||
const floorGeometry = new PlaneGeometry(bbox.r - bbox.l + 10*scale, bbox.f + 10*scale);
|
||||
const floor = new Mesh(floorGeometry,new MeshStandardMaterial({
|
||||
roughness: 0, metalness:1, color: 0x00ffff, side: DoubleSide
|
||||
}))
|
||||
floor.rotation.set(Math.PI/2, 0, 0)
|
||||
floor.position.set((bbox.l + bbox.r)/2, 0.3, bbox.f/2);
|
||||
root.add(floor);
|
||||
//scene.add(new Mesh(BufferGeometryUtils.mergeGeometries(mazeGeometries, false), o.tunnel.material));
|
||||
//console.log(room);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user