|
951 | 951 | }); |
952 | 952 | </script> |
953 | 953 |
|
954 | | -// Adicionar evento de clique para o botão de skybox |
955 | | -document.getElementById('skyboxButton').addEventListener('click', function() { |
956 | | - // Carregar um novo skybox aleatório |
957 | | - loadRandomSkybox(); |
958 | | - |
959 | | - // Efeito visual de clique |
960 | | - gsap.to(this, { |
961 | | - scale: 0.95, |
962 | | - duration: 0.1, |
963 | | - onComplete: function() { |
964 | | - gsap.to(document.getElementById('skyboxButton'), { |
965 | | - scale: 1, |
966 | | - duration: 0.2 |
967 | | - }); |
968 | | - } |
969 | | - }); |
970 | | -}); |
971 | | - |
972 | | -document.addEventListener('DOMContentLoaded', function() { |
973 | | - // ... existing code ... |
974 | | -}); |
975 | | - |
976 | | -// Função para trocar o skybox ao clicar no botão |
977 | | -function changeSkybox() { |
978 | | - // Efeito visual no botão para indicar que foi clicado |
979 | | - var skyboxButton = document.getElementById('skyboxButton'); |
980 | | - |
981 | | - // Animação de clique usando GSAP |
982 | | - gsap.timeline() |
983 | | - .to(skyboxButton, { |
984 | | - scale: 0.9, |
985 | | - backgroundColor: 'rgba(51, 255, 51, 0.3)', |
986 | | - duration: 0.1 |
987 | | - }) |
988 | | - .to(skyboxButton, { |
989 | | - scale: 1, |
990 | | - backgroundColor: 'rgba(0, 0, 0, 0.7)', |
991 | | - duration: 0.2, |
992 | | - delay: 0.1 |
993 | | - }); |
994 | | - |
995 | | - // Incrementa o índice e volta ao início se necessário |
996 | | - currentSkyboxIndex = (currentSkyboxIndex + 1) % skyboxes.length; |
997 | | - |
998 | | - // Carrega o skybox com o novo índice |
999 | | - var selectedSkybox = skyboxes[currentSkyboxIndex]; |
1000 | | - |
1001 | | - var loader = new THREE.CubeTextureLoader(); |
1002 | | - loader.load(selectedSkybox, function(texture) { |
1003 | | - scene.background = texture; |
| 954 | +<script> |
| 955 | + // Adicionar evento de clique para o botão de skybox (colocando dentro de uma tag script) |
| 956 | + document.getElementById('skyboxButton').addEventListener('click', function() { |
| 957 | + // Carregar um novo skybox aleatório |
| 958 | + loadRandomSkybox(); |
1004 | 959 |
|
1005 | | - // Aplicar o mapa de ambiente aos materiais, exceto aos olhos |
1006 | | - scene.traverse(function(child) { |
1007 | | - if (child.isMesh) { |
1008 | | - // Verificar se o objeto é parte dos olhos |
1009 | | - const isEyePart = child.name && ( |
1010 | | - child.name.toLowerCase().includes('eye') || |
1011 | | - child.name.toLowerCase().includes('olho') |
1012 | | - ); |
1013 | | - |
1014 | | - // Só aplicar o envMap se não for parte dos olhos |
1015 | | - if (!isEyePart) { |
1016 | | - if (child.material) { |
1017 | | - if (Array.isArray(child.material)) { |
1018 | | - child.material.forEach(mat => { |
1019 | | - if (mat.envMap !== undefined) { |
1020 | | - mat.envMap = texture; |
1021 | | - mat.needsUpdate = true; |
1022 | | - } |
1023 | | - }); |
1024 | | - } else if (child.material.envMap !== undefined) { |
1025 | | - child.material.envMap = texture; |
1026 | | - child.material.needsUpdate = true; |
1027 | | - } |
1028 | | - } |
1029 | | - } |
| 960 | + // Efeito visual de clique |
| 961 | + gsap.to(this, { |
| 962 | + scale: 0.95, |
| 963 | + duration: 0.1, |
| 964 | + onComplete: function() { |
| 965 | + gsap.to(document.getElementById('skyboxButton'), { |
| 966 | + scale: 1, |
| 967 | + duration: 0.2 |
| 968 | + }); |
1030 | 969 | } |
1031 | 970 | }); |
1032 | 971 | }); |
1033 | | -} |
| 972 | + |
| 973 | + // Função para trocar o skybox ao clicar no botão |
| 974 | + function changeSkybox() { |
| 975 | + // Efeito visual no botão para indicar que foi clicado |
| 976 | + var skyboxButton = document.getElementById('skyboxButton'); |
| 977 | + |
| 978 | + // Animação de clique usando GSAP |
| 979 | + gsap.timeline() |
| 980 | + .to(skyboxButton, { |
| 981 | + scale: 0.9, |
| 982 | + backgroundColor: 'rgba(51, 255, 51, 0.3)', |
| 983 | + duration: 0.1 |
| 984 | + }) |
| 985 | + .to(skyboxButton, { |
| 986 | + scale: 1, |
| 987 | + backgroundColor: 'rgba(0, 0, 0, 0.7)', |
| 988 | + duration: 0.2, |
| 989 | + delay: 0.1 |
| 990 | + }); |
| 991 | + |
| 992 | + // Carrega o skybox com o novo índice |
| 993 | + loadRandomSkybox(); |
| 994 | + } |
| 995 | +</script> |
0 commit comments