This commit is contained in:
2025-10-14 18:36:02 +03:00
parent a6827f4ddb
commit a60d94fe66
16 changed files with 1225 additions and 33 deletions
@@ -4,7 +4,7 @@ import { MotionEngine } from '../../lib/MotionEngine';
class Game1 {
constructor(context, image, w, h) {
this.game = new Group();
this.object = new Group();
const aq = new MotionEngine();
const pr = [[0, -1], [0, 1], [1, 0], [-1, 0], [0, 0], [0, 2]];
let d = 1.2;
@@ -40,20 +40,20 @@ class Game1 {
let ri;
do {
ri = Math.floor(Math.random() * 6);
} while (ri == this.game.children.length);
} while (ri == this.object.children.length);
mesh.rotation.set(pr[ri][0] * Math.PI / 2, pr[ri][1] * Math.PI / 2, 0);
mesh._ri = ri;
this.game.add(mesh);
this.object.add(mesh);
}
this.game.children[0].onBeforeRender = () => {
this.object.children[0].onBeforeRender = () => {
this.update();
};
var check = () => {
if (!this.game.children.length) return false;
if (!this.object.children.length) return false;
let i = 0;
for (let c of this.game.children) {
for (let c of this.object.children) {
if (Math.abs(c.rotation.x - pr[i][0] * Math.PI / 2) > 0.0001 || Math.abs(c.rotation.y - pr[i][1] * Math.PI / 2) > 0.0001) return false;
i++;
}
@@ -71,7 +71,7 @@ class Game1 {
}
};
this.game.children.forEach(c => {
this.object.children.forEach(c => {
context.clickable.add(c, clickFn);
});
@@ -79,7 +79,7 @@ class Game1 {
aq.update();
if (aq.isIdle() && !this.done && check()) {
this.done = true;
this.game.children.forEach((c, i) => {
this.object.children.forEach((c, i) => {
aq.add({
o: c,
a: { position: { x: i % w, y: i % h } },