This commit is contained in:
@@ -36,7 +36,7 @@ class GenericObject extends EventManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.description){
|
if (data.description){
|
||||||
engine.dashboard.updateText(this.object.__onhud ? data.description : '', (d)=>{
|
engine.dashboard.updateText(this.object.__onhud ? data.description : '', false, (d)=>{
|
||||||
d && this.dispatchEvent({type:'finish'})
|
d && this.dispatchEvent({type:'finish'})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ class InteractiveObject extends EventManager{
|
|||||||
// this.io.addEventListener?.(event, this.dispatchEvent.bind(this))
|
// this.io.addEventListener?.(event, this.dispatchEvent.bind(this))
|
||||||
// })
|
// })
|
||||||
this.io.forwardEvents?.(this);
|
this.io.forwardEvents?.(this);
|
||||||
|
if (this.emits?.includes('interaction')){
|
||||||
|
this.io.once('interaction', ()=>{
|
||||||
|
if (obj.introText){
|
||||||
|
engine.dashboard.updateText(obj.introText, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (obj.shouldBeLocked){
|
if (obj.shouldBeLocked){
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { EventManager } from '@/lib/EventManager';
|
|||||||
import Utils from '@/lib/Utils';
|
import Utils from '@/lib/Utils';
|
||||||
|
|
||||||
class PairMatchingGame extends EventManager {
|
class PairMatchingGame extends EventManager {
|
||||||
emits = ['finish']
|
emits = ['finish', 'interaction']
|
||||||
constructor(engine, data) {
|
constructor(engine, data) {
|
||||||
super();
|
super();
|
||||||
return new Promise(async (resolve, reject)=>{
|
return new Promise(async (resolve, reject)=>{
|
||||||
@@ -76,6 +76,7 @@ class PairMatchingGame extends EventManager {
|
|||||||
let actionDef = {material:{emissiveIntensity:k=>(1+Math.sin((k*2+1.5)*Math.PI))*4 }};
|
let actionDef = {material:{emissiveIntensity:k=>(1+Math.sin((k*2+1.5)*Math.PI))*4 }};
|
||||||
|
|
||||||
let clickFn = (i) => {
|
let clickFn = (i) => {
|
||||||
|
this.dispatchEvent({type:'interaction'});
|
||||||
let oc = clicked;
|
let oc = clicked;
|
||||||
if (done.includes(i.object.userData.gd.id)) return;
|
if (done.includes(i.object.userData.gd.id)) return;
|
||||||
clicked = i.object;
|
clicked = i.object;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="modelValue.go">
|
<div v-if="modelValue.go">
|
||||||
<v-number-input density="compact" label="Number of elements" v-model="modelValue.c"></v-number-input>
|
<v-number-input density="compact" label="Number of elements" v-model="modelValue.c"></v-number-input>
|
||||||
|
<v-textarea :label="l.description" v-model="modelValue.introText" class="mt-3"></v-textarea>
|
||||||
<v-img :src="`/asset/thumb/${modelValue.go}.webp`" />
|
<v-img :src="`/asset/thumb/${modelValue.go}.webp`" />
|
||||||
<div class="text-caption text-center">{{ modelValue.title }}</div>
|
<div class="text-caption text-center">{{ modelValue.title }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+12
-2
@@ -5,6 +5,7 @@ import {
|
|||||||
|
|
||||||
import { Text } from "troika-three-text";
|
import { Text } from "troika-three-text";
|
||||||
import { EventManager } from "./EventManager";
|
import { EventManager } from "./EventManager";
|
||||||
|
import Utils from "./Utils";
|
||||||
class DashBoard extends EventManager {
|
class DashBoard extends EventManager {
|
||||||
#points = 0;
|
#points = 0;
|
||||||
constructor(engine) {
|
constructor(engine) {
|
||||||
@@ -133,13 +134,13 @@ class DashBoard extends EventManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateText = function(t, textScrolledCallback){
|
this.updateText = function(t, hideOnFinish = false, textScrolledCallback){
|
||||||
if (!textPlane) return;
|
if (!textPlane) return;
|
||||||
textPlane.visible = !!t;
|
textPlane.visible = !!t;
|
||||||
engine.motionQueue.clear(text);
|
engine.motionQueue.clear(text);
|
||||||
text.text = t;
|
text.text = t;
|
||||||
text.anchorY = 0.03 * dashHeight;
|
text.anchorY = 0.03 * dashHeight;
|
||||||
text.sync(()=>{
|
text.sync(async()=>{
|
||||||
let dMax = text.textRenderInfo.blockBounds[3] - text.textRenderInfo.blockBounds[1];
|
let dMax = text.textRenderInfo.blockBounds[3] - text.textRenderInfo.blockBounds[1];
|
||||||
let dh = dMax + text.clipRect[1];
|
let dh = dMax + text.clipRect[1];
|
||||||
if (dh > 0){
|
if (dh > 0){
|
||||||
@@ -148,6 +149,9 @@ class DashBoard extends EventManager {
|
|||||||
if (text.textRenderInfo.blockBounds[1]> text.clipRect[1] * 1.33 ){
|
if (text.textRenderInfo.blockBounds[1]> text.clipRect[1] * 1.33 ){
|
||||||
textScrolledCallback?.(true);
|
textScrolledCallback?.(true);
|
||||||
textScrolledCallback = null;
|
textScrolledCallback = null;
|
||||||
|
if (hideOnFinish){
|
||||||
|
this.updateText('')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
engine.motionQueue.add({
|
engine.motionQueue.add({
|
||||||
@@ -157,7 +161,13 @@ class DashBoard extends EventManager {
|
|||||||
u: updateFn
|
u: updateFn
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
|
if (hideOnFinish){
|
||||||
|
await Utils.wait(10000);
|
||||||
|
this.updateText('')
|
||||||
textScrolledCallback?.(false)
|
textScrolledCallback?.(false)
|
||||||
|
}else{
|
||||||
|
textScrolledCallback?.(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user