From d8618c69f4415398df2d905e28b9a5298e9a90f6 Mon Sep 17 00:00:00 2001 From: goynov Date: Sun, 2 Nov 2025 18:03:46 +0200 Subject: [PATCH] interactive objects parametrization --- .../AssetsManagement/AssetSelector.vue | 10 +- src/components/GameDesigner/GameDesigner.vue | 164 +------- src/components/GamePlaying/GamePlaying.vue | 356 ++++++------------ .../InteractiveObjects/InteractiveObject.js | 42 +-- .../MazeQuizGame/MazeQuizGame.js | 2 +- .../MazeQuizGame/MazeQuizGame.vue | 11 + .../InteractiveObjects/PuzzleGame1.js | 4 +- .../InteractiveObjects/PuzzleGame1.vue | 8 + .../InteractiveObjects/PuzzleGame2.js | 4 +- .../InteractiveObjects/PuzzleGame4.js | 4 +- .../InteractiveObjects/VideoPlayer.vue | 44 +-- src/components/SceneDesigner/GameObject.vue | 18 +- src/mixins/GameEnvironmentMixin.js | 205 ++++++++++ src/plugins/params.js | 12 +- src/styles/style.scss | 1 - 15 files changed, 411 insertions(+), 474 deletions(-) create mode 100644 src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue create mode 100644 src/mixins/GameEnvironmentMixin.js diff --git a/src/components/AssetsManagement/AssetSelector.vue b/src/components/AssetsManagement/AssetSelector.vue index f0f4390..341da77 100644 --- a/src/components/AssetsManagement/AssetSelector.vue +++ b/src/components/AssetsManagement/AssetSelector.vue @@ -2,6 +2,9 @@ + + {{ v.id }} + @@ -12,6 +15,8 @@ \ No newline at end of file diff --git a/src/components/GamePlaying/GamePlaying.vue b/src/components/GamePlaying/GamePlaying.vue index c2a624e..48e221e 100644 --- a/src/components/GamePlaying/GamePlaying.vue +++ b/src/components/GamePlaying/GamePlaying.vue @@ -47,31 +47,32 @@ - + \ No newline at end of file diff --git a/src/components/InteractiveObjects/InteractiveObject.js b/src/components/InteractiveObjects/InteractiveObject.js index f9c4b71..81609e0 100644 --- a/src/components/InteractiveObjects/InteractiveObject.js +++ b/src/components/InteractiveObjects/InteractiveObject.js @@ -2,16 +2,16 @@ import { Group, AnimationMixer, LoopPingPong, Vector3 } from "three"; import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"; import { assignMaterial, assignParams } from "@/lib/MeshUtils"; -import { Game1 } from "./PuzzleGame1"; -import { Game2 } from "./PuzzleGame2"; +import { PuzzleGame1 } from "./PuzzleGame1"; +import { PuzzleGame2 } from "./PuzzleGame2"; // import { Game3 } from "./games/Game3"; -import { Game4 } from "./PuzzleGame4"; +import { PuzzleGame4 } 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}; +const games = {PuzzleGame1, PuzzleGame2, PuzzleGame4}; class InteractiveObject { constructor(obj, context) { @@ -75,12 +75,12 @@ class InteractiveObject { assignMaterial(mesh, obj, context); resolve(mesh); break; - case 'Game1': - case 'Game2': - case 'Game3': - case 'Game4': - case 'Game5': - case 'Game6': + case 'PuzzleGame1': + case 'PuzzleGame2': + case 'PuzzleGame3': + case 'PuzzleGame4': + case 'PuzzleGame5': + case 'PuzzleGame6': var game = new games[obj.type](context, obj.args[0], obj.args[1], obj.args[2]); mesh = game.object; mesh.game = game; @@ -129,16 +129,14 @@ class InteractiveObject { } } - -// function textObject(text, context){ -// const geometry = new TextGeometry( text, { -// font: context.font, -// size: .05, -// height: .01, -// curveSegments: 1 -// } ); -// return new Mesh(geometry, context.fontMaterial); -// } +const InteractiveObjectTypes = [ + { + id: 'PuzzleGame1', name: 'Puzzle Game 1' + }, { + id: 'MazeQuizGame', name: 'Maze Quiz Game' + }, { + id: 'VideoPlayer', name: 'Video Player' + } +] - -export {InteractiveObject} \ No newline at end of file +export { InteractiveObject, InteractiveObjectTypes } \ No newline at end of file diff --git a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js index 1d1eb04..7021a52 100644 --- a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js +++ b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js @@ -96,7 +96,7 @@ class MazeQuizGame { ) let dd; if (d == 'f'){ - dd = Math.round() > 0.5 ? 'l' : 'r'; + dd = Math.random() > 0.5 ? 'l' : 'r'; }else { dd = d == 'l' ? 'r' : 'l' } diff --git a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue new file mode 100644 index 0000000..b9c9cfb --- /dev/null +++ b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/src/components/InteractiveObjects/PuzzleGame1.js b/src/components/InteractiveObjects/PuzzleGame1.js index e440f13..e208ea8 100644 --- a/src/components/InteractiveObjects/PuzzleGame1.js +++ b/src/components/InteractiveObjects/PuzzleGame1.js @@ -2,7 +2,7 @@ import { BoxGeometry, Mesh, MeshBasicMaterial, Group } from 'three'; import { TextureLoader } from 'three/src/loaders/TextureLoader'; import { MotionEngine } from '../../lib/MotionEngine'; -class Game1 { +class PuzzleGame1 { constructor(context, image, w, h) { this.object = new Group(); const aq = new MotionEngine(); @@ -93,4 +93,4 @@ class Game1 { } } -export {Game1} \ No newline at end of file +export { PuzzleGame1 } \ No newline at end of file diff --git a/src/components/InteractiveObjects/PuzzleGame1.vue b/src/components/InteractiveObjects/PuzzleGame1.vue index e69de29..c6a6774 100644 --- a/src/components/InteractiveObjects/PuzzleGame1.vue +++ b/src/components/InteractiveObjects/PuzzleGame1.vue @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/src/components/InteractiveObjects/PuzzleGame2.js b/src/components/InteractiveObjects/PuzzleGame2.js index bb6925d..12c16c5 100644 --- a/src/components/InteractiveObjects/PuzzleGame2.js +++ b/src/components/InteractiveObjects/PuzzleGame2.js @@ -2,7 +2,7 @@ import { BoxGeometry, Mesh, MeshBasicMaterial, Group } from 'three'; import { TextureLoader } from 'three/src/loaders/TextureLoader'; import { MotionEngine } from '../../lib/MotionEngine'; -class Game2 { +class PuzzleGame2 { constructor(context, image, w, h) { const texture = new TextureLoader().load(image); //texture.encoding = sRGBEncoding; @@ -143,4 +143,4 @@ class Game2 { } } -export { Game2 }; \ No newline at end of file +export { PuzzleGame2 }; \ No newline at end of file diff --git a/src/components/InteractiveObjects/PuzzleGame4.js b/src/components/InteractiveObjects/PuzzleGame4.js index 95bc064..56e148d 100644 --- a/src/components/InteractiveObjects/PuzzleGame4.js +++ b/src/components/InteractiveObjects/PuzzleGame4.js @@ -2,7 +2,7 @@ import { Group, RGBAFormat } from 'three'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; import { MotionEngine } from '../../lib/MotionEngine'; -var Game4 = function(context, gltf, w, h){ +var PuzzleGame4 = function(context, gltf, w, h){ this.object = new Group(); const aq = new MotionEngine(); const pr = []; @@ -121,4 +121,4 @@ var Game4 = function(context, gltf, w, h){ } } -export { Game4 } \ No newline at end of file +export { PuzzleGame4 } \ No newline at end of file diff --git a/src/components/InteractiveObjects/VideoPlayer.vue b/src/components/InteractiveObjects/VideoPlayer.vue index 8f66eb1..0f2568c 100644 --- a/src/components/InteractiveObjects/VideoPlayer.vue +++ b/src/components/InteractiveObjects/VideoPlayer.vue @@ -1,24 +1,20 @@