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,8 +1,7 @@
import { ImageObject } from "./ImageObject";
import { Hint } from "./Hint";
//import { Hint } from "./Hint";
import { Group, AnimationMixer, LoopPingPong, Vector3 } from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
import { Utils } from "./Utils";
import { assignMaterial, assignParams } from "@/lib/MeshUtils";
import { Game1 } from "./PuzzleGame1";
import { Game2 } from "./PuzzleGame2";
// import { Game3 } from "./games/Game3";
@@ -10,6 +9,7 @@ import { Game4 } from "./PuzzleGame4";
// import { Game5 } from "./games/Game5";
// import { Game6 } from "./games/Game6";
import { TextObject } from "./TextObject";
import { ImageObject } from "./ImageObject";
const games = {Game1, Game2, Game4};
@@ -31,7 +31,7 @@ class InteractiveObject {
break;
case 'text':
let text = new TextObject(obj, context);
resolve(text.mesh);
resolve(text.object);
break;
case 'mesh':
mesh = obj.value;
@@ -39,12 +39,12 @@ class InteractiveObject {
break;
case 'image':
let imo = new ImageObject(obj, context);
mesh = imo.mesh;
mesh = imo.object;
resolve(mesh);
break;
case 'hint':
let hint = new Hint(obj, context);
mesh = hint.mesh;
mesh = hint.object;
resolve(mesh);
break;
case 'gltf':
@@ -58,7 +58,7 @@ class InteractiveObject {
// object.castShadow = true;
// object.receiveShadow = true;
});
Utils.assignMaterial(gltfObj, obj, context);
assignMaterial(gltfObj, obj, context);
if (gltf.animations && gltf.animations.length) {
let mixer = new AnimationMixer(gltfObj);
context.mixers.push(mixer);
@@ -71,7 +71,7 @@ class InteractiveObject {
break;
case 'asset':
mesh = context.assets[obj.value].clone();
Utils.assignMaterial(mesh, obj, context);
assignMaterial(mesh, obj, context);
resolve(mesh);
break;
case 'Game1':
@@ -81,7 +81,7 @@ class InteractiveObject {
case 'Game5':
case 'Game6':
var game = new games[obj.type](context, obj.args[0], obj.args[1], obj.args[2]);
mesh = game.game;
mesh = game.object;
mesh.game = game;
resolve(mesh);
break;
@@ -89,14 +89,14 @@ class InteractiveObject {
});
this.ready.then((mesh) => {
mesh.go = {};
let restriction;
if (!context.disableRestrictions && obj.restriction) {
restriction = {
type: 'deny',
a: [obj.room.localToWorld(new Vector3().fromArray(obj.restriction[0])), obj.room.localToWorld(new Vector3().fromArray(obj.restriction[1]))]
};
context.areas.push(restriction);
}
// let restriction;
// if (!context.disableRestrictions && obj.restriction) {
// restriction = {
// type: 'deny',
// a: [obj.room.localToWorld(new Vector3().fromArray(obj.restriction[0])), obj.room.localToWorld(new Vector3().fromArray(obj.restriction[1]))]
// };
// context.areas.push(restriction);
// }
mesh.go.finish = () => {
if (obj.finish) {
var f;
@@ -115,15 +115,15 @@ class InteractiveObject {
}
if (restriction) context.areas.splice(context.areas.indexOf(restriction), 1);
};
if (mesh.game) mesh.game.onfinish = mesh.go.finish;
Utils.assignParams(mesh, obj);
if (mesh.object) mesh.object.onfinish = mesh.go.finish;
assignParams(mesh, obj);
obj.animation && context.motionEngine.add({
o: mesh,
a: obj.animation.motion,
r: obj.animation.repeat,
t: obj.animation.duration || 1
});
this.mesh = mesh;
this.object = mesh;
});
}
}