stats if hash, animate on load
This commit is contained in:
parent
ba65ac67f6
commit
eae4c0cf56
22
main.js
22
main.js
@ -73,6 +73,9 @@ const waterTexture = loader.load('img/waternormals.jpg');
|
|||||||
const groundTexture = loader.load('img/ground.jpg');
|
const groundTexture = loader.load('img/ground.jpg');
|
||||||
const wallTexture = loader.load('img/wall.jpg');
|
const wallTexture = loader.load('img/wall.jpg');
|
||||||
const woodTexture = loader.load('img/wood.jpg');
|
const woodTexture = loader.load('img/wood.jpg');
|
||||||
|
loadMngr.onLoad = () => {
|
||||||
|
animate();
|
||||||
|
};
|
||||||
|
|
||||||
const clock = new THREE.Clock();
|
const clock = new THREE.Clock();
|
||||||
|
|
||||||
@ -182,9 +185,9 @@ const wallMaterial = new THREE.MeshPhongMaterial( {
|
|||||||
|
|
||||||
const mazeMap = new Labyrinthe(mazeLength, mazeWidth)
|
const mazeMap = new Labyrinthe(mazeLength, mazeWidth)
|
||||||
const maze = new THREE.InstancedMesh( wallGeometry, wallMaterial, mazeMap.walls );
|
const maze = new THREE.InstancedMesh( wallGeometry, wallMaterial, mazeMap.walls );
|
||||||
let i=0
|
|
||||||
let matrix = new THREE.Matrix4()
|
let matrix = new THREE.Matrix4()
|
||||||
const cube = new THREE.Mesh(wallGeometry)
|
const cube = new THREE.Mesh(wallGeometry)
|
||||||
|
let i=0
|
||||||
mazeMap.forEach((row, z) => {
|
mazeMap.forEach((row, z) => {
|
||||||
row.forEach((isWall, x) => {
|
row.forEach((isWall, x) => {
|
||||||
if (isWall) {
|
if (isWall) {
|
||||||
@ -289,10 +292,17 @@ function updateSun() {
|
|||||||
updateSun();
|
updateSun();
|
||||||
setInterval( updateSun, 10000 );
|
setInterval( updateSun, 10000 );
|
||||||
|
|
||||||
|
let showStats = false
|
||||||
const stats = new Stats();
|
const stats = new Stats();
|
||||||
stats.domElement.style.position = 'absolute';
|
window.onhashchange = function(event) {
|
||||||
stats.domElement.style.top = '0px';
|
showStats = document.location.hash == "#stats"
|
||||||
container.appendChild( stats.domElement );
|
if ( showStats ) {
|
||||||
|
stats.domElement.style.position = 'absolute';
|
||||||
|
stats.domElement.style.top = '0px';
|
||||||
|
container.appendChild( stats.domElement );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.onhashchange()
|
||||||
|
|
||||||
const GRAVITY = 30;
|
const GRAVITY = 30;
|
||||||
|
|
||||||
@ -487,8 +497,6 @@ gui.add( { debug: false }, 'debug' )
|
|||||||
} );
|
} );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
animate();
|
|
||||||
|
|
||||||
function teleportPlayerIfOob() {
|
function teleportPlayerIfOob() {
|
||||||
|
|
||||||
if ( camera.position.y <= - 25 ) {
|
if ( camera.position.y <= - 25 ) {
|
||||||
@ -530,7 +538,7 @@ function animate() {
|
|||||||
|
|
||||||
renderer.render( scene, camera );
|
renderer.render( scene, camera );
|
||||||
|
|
||||||
stats.update();
|
if ( showStats ) stats.update();
|
||||||
|
|
||||||
requestAnimationFrame( animate );
|
requestAnimationFrame( animate );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user