change event dispatcher

This commit is contained in:
2025-11-11 15:15:13 +02:00
parent 35fa1863ff
commit 351c6097f3
10 changed files with 71 additions and 67 deletions
@@ -1,9 +1,10 @@
import { BoxGeometry, Mesh, MeshStandardMaterial, Group } from 'three';
import { BoxGeometry, Mesh, MeshStandardMaterial, Group, EventDispatcher } from 'three';
import { MotionEngine } from '../../lib/MotionEngine';
import { centerOrigin } from '@/lib/MeshUtils';
class PuzzleGame1 {
class PuzzleGame1 extends EventDispatcher {
constructor(engine, data) {
super();
return new Promise(async (resolve, reject)=>{
let w = data.w, h = data.h, wh = w*h;
let container = new Group();
@@ -92,7 +93,9 @@ class PuzzleGame1 {
o: c,
a: { position: { x: i % w, y: Math.trunc(i/w)} },
t: 1,
f: i == 0 && this.onfinish || undefined
f: i == 0 ? ()=>{
this.dispatchEvent({type:'finish'})
} : undefined
});
});
//engine.dashboard.addPoints(10);