diff --git a/site/real_game/class/Player.js b/site/real_game/class/Player.js index 6b27134..c925688 100644 --- a/site/real_game/class/Player.js +++ b/site/real_game/class/Player.js @@ -6,11 +6,10 @@ /* By: edbernar { playerExist = false; }) @@ -90,60 +103,110 @@ class Player }); document.addEventListener('keypress', (e) => { - if (e.key == 'm') + if (e.key == 'm' && !this.isOnPointAnim) { this.cameraFixed = !this.cameraFixed; if (!this.cameraFixed) { this.setCameraPosition( this.object.position.x, - this.object.position.y + 0.5, + this.object.position.y - (this.object.position.y >= limits.up ? 0.7 : -0.7), this.object.position.z + 1 ); this.camera.rotation.set(0, 0, 0); } else - this.setCameraPosition(0, 1, 0.7) - } + this.setCameraPosition(0, 1.5, 2.6); + } }); } + pointAnimation(scene, ...lights) + { + const tmpCamera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 10000); + const tmp = this.camera; + let interval = null; + const startColor = this.object.material.color.clone(); + let hue = 0; + + tmpCamera.position.set(3, 3, 3); + this.isOnPointAnim = true; + this.camera = tmpCamera; + interval = setInterval(() => { + tmpCamera.lookAt(this.object.position); + hue += 0.01; + if (hue > 1) + hue = 0; + this.object.material.color.setHSL(hue, 1, 0.5); + tmpCamera.fov -= 0.05; + tmpCamera.updateProjectionMatrix(); + }, 10); + setTimeout(() => { + clearInterval(interval); + this.camera = tmp; + this.object.material.color.copy(startColor); + this.isOnPointAnim = false; + if (!this.cameraFixed) + { + this.setCameraPosition( + this.object.position.x, + this.object.position.y - (this.object.position.y >= limits.up ? 0.7 : -0.7), + this.object.position.z + 1 + ); + } + }, 4000); + } + update() { let i; i = 0; - if (this.cameraFixed) - this.camera.lookAt(new THREE.Vector3(this.object.position.x / 4, (this.object.position.y + 1) / 1.75, this.object.position.z - 1.5)); while (i < this.pressedButton.length) { if (this.pressedButton[i] == 'w' && this.object.position.y < limits.up) { - this.object.position.y += this.speed; - if (!this.cameraFixed) - this.camera.position.y += (this.speed / 2); + if (this.interval) + clearInterval(this.interval); + this.interval = setInterval(() => { + this.object.position.y += this.speed; + if (!this.cameraFixed && !this.isOnPointAnim) + this.camera.position.y += (this.speed / 2); + if (this.object.position.y >= limits.up) + { + clearInterval(this.interval); + this.interval = null; + } + }, 5); } if (this.pressedButton[i] == 's' && this.object.position.y > limits.down) { - this.object.position.y -= this.speed; - if (!this.cameraFixed) - this.camera.position.y -= (this.speed / 2); + if (this.interval) + clearInterval(this.interval); + this.interval = setInterval(() => { + this.object.position.y -= this.speed; + if (!this.cameraFixed && !this.isOnPointAnim) + this.camera.position.y -= (this.speed / 2); + if (this.object.position.y <= limits.down) + { + clearInterval(this.interval); + this.interval = null; + } + }, 5); } if (this.pressedButton[i] == 'd' && this.object.position.x < limits.right) - { - this.object.position.x += this.speed; - if (!this.cameraFixed) - this.camera.position.x += this.speed; - } + { + this.object.position.x += this.speed; + if (!this.cameraFixed && !this.isOnPointAnim) + this.camera.position.x += this.speed; + } if (this.pressedButton[i] == 'a' && this.object.position.x > limits.left) { this.object.position.x -= this.speed; - if (!this.cameraFixed) + if (!this.cameraFixed && !this.isOnPointAnim) this.camera.position.x -= this.speed; } i++; - - } } @@ -153,5 +216,4 @@ class Player } }; - export { Player }; \ No newline at end of file diff --git a/site/real_game/main.js b/site/real_game/main.js index eee5917..2c60732 100644 --- a/site/real_game/main.js +++ b/site/real_game/main.js @@ -6,7 +6,7 @@ /* By: edbernar { + if (e.key == 'g') + player.pointAnimation(scene); +}) + renderer.setAnimationLoop(loop) diff --git a/site/real_game/node_modules/.package-lock.json b/site/real_game/node_modules/.package-lock.json index 4c121de..a232e61 100644 --- a/site/real_game/node_modules/.package-lock.json +++ b/site/real_game/node_modules/.package-lock.json @@ -35,6 +35,18 @@ "node": ">=12" } }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.0.tgz", + "integrity": "sha512-zOnKWLgDld/svhKO5PD9ozmL6roy5OQ5T4ThvdYZLpiOhEGY+dp2NwUmxK0Ld91LrbjrvtNAE0ERBwjqhZTRAA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "os": [ + "darwin" + ] + }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.0.tgz", diff --git a/site/real_game/node_modules/.vite/deps/_metadata.json b/site/real_game/node_modules/.vite/deps/_metadata.json index 56f0b99..6a3e58d 100644 --- a/site/real_game/node_modules/.vite/deps/_metadata.json +++ b/site/real_game/node_modules/.vite/deps/_metadata.json @@ -1,19 +1,19 @@ { - "hash": "0d872a36", - "configHash": "0b4c6e74", - "lockfileHash": "db0c8729", - "browserHash": "9bd24b43", + "hash": "b5ed7c4e", + "configHash": "4027b9ee", + "lockfileHash": "cd36b699", + "browserHash": "32c4be3f", "optimized": { "three": { "src": "../../three/build/three.module.js", "file": "three.js", - "fileHash": "cbcebf47", + "fileHash": "aeffa42d", "needsInterop": false }, "three/examples/jsm/controls/OrbitControls.js": { "src": "../../three/examples/jsm/controls/OrbitControls.js", "file": "three_examples_jsm_controls_OrbitControls__js.js", - "fileHash": "40fe091e", + "fileHash": "fcc35eca", "needsInterop": false } }, diff --git a/site/real_game/node_modules/@rollup/rollup-darwin-arm64/README.md b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/README.md new file mode 100644 index 0000000..c29619c --- /dev/null +++ b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-darwin-arm64` + +This is the **aarch64-apple-darwin** binary for `rollup` diff --git a/site/real_game/node_modules/@rollup/rollup-darwin-arm64/package.json b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/package.json new file mode 100644 index 0000000..c02c398 --- /dev/null +++ b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/package.json @@ -0,0 +1,19 @@ +{ + "name": "@rollup/rollup-darwin-arm64", + "version": "4.21.0", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.darwin-arm64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": "rollup/rollup", + "main": "./rollup.darwin-arm64.node" +} \ No newline at end of file diff --git a/site/real_game/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node new file mode 100644 index 0000000..714d3fb Binary files /dev/null and b/site/real_game/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node differ diff --git a/site/real_game/package-lock.json b/site/real_game/package-lock.json index 2d7a4c0..a6a2112 100644 --- a/site/real_game/package-lock.json +++ b/site/real_game/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "@rollup/rollup-darwin-arm64": "^4.21.0", "rollup": "^4.21.0", "three": "^0.167.1", "vite": "^5.4.1" @@ -412,7 +413,6 @@ "arm64" ], "license": "MIT", - "optional": true, "os": [ "darwin" ] diff --git a/site/real_game/package.json b/site/real_game/package.json index 98df8eb..fe9ee82 100644 --- a/site/real_game/package.json +++ b/site/real_game/package.json @@ -3,6 +3,7 @@ "dev": "vite" }, "dependencies": { + "@rollup/rollup-darwin-arm64": "^4.21.0", "rollup": "^4.21.0", "three": "^0.167.1", "vite": "^5.4.1"