amazing maze

This commit is contained in:
2025-10-20 22:49:08 +03:00
parent 192a900a96
commit 3ff60a1cf4
9 changed files with 140 additions and 70 deletions
@@ -1,6 +1,5 @@
import { Group, Vector3, Matrix4, Mesh, Quaternion, BoxGeometry } from 'three';
import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';
import { TextObject } from '../TextObject';
import { InteractiveObject } from '../InteractiveObject';
class MazeObject {
constructor(engine, def, params = {}){
@@ -14,7 +13,8 @@ class MazeObject {
context.wallSize = params.wallSize || 1.2*scale; //half
context.tubeSize = params.tubeSize || 1.2*scale;
context.wallDepth = params.wallDepth || 0*scale;
context.fontPath = params.fontPath || '/static/fonts/Jura-SemiBold.ttf';
context.fontPath = params.fontPath || '/static/fonts/Montserrat-Regular.ttf';
context.scale = scale;
this.context = context;
let _tf = {
@@ -29,7 +29,6 @@ class MazeObject {
};
let o = {};
let areas = [], mazeMeshes = [];
function addPhysics(matrix, position, size, placement = 'side'){
let quat = new Quaternion().setFromRotationMatrix(matrix);
@@ -58,7 +57,7 @@ class MazeObject {
let t = o.tunnel.clone();
t.position.set(0, 0, i * context.tubeSize);
def.matrix && t.applyMatrix4(def.matrix);
mazeMeshes.push(t);
root.add(t);
}
offsetZ = def.len * context.tubeSize;
//if (!def.len) offsetZ = -.275;
@@ -70,7 +69,6 @@ class MazeObject {
// console.log(offsetZ, room.localToWorld(new Vector3(context.tubeSize / 2, 0.6, offsetZ/2)))
let ofZ = def.len * context.tubeSize
addPhysics(def.matrix, [context.tubeSize / 2, 0.6, offsetZ/2], offsetZ)
addPhysics(def.matrix, [-context.tubeSize / 2, 0.6, offsetZ/2], offsetZ)
@@ -109,18 +107,19 @@ class MazeObject {
}
e.forEach(g => {
def.matrix && g.applyMatrix4(def.matrix);
mazeMeshes.push(g);
g.applyMatrix4(def.matrix);
root.add(g);
});
def.objects && def.objects.forEach(obj => {
def.objects && def.objects.forEach(async obj => {
obj.room = room;
// let go = new GameObject(obj, context);
let go = new TextObject(obj, context)
go.mesh.scale.multiplyScalar(scale)
go.mesh.position.multiply(new Vector3(scale, scale, context.wallSize))
go.mesh.applyMatrix4(def.matrix);
root.add(go.mesh);
let go = new InteractiveObject(obj, context)
await go.ready;
go.object.scale.multiplyScalar(context.wallSize)
go.object.position.multiplyScalar(context.wallSize)
go.object.applyMatrix4(def.matrix);
root.add(go.object);
// go.ready.then(mesh => {
// room.add(mesh);
// });
@@ -151,11 +150,11 @@ class MazeObject {
// console.log(e, o[e].geometry.boundingBox)
});
this.mazeObject(def, room);
mazeMeshes.forEach(mesh=>{
//let mesh = new Mesh(mg, o.tunnel.material)
root.add(mesh);
//engine.phy.add(mesh, 'fixed')
})
// mazeMeshes.forEach(mesh=>{
// //let mesh = new Mesh(mg, o.tunnel.material)
// root.add(mesh);
// //engine.phy.add(mesh, 'fixed')
// })
console.log(o.tunnel)
//scene.add(new Mesh(BufferGeometryUtils.mergeGeometries(mazeGeometries, false), o.tunnel.material));