scoring system

This commit is contained in:
2025-11-12 07:27:42 +02:00
parent b1312d9b54
commit 2a1423877b
5 changed files with 31 additions and 12 deletions
Binary file not shown.
@@ -1,4 +1,4 @@
import { TextureLoader, MeshStandardMaterial, MeshBasicMaterial, PlaneGeometry, Mesh } from "three"; import { TextureLoader, MeshStandardMaterial, MeshBasicMaterial, PlaneGeometry, Mesh, DoubleSide } from "three";
import { assignParams } from "@/lib/MeshUtils"; import { assignParams } from "@/lib/MeshUtils";
class ImageObject { class ImageObject {
@@ -7,7 +7,8 @@ class ImageObject {
var t = await engine.loadTexture(obj.value, obj.path) var t = await engine.loadTexture(obj.value, obj.path)
var mp = { var mp = {
map: t, map: t,
alphaTest: 0.5 alphaTest: 0.5,
side: DoubleSide
}; };
if (obj.nm) { if (obj.nm) {
mp.normalMap = new TextureLoader().setPath(obj.path).load(obj.nm); mp.normalMap = new TextureLoader().setPath(obj.path).load(obj.nm);
@@ -104,9 +104,13 @@ class MazeObject {
addPhysics(def.matrix, [-tubeSize / 2, 0.6, offsetZ/2], offsetZ) addPhysics(def.matrix, [-tubeSize / 2, 0.6, offsetZ/2], offsetZ)
addRoom(['floor', 'door', def.r ? 'door' : 'wall', def.f ? 'door' : 'wall', def.l ? 'door' : 'wall'], def, offsetZ) addRoom(['floor', 'door', def.r ? 'door' : 'wall', def.f ? 'door' : 'wall', def.l ? 'door' : 'wall'], def, offsetZ)
if (def.userData?.qid !== undefined || def.userData?.finish || def.userData?.corner){ if (def.userData?.qid !== undefined || def.userData?.finish){
addPhysics(def.matrix, [0,0,offsetZ + wallSize/2], { width: wallSize/2, height: wallSize/2, depth: wallSize/2}, 'side', true, def.userData) addPhysics(def.matrix, [0,0,offsetZ + wallSize/2], { width: wallSize/2, height: wallSize/2, depth: wallSize/2}, 'side', true, def.userData)
} }
if (def.userData?.corner){
addPhysics(def.matrix, [0,0,-wallSize/2], { width: wallSize/2, height: wallSize/2, depth: wallSize/2}, 'side', true, {corner: def.userData.corner})
}
//console.log('loadingggg', def.objects) //console.log('loadingggg', def.objects)
def.objects?.forEach(async obj => { def.objects?.forEach(async obj => {
obj.room = room; obj.room = room;
@@ -130,16 +130,18 @@ class MazeQuizGame extends EventDispatcher {
dd = d == 'l' ? 'r' : 'l' dd = d == 'l' ? 'r' : 'l'
} }
if (i == 0){ if (i == 0){
let next = this.generate(questions, qid + 1, 3)
next.userData.corner = { question };
mo[d] = { mo[d] = {
userData: { corner: { question }},
len: 4, len: 4,
[dd]: this.generate(questions, qid + 1, 3) [dd]: next
} }
}else{ }else{
mo[d] = { mo[d] = {
userData: { question, qid, answer: i, corner: { question, penalty: true } }, userData: { question, qid, answer: i },
len: 4, len: 4,
[dd]: { [dd]: {
userData: { corner: { question, penalty: true } },
len: 2, len: 2,
objects:[ objects:[
{ {
@@ -155,10 +157,8 @@ class MazeQuizGame extends EventDispatcher {
let path = mo[d][dd]; let path = mo[d][dd];
mo[d][dd] = { mo[d][dd] = {
len: 1, len: 1,
userData: mo[d].userData,
[dd == 'r' ? 'l' : 'r']: path [dd == 'r' ? 'l' : 'r']: path
} }
delete mo[d].userData;
} }
} }
}) })
+18 -4
View File
@@ -106,9 +106,10 @@ class DashBoard {
const pointsText = new Text() const pointsText = new Text()
Object.assign(pointsText, { Object.assign(pointsText, {
text:``, fontSize: 0.044, font: '/static/fonts/Montserrat-Regular.ttf' text:``, fontSize: 0.044, font: '/static/fonts/Montserrat-Bold.ttf',
outlineColor: 0x113377, outlineWidth: '3%', anchorX: 'center',
}) })
pointsText.position.set(0.88 * engine.aspect/2, 0.33, 0); pointsText.position.set(0.86 * engine.aspect/2, 0.47, 0);
dash.add(pointsText); dash.add(pointsText);
engine.addEventListener('beforeRender', ()=>{ engine.addEventListener('beforeRender', ()=>{
@@ -152,8 +153,21 @@ class DashBoard {
this.addPoints = function(p){ this.addPoints = function(p){
points += p; points += p;
pointsText.text = points; engine.motionQueue.add({
pointsText.sync(); o: pointsText,
a: {rotation:{y: Math.PI}, scale:{x:1.5, y:1.5, z:1.5}},
t: 0.25,
f:()=>{
pointsText.text = points;
pointsText.sync();
engine.motionQueue.add({
o: pointsText,
a: {rotation:{y: Math.PI*2}, scale:{x:1, y:1, z:1}},
t: 0.5,
f: ()=>{pointsText.rotation.y = 0;}
})
}
})
} }
this.enable = ()=>{ this.enable = ()=>{