diff --git a/docker-compose/requirements/nginx/static/javascript/filesLoader.js b/docker-compose/requirements/nginx/static/javascript/filesLoader.js index 863cc89..c710ff3 100644 --- a/docker-compose/requirements/nginx/static/javascript/filesLoader.js +++ b/docker-compose/requirements/nginx/static/javascript/filesLoader.js @@ -6,7 +6,7 @@ /* By: edbernar { + if (typeof value === 'object') + { + files[key] = {}; + Object.entries(value).forEach(([k, v]) => { + fetch(v) + .then(response => response.blob()) + .then(blob => { + files[key][k] = URL.createObjectURL(blob); + }); + }); + return; + } fetch(value) .then(response => response.blob()) .then(blob => { diff --git a/docker-compose/requirements/nginx/static/javascript/lobbyPage/3d.js b/docker-compose/requirements/nginx/static/javascript/lobbyPage/3d.js index 846bf27..db24a49 100644 --- a/docker-compose/requirements/nginx/static/javascript/lobbyPage/3d.js +++ b/docker-compose/requirements/nginx/static/javascript/lobbyPage/3d.js @@ -6,11 +6,12 @@ /* By: edbernar { + if (material.map) + material.map.dispose(); + material.dispose(); + }); + } else - this.bar.material = new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture)}); + { + if (this.bar.material.map) + this.bar.material.map.dispose(); + this.bar.material.dispose(); + } + lastSelected = availableSkins[id]; + if (availableSkins[id].color) + this.bar.material = new THREE.MeshPhysicalMaterial({color: skin.color}); + else + { + if (typeof availableSkins[id].texture !== 'object') + this.bar.material = new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(skin.texture)}); + else + { + this.bar.material = [ + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.left)}), + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.right)}), + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.top)}), + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.bottom)}), + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.front)}), + new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(availableSkins[id].texture.back)}), + ] + } + } this.selected = availableSkins[id]; } createBarPlayer(color) { - const geometry = new THREE.BoxGeometry(1, 0.1, 0.1); - let material = null; - - if (typeof(color) == 'number') - material = new THREE.MeshPhysicalMaterial({color: color}); - else - material = new THREE.MeshPhysicalMaterial({map: new THREE.TextureLoader().load(color)}); - const mesh = new THREE.Mesh(geometry, material); - - mesh.castShadow = true; - return (mesh); + return (createBarPlayer(color)); } #loop() @@ -204,6 +222,7 @@ class goalSelecter const goal = document.getElementsByClassName('color-box-goal'); popup.style.display = 'flex'; + for (let i = 0; i < goal.length; i++) { const canvas = goal[i].getElementsByTagName('canvas'); @@ -223,11 +242,11 @@ class goalSelecter { const scene = new THREE.Scene(); const renderer = new THREE.WebGLRenderer({antialias: true}); - const camera = new THREE.PerspectiveCamera(60, (pos.width - 5) / (pos.height - 5)); + const camera = new THREE.PerspectiveCamera(60, (pos.width - 8) / (pos.height - 8)); const mesh = func(colorList[Math.floor(Math.random() * 100 % colorList.length)]); const spotLight = new THREE.SpotLight(0xffffff, 5000); - renderer.setSize(pos.width - 5, pos.height - 5); + renderer.setSize(pos.width - 8, pos.height - 8); scene.add(mesh); camera.position.set(1.5, 1.5, 1.5); spotLight.position.set(1.5, 1.5, 1.5); @@ -238,7 +257,7 @@ class goalSelecter this.sceneList.push(scene); this.rendererList.push(renderer); this.cameraList.push(camera); - return (renderer.domElement) + return (renderer.domElement); } changeGoal(event) diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js index 48147d7..7ac73cd 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js @@ -6,7 +6,7 @@ /* By: edbernar