Game
- Update all class
This commit is contained in:
BIN
site/real_game/blender/exported/map1.glb
Normal file
BIN
site/real_game/blender/exported/map1.glb
Normal file
Binary file not shown.
BIN
site/real_game/blender/map1.blend
Normal file
BIN
site/real_game/blender/map1.blend
Normal file
Binary file not shown.
BIN
site/real_game/blender/map1.blend1
Normal file
BIN
site/real_game/blender/map1.blend1
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
||||
/* Updated: 2024/08/21 00:57:42 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/08/21 10:33:58 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,7 +14,9 @@ import * as THREE from 'three';
|
||||
|
||||
/*
|
||||
Todo (Eddy) :
|
||||
- Ajouter fonction pour changer la gravité de la balle
|
||||
- Ajouter fonction pour changer la gravité de la balle (OK)
|
||||
- Ajouter un effet plus naturel pour le déplacement de la balle (OK)
|
||||
|
||||
*/
|
||||
|
||||
class Ball
|
||||
@ -58,9 +60,10 @@ class Ball
|
||||
|
||||
changeGravity()
|
||||
{
|
||||
let diffTop = this.limits.up - this.object.position.y;
|
||||
let diffBot = this.object.position.y - this.limits.down;
|
||||
let speed = 0.1;
|
||||
let diffTop = this.limits.up - this.object.position.y;
|
||||
let diffBot = this.object.position.y - this.limits.down;
|
||||
let speed = 0.25;
|
||||
const slower = speed / 3;
|
||||
|
||||
if (diffBot > diffTop)
|
||||
speed *= -1;
|
||||
@ -78,6 +81,7 @@ class Ball
|
||||
else
|
||||
this.setPosition(this.object.position.x, this.limits.down, this.object.position.z);
|
||||
}
|
||||
speed -= speed * slower;
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,27 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
||||
/* Updated: 2024/08/21 00:59:01 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/08/21 14:56:10 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
|
||||
/*
|
||||
Todo (Eddy) :
|
||||
- Ajouter la transparence sur les murs sur la distance de la balle (OK)
|
||||
- Ajouter des textures selon le type : number pour couleur, string pour img (OK)
|
||||
- Ajouter une fonctione pour modifier la gravité
|
||||
*/
|
||||
|
||||
const loader = new GLTFLoader();
|
||||
|
||||
class Map
|
||||
{
|
||||
scene = null;
|
||||
arrObject = [];
|
||||
ballObject = null;
|
||||
centerPos = {
|
||||
x: -1,
|
||||
y: -1,
|
||||
@ -44,11 +49,11 @@ class Map
|
||||
scene.add(this.#createWall(3.5, 0.4, -length/2, "wallRight"));
|
||||
this.centerPos.x = 0;
|
||||
this.centerPos.y = 0.15;
|
||||
this.centerPos.z = -length/2;
|
||||
this.centerPos.z = -length / 2 + length / 2;
|
||||
this.mapLength = length;
|
||||
};
|
||||
|
||||
#createPlanes(x, y, rot, name, isBottom, visual) // passer un materiel
|
||||
#createPlanes(x, y, rot, name, isBottom, visual)
|
||||
{
|
||||
for (let i = 0; i < this.arrObject.length; i++)
|
||||
{
|
||||
@ -68,16 +73,13 @@ class Map
|
||||
else if (typeof(visual) == 'number')
|
||||
material = new THREE.MeshPhysicalMaterial({ color: visual });
|
||||
else
|
||||
{
|
||||
console.log("kjdsjksd");
|
||||
material = new THREE.MeshPhysicalMaterial();
|
||||
}
|
||||
mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.rotateX(rot);
|
||||
if (isBottom)
|
||||
mesh.position.set(0, 0.15, -6);
|
||||
mesh.position.set(0, 0.15, 0);
|
||||
else
|
||||
mesh.position.set(0, 3.15, -6);
|
||||
mesh.position.set(0, 3.15, 0);
|
||||
this.arrObject.push({mesh: mesh, name: name});
|
||||
mesh.receiveShadow = true;
|
||||
return (mesh);
|
||||
@ -101,6 +103,13 @@ class Map
|
||||
return (mesh);
|
||||
};
|
||||
|
||||
createGravityChanger(ball, x, z, onTop)
|
||||
{
|
||||
if (this.ballObject == null)
|
||||
throw Error("Ball is not init");
|
||||
|
||||
}
|
||||
|
||||
update(ball)
|
||||
{
|
||||
for (let i = 0; i < this.arrObject.length; i++)
|
||||
@ -136,7 +145,7 @@ class Map
|
||||
this.arrObject[i].mesh.material.opacity = 1 - (diff / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export { Map };
|
48
site/real_game/class/Opponent.js
Normal file
48
site/real_game/class/Opponent.js
Normal file
@ -0,0 +1,48 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Opponent.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/21 10:34:49 by edbernar #+# #+# */
|
||||
/* Updated: 2024/08/21 14:38:44 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import { playerExist } from './Player'
|
||||
import * as THREE from 'three';
|
||||
|
||||
let opponentExist = false;
|
||||
|
||||
class Opponent
|
||||
{
|
||||
object = null;
|
||||
speed = 0.1;
|
||||
interval = null;
|
||||
limits = {};
|
||||
player = null;
|
||||
|
||||
constructor (object, map)
|
||||
{
|
||||
if (!playerExist)
|
||||
throw Error('Player need to be init before opponent.')
|
||||
if (opponentExist)
|
||||
throw Error("Opponent is already init.");
|
||||
opponentExist = true;
|
||||
this.object = object;
|
||||
this.limits = map.limits;
|
||||
this.object.position.set(0, 0.3, -map.mapLength / 2 + 0.2);
|
||||
this.cleanup = new FinalizationRegistry((heldValue) => {
|
||||
playerExist = false;
|
||||
})
|
||||
this.cleanup.register(this, null);
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
//en attente du serveur
|
||||
}
|
||||
}
|
||||
|
||||
export { Opponent };
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
||||
/* Updated: 2024/08/21 00:27:01 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/08/21 14:42:20 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -40,6 +40,7 @@ import * as THREE from 'three';
|
||||
- Ajouter les mouvements définis sur l'axe y (OK)
|
||||
- Faire une fonction qui change de camera quand il y a un but avec un fondu en noir (OK)
|
||||
- Ajouter un zoom sur la camera de la fonction pointAnimation (OK)
|
||||
- Ajouter une fonction pour l'animation de point marqué (OK)
|
||||
*/
|
||||
|
||||
let playerExist = false;
|
||||
@ -63,12 +64,12 @@ class Player
|
||||
this.object = object;
|
||||
this.limits = map.playerLimits;
|
||||
this.camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 10000);
|
||||
this.object.position.set(0, 0.32, map.mapLength / 2 - 0.2);
|
||||
this.setCameraPosition(
|
||||
this.object.position.x,
|
||||
this.object.position.y + 0.7,
|
||||
this.object.position.z + 2
|
||||
);
|
||||
this.object.position.set(this.object.position.x, this.limits.down, this.object.position.z);
|
||||
this.cleanup = new FinalizationRegistry((heldValue) => {
|
||||
playerExist = false;
|
||||
})
|
||||
@ -103,7 +104,7 @@ class Player
|
||||
this.setCameraPosition(
|
||||
this.object.position.x,
|
||||
this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7),
|
||||
this.object.position.z + 2
|
||||
this.object.position.z + 5
|
||||
);
|
||||
this.camera.rotation.set(0, 0, 0);
|
||||
}
|
||||
@ -113,7 +114,7 @@ class Player
|
||||
});
|
||||
}
|
||||
|
||||
pointAnimation(scene)
|
||||
pointAnimation(map)
|
||||
{
|
||||
const tmpCamera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 10000);
|
||||
const tmp = this.camera;
|
||||
@ -128,7 +129,7 @@ class Player
|
||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)';
|
||||
}, 300)
|
||||
setTimeout(() => {
|
||||
tmpCamera.position.set(-3, this.limits.up / 2 + 0.5, -3);
|
||||
tmpCamera.position.set(this.limits.left, this.limits.up / 2 + 0.5, map.centerPos.z);
|
||||
this.isOnPointAnim = true;
|
||||
this.camera = tmpCamera;
|
||||
interval = setInterval(() => {
|
||||
@ -164,6 +165,58 @@ class Player
|
||||
}, 200)
|
||||
}
|
||||
|
||||
pointOpponentAnimation(map, oppponentObject)
|
||||
{
|
||||
const tmpCamera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 10000);
|
||||
const tmp = this.camera;
|
||||
let interval = null;
|
||||
const startColor = oppponentObject.material.color.clone();
|
||||
let hue = 0;
|
||||
|
||||
document.getElementsByTagName('canvas')[0].style.animation = 'fadeIn 0.199s';
|
||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(0)';
|
||||
setTimeout(() => {
|
||||
document.getElementsByTagName('canvas')[0].style.animation = 'fadeOut 0.199s';
|
||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)';
|
||||
}, 300)
|
||||
setTimeout(() => {
|
||||
tmpCamera.position.set(this.limits.left, this.limits.up / 2 + 0.5, map.centerPos.z);
|
||||
this.isOnPointAnim = true;
|
||||
this.camera = tmpCamera;
|
||||
interval = setInterval(() => {
|
||||
tmpCamera.lookAt(oppponentObject.position);
|
||||
console.log(tmpCamera.position)
|
||||
hue += 0.01;
|
||||
if (hue > 1)
|
||||
hue = 0;
|
||||
oppponentObject.material.color.setHSL(hue, 1, 0.5);
|
||||
tmpCamera.fov -= 0.05;
|
||||
tmpCamera.updateProjectionMatrix();
|
||||
}, 10);
|
||||
setTimeout(() => {
|
||||
clearInterval(interval);
|
||||
document.getElementsByTagName('canvas')[0].style.animation = null;
|
||||
document.getElementsByTagName('canvas')[0].style.animation = 'fadeIn 0.19s';
|
||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(0)';
|
||||
setTimeout(() => {
|
||||
this.camera = tmp;
|
||||
oppponentObject.material.color.copy(startColor);
|
||||
this.isOnPointAnim = false;
|
||||
if (!this.cameraFixed)
|
||||
{
|
||||
this.setCameraPosition(
|
||||
this.object.position.x,
|
||||
this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7),
|
||||
this.object.position.z + 2
|
||||
);
|
||||
}
|
||||
document.getElementsByTagName('canvas')[0].style.animation = 'fadeOut 0.199s';
|
||||
document.getElementsByTagName('canvas')[0].style.filter = 'brightness(1)';
|
||||
}, 200);
|
||||
}, 4000);
|
||||
}, 200)
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
let i;
|
||||
@ -223,4 +276,4 @@ class Player
|
||||
}
|
||||
};
|
||||
|
||||
export { Player };
|
||||
export { Player, playerExist };
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
||||
/* Updated: 2024/08/21 00:10:46 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/08/21 14:51:31 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,6 +14,10 @@ import * as THREE from 'three';
|
||||
import { Player } from './class/Player'
|
||||
import { Map } from './class/Map'
|
||||
import { Ball } from './class/Ball'
|
||||
import { Opponent } from './class/Opponent'
|
||||
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
||||
|
||||
let debug = false;
|
||||
|
||||
function createBarPlayer(color)
|
||||
{
|
||||
@ -21,7 +25,6 @@ function createBarPlayer(color)
|
||||
const material = new THREE.MeshPhysicalMaterial({color: color});
|
||||
const mesh = new THREE.Mesh(geometry, material);
|
||||
|
||||
mesh.position.set(0, 0.2, 0);
|
||||
mesh.castShadow = true;
|
||||
return (mesh);
|
||||
}
|
||||
@ -30,24 +33,35 @@ function loop()
|
||||
{
|
||||
player.update();
|
||||
map.update(ball.object);
|
||||
renderer.render(scene, player.camera);
|
||||
if (debug)
|
||||
{
|
||||
controls.update();
|
||||
renderer.render(scene, cameraTmp);
|
||||
}
|
||||
else
|
||||
renderer.render(scene, player.camera);
|
||||
|
||||
}
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
const map = new Map(scene, 13);
|
||||
const bar = createBarPlayer(0xed56ea);
|
||||
const bar1 = createBarPlayer(0xed56ea);
|
||||
const renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
renderer.shadowMap.enabled = true;
|
||||
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||
const player = new Player(bar, map);
|
||||
const player = new Player(bar1, map);
|
||||
const spotLight = new THREE.SpotLight(0xffffff, 10000, 0, 0.2);
|
||||
spotLight.castShadow = true;
|
||||
const ambiantLight = new THREE.AmbientLight(0xffffff, 0.5);
|
||||
const ball = new Ball(scene, map)
|
||||
const ball = new Ball(scene, map);
|
||||
const bar2 = createBarPlayer(0xf3e11e);
|
||||
const opponent = new Opponent(bar2, map);
|
||||
|
||||
|
||||
scene.add(player.object);
|
||||
scene.add(opponent.object);
|
||||
console.log(player.object.position);
|
||||
console.log(opponent.object.position);
|
||||
scene.add(ambiantLight);
|
||||
spotLight.position.set(0, 100, 0);
|
||||
scene.add(spotLight);
|
||||
@ -55,10 +69,28 @@ scene.background = new THREE.Color(0x1a1a1a);
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
document.body.appendChild(renderer.domElement);
|
||||
ball.initMoveBallTmp();
|
||||
map.ballObject = ball.object;
|
||||
|
||||
// map.addDecor('blender/exported/map1.glb')
|
||||
map.createGravityChanger(1, 1, false);
|
||||
|
||||
|
||||
|
||||
/*---------------DEBUG----------------*/
|
||||
const cameraTmp = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight);
|
||||
const controls = new OrbitControls(cameraTmp, renderer.domElement);
|
||||
cameraTmp.position.set(15, 0, 15);
|
||||
controls.target = new THREE.Vector3(map.centerPos.x, 0, map.centerPos.z);
|
||||
|
||||
/*------------------------------------*/
|
||||
|
||||
document.addEventListener('keypress', (e) => {
|
||||
if (e.key == 'g')
|
||||
player.pointAnimation(scene);
|
||||
player.pointAnimation(map);
|
||||
if (e.key == 'h')
|
||||
player.pointOpponentAnimation(map, opponent.object);
|
||||
if (e.key == 'c')
|
||||
debug = !debug;
|
||||
})
|
||||
|
||||
renderer.setAnimationLoop(loop)
|
||||
|
30
site/real_game/node_modules/.vite/deps/_metadata.json
generated
vendored
30
site/real_game/node_modules/.vite/deps/_metadata.json
generated
vendored
@ -1,34 +1,34 @@
|
||||
{
|
||||
"hash": "aeb97021",
|
||||
"configHash": "0b4c6e74",
|
||||
"hash": "b5ed7c4e",
|
||||
"configHash": "4027b9ee",
|
||||
"lockfileHash": "cd36b699",
|
||||
"browserHash": "84f752d1",
|
||||
"browserHash": "02ec5995",
|
||||
"optimized": {
|
||||
"three": {
|
||||
"src": "../../three/build/three.module.js",
|
||||
"file": "three.js",
|
||||
"fileHash": "a5c835fb",
|
||||
"fileHash": "b8c4b79b",
|
||||
"needsInterop": false
|
||||
},
|
||||
"three/addons/loaders/GLTFLoader.js": {
|
||||
"src": "../../three/examples/jsm/loaders/GLTFLoader.js",
|
||||
"file": "three_addons_loaders_GLTFLoader__js.js",
|
||||
"fileHash": "605336b1",
|
||||
"needsInterop": false
|
||||
},
|
||||
"three/examples/jsm/Addons.js": {
|
||||
"src": "../../three/examples/jsm/Addons.js",
|
||||
"file": "three_examples_jsm_Addons__js.js",
|
||||
"fileHash": "aa17f873",
|
||||
"needsInterop": false
|
||||
},
|
||||
"three/examples/jsm/libs/tween.module.js": {
|
||||
"src": "../../three/examples/jsm/libs/tween.module.js",
|
||||
"file": "three_examples_jsm_libs_tween__module__js.js",
|
||||
"fileHash": "b4479a8c",
|
||||
"fileHash": "cc6bff05",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
"chunks": {
|
||||
"chunk-IS2ZBFBB": {
|
||||
"file": "chunk-IS2ZBFBB.js"
|
||||
"chunk-LBH6F3OL": {
|
||||
"file": "chunk-LBH6F3OL.js"
|
||||
},
|
||||
"chunk-PZ5AY32C": {
|
||||
"file": "chunk-PZ5AY32C.js"
|
||||
"chunk-33KXLYU5": {
|
||||
"file": "chunk-33KXLYU5.js"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,9 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
|
||||
// node_modules/three/build/three.module.js
|
||||
var REVISION = "167";
|
||||
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
||||
@ -30704,6 +30710,7 @@ if (typeof window !== "undefined") {
|
||||
}
|
||||
|
||||
export {
|
||||
__export,
|
||||
REVISION,
|
||||
MOUSE,
|
||||
TOUCH,
|
||||
@ -31132,4 +31139,4 @@ three/build/three.module.js:
|
||||
* SPDX-License-Identifier: MIT
|
||||
*)
|
||||
*/
|
||||
//# sourceMappingURL=chunk-IS2ZBFBB.js.map
|
||||
//# sourceMappingURL=chunk-33KXLYU5.js.map
|
File diff suppressed because one or more lines are too long
3334
site/real_game/node_modules/.vite/deps/chunk-LBH6F3OL.js
generated
vendored
Normal file
3334
site/real_game/node_modules/.vite/deps/chunk-LBH6F3OL.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
site/real_game/node_modules/.vite/deps/chunk-LBH6F3OL.js.map
generated
vendored
Normal file
7
site/real_game/node_modules/.vite/deps/chunk-LBH6F3OL.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
site/real_game/node_modules/.vite/deps/chunk-PZ5AY32C.js
generated
vendored
10
site/real_game/node_modules/.vite/deps/chunk-PZ5AY32C.js
generated
vendored
@ -1,10 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
|
||||
export {
|
||||
__export
|
||||
};
|
||||
//# sourceMappingURL=chunk-PZ5AY32C.js.map
|
3
site/real_game/node_modules/.vite/deps/three.js
generated
vendored
3
site/real_game/node_modules/.vite/deps/three.js
generated
vendored
@ -417,8 +417,7 @@ import {
|
||||
ZeroSlopeEnding,
|
||||
ZeroStencilOp,
|
||||
createCanvasElement
|
||||
} from "./chunk-IS2ZBFBB.js";
|
||||
import "./chunk-PZ5AY32C.js";
|
||||
} from "./chunk-33KXLYU5.js";
|
||||
export {
|
||||
ACESFilmicToneMapping,
|
||||
AddEquation,
|
||||
|
8
site/real_game/node_modules/.vite/deps/three_addons_loaders_GLTFLoader__js.js
generated
vendored
Normal file
8
site/real_game/node_modules/.vite/deps/three_addons_loaders_GLTFLoader__js.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import {
|
||||
GLTFLoader
|
||||
} from "./chunk-LBH6F3OL.js";
|
||||
import "./chunk-33KXLYU5.js";
|
||||
export {
|
||||
GLTFLoader
|
||||
};
|
||||
//# sourceMappingURL=three_addons_loaders_GLTFLoader__js.js.map
|
3278
site/real_game/node_modules/.vite/deps/three_examples_jsm_Addons__js.js
generated
vendored
3278
site/real_game/node_modules/.vite/deps/three_examples_jsm_Addons__js.js
generated
vendored
File diff suppressed because it is too large
Load Diff
8
site/real_game/node_modules/.vite/deps/three_examples_jsm_Addons__js.js.map
generated
vendored
8
site/real_game/node_modules/.vite/deps/three_examples_jsm_Addons__js.js.map
generated
vendored
File diff suppressed because one or more lines are too long
836
site/real_game/node_modules/.vite/deps/three_examples_jsm_libs_tween__module__js.js
generated
vendored
836
site/real_game/node_modules/.vite/deps/three_examples_jsm_libs_tween__module__js.js
generated
vendored
@ -1,836 +0,0 @@
|
||||
import "./chunk-PZ5AY32C.js";
|
||||
|
||||
// node_modules/three/examples/jsm/libs/tween.module.js
|
||||
var Easing = Object.freeze({
|
||||
Linear: Object.freeze({
|
||||
None: function(amount) {
|
||||
return amount;
|
||||
},
|
||||
In: function(amount) {
|
||||
return this.None(amount);
|
||||
},
|
||||
Out: function(amount) {
|
||||
return this.None(amount);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
return this.None(amount);
|
||||
}
|
||||
}),
|
||||
Quadratic: Object.freeze({
|
||||
In: function(amount) {
|
||||
return amount * amount;
|
||||
},
|
||||
Out: function(amount) {
|
||||
return amount * (2 - amount);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount;
|
||||
}
|
||||
return -0.5 * (--amount * (amount - 2) - 1);
|
||||
}
|
||||
}),
|
||||
Cubic: Object.freeze({
|
||||
In: function(amount) {
|
||||
return amount * amount * amount;
|
||||
},
|
||||
Out: function(amount) {
|
||||
return --amount * amount * amount + 1;
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount;
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
||||
}
|
||||
}),
|
||||
Quartic: Object.freeze({
|
||||
In: function(amount) {
|
||||
return amount * amount * amount * amount;
|
||||
},
|
||||
Out: function(amount) {
|
||||
return 1 - --amount * amount * amount * amount;
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount * amount;
|
||||
}
|
||||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
||||
}
|
||||
}),
|
||||
Quintic: Object.freeze({
|
||||
In: function(amount) {
|
||||
return amount * amount * amount * amount * amount;
|
||||
},
|
||||
Out: function(amount) {
|
||||
return --amount * amount * amount * amount * amount + 1;
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount * amount * amount;
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
||||
}
|
||||
}),
|
||||
Sinusoidal: Object.freeze({
|
||||
In: function(amount) {
|
||||
return 1 - Math.sin((1 - amount) * Math.PI / 2);
|
||||
},
|
||||
Out: function(amount) {
|
||||
return Math.sin(amount * Math.PI / 2);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
|
||||
}
|
||||
}),
|
||||
Exponential: Object.freeze({
|
||||
In: function(amount) {
|
||||
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
||||
},
|
||||
Out: function(amount) {
|
||||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * Math.pow(1024, amount - 1);
|
||||
}
|
||||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
||||
}
|
||||
}),
|
||||
Circular: Object.freeze({
|
||||
In: function(amount) {
|
||||
return 1 - Math.sqrt(1 - amount * amount);
|
||||
},
|
||||
Out: function(amount) {
|
||||
return Math.sqrt(1 - --amount * amount);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
|
||||
}
|
||||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
||||
}
|
||||
}),
|
||||
Elastic: Object.freeze({
|
||||
In: function(amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
||||
},
|
||||
Out: function(amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
amount *= 2;
|
||||
if (amount < 1) {
|
||||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
||||
}
|
||||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
||||
}
|
||||
}),
|
||||
Back: Object.freeze({
|
||||
In: function(amount) {
|
||||
var s = 1.70158;
|
||||
return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
|
||||
},
|
||||
Out: function(amount) {
|
||||
var s = 1.70158;
|
||||
return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
|
||||
},
|
||||
InOut: function(amount) {
|
||||
var s = 1.70158 * 1.525;
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * (amount * amount * ((s + 1) * amount - s));
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
||||
}
|
||||
}),
|
||||
Bounce: Object.freeze({
|
||||
In: function(amount) {
|
||||
return 1 - Easing.Bounce.Out(1 - amount);
|
||||
},
|
||||
Out: function(amount) {
|
||||
if (amount < 1 / 2.75) {
|
||||
return 7.5625 * amount * amount;
|
||||
} else if (amount < 2 / 2.75) {
|
||||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
|
||||
} else if (amount < 2.5 / 2.75) {
|
||||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
|
||||
} else {
|
||||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
|
||||
}
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if (amount < 0.5) {
|
||||
return Easing.Bounce.In(amount * 2) * 0.5;
|
||||
}
|
||||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
||||
}
|
||||
}),
|
||||
generatePow: function(power) {
|
||||
if (power === void 0) {
|
||||
power = 4;
|
||||
}
|
||||
power = power < Number.EPSILON ? Number.EPSILON : power;
|
||||
power = power > 1e4 ? 1e4 : power;
|
||||
return {
|
||||
In: function(amount) {
|
||||
return Math.pow(amount, power);
|
||||
},
|
||||
Out: function(amount) {
|
||||
return 1 - Math.pow(1 - amount, power);
|
||||
},
|
||||
InOut: function(amount) {
|
||||
if (amount < 0.5) {
|
||||
return Math.pow(amount * 2, power) / 2;
|
||||
}
|
||||
return (1 - Math.pow(2 - amount * 2, power)) / 2 + 0.5;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
var now = function() {
|
||||
return performance.now();
|
||||
};
|
||||
var Group = (
|
||||
/** @class */
|
||||
function() {
|
||||
function Group2() {
|
||||
this._tweens = {};
|
||||
this._tweensAddedDuringUpdate = {};
|
||||
}
|
||||
Group2.prototype.getAll = function() {
|
||||
var _this = this;
|
||||
return Object.keys(this._tweens).map(function(tweenId) {
|
||||
return _this._tweens[tweenId];
|
||||
});
|
||||
};
|
||||
Group2.prototype.removeAll = function() {
|
||||
this._tweens = {};
|
||||
};
|
||||
Group2.prototype.add = function(tween) {
|
||||
this._tweens[tween.getId()] = tween;
|
||||
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
||||
};
|
||||
Group2.prototype.remove = function(tween) {
|
||||
delete this._tweens[tween.getId()];
|
||||
delete this._tweensAddedDuringUpdate[tween.getId()];
|
||||
};
|
||||
Group2.prototype.update = function(time, preserve) {
|
||||
if (time === void 0) {
|
||||
time = now();
|
||||
}
|
||||
if (preserve === void 0) {
|
||||
preserve = false;
|
||||
}
|
||||
var tweenIds = Object.keys(this._tweens);
|
||||
if (tweenIds.length === 0) {
|
||||
return false;
|
||||
}
|
||||
while (tweenIds.length > 0) {
|
||||
this._tweensAddedDuringUpdate = {};
|
||||
for (var i = 0; i < tweenIds.length; i++) {
|
||||
var tween = this._tweens[tweenIds[i]];
|
||||
var autoStart = !preserve;
|
||||
if (tween && tween.update(time, autoStart) === false && !preserve) {
|
||||
delete this._tweens[tweenIds[i]];
|
||||
}
|
||||
}
|
||||
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return Group2;
|
||||
}()
|
||||
);
|
||||
var Interpolation = {
|
||||
Linear: function(v, k) {
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
var fn = Interpolation.Utils.Linear;
|
||||
if (k < 0) {
|
||||
return fn(v[0], v[1], f);
|
||||
}
|
||||
if (k > 1) {
|
||||
return fn(v[m], v[m - 1], m - f);
|
||||
}
|
||||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
||||
},
|
||||
Bezier: function(v, k) {
|
||||
var b = 0;
|
||||
var n = v.length - 1;
|
||||
var pw = Math.pow;
|
||||
var bn = Interpolation.Utils.Bernstein;
|
||||
for (var i = 0; i <= n; i++) {
|
||||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
|
||||
}
|
||||
return b;
|
||||
},
|
||||
CatmullRom: function(v, k) {
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
var fn = Interpolation.Utils.CatmullRom;
|
||||
if (v[0] === v[m]) {
|
||||
if (k < 0) {
|
||||
i = Math.floor(f = m * (1 + k));
|
||||
}
|
||||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
||||
} else {
|
||||
if (k < 0) {
|
||||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
|
||||
}
|
||||
if (k > 1) {
|
||||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
||||
}
|
||||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
|
||||
}
|
||||
},
|
||||
Utils: {
|
||||
Linear: function(p0, p1, t) {
|
||||
return (p1 - p0) * t + p0;
|
||||
},
|
||||
Bernstein: function(n, i) {
|
||||
var fc = Interpolation.Utils.Factorial;
|
||||
return fc(n) / fc(i) / fc(n - i);
|
||||
},
|
||||
Factorial: /* @__PURE__ */ function() {
|
||||
var a = [1];
|
||||
return function(n) {
|
||||
var s = 1;
|
||||
if (a[n]) {
|
||||
return a[n];
|
||||
}
|
||||
for (var i = n; i > 1; i--) {
|
||||
s *= i;
|
||||
}
|
||||
a[n] = s;
|
||||
return s;
|
||||
};
|
||||
}(),
|
||||
CatmullRom: function(p0, p1, p2, p3, t) {
|
||||
var v0 = (p2 - p0) * 0.5;
|
||||
var v1 = (p3 - p1) * 0.5;
|
||||
var t2 = t * t;
|
||||
var t3 = t * t2;
|
||||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
||||
}
|
||||
}
|
||||
};
|
||||
var Sequence = (
|
||||
/** @class */
|
||||
function() {
|
||||
function Sequence2() {
|
||||
}
|
||||
Sequence2.nextId = function() {
|
||||
return Sequence2._nextId++;
|
||||
};
|
||||
Sequence2._nextId = 0;
|
||||
return Sequence2;
|
||||
}()
|
||||
);
|
||||
var mainGroup = new Group();
|
||||
var Tween = (
|
||||
/** @class */
|
||||
function() {
|
||||
function Tween2(_object, _group) {
|
||||
if (_group === void 0) {
|
||||
_group = mainGroup;
|
||||
}
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
this._pauseStart = 0;
|
||||
this._valuesStart = {};
|
||||
this._valuesEnd = {};
|
||||
this._valuesStartRepeat = {};
|
||||
this._duration = 1e3;
|
||||
this._isDynamic = false;
|
||||
this._initialRepeat = 0;
|
||||
this._repeat = 0;
|
||||
this._yoyo = false;
|
||||
this._isPlaying = false;
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
this._startTime = 0;
|
||||
this._easingFunction = Easing.Linear.None;
|
||||
this._interpolationFunction = Interpolation.Linear;
|
||||
this._chainedTweens = [];
|
||||
this._onStartCallbackFired = false;
|
||||
this._onEveryStartCallbackFired = false;
|
||||
this._id = Sequence.nextId();
|
||||
this._isChainStopped = false;
|
||||
this._propertiesAreSetUp = false;
|
||||
this._goToEnd = false;
|
||||
}
|
||||
Tween2.prototype.getId = function() {
|
||||
return this._id;
|
||||
};
|
||||
Tween2.prototype.isPlaying = function() {
|
||||
return this._isPlaying;
|
||||
};
|
||||
Tween2.prototype.isPaused = function() {
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween2.prototype.getDuration = function() {
|
||||
return this._duration;
|
||||
};
|
||||
Tween2.prototype.to = function(target, duration) {
|
||||
if (duration === void 0) {
|
||||
duration = 1e3;
|
||||
}
|
||||
if (this._isPlaying)
|
||||
throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");
|
||||
this._valuesEnd = target;
|
||||
this._propertiesAreSetUp = false;
|
||||
this._duration = duration < 0 ? 0 : duration;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.duration = function(duration) {
|
||||
if (duration === void 0) {
|
||||
duration = 1e3;
|
||||
}
|
||||
this._duration = duration < 0 ? 0 : duration;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.dynamic = function(dynamic) {
|
||||
if (dynamic === void 0) {
|
||||
dynamic = false;
|
||||
}
|
||||
this._isDynamic = dynamic;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.start = function(time, overrideStartingValues) {
|
||||
if (time === void 0) {
|
||||
time = now();
|
||||
}
|
||||
if (overrideStartingValues === void 0) {
|
||||
overrideStartingValues = false;
|
||||
}
|
||||
if (this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._group && this._group.add(this);
|
||||
this._repeat = this._initialRepeat;
|
||||
if (this._reversed) {
|
||||
this._reversed = false;
|
||||
for (var property in this._valuesStartRepeat) {
|
||||
this._swapEndStartRepeatValues(property);
|
||||
this._valuesStart[property] = this._valuesStartRepeat[property];
|
||||
}
|
||||
}
|
||||
this._isPlaying = true;
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
this._onEveryStartCallbackFired = false;
|
||||
this._isChainStopped = false;
|
||||
this._startTime = time;
|
||||
this._startTime += this._delayTime;
|
||||
if (!this._propertiesAreSetUp || overrideStartingValues) {
|
||||
this._propertiesAreSetUp = true;
|
||||
if (!this._isDynamic) {
|
||||
var tmp = {};
|
||||
for (var prop in this._valuesEnd)
|
||||
tmp[prop] = this._valuesEnd[prop];
|
||||
this._valuesEnd = tmp;
|
||||
}
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.startFromCurrentValues = function(time) {
|
||||
return this.start(time, true);
|
||||
};
|
||||
Tween2.prototype._setupProperties = function(_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
|
||||
for (var property in _valuesEnd) {
|
||||
var startValue = _object[property];
|
||||
var startValueIsArray = Array.isArray(startValue);
|
||||
var propType = startValueIsArray ? "array" : typeof startValue;
|
||||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
|
||||
if (propType === "undefined" || propType === "function") {
|
||||
continue;
|
||||
}
|
||||
if (isInterpolationList) {
|
||||
var endValues = _valuesEnd[property];
|
||||
if (endValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
var temp = [startValue];
|
||||
for (var i = 0, l = endValues.length; i < l; i += 1) {
|
||||
var value = this._handleRelativeValue(startValue, endValues[i]);
|
||||
if (isNaN(value)) {
|
||||
isInterpolationList = false;
|
||||
console.warn("Found invalid interpolation list. Skipping.");
|
||||
break;
|
||||
}
|
||||
temp.push(value);
|
||||
}
|
||||
if (isInterpolationList) {
|
||||
_valuesEnd[property] = temp;
|
||||
}
|
||||
}
|
||||
if ((propType === "object" || startValueIsArray) && startValue && !isInterpolationList) {
|
||||
_valuesStart[property] = startValueIsArray ? [] : {};
|
||||
var nestedObject = startValue;
|
||||
for (var prop in nestedObject) {
|
||||
_valuesStart[property][prop] = nestedObject[prop];
|
||||
}
|
||||
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
|
||||
var endValues = _valuesEnd[property];
|
||||
if (!this._isDynamic) {
|
||||
var tmp = {};
|
||||
for (var prop in endValues)
|
||||
tmp[prop] = endValues[prop];
|
||||
_valuesEnd[property] = endValues = tmp;
|
||||
}
|
||||
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
|
||||
} else {
|
||||
if (typeof _valuesStart[property] === "undefined" || overrideStartingValues) {
|
||||
_valuesStart[property] = startValue;
|
||||
}
|
||||
if (!startValueIsArray) {
|
||||
_valuesStart[property] *= 1;
|
||||
}
|
||||
if (isInterpolationList) {
|
||||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
|
||||
} else {
|
||||
_valuesStartRepeat[property] = _valuesStart[property] || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Tween2.prototype.stop = function() {
|
||||
if (!this._isChainStopped) {
|
||||
this._isChainStopped = true;
|
||||
this.stopChainedTweens();
|
||||
}
|
||||
if (!this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._group && this._group.remove(this);
|
||||
this._isPlaying = false;
|
||||
this._isPaused = false;
|
||||
if (this._onStopCallback) {
|
||||
this._onStopCallback(this._object);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.end = function() {
|
||||
this._goToEnd = true;
|
||||
this.update(Infinity);
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.pause = function(time) {
|
||||
if (time === void 0) {
|
||||
time = now();
|
||||
}
|
||||
if (this._isPaused || !this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time;
|
||||
this._group && this._group.remove(this);
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.resume = function(time) {
|
||||
if (time === void 0) {
|
||||
time = now();
|
||||
}
|
||||
if (!this._isPaused || !this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += time - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
this._group && this._group.add(this);
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.stopChainedTweens = function() {
|
||||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
||||
this._chainedTweens[i].stop();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.group = function(group) {
|
||||
if (group === void 0) {
|
||||
group = mainGroup;
|
||||
}
|
||||
this._group = group;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.delay = function(amount) {
|
||||
if (amount === void 0) {
|
||||
amount = 0;
|
||||
}
|
||||
this._delayTime = amount;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.repeat = function(times) {
|
||||
if (times === void 0) {
|
||||
times = 0;
|
||||
}
|
||||
this._initialRepeat = times;
|
||||
this._repeat = times;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.repeatDelay = function(amount) {
|
||||
this._repeatDelayTime = amount;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.yoyo = function(yoyo) {
|
||||
if (yoyo === void 0) {
|
||||
yoyo = false;
|
||||
}
|
||||
this._yoyo = yoyo;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.easing = function(easingFunction) {
|
||||
if (easingFunction === void 0) {
|
||||
easingFunction = Easing.Linear.None;
|
||||
}
|
||||
this._easingFunction = easingFunction;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.interpolation = function(interpolationFunction) {
|
||||
if (interpolationFunction === void 0) {
|
||||
interpolationFunction = Interpolation.Linear;
|
||||
}
|
||||
this._interpolationFunction = interpolationFunction;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.chain = function() {
|
||||
var tweens = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
tweens[_i] = arguments[_i];
|
||||
}
|
||||
this._chainedTweens = tweens;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onStart = function(callback) {
|
||||
this._onStartCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onEveryStart = function(callback) {
|
||||
this._onEveryStartCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onUpdate = function(callback) {
|
||||
this._onUpdateCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onRepeat = function(callback) {
|
||||
this._onRepeatCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onComplete = function(callback) {
|
||||
this._onCompleteCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.onStop = function(callback) {
|
||||
this._onStopCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween2.prototype.update = function(time, autoStart) {
|
||||
var _this = this;
|
||||
var _a;
|
||||
if (time === void 0) {
|
||||
time = now();
|
||||
}
|
||||
if (autoStart === void 0) {
|
||||
autoStart = true;
|
||||
}
|
||||
if (this._isPaused)
|
||||
return true;
|
||||
var property;
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (!this._goToEnd && !this._isPlaying) {
|
||||
if (time > endTime)
|
||||
return false;
|
||||
if (autoStart)
|
||||
this.start(time, true);
|
||||
}
|
||||
this._goToEnd = false;
|
||||
if (time < this._startTime) {
|
||||
return true;
|
||||
}
|
||||
if (this._onStartCallbackFired === false) {
|
||||
if (this._onStartCallback) {
|
||||
this._onStartCallback(this._object);
|
||||
}
|
||||
this._onStartCallbackFired = true;
|
||||
}
|
||||
if (this._onEveryStartCallbackFired === false) {
|
||||
if (this._onEveryStartCallback) {
|
||||
this._onEveryStartCallback(this._object);
|
||||
}
|
||||
this._onEveryStartCallbackFired = true;
|
||||
}
|
||||
var elapsedTime = time - this._startTime;
|
||||
var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
|
||||
var totalTime = this._duration + this._repeat * durationAndDelay;
|
||||
var calculateElapsedPortion = function() {
|
||||
if (_this._duration === 0)
|
||||
return 1;
|
||||
if (elapsedTime > totalTime) {
|
||||
return 1;
|
||||
}
|
||||
var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
|
||||
var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
|
||||
var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
|
||||
if (portion === 0 && elapsedTime === _this._duration) {
|
||||
return 1;
|
||||
}
|
||||
return portion;
|
||||
};
|
||||
var elapsed = calculateElapsedPortion();
|
||||
var value = this._easingFunction(elapsed);
|
||||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
||||
if (this._onUpdateCallback) {
|
||||
this._onUpdateCallback(this._object, elapsed);
|
||||
}
|
||||
if (this._duration === 0 || elapsedTime >= this._duration) {
|
||||
if (this._repeat > 0) {
|
||||
var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
|
||||
if (isFinite(this._repeat)) {
|
||||
this._repeat -= completeCount;
|
||||
}
|
||||
for (property in this._valuesStartRepeat) {
|
||||
if (!this._yoyo && typeof this._valuesEnd[property] === "string") {
|
||||
this._valuesStartRepeat[property] = // eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
|
||||
}
|
||||
if (this._yoyo) {
|
||||
this._swapEndStartRepeatValues(property);
|
||||
}
|
||||
this._valuesStart[property] = this._valuesStartRepeat[property];
|
||||
}
|
||||
if (this._yoyo) {
|
||||
this._reversed = !this._reversed;
|
||||
}
|
||||
this._startTime += durationAndDelay * completeCount;
|
||||
if (this._onRepeatCallback) {
|
||||
this._onRepeatCallback(this._object);
|
||||
}
|
||||
this._onEveryStartCallbackFired = false;
|
||||
return true;
|
||||
} else {
|
||||
if (this._onCompleteCallback) {
|
||||
this._onCompleteCallback(this._object);
|
||||
}
|
||||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
||||
this._chainedTweens[i].start(this._startTime + this._duration, false);
|
||||
}
|
||||
this._isPlaying = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Tween2.prototype._updateProperties = function(_object, _valuesStart, _valuesEnd, value) {
|
||||
for (var property in _valuesEnd) {
|
||||
if (_valuesStart[property] === void 0) {
|
||||
continue;
|
||||
}
|
||||
var start = _valuesStart[property] || 0;
|
||||
var end = _valuesEnd[property];
|
||||
var startIsArray = Array.isArray(_object[property]);
|
||||
var endIsArray = Array.isArray(end);
|
||||
var isInterpolationList = !startIsArray && endIsArray;
|
||||
if (isInterpolationList) {
|
||||
_object[property] = this._interpolationFunction(end, value);
|
||||
} else if (typeof end === "object" && end) {
|
||||
this._updateProperties(_object[property], start, end, value);
|
||||
} else {
|
||||
end = this._handleRelativeValue(start, end);
|
||||
if (typeof end === "number") {
|
||||
_object[property] = start + (end - start) * value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Tween2.prototype._handleRelativeValue = function(start, end) {
|
||||
if (typeof end !== "string") {
|
||||
return end;
|
||||
}
|
||||
if (end.charAt(0) === "+" || end.charAt(0) === "-") {
|
||||
return start + parseFloat(end);
|
||||
}
|
||||
return parseFloat(end);
|
||||
};
|
||||
Tween2.prototype._swapEndStartRepeatValues = function(property) {
|
||||
var tmp = this._valuesStartRepeat[property];
|
||||
var endValue = this._valuesEnd[property];
|
||||
if (typeof endValue === "string") {
|
||||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
|
||||
} else {
|
||||
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
||||
}
|
||||
this._valuesEnd[property] = tmp;
|
||||
};
|
||||
return Tween2;
|
||||
}()
|
||||
);
|
||||
var VERSION = "23.1.1";
|
||||
var nextId = Sequence.nextId;
|
||||
var TWEEN = mainGroup;
|
||||
var getAll = TWEEN.getAll.bind(TWEEN);
|
||||
var removeAll = TWEEN.removeAll.bind(TWEEN);
|
||||
var add = TWEEN.add.bind(TWEEN);
|
||||
var remove = TWEEN.remove.bind(TWEEN);
|
||||
var update = TWEEN.update.bind(TWEEN);
|
||||
var exports = {
|
||||
Easing,
|
||||
Group,
|
||||
Interpolation,
|
||||
now,
|
||||
Sequence,
|
||||
nextId,
|
||||
Tween,
|
||||
VERSION,
|
||||
getAll,
|
||||
removeAll,
|
||||
add,
|
||||
remove,
|
||||
update
|
||||
};
|
||||
export {
|
||||
Easing,
|
||||
Group,
|
||||
Interpolation,
|
||||
Sequence,
|
||||
Tween,
|
||||
VERSION,
|
||||
add,
|
||||
exports as default,
|
||||
getAll,
|
||||
nextId,
|
||||
now,
|
||||
remove,
|
||||
removeAll,
|
||||
update
|
||||
};
|
||||
//# sourceMappingURL=three_examples_jsm_libs_tween__module__js.js.map
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user