Merge branch 'main' of github.com:Kum1ta/PTME_Transcendence

This commit is contained in:
Kum1ta
2024-08-22 19:36:38 +02:00
65 changed files with 2919 additions and 170 deletions

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* Ball.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
/* Updated: 2024/08/22 14:28:34 by edbernar ### ########.fr */
/* Updated: 2024/08/22 16:21:59 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* Map.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
/* Updated: 2024/08/22 14:32:54 by edbernar ### ########.fr */
/* Updated: 2024/08/22 18:59:54 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */
@ -55,8 +55,6 @@ class Map
scene.add(this.#createPlanes(7.5, length, (Math.PI / 2), "planeTop", false, '/textures/pastel.jpg'));
scene.add(this.#createWall(-3.5, 0.4, -length/2, "wallLeft"));
scene.add(this.#createWall(3.5, 0.4, -length/2, "wallRight"));
scene.add(this.#createWallObstacle(1, 1, 1, false));
scene.add(this.#createWallObstacle(-1, 1, 1, true));
this.#createBanner(10, 1);
if (obstacles)
this.#generateObstacle();
@ -127,11 +125,11 @@ class Map
return (mesh);
};
#createGravityChanger(x, y, z, name, onTop)
#createGravityChanger(x, y, z, name, typeName, onTop)
{
for (let i = 0; i < this.arrObject.length; i++)
{
if (this.arrObject[i].name == name + "1")
if (this.arrObject[i].name == name)
throw Error("Name already exist.");
}
const geometry0 = new THREE.CircleGeometry(0.2, 24);
@ -193,7 +191,7 @@ class Map
group.rotateX(Math.PI);
group.translateY(-6.3);
}
this.arrObject.push({mesh: group, name: name, type: 'jumper'});
this.arrObject.push({mesh: group, name: name, type: typeName});
this.scene.add(group);
};
@ -262,7 +260,7 @@ class Map
} );
}
#animationGravityChanger(group)
#animationGravityChanger(group, onTop)
{
const geometry1 = new THREE.TorusGeometry(1.5, 0.05, 12, 24);
const material1 = new THREE.MeshPhysicalMaterial({color: 0x00ff00});
@ -278,6 +276,9 @@ class Map
this.scene.add(ring1);
interval = setInterval(() => {
if (onTop)
ring1.position.y -= speed;
else
ring1.position.y += speed;
ring1.material.opacity -= 0.02;
speed *= 0.90;
@ -288,41 +289,37 @@ class Map
#generateObstacle()
{
this.#createGravityChanger(-1.5, 0.2, this.mapLength / 4, "gravityChangerGroupBottom1", 0);
const wallPos = [
{ x: 1, y: 0, z: 1, onTop: false},
{ x: 1, y: 0, z: 1, onTop: true},
{ x: -1, y: 0, z: 1, onTop: false},
{ x: -1, y: 0, z: 1, onTop: true}
];
for (let i = 0; i < wallPos.length; i++)
{
if (Math.random() < 0.5)
this.scene.add(this.#createWallObstacle(wallPos[i].x, wallPos[i].y, wallPos[i].z, wallPos[i].onTop));
}
// let randomNumber;
// if (Math.random() < 0.5)
// {
// randomNumber = Math.random();
// if (randomNumber < 0.5)
// this.#createGravityChanger(-1.5, 0.2, this.mapLength / 4, "gravityChangerGroupBottom1", 0);
// else
// this.#createGravityChanger(1.5, 0.2, this.mapLength / 4, "gravityChangerGroupBottom2", 0);
// }
// if (Math.random() < 0.5)
// {
// randomNumber = Math.random();
// if (randomNumber < 0.5)
// this.#createGravityChanger(-1.5, 0.2, -this.mapLength / 4, "gravityChangerGroupBottom3", 0);
// else
// this.#createGravityChanger(1.5, 0.2, -this.mapLength / 4, "gravityChangerGroupBottom4", 0);
// }
// if (Math.random() < 0.5)
// {
// randomNumber = Math.random();
// if (randomNumber < 0.5)
// this.#createGravityChanger(-1.5, 3.2, this.mapLength / 4, "gravityChangerGroupTop1", 1);
// else
// this.#createGravityChanger(1.5, 3.2, this.mapLength / 4, "gravityChangerGroupTop2", 1);
// }
// if (Math.random() < 0.5)
// {
// randomNumber = Math.random();
// if (randomNumber < 0.5)
// this.#createGravityChanger(-1.5, 3.2, -this.mapLength / 4, "gravityChangerGroupTop3", 1);
// else
// this.#createGravityChanger(1.5, 3.2, -this.mapLength / 4, "gravityChangerGroupTop4", 1);
// }
const jumperPos = [
{ x: -1.5, y: 0.2, z: this.mapLength / 4, type: "gravityChanger", typeName: "jumperBottom", onTop: false},
{ x: -1.5, y: 3.2, z: -this.mapLength / 4, type: "gravityChanger", typeName: "jumperTop", onTop: true},
{ x: 1.5, y: 0.2, z: this.mapLength / 4, type: "gravityChanger", typeName: "jumperBottom", onTop: false},
{ x: 1.5, y: 3.2, z: -this.mapLength / 4, type: "gravityChanger", typeName: "jumperTop", onTop: true},
{ x: -1.5, y: 0.2, z: -this.mapLength / 4, type: "gravityChanger", typeName: "jumperBottom", onTop: false},
{ x: -1.5, y: 3.2, z: this.mapLength / 4, type: "gravityChanger", typeName: "jumperTop", onTop: true},
{ x: 1.5, y: 0.2, z: -this.mapLength / 4, type: "gravityChanger", typeName: "jumperBottom", onTop: false},
{ x: 1.5, y: 3.2, z: this.mapLength / 4, type: "gravityChanger", typeName: "jumperTop", onTop: true}
];
for (let i = 0; i < jumperPos.length; i++)
{
if (Math.random() < 0.5)
{
this.#createGravityChanger(jumperPos[i].x, jumperPos[i].y, jumperPos[i].z, jumperPos[i].type + i, jumperPos[i].typeName, jumperPos[i].onTop);
if (i % 2 == 0)
i++;
}
}
};
update(ball)
@ -331,20 +328,14 @@ class Map
{
if (this.arrObject[i].name == "wallLeft")
{
if (ball.object.position.z < 0.1 && ball.object.position.z > -this.mapLength + 1)
// Move the wall with the ball position
if (ball.object.position.z < this.mapLength / 2 - 0.35 && ball.object.position.z > -this.mapLength / 2 + 0.35)
this.arrObject[i].mesh.position.z = ball.object.position.z;
this.arrObject[i].mesh.position.y = ball.object.position.y;
}
if (this.arrObject[i].name == "wallRight")
{
if (ball.object.position.z < 0.1 && ball.object.position.z > -this.mapLength + 1)
this.arrObject[i].mesh.position.z = ball.object.position.z;
this.arrObject[i].mesh.position.y = ball.object.position.y;
}
if (this.arrObject[i].name == "wallLeft")
{
if (ball.object.position.y > 0.4 + 0.1 && ball.object.position.y < 3.2)
this.arrObject[i].mesh.position.y = ball.object.position.y - 0.1;
// Change the opacity of the wall
let diff = ball.object.position.x - this.arrObject[i].mesh.position.x - 0.1;
if (diff > 2)
this.arrObject[i].mesh.material.opacity = 0;
else
@ -352,48 +343,34 @@ class Map
}
if (this.arrObject[i].name == "wallRight")
{
let diff = this.arrObject[i].mesh.position.x - ball.object.position.x - 0.1;
// Move the wall with the ball position
if (ball.object.position.z < this.mapLength / 2 - 0.35 && ball.object.position.z > -this.mapLength / 2 + 0.35)
this.arrObject[i].mesh.position.z = ball.object.position.z;
if (ball.object.position.y > 0.4 + 0.1 && ball.object.position.y < 3.2)
this.arrObject[i].mesh.position.y = ball.object.position.y - 0.1;
// Change the opacity of the wall
let diff = this.arrObject[i].mesh.position.x - ball.object.position.x - 0.1;
if (diff > 2)
this.arrObject[i].mesh.material.opacity = 0;
else
this.arrObject[i].mesh.material.opacity = 1 - (diff / 2);
}
if (this.arrObject[i].type == 'jumper')
if (this.arrObject[i].type == 'jumperBottom')
{
const cylinder = this.arrObject[i].mesh.children[5];
const distance = ball.object.position.distanceTo(cylinder.position);
const speed = 0.1;
// Detect if the ball is on the jumper
if (distance < 0.25 && this.ballIsOnJumper.can)
{
this.ballIsOnJumper.can = false;
ball.changeGravity(this.ballIsOnJumper);
this.#animationGravityChanger(this.arrObject[i].mesh);
this.#animationGravityChanger(this.arrObject[i].mesh, false);
}
}
if (this.arrObject[i].name == "gravityChangerGroupBottom1")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 0.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupBottom2")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 0.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupBottom3")
{
// Gravity changer animation
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
@ -401,37 +378,21 @@ class Map
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 0.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupBottom4")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 0.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupTop1")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
if (this.arrObject[i].type == 'jumperTop')
{
const cylinder = this.arrObject[i].mesh.children[5];
const distance = ball.object.position.distanceTo(cylinder.position);
const speed = 0.1;
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 3.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupTop2")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
// Detect if the ball is on the jumper
if (distance < 0.4 && this.ballIsOnJumper.can)
{
this.ballIsOnJumper.can = false;
ball.changeGravity(this.ballIsOnJumper);
this.#animationGravityChanger(this.arrObject[i].mesh, true);
}
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 3.25;;
}
}
if (this.arrObject[i].name == "gravityChangerGroupTop3")
{
// Gravity changer animation
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
@ -439,15 +400,6 @@ class Map
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 3.25;
}
}
if (this.arrObject[i].name == "gravityChangerGroupTop4")
{
for (let j = 2; j < this.arrObject[i].mesh.children.length - 1; j++)
{
this.arrObject[i].mesh.children[j].rotation.x = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.PI / 2;
this.arrObject[i].mesh.children[j].rotation.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.1 + Math.cos(Date.now() * 0.001) * 0.1;;
this.arrObject[i].mesh.children[j].position.y = Math.sin(Date.now() * 0.001 + (j - 2) * 5) * 0.03 + ( 0.25 * (j - 2) / 2) + 3.25;;
}
}
}
};
};

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* Player.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
/* Updated: 2024/08/22 00:52:14 by edbernar ### ########.fr */
/* Updated: 2024/08/22 17:06:28 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */
@ -50,11 +50,13 @@ class Player
pressedButton = [];
object = null;
camera = null;
speed = 0.1;
speed = 4;
cameraFixed = false;
interval = null;
isOnPointAnim = false;
limits = {};
previousTime = Date.now();
deltaTime = 1;
constructor (object, map)
{
@ -219,6 +221,10 @@ class Player
update()
{
const currentTime = Date.now();
this.deltaTime = (currentTime - this.previousTime) / 1000;
this.previousTime = currentTime;
let i;
i = 0;
@ -229,9 +235,9 @@ class Player
if (this.interval)
clearInterval(this.interval);
this.interval = setInterval(() => {
this.object.position.y += this.speed;
this.object.position.y += this.speed / 40;
if (!this.cameraFixed && !this.isOnPointAnim)
this.camera.position.y += (this.speed / 2);
this.camera.position.y += (this.speed / 80);
if (this.object.position.y >= this.limits.up)
{
clearInterval(this.interval);
@ -244,9 +250,9 @@ class Player
if (this.interval)
clearInterval(this.interval);
this.interval = setInterval(() => {
this.object.position.y -= this.speed;
this.object.position.y -= this.speed / 40;
if (!this.cameraFixed && !this.isOnPointAnim)
this.camera.position.y -= (this.speed / 2);
this.camera.position.y -= (this.speed / 80);
if (this.object.position.y <= this.limits.down)
{
clearInterval(this.interval);
@ -257,15 +263,15 @@ class Player
}
if (this.pressedButton[i] == 'd' && this.object.position.x < this.limits.right)
{
this.object.position.x += this.speed;
this.object.position.x += this.speed * this.deltaTime;
if (!this.cameraFixed && !this.isOnPointAnim)
this.camera.position.x += this.speed;
this.camera.position.x += this.speed * this.deltaTime;
}
if (this.pressedButton[i] == 'a' && this.object.position.x > this.limits.left)
{
this.object.position.x -= this.speed;
this.object.position.x -= this.speed * this.deltaTime;
if (!this.cameraFixed && !this.isOnPointAnim)
this.camera.position.x -= this.speed;
this.camera.position.x -= this.speed * this.deltaTime;
}
i++;
}

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* main.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
/* Updated: 2024/08/22 10:48:29 by edbernar ### ########.fr */
/* Updated: 2024/08/22 17:11:54 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,6 +16,7 @@ import { Map } from './class/Map'
import { Ball } from './class/Ball'
import { Opponent } from './class/Opponent'
import { OrbitControls } from 'three/examples/jsm/Addons.js';
import Stats from 'stats.js';
/*
Controls :
@ -38,6 +39,11 @@ Controls :
let debug = false;
// ------------------- Stats -------------------- //
const stats = new Stats();
stats.showPanel(0); // 0: fps, 1: ms, 2: mémoire
document.body.appendChild(stats.dom);
function createBarPlayer(color)
{
const geometry = new THREE.BoxGeometry(1, 0.1, 0.1);
@ -48,8 +54,17 @@ function createBarPlayer(color)
return (mesh);
}
let previousTime = Date.now();
function loop()
{
stats.begin();
// ===== FPS locker ===== //
const currentTime = Date.now();
if (currentTime - previousTime < 1000 / 60)
return ;
previousTime = currentTime;
// ====================== //
player.update();
map.update(ball);
if (debug)
@ -60,6 +75,7 @@ function loop()
else
renderer.render(scene, player.camera);
stats.end();
}
const scene = new THREE.Scene();

View File

@ -1,34 +1,43 @@
{
"hash": "b5ed7c4e",
"configHash": "4027b9ee",
"hash": "fba7eca6",
"configHash": "345fb419",
"lockfileHash": "cd36b699",
"browserHash": "d0607953",
"browserHash": "f41bc951",
"optimized": {
"three": {
"src": "../../three/build/three.module.js",
"file": "three.js",
"fileHash": "e1599062",
"needsInterop": false
},
"three/examples/jsm/Addons.js": {
"src": "../../three/examples/jsm/Addons.js",
"file": "three_examples_jsm_Addons__js.js",
"fileHash": "9f0a165c",
"fileHash": "bafac1ea",
"needsInterop": false
},
"three/addons/loaders/GLTFLoader.js": {
"src": "../../three/examples/jsm/loaders/GLTFLoader.js",
"file": "three_addons_loaders_GLTFLoader__js.js",
"fileHash": "13ce7c2e",
"fileHash": "31ea0df1",
"needsInterop": false
},
"three/examples/jsm/Addons.js": {
"src": "../../three/examples/jsm/Addons.js",
"file": "three_examples_jsm_Addons__js.js",
"fileHash": "43d0b53e",
"needsInterop": false
},
"stats.js": {
"src": "../../stats.js/build/stats.min.js",
"file": "stats__js.js",
"fileHash": "fb9a7c1e",
"needsInterop": true
}
},
"chunks": {
"chunk-LBH6F3OL": {
"file": "chunk-LBH6F3OL.js"
"chunk-PJQOQ23Z": {
"file": "chunk-PJQOQ23Z.js"
},
"chunk-33KXLYU5": {
"file": "chunk-33KXLYU5.js"
"chunk-IS2ZBFBB": {
"file": "chunk-IS2ZBFBB.js"
},
"chunk-HKJ2B2AA": {
"file": "chunk-HKJ2B2AA.js"
}
}
}

View File

@ -0,0 +1,15 @@
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
export {
__commonJS,
__export
};
//# sourceMappingURL=chunk-HKJ2B2AA.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

View File

@ -1,9 +1,3 @@
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 };
@ -30710,7 +30704,6 @@ if (typeof window !== "undefined") {
}
export {
__export,
REVISION,
MOUSE,
TOUCH,
@ -31139,4 +31132,4 @@ three/build/three.module.js:
* SPDX-License-Identifier: MIT
*)
*/
//# sourceMappingURL=chunk-33KXLYU5.js.map
//# sourceMappingURL=chunk-IS2ZBFBB.js.map

View File

@ -65,9 +65,11 @@ import {
TrianglesDrawMode,
Vector2,
Vector3,
VectorKeyframeTrack,
VectorKeyframeTrack
} from "./chunk-IS2ZBFBB.js";
import {
__export
} from "./chunk-33KXLYU5.js";
} from "./chunk-HKJ2B2AA.js";
// node_modules/three/examples/jsm/utils/BufferGeometryUtils.js
var BufferGeometryUtils_exports = {};
@ -3331,4 +3333,4 @@ export {
BufferGeometryUtils_exports,
GLTFLoader
};
//# sourceMappingURL=chunk-LBH6F3OL.js.map
//# sourceMappingURL=chunk-PJQOQ23Z.js.map

80
site/real_game/node_modules/.vite/deps/stats__js.js generated vendored Normal file
View File

@ -0,0 +1,80 @@
import {
__commonJS
} from "./chunk-HKJ2B2AA.js";
// node_modules/stats.js/build/stats.min.js
var require_stats_min = __commonJS({
"node_modules/stats.js/build/stats.min.js"(exports, module) {
(function(f, e) {
"object" === typeof exports && "undefined" !== typeof module ? module.exports = e() : "function" === typeof define && define.amd ? define(e) : f.Stats = e();
})(exports, function() {
var f = function() {
function e(a2) {
c.appendChild(a2.dom);
return a2;
}
function u(a2) {
for (var d = 0; d < c.children.length; d++) c.children[d].style.display = d === a2 ? "block" : "none";
l = a2;
}
var l = 0, c = document.createElement("div");
c.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";
c.addEventListener("click", function(a2) {
a2.preventDefault();
u(++l % c.children.length);
}, false);
var k = (performance || Date).now(), g = k, a = 0, r = e(new f.Panel("FPS", "#0ff", "#002")), h = e(new f.Panel("MS", "#0f0", "#020"));
if (self.performance && self.performance.memory) var t = e(new f.Panel("MB", "#f08", "#201"));
u(0);
return { REVISION: 16, dom: c, addPanel: e, showPanel: u, begin: function() {
k = (performance || Date).now();
}, end: function() {
a++;
var c2 = (performance || Date).now();
h.update(c2 - k, 200);
if (c2 > g + 1e3 && (r.update(1e3 * a / (c2 - g), 100), g = c2, a = 0, t)) {
var d = performance.memory;
t.update(d.usedJSHeapSize / 1048576, d.jsHeapSizeLimit / 1048576);
}
return c2;
}, update: function() {
k = this.end();
}, domElement: c, setMode: u };
};
f.Panel = function(e, f2, l) {
var c = Infinity, k = 0, g = Math.round, a = g(window.devicePixelRatio || 1), r = 80 * a, h = 48 * a, t = 3 * a, v = 2 * a, d = 3 * a, m = 15 * a, n = 74 * a, p = 30 * a, q = document.createElement("canvas");
q.width = r;
q.height = h;
q.style.cssText = "width:80px;height:48px";
var b = q.getContext("2d");
b.font = "bold " + 9 * a + "px Helvetica,Arial,sans-serif";
b.textBaseline = "top";
b.fillStyle = l;
b.fillRect(0, 0, r, h);
b.fillStyle = f2;
b.fillText(e, t, v);
b.fillRect(d, m, n, p);
b.fillStyle = l;
b.globalAlpha = 0.9;
b.fillRect(d, m, n, p);
return { dom: q, update: function(h2, w) {
c = Math.min(c, h2);
k = Math.max(k, h2);
b.fillStyle = l;
b.globalAlpha = 1;
b.fillRect(0, 0, r, m);
b.fillStyle = f2;
b.fillText(g(h2) + " " + e + " (" + g(c) + "-" + g(k) + ")", t, v);
b.drawImage(q, d + a, m, n - a, p, d, m, n - a, p);
b.fillRect(d + n - a, m, a, p);
b.fillStyle = l;
b.globalAlpha = 0.9;
b.fillRect(d + n - a, m, a, g((1 - h2 / w) * p));
} };
};
return f;
});
}
});
export default require_stats_min();
//# sourceMappingURL=stats__js.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../stats.js/build/stats.min.js"],
"sourcesContent": ["// stats.js - http://github.com/mrdoob/stats.js\n(function(f,e){\"object\"===typeof exports&&\"undefined\"!==typeof module?module.exports=e():\"function\"===typeof define&&define.amd?define(e):f.Stats=e()})(this,function(){var f=function(){function e(a){c.appendChild(a.dom);return a}function u(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?\"block\":\"none\";l=a}var l=0,c=document.createElement(\"div\");c.style.cssText=\"position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000\";c.addEventListener(\"click\",function(a){a.preventDefault();\nu(++l%c.children.length)},!1);var k=(performance||Date).now(),g=k,a=0,r=e(new f.Panel(\"FPS\",\"#0ff\",\"#002\")),h=e(new f.Panel(\"MS\",\"#0f0\",\"#020\"));if(self.performance&&self.performance.memory)var t=e(new f.Panel(\"MB\",\"#f08\",\"#201\"));u(0);return{REVISION:16,dom:c,addPanel:e,showPanel:u,begin:function(){k=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();h.update(c-k,200);if(c>g+1E3&&(r.update(1E3*a/(c-g),100),g=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/\n1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){k=this.end()},domElement:c,setMode:u}};f.Panel=function(e,f,l){var c=Infinity,k=0,g=Math.round,a=g(window.devicePixelRatio||1),r=80*a,h=48*a,t=3*a,v=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement(\"canvas\");q.width=r;q.height=h;q.style.cssText=\"width:80px;height:48px\";var b=q.getContext(\"2d\");b.font=\"bold \"+9*a+\"px Helvetica,Arial,sans-serif\";b.textBaseline=\"top\";b.fillStyle=l;b.fillRect(0,0,r,h);b.fillStyle=f;b.fillText(e,t,v);\nb.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(h,w){c=Math.min(c,h);k=Math.max(k,h);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=f;b.fillText(g(h)+\" \"+e+\" (\"+g(c)+\"-\"+g(k)+\")\",t,v);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,g((1-h/w)*p))}}};return f});\n"],
"mappings": "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",
"names": ["a", "c", "f", "h"]
}

View File

@ -417,7 +417,8 @@ import {
ZeroSlopeEnding,
ZeroStencilOp,
createCanvasElement
} from "./chunk-33KXLYU5.js";
} from "./chunk-IS2ZBFBB.js";
import "./chunk-HKJ2B2AA.js";
export {
ACESFilmicToneMapping,
AddEquation,

View File

@ -1,7 +1,8 @@
import {
GLTFLoader
} from "./chunk-LBH6F3OL.js";
import "./chunk-33KXLYU5.js";
} from "./chunk-PJQOQ23Z.js";
import "./chunk-IS2ZBFBB.js";
import "./chunk-HKJ2B2AA.js";
export {
GLTFLoader
};

View File

@ -5,7 +5,7 @@ import {
mergeGeometries,
mergeGroups,
mergeVertices
} from "./chunk-LBH6F3OL.js";
} from "./chunk-PJQOQ23Z.js";
import {
ACESFilmicToneMapping,
AddEquation,
@ -208,9 +208,11 @@ import {
WebGLRenderTarget,
WebGLRenderer,
WireframeGeometry,
ZeroFactor,
ZeroFactor
} from "./chunk-IS2ZBFBB.js";
import {
__export
} from "./chunk-33KXLYU5.js";
} from "./chunk-HKJ2B2AA.js";
// node_modules/three/examples/jsm/animation/AnimationClipCreator.js
var AnimationClipCreator = class {

File diff suppressed because one or more lines are too long

21
site/real_game/node_modules/stats.js/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2009-2016 stats.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,5 @@
// stats.js - http://github.com/mrdoob/stats.js
(function(f,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"===typeof define&&define.amd?define(e):f.Stats=e()})(this,function(){var f=function(){function e(a){c.appendChild(a.dom);return a}function u(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();
u(++l%c.children.length)},!1);var k=(performance||Date).now(),g=k,a=0,r=e(new f.Panel("FPS","#0ff","#002")),h=e(new f.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var t=e(new f.Panel("MB","#f08","#201"));u(0);return{REVISION:16,dom:c,addPanel:e,showPanel:u,begin:function(){k=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();h.update(c-k,200);if(c>g+1E3&&(r.update(1E3*a/(c-g),100),g=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/
1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){k=this.end()},domElement:c,setMode:u}};f.Panel=function(e,f,l){var c=Infinity,k=0,g=Math.round,a=g(window.devicePixelRatio||1),r=80*a,h=48*a,t=3*a,v=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=h;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,h);b.fillStyle=f;b.fillText(e,t,v);
b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(h,w){c=Math.min(c,h);k=Math.max(k,h);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=f;b.fillText(g(h)+" "+e+" ("+g(c)+"-"+g(k)+")",t,v);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,g((1-h/w)*p))}}};return f});

38
site/real_game/node_modules/stats.js/package.json generated vendored Normal file
View File

@ -0,0 +1,38 @@
{
"name": "stats.js",
"version": "0.17.0",
"description": "JavaScript Performance Monitor",
"main": "build/stats.min.js",
"directories": {
"example": "examples"
},
"files": [
"build",
"src"
],
"scripts": {
"build": "rollup -c",
"build-uglify": "rollup -c && uglifyjs build/stats.js -cm --preamble \"// stats.js - http://github.com/mrdoob/stats.js\" > build/stats.min.js",
"build-closure": "rollup -c && java -jar utils/compiler/closure-compiler-v20160713.jar --language_in=ECMASCRIPT5_STRICT --js build/stats.js --js_output_file build/stats.min.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/mrdoob/stats.js.git"
},
"keywords": [
"performance",
"fps",
"stats"
],
"author": "mrdoob",
"license": "MIT",
"bugs": {
"url": "https://github.com/mrdoob/stats.js/issues"
},
"homepage": "https://github.com/mrdoob/stats.js",
"devDependencies": {
"rollup": "^0.36.0",
"uglifyjs": "^2.4.10"
}
}

171
site/real_game/node_modules/stats.js/src/Stats.js generated vendored Normal file
View File

@ -0,0 +1,171 @@
/**
* @author mrdoob / http://mrdoob.com/
*/
var Stats = function () {
var mode = 0;
var container = document.createElement( 'div' );
container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
container.addEventListener( 'click', function ( event ) {
event.preventDefault();
showPanel( ++ mode % container.children.length );
}, false );
//
function addPanel( panel ) {
container.appendChild( panel.dom );
return panel;
}
function showPanel( id ) {
for ( var i = 0; i < container.children.length; i ++ ) {
container.children[ i ].style.display = i === id ? 'block' : 'none';
}
mode = id;
}
//
var beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;
var fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );
var msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );
if ( self.performance && self.performance.memory ) {
var memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );
}
showPanel( 0 );
return {
REVISION: 16,
dom: container,
addPanel: addPanel,
showPanel: showPanel,
begin: function () {
beginTime = ( performance || Date ).now();
},
end: function () {
frames ++;
var time = ( performance || Date ).now();
msPanel.update( time - beginTime, 200 );
if ( time > prevTime + 1000 ) {
fpsPanel.update( ( frames * 1000 ) / ( time - prevTime ), 100 );
prevTime = time;
frames = 0;
if ( memPanel ) {
var memory = performance.memory;
memPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );
}
}
return time;
},
update: function () {
beginTime = this.end();
},
// Backwards Compatibility
domElement: container,
setMode: showPanel
};
};
Stats.Panel = function ( name, fg, bg ) {
var min = Infinity, max = 0, round = Math.round;
var PR = round( window.devicePixelRatio || 1 );
var WIDTH = 80 * PR, HEIGHT = 48 * PR,
TEXT_X = 3 * PR, TEXT_Y = 2 * PR,
GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,
GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
var canvas = document.createElement( 'canvas' );
canvas.width = WIDTH;
canvas.height = HEIGHT;
canvas.style.cssText = 'width:80px;height:48px';
var context = canvas.getContext( '2d' );
context.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';
context.textBaseline = 'top';
context.fillStyle = bg;
context.fillRect( 0, 0, WIDTH, HEIGHT );
context.fillStyle = fg;
context.fillText( name, TEXT_X, TEXT_Y );
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
context.fillStyle = bg;
context.globalAlpha = 0.9;
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
return {
dom: canvas,
update: function ( value, maxValue ) {
min = Math.min( min, value );
max = Math.max( max, value );
context.fillStyle = bg;
context.globalAlpha = 1;
context.fillRect( 0, 0, WIDTH, GRAPH_Y );
context.fillStyle = fg;
context.fillText( round( value ) + ' ' + name + ' (' + round( min ) + '-' + round( max ) + ')', TEXT_X, TEXT_Y );
context.drawImage( canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT );
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT );
context.fillStyle = bg;
context.globalAlpha = 0.9;
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round( ( 1 - ( value / maxValue ) ) * GRAPH_HEIGHT ) );
}
};
};
export { Stats as default };

4
site/real_game/node_modules/stats/.npmignore generated vendored Normal file
View File

@ -0,0 +1,4 @@
support
test
examples
*.sock

41
site/real_game/node_modules/stats/History.md generated vendored Normal file
View File

@ -0,0 +1,41 @@
1.0.0 / 2012-02-26
==================
* Added 0.6.x support
0.0.6 / 2011-08-15
==================
* Added `commander` dependency
* Changed stats(1) to use the commander module
* Fixed error messages for files not found (now throwing)
0.0.5 / 2011-08-03
==================
* Added shebang support
0.0.4 / 2011-08-03
==================
* Removed uglifyjs dep (inlined)
* Fixed single-file stats [saschagehlich]
* Fixed top-level returns
* Fixed: show help when no args are present [criso]
0.0.3 / 2011-08-03
==================
* Fixed mutation of first file's stats
0.0.2 / 2011-08-03
==================
* Added `-I, --ignore-errors`
* Fixed uglify error handling
0.0.1 / 2010-01-03
==================
* Initial release

7
site/real_game/node_modules/stats/Makefile generated vendored Normal file
View File

@ -0,0 +1,7 @@
TESTS = $(shell find test -name "test.*.js")
test:
@./test/run $(TESTS)
.PHONY: test

123
site/real_game/node_modules/stats/Readme.md generated vendored Normal file
View File

@ -0,0 +1,123 @@
# stats
JavaScript statistics library built on uglify-js, reporting all sorts of interesting (and non-interesting) stats. Comes complete with an extremely simple js API, as well as a CLI.
## Installation
$ npm install -g stats
## Example
The following is an example of `stats(1)` running against the nodejs core libraries, completing in less than 300ms.
```
λ projects: stats --totals node/lib
totals:
loc: 14855
bytes: 390.80 kb
statements: 6547
assignments: 3343
functions: 868
stringBytes: 10.28 kb
arrayLiterals: 108
objectLiterals: 99
objectsCreated: 183
regexpLiterals: 60
strings: 1211
numbers: 512
throws: 91
```
## Statistics
The following are currently supported:
- **loc**: lines of code as shown in source
- **statements**: total number of statements
- **assignments**: total number of assignments
- **functions**: total number of functions (both statement & expression)
- **numbers**: total number of ... numbers :)
- **throws**: total number of `throw`s
- **strings**: total number of strings
- **stringBytes**: total byte-length of all strings
- **regexpLiterals**: total number of regexp literals
- **arrayLiterals**: total number of array literals
- **objectLiterals**: total number of object literals
- **objectsCreated**: total number of objects initialized with `new`
- **bytes**: byte-length of source
## API
### .parse(js)
Returns statistics for the given string of `js`:
```js
var stats = require('stats');
console.log(stats.parse(str))
```
Outputs something similar to:
```js
{ loc: 65,
bytes: 1112,
statements: 16,
assignments: 9,
functions: 3,
stringBytes: 20,
arrayLiterals: 0,
objectLiterals: 1,
objectsCreated: 1,
strings: 4,
numbers: 9,
throws: 1 }
```
## CLI Usage
```
Usage: stats [options] [file|dir ...]
Options:
-f, --format <name> Output the given format. text, json
-j, --json Output JSON statistics
-t, --text Output human-readable plain-text stats
-T, --totals Output totals only
-V, --version Display the version of stats
-h, --help Display help information
```
## Running tests
$ make test
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

68
site/real_game/node_modules/stats/bin/stats generated vendored Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env node
/**
* Module dependencies.
*/
var stats = require('../')
, program = require('commander')
, fs = require('fs');
/**
* Statistics.
*/
var statistics = {};
/**
* Options.
*/
program
.version(stats.version)
.option('-f, --format <name>', 'output the given format. text or json. [text]', 'text')
.option('-j, --json', 'output json stats')
.option('-t, --text', 'output human-readable text stats')
.option('-T, --totals', 'output totals only')
.parse(process.argv);
// format shortcuts
if (program.text) program.format = 'text';
if (program.json) program.format = 'json';
// paths
var paths = program.args;
// process
var totals = {};
stats.find(paths, function(err, files){
if (err) throw err;
var pending = files.length;
files.forEach(function(file){
fs.readFile(file, 'utf8', function(err, str){
if (err) throw err;
statistics[file] = stats.parse(str, program);
Object.keys(statistics[file]).forEach(function(key){
totals[key] = (totals[key] || 0) + statistics[file][key];
});
--pending || done();
});
});
});
// finished
function done() {
if (program.text) {}
var format = stats.formats[program.format];
if (!format) throw new Error('invalid format "' + program.format + '"');
var obj = { totals: totals };
totals.files = Object.keys(statistics).length;
if (!program.totals) {
for (var file in statistics) obj[file] = statistics[file];
}
format(obj);
}

2
site/real_game/node_modules/stats/index.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
module.exports = require('./lib/stats');

83
site/real_game/node_modules/stats/lib/find.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
/*!
* stats - find
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var fs = require('fs')
, path = require('path')
, join = path.join
, extname = path.extname
, noop = function(){};
/**
* Find JavaScript files by the given `paths`
* and callback `fn(err, files)`.
*
* @param {Array} paths
* @param {Function} fn
* @api public
*/
module.exports = function(paths, fn){
var pending = paths.length
, ret = [];
function find(path) {
fs.stat(path, function(err, stat) {
if (err) {
fn(err);
fn = noop;
return
}
if (stat.isFile() && isJavaScript(path)) {
ret.push(path);
--pending || fn(null, ret);
} else {
fs.readdir(path, function(err, files){
if (err) {
fn(err);
fn = noop;
return
}
files.forEach(function(file){
file = join(path, file);
if (isJavaScript(file)) {
ret.push(file);
} else {
++pending;
fs.stat(file, function(err, stat){
if (err) return;
if (!stat.isDirectory()) return --pending || fn(null, ret);
find(file);
});
}
});
--pending || fn(null, ret);
});
}
});
}
paths.forEach(find);
};
/**
* Filter `file` by ".js" extension.
*
* @param {String} file
* @return {Boolean}
* @api private
*/
function isJavaScript(file) {
return '.js' == extname(file);
}

View File

@ -0,0 +1,9 @@
/*!
* stats - formats
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
exports.json = require('./json');
exports.text = require('./text');

17
site/real_game/node_modules/stats/lib/formats/json.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/*!
* stats - formats - json
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Output `stats` as JSON.
*
* @param {Object} stats
* @api private
*/
module.exports = function(stats){
process.stdout.write(JSON.stringify(stats));
};

39
site/real_game/node_modules/stats/lib/formats/text.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
/*!
* stats - formats - text
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Output `stats` as plain-text.
*
* @param {Object} stats
* @api private
*/
exports = module.exports = function(files){
Object.keys(files).forEach(function(file){
var stats = files[file];
console.log('\n \033[90m%s:\033[0m', file);
Object.keys(stats).forEach(function(name){
var val = stats[name];
if (exports[name]) val = exports[name](val);
console.log(' \033[90m%s: \033[36m%s\033[0m', name, val);
});
});
console.log();
};
/**
* Format bytes.
*/
exports.bytes =
exports.stringBytes = function(n){
var kb = 1024
, mb = kb * 1024;
if (n < kb) return n + ' bytes';
if (n < mb) return (n / kb).toFixed(2) + ' kb';
return (n / mb).toFixed(2) + ' mb';
};

253
site/real_game/node_modules/stats/lib/parser.js generated vendored Normal file
View File

@ -0,0 +1,253 @@
/*!
* stats - parser
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var parse = require('./uglify/parser').parse
, sys = require('util');
/**
* Return stats for the given javascript `str`.
*
* @param {String} str
* @param {Object} options
* @return {Object}
* @api public
*/
module.exports = function(str, options){
var options = options || {}
, stats = {
loc: str.split('\n').length
, bytes: Buffer.byteLength(str)
, statements: 0
, assignments: 0
, functions: 0
, stringBytes: 0
, arrayLiterals: 0
, objectLiterals: 0
, objectsCreated: 0
, regexpLiterals: 0
, strings: 0
, numbers: 0
, throws: 0
};
// strip shebang
if ('#' == str[0]) str = str.slice(str.indexOf('\n'));
function visit(node) {
if (!node) return;
var name = node[0];
// array support
if ('string' != typeof name) {
for (var i = 0, len = node.length; i < len; ++i) {
visit(node[i]);
}
return;
}
// rename "name" to "ident"
if ('name' == name) name = 'ident';
// visit the node
if (!visit[name]) throw new Error('no visitor implemented for "' + name + '"');
visit[name](node);
}
visit['toplevel'] = function(node){
visit(node[1]);
};
visit['seq'] = function(node){
visit(node[1]);
visit(node[2]);
};
visit['for-in'] = function(node){
visit(node[1]);
visit(node[2]);
visit(node[3]);
visit(node[4]);
};
visit['switch'] = function(node){
++stats.statements;
visit(node[1]);
node[2].forEach(function(node){
visit(node[1]);
visit(node[2]);
});
};
visit['with'] = function(node){
++stats.statements;
visit(node[1]);
visit(node[2]);
};
visit['try'] = function(node){
++stats.statements;
visit(node[1]);
node[2] && visit(node[2][1]);
};
visit['conditional'] = function(node){
visit(node[1]);
visit(node[2]);
visit(node[3]);
};
visit['break'] = function(node){
++stats.statements;
};
visit['array'] = function(node){
++stats.arrayLiterals;
visit(node[1]);
};
visit['object'] = function(node){
++stats.objectLiterals;
node[1].forEach(function(pair){
visit(pair[1]);
});
};
visit['var'] =
visit['const'] = function(node){
node[1].forEach(function(node){
if (node[1]) ++stats.assignments;
visit(node[1]);
});
++stats.statements;
};
visit['regexp'] = function(node){
++stats.regexpLiterals;
};
visit['num'] = function(node){
++stats.numbers;
};
visit['do'] = function(node){
++stats.statements;
visit(node[1]);
visit(node[2]);
};
visit['label'] = function(node){
visit(node[2]);
};
visit['atom'] = function(node){};
visit['unary-prefix'] = function(node){};
visit['unary-postfix'] = function(node){};
visit['continue'] = function(node){};
visit['return'] = function(node){};
visit['binary'] = function(node){};
visit['ident'] = function(node){};
visit['new'] = function(node){
++stats.objectsCreated;
visit(node[1]);
visit(node[2]);
};
visit['throw'] = function(node){
++stats.throws;
visit(node[1]);
};
visit['for'] = function(node){
visit(node[1]);
visit(node[2]);
visit(node[3]);
visit(node[4]);
};
visit['sub'] = function(node){
visit(node[1]);
visit(node[2]);
};
visit['string'] = function(node){
++stats.strings;
stats.stringBytes += Buffer.byteLength(node[1]);
};
visit['dot'] = function(node){
visit(node[1]);
};
visit['block'] = function(node){
visit(node[1]);
};
visit['while'] = function(node){
++stats.statements;
visit(node[2]);
};
visit['if'] = function(node){
++stats.statements;
visit(node[1]);
visit(node[2]);
visit(node[3]);
};
visit['defun'] = function(node){
++stats.functions;
++stats.statements;
visit(node[3]);
};
visit['function'] = function(node){
++stats.functions;
visit(node[3]);
};
visit['call'] = function(node){
visit(node[1]);
visit(node[2]);
};
visit['assign'] = function(node){
++stats.assignments;
visit(node[3]);
};
visit['stat'] = function(node){
++stats.statements;
visit(node[1]);
};
try {
visit(parse(str));
} catch (err) {
if ('JS_Parse_Error' != err.constructor.name) throw err;
var line = str.split('\n')[err.line];
err = new SyntaxError(err.message
+ ' on line '
+ err.line
+ ':' + err.col
+ ':\n ' + sys.inspect(line));
if (!options.ignoreParseErrors) throw err;
}
return stats;
};

39
site/real_game/node_modules/stats/lib/stats.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
/*!
* stats
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Library version.
*/
exports.version = '0.0.6';
/**
* Return stats for the given javascript `str`.
*
* @param {String} str
* @return {Object}
* @api public
*/
exports.parse = require('./parser');
/**
* Find JavaScript files by the given `paths`
* and callback `fn(err, files)`.
*
* @param {Array} paths
* @param {Function} fn
* @api public
*/
exports.find = require('./find');
/**
* Expose formatters.
*/
exports.formats = require('./formats');

1341
site/real_game/node_modules/stats/lib/uglify/parser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

18
site/real_game/node_modules/stats/package.json generated vendored Normal file
View File

@ -0,0 +1,18 @@
{
"name": "stats"
, "version": "1.0.0"
, "description": "JavaScript statistics (LOC, SLOC, etc)"
, "keywords": ["metrics", "stats", "statistics", "sloc", "uglify"]
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
, "bin": {
"stats": "./bin/stats"
}
, "dependencies": {
"commander": "0.5.2"
}
, "devDependencies": {
"should": ">= 0.0.1"
}
, "main": "index"
, "engines": { "node": ">=0.4.x" }
}

13
site/real_game/node_modules/stats/test/common.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Module dependencies.
*/
var should = require('should')
, fs = require('fs');
// load fixture path
global.fixture = function fixture(path) {
return fs.readFileSync(__dirname + '/fixtures/' + path, 'utf8');
};

View File

@ -0,0 +1,8 @@
var foo = [
'bar',
'baz',
'raz'
];
foo.push(['foo', 'bar', 'baz']);

View File

@ -0,0 +1,8 @@
/**
* testing stuff.
*
* @param {Type} name
* @return {Type}
* @api public
*/

View File

@ -0,0 +1,18 @@
function foo() {
console.log('test');
}
function bar() {
console.log('test');
}
var baz = function(){
console.log('stuff');
};
global = function(){
console.log('foo');
console.log('bar');
console.log('baz');
}

View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var http = require('http');
http.createServer(function(req, res){
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
}).listen(3000);

View File

@ -0,0 +1,65 @@
/*!
* jss
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var parse = require('uglify-js').parser.parse;
/**
* Library version.
*/
exports.version = '0.0.1';
/**
* Return stats for the given javascript `str`.
*
* @param {String} str
* @return {Object}
* @api public
*/
exports.stats = function(str){
var stats = {
statements: 0
, assignments: 0
, functions: 0
, numbers: 0
, strings: 0
, stringBytes: 0
, loc: str.split('\n').length
, bytes: Buffer.byteLength(str)
};
function visit(node) {
if (!node) return;
var name = node[0];
// array support
if ('string' != typeof name) {
for (var i = 0, len = node.length; i < len; ++i) {
visit(node[i]);
}
return;
}
// rename "name" to "ident"
if ('name' == name) name = 'ident';
// visit the node
if (!visit[name]) throw new Error('no visitor implemented for "' + name + '"');
visit[name](node);
}
visit['toplevel'] = function(node){
visit(node[1]);
};
return stats;
};

View File

@ -0,0 +1,9 @@
var foo = { foo: 'bar' };
var tj = {
first: 'tj'
, last: 'holowaychuk'
};
tj = new User(tj);

View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
console.log('foo')
console.log('bar')
console.log('baz')

View File

@ -0,0 +1,9 @@
var foo = 'foo'
, bar = 'bar'
, baz = 'baz'
, test;
console.log(foo = 'hey');
console.log(bar);
console.log(baz);

View File

@ -0,0 +1,9 @@
switch ('foo') {
case 'foo':
console.log('foo');
break;
case 'bar':
console.log('bar');
break;
}

View File

@ -0,0 +1,9 @@
out: while (foo) {
if (bar) continue;
break out;
}
do {
console.log(foo);
} while(bar);

View File

@ -0,0 +1,5 @@
with (foo) {
bar();
baz();
}

16
site/real_game/node_modules/stats/test/run generated vendored Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
export NODE_ENV=test
echo
for file in $@; do
printf "\033[90m ${file#test/}\033[0m "
node $file 2> /tmp/stderr && echo "\033[36m✓\033[0m"
code=$?
if test $code -ne 0; then
echo "\033[31m✖\033[0m"
cat /tmp/stderr >&2
exit $code
fi
done
echo

11
site/real_game/node_modules/stats/test/test.arrays.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('arrays.js'));
stats.should.have.property('arrayLiterals', 2);
stats.should.have.property('strings', 6);

View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('comments.js'));
stats.should.have.property('statements', 0);
stats.should.have.property('loc', 8);

11
site/real_game/node_modules/stats/test/test.forin.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('for (var key in val) "hey";');
stats.should.have.property('statements', 2);
stats.should.have.property('strings', 1);

View File

@ -0,0 +1,12 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('functions.js'));
stats.should.have.property('statements', 10);
stats.should.have.property('assignments', 2);
stats.should.have.property('functions', 4);

15
site/real_game/node_modules/stats/test/test.http.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('http.js'));
stats.should.have.property('strings', 4);
stats.should.have.property('numbers', 1);
stats.should.have.property('statements', 4);
stats.should.have.property('assignments', 1);
stats.should.have.property('stringBytes', 38);
stats.should.have.property('loc', 11);

15
site/real_game/node_modules/stats/test/test.large.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('large.js'));
stats.should.have.property('statements', 16);
stats.should.have.property('assignments', 9);
stats.should.have.property('loc', 65);
stats.should.have.property('objectLiterals', 1);
stats.should.have.property('objectsCreated', 1);
stats.should.have.property('throws', 1);

11
site/real_game/node_modules/stats/test/test.objects.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('objects.js'));
stats.should.have.property('objectLiterals', 2);
stats.should.have.property('objectsCreated', 1);

View File

@ -0,0 +1,9 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('foo++');

11
site/real_game/node_modules/stats/test/test.regexp.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('foo.text(/something/)');
stats.should.have.property('statements', 1);
stats.should.have.property('regexpLiterals', 1);

View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('("foo", "bar", "baz")');
stats.should.have.property('statements', 1);
stats.should.have.property('strings', 3);

10
site/real_game/node_modules/stats/test/test.shebang.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('shebang.js'));
stats.should.have.property('statements', 3);

15
site/real_game/node_modules/stats/test/test.simple.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
stats.should.have.property('version');
var stats = stats.parse(fixture('simple.js'));
stats.should.have.property('statements', 4);
stats.should.have.property('assignments', 4);
stats.should.have.property('loc', 9);
stats.should.have.property('bytes', 121);

10
site/real_game/node_modules/stats/test/test.switch.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('switch.js'));
stats.should.have.property('statements', 5);

11
site/real_game/node_modules/stats/test/test.ternary.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('"foo" ? "bar" : "baz"');
stats.should.have.property('statements', 1);
stats.should.have.property('strings', 3);

View File

@ -0,0 +1,11 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse('try { "test" } catch (err) { "testing" }');
stats.should.have.property('statements', 3);
stats.should.have.property('strings', 2);

10
site/real_game/node_modules/stats/test/test.while.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('while.js'));
stats.should.have.property('statements', 5);

10
site/real_game/node_modules/stats/test/test.with.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Module dependencies.
*/
var stats = require('../')
, common = require('./common');
var stats = stats.parse(fixture('with.js'));
stats.should.have.property('statements', 3);