scene switcher feature
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { MazeObject } from "./MazeObject";
|
||||
import Utils from "@/lib/Utils";
|
||||
import { EventDispatcher } from "three";
|
||||
import { EventManager } from '@/lib/EventManager';
|
||||
|
||||
const params = {
|
||||
scale: 3,
|
||||
@@ -17,7 +17,7 @@ const imgParams = {
|
||||
}
|
||||
|
||||
const textParams = {
|
||||
type: 'TextObject', width:0.44,
|
||||
type: 'TextObject', maxWidth:0.44,
|
||||
fontPath:'/static/fonts/Montserrat-Regular.ttf',
|
||||
fontSize:0.025, distance: params.wallSize*2
|
||||
}
|
||||
@@ -37,12 +37,14 @@ const defaults = {
|
||||
|
||||
const tl = 4;
|
||||
|
||||
class MazeQuizGame extends EventDispatcher {
|
||||
emits = ['finish']
|
||||
class MazeQuizGame extends EventManager {
|
||||
emits = ['finish', 'sceneSwitch']
|
||||
constructor(engine, data) {
|
||||
super();
|
||||
this.data = data;
|
||||
data.noPhysics = true;
|
||||
params.mazeFile = data.style || 'quiz-s2.gltf';
|
||||
params.io = this;
|
||||
return new Promise(async (resolve, reject)=>{
|
||||
let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions;
|
||||
let def = this.generate(questions);
|
||||
@@ -101,11 +103,16 @@ class MazeQuizGame extends EventDispatcher {
|
||||
len,
|
||||
userData: { finish: true },
|
||||
objects:[
|
||||
// {
|
||||
// type: 'GltfObject',
|
||||
// position:[0,.22,len + .52], scale: [0.33, 0.33, 0.33], rotation: [0, Math.PI/4, 0],
|
||||
// value: 'trophy.glb', path: imgParams.path, distance: params.wallSize*2,
|
||||
// motion: { a:{rotation: { y: k=>k*Math.PI*2 }}, r: true, t: 4 }
|
||||
// }
|
||||
{
|
||||
type: 'GltfObject',
|
||||
position:[0,.22,len + .52], scale: [0.33, 0.33, 0.33], rotation: [0, Math.PI/4, 0],
|
||||
value: 'trophy.glb', path: imgParams.path, distance: params.wallSize*2,
|
||||
motion: { a:{rotation: { y: k=>k*Math.PI*2 }}, r: true, t: 4 }
|
||||
type: 'SceneSwitcher', switchScene: this.data.switchScene, switchType: this.data.switchType,
|
||||
position:[0,.22,len + .52], scale: [0.33, 0.33, 0.33],
|
||||
distance: params.wallSize*2
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -116,7 +123,7 @@ class MazeQuizGame extends EventDispatcher {
|
||||
len, userData: { question, qid },
|
||||
objects:[
|
||||
{
|
||||
...textParams, text: question.q, fontSize:0.033, width:0.55, position:[0,.55,len + .96], rotation:[0,Math.PI, 0]
|
||||
...textParams, text: question.q, fontSize:0.033, maxWidth:0.55, position:[0,.55,len + .96], rotation:[0,Math.PI, 0]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -149,7 +156,7 @@ class MazeQuizGame extends EventDispatcher {
|
||||
len: 3,
|
||||
objects:[
|
||||
{
|
||||
...textParams, color:0xc71414, text: question.h, fontSize:0.033, width:0.66, position:[0,.44,3+.96], rotation:[0,Math.PI, 0]
|
||||
...textParams, color:0xc71414, text: question.h, fontSize:0.033, maxWidth:0.66, position:[0,.44,3+.96], rotation:[0,Math.PI, 0]
|
||||
},{
|
||||
...imgParams, value:'x.webp', position:[0,.33,3+.96], rotation:[0,Math.PI, 0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user