Game mutli - Set ball ivisible while gaol - Set/Unset ball shadow if on bottom/top
This commit is contained in:
@ -59,6 +59,7 @@ class Ball
|
|||||||
|
|
||||||
mesh.receiveShadow = true;
|
mesh.receiveShadow = true;
|
||||||
mesh.castShadow = true;
|
mesh.castShadow = true;
|
||||||
|
mesh.material.transparent = true;
|
||||||
mesh.position.set(this.centerPos.x, this.centerPos.y, this.centerPos.z);
|
mesh.position.set(this.centerPos.x, this.centerPos.y, this.centerPos.z);
|
||||||
return (mesh);
|
return (mesh);
|
||||||
}
|
}
|
||||||
@ -73,6 +74,23 @@ class Ball
|
|||||||
this.object.scale.set(1, 1, 1);
|
this.object.scale.set(1, 1, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setVisibility(bool)
|
||||||
|
{
|
||||||
|
if (bool)
|
||||||
|
this.object.material.opacity = 1;
|
||||||
|
else
|
||||||
|
this.object.material.opacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCastShadow(bool)
|
||||||
|
{
|
||||||
|
if (bool)
|
||||||
|
this.object.castShadow = true;
|
||||||
|
else
|
||||||
|
this.object.castShadow = false;
|
||||||
|
console.log("this.object.castShadow", bool);
|
||||||
|
}
|
||||||
|
|
||||||
setPosition(x, y, z)
|
setPosition(x, y, z)
|
||||||
{
|
{
|
||||||
this.object.position.set(x, y, z);
|
this.object.position.set(x, y, z);
|
||||||
@ -86,7 +104,12 @@ class Ball
|
|||||||
const slower = speed / 3;
|
const slower = speed / 3;
|
||||||
|
|
||||||
if (diffBot > diffTop)
|
if (diffBot > diffTop)
|
||||||
|
{
|
||||||
speed *= -1;
|
speed *= -1;
|
||||||
|
this.setCastShadow(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.setCastShadow(false);
|
||||||
if (this.interval)
|
if (this.interval)
|
||||||
clearInterval(this.interval);
|
clearInterval(this.interval);
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
import { fetchProfile, MotionController } from '/static/javascript/three/examples/jsm/libs/motion-controllers.module.js'
|
import { fetchProfile, MotionController } from '/static/javascript/three/examples/jsm/libs/motion-controllers.module.js'
|
||||||
import { XRControllerModelFactory } from '/static/javascript/three/examples/jsm/webxr/XRControllerModelFactory.js'
|
import { XRControllerModelFactory } from '/static/javascript/three/examples/jsm/webxr/XRControllerModelFactory.js'
|
||||||
import { scene, renderer, isInVrMode } from '/static/javascript/multiOnlineGame/multiOnlineGamePage.js'
|
import { scene, renderer, isInVrMode, ball } from '/static/javascript/multiOnlineGame/multiOnlineGamePage.js'
|
||||||
import { lastSelectedGoal, availableGoals } from '/static/javascript/lobbyPage/3d.js';
|
import { lastSelectedGoal, availableGoals } from '/static/javascript/lobbyPage/3d.js';
|
||||||
import * as THREE from '/static/javascript/three/build/three.module.js'
|
import * as THREE from '/static/javascript/three/build/three.module.js'
|
||||||
import { layoutSelected } from '/static/javascript/lobbyPage/main.js'
|
import { layoutSelected } from '/static/javascript/lobbyPage/main.js'
|
||||||
@ -147,6 +147,9 @@ class Player
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.mapVar.putVideoOnCanvas(0, null);
|
this.mapVar.putVideoOnCanvas(0, null);
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
|
||||||
|
ball.setVisibility(false);
|
||||||
|
|
||||||
if (isOpponent)
|
if (isOpponent)
|
||||||
{
|
{
|
||||||
this.mapVar.reCreate("opponent");
|
this.mapVar.reCreate("opponent");
|
||||||
@ -171,7 +174,7 @@ class Player
|
|||||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
||||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeInGames 0.199s';
|
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeInGames 0.199s';
|
||||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
||||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOutGames 0.199s';
|
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOutGames 0.199s';
|
||||||
@ -208,6 +211,9 @@ class Player
|
|||||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
ball.setVisibility(true);
|
||||||
|
ball.setCastShadow(true);
|
||||||
|
|
||||||
this.camera = tmp;
|
this.camera = tmp;
|
||||||
this.object.material.color.copy(startColor);
|
this.object.material.color.copy(startColor);
|
||||||
isOnPointAnim = false;
|
isOnPointAnim = false;
|
||||||
@ -246,6 +252,7 @@ class Player
|
|||||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOut 0.199s';
|
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOut 0.199s';
|
||||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(1)';
|
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(1)';
|
||||||
}, 300)
|
}, 300)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tmpCamera.position.set(this.limits.left, this.limits.up / 2 + 0.5, map.centerPos.z);
|
tmpCamera.position.set(this.limits.left, this.limits.up / 2 + 0.5, map.centerPos.z);
|
||||||
isOnPointAnim = true;
|
isOnPointAnim = true;
|
||||||
@ -272,6 +279,9 @@ class Player
|
|||||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
ball.setVisibility(true);
|
||||||
|
ball.setCastShadow(true);
|
||||||
|
|
||||||
this.camera = tmp;
|
this.camera = tmp;
|
||||||
oppponentObject.material.color.copy(startColor);
|
oppponentObject.material.color.copy(startColor);
|
||||||
isOnPointAnim = false;
|
isOnPointAnim = false;
|
||||||
|
Reference in New Issue
Block a user