Fixing Co Hai Se page on responsive version
This commit is contained in:
+2
-4
@@ -1,12 +1,10 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# 1. Redirection du sous-domaine vers le dossier /cohaise
|
||||
|
||||
RewriteCond %{HTTP_HOST} ^cohaise\.esiah\.dev$ [NC]
|
||||
RewriteRule ^(.*)$ https://esiah.dev/cohaise/$1 [L,R=301]
|
||||
RewriteRule ^(.*)$ https://esiah.dev/cohaise$1 [L,R=301]
|
||||
|
||||
# 2. Gestion standard du SPA React (ne pas toucher)
|
||||
RewriteRule ^index\.html$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
@@ -198,3 +198,13 @@
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
.marquee {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.menu__item-link:hover {
|
||||
padding-left: 4vw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,19 +101,22 @@ function MenuItem({
|
||||
}, [speed, repetitions]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
if (isOpen && itemRef.current) {
|
||||
const isMobile = window.innerWidth < 768;
|
||||
|
||||
gsap.to(contentRef.current, {
|
||||
height: "auto",
|
||||
opacity: 1,
|
||||
duration: 0.6,
|
||||
ease: "power3.out",
|
||||
});
|
||||
|
||||
gsap.to(window, {
|
||||
duration: 1,
|
||||
delay: 0.4,
|
||||
scrollTo: {
|
||||
y: itemRef.current,
|
||||
offsetY: 60,
|
||||
offsetY: isMobile ? 10 : 60,
|
||||
autoKill: true,
|
||||
},
|
||||
ease: "power3.inOut",
|
||||
@@ -135,6 +138,8 @@ function MenuItem({
|
||||
}, [isOpen]);
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
if (window.matchMedia("(pointer: coarse)").matches) return;
|
||||
|
||||
if (isOpen) return;
|
||||
|
||||
gsap.to(marqueeRef.current, { y: "0%", duration: 0.6, ease: "expo" });
|
||||
@@ -142,6 +147,7 @@ function MenuItem({
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
if (window.matchMedia("(pointer: coarse)").matches) return;
|
||||
gsap.to(marqueeRef.current, { y: "101%", duration: 0.6, ease: "expo" });
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable react-hooks/set-state-in-effect */
|
||||
import { useRef, useEffect, useState } from "react";
|
||||
import * as THREE from "three";
|
||||
import "./LightPillar.css";
|
||||
@@ -19,7 +18,6 @@ const LightPillar = ({
|
||||
quality = "high",
|
||||
}) => {
|
||||
const containerRef = useRef(null);
|
||||
const rafRef = useRef(null);
|
||||
const rendererRef = useRef(null);
|
||||
const materialRef = useRef(null);
|
||||
const sceneRef = useRef(null);
|
||||
@@ -27,16 +25,19 @@ const LightPillar = ({
|
||||
const geometryRef = useRef(null);
|
||||
const mouseRef = useRef(new THREE.Vector2(0, 0));
|
||||
const timeRef = useRef(0);
|
||||
const [webGLSupported, setWebGLSupported] = useState(true);
|
||||
const rafRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = document.createElement("canvas");
|
||||
const gl =
|
||||
canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
||||
if (!gl) {
|
||||
setWebGLSupported(false);
|
||||
const [webGLSupported, setWebGLSupported] = useState(() => {
|
||||
try {
|
||||
const canvas = document.createElement("canvas");
|
||||
return !!(
|
||||
window.WebGLRenderingContext &&
|
||||
(canvas.getContext("webgl") || canvas.getContext("experimental-webgl"))
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, []);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!containerRef.current || !webGLSupported) return;
|
||||
@@ -50,17 +51,8 @@ const LightPillar = ({
|
||||
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||
cameraRef.current = camera;
|
||||
|
||||
const isMobile =
|
||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||
navigator.userAgent,
|
||||
);
|
||||
const isLowEndDevice =
|
||||
isMobile ||
|
||||
(navigator.hardwareConcurrency && navigator.hardwareConcurrency <= 4);
|
||||
|
||||
// Fini le bridage ! On respecte la prop `quality` que tu as passé (high)
|
||||
let effectiveQuality = quality;
|
||||
if (isLowEndDevice && quality === "high") effectiveQuality = "medium";
|
||||
if (isMobile && quality !== "low") effectiveQuality = "low";
|
||||
|
||||
const qualitySettings = {
|
||||
low: {
|
||||
@@ -100,9 +92,8 @@ const LightPillar = ({
|
||||
stencil: false,
|
||||
depth: false,
|
||||
});
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
} catch (error) {
|
||||
setWebGLSupported(false);
|
||||
} catch {
|
||||
setTimeout(() => setWebGLSupported(false), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +117,6 @@ const LightPillar = ({
|
||||
|
||||
const fragmentShader = `
|
||||
precision ${settings.precision} float;
|
||||
|
||||
uniform float uTime;
|
||||
uniform vec2 uResolution;
|
||||
uniform vec2 uMouse;
|
||||
@@ -151,7 +141,15 @@ const LightPillar = ({
|
||||
const int WAVE_ITER = ${settings.waveIterations};
|
||||
|
||||
void main() {
|
||||
vec2 uv = (vUv * 2.0 - 1.0) * vec2(uResolution.x / uResolution.y, 1.0);
|
||||
vec2 uv = vUv * 2.0 - 1.0;
|
||||
float aspect = uResolution.x / uResolution.y;
|
||||
|
||||
if (aspect > 1.0) {
|
||||
uv.x *= aspect;
|
||||
} else {
|
||||
uv.y /= aspect;
|
||||
}
|
||||
|
||||
uv = vec2(uPillarRotCos * uv.x - uPillarRotSin * uv.y, uPillarRotSin * uv.x + uPillarRotCos * uv.y);
|
||||
|
||||
vec3 ro = vec3(0.0, 0.0, -10.0);
|
||||
@@ -159,8 +157,9 @@ const LightPillar = ({
|
||||
|
||||
float rotC = uRotCos;
|
||||
float rotS = uRotSin;
|
||||
|
||||
if(uInteractive && (uMouse.x != 0.0 || uMouse.y != 0.0)) {
|
||||
float a = uMouse.x * 6.283185;
|
||||
float a = uMouse.x * 3.14159;
|
||||
rotC = cos(a);
|
||||
rotS = sin(a);
|
||||
}
|
||||
@@ -171,12 +170,12 @@ const LightPillar = ({
|
||||
for(int i = 0; i < MAX_ITER; i++) {
|
||||
vec3 p = ro + rd * t;
|
||||
p.xz = vec2(rotC * p.x - rotS * p.z, rotS * p.x + rotC * p.z);
|
||||
|
||||
vec3 q = p;
|
||||
q.y = p.y * uPillarHeight + uTime;
|
||||
|
||||
float freq = 1.0;
|
||||
float amp = 1.0;
|
||||
|
||||
for(int j = 0; j < WAVE_ITER; j++) {
|
||||
q.xz = vec2(uWaveCos * q.x - uWaveSin * q.z, uWaveSin * q.x + uWaveCos * q.z);
|
||||
q += cos(q.zxy * freq - uTime * float(j) * 2.0) * amp;
|
||||
@@ -200,8 +199,7 @@ const LightPillar = ({
|
||||
|
||||
float widthNorm = uPillarWidth / 3.0;
|
||||
col = tanh(col * uGlowAmount / widthNorm);
|
||||
|
||||
col -= fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) / 15.0 * uNoiseIntensity;
|
||||
col -= fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) / 15.0 * uNoiseIntensity;
|
||||
|
||||
gl_FragColor = vec4(col * uIntensity, 1.0);
|
||||
}
|
||||
@@ -225,7 +223,7 @@ const LightPillar = ({
|
||||
uGlowAmount: { value: glowAmount },
|
||||
uPillarWidth: { value: pillarWidth },
|
||||
uPillarHeight: { value: pillarHeight },
|
||||
uNoiseIntensity: { value: noiseIntensity },
|
||||
uNoiseIntensity: { value: noiseIntensity }, // Valeur exacte
|
||||
uRotCos: { value: 1.0 },
|
||||
uRotSin: { value: 0.0 },
|
||||
uPillarRotCos: { value: Math.cos(pillarRotRad) },
|
||||
@@ -244,26 +242,15 @@ const LightPillar = ({
|
||||
const mesh = new THREE.Mesh(geometry, material);
|
||||
scene.add(mesh);
|
||||
|
||||
let mouseMoveTimeout = null;
|
||||
const handleMouseMove = (event) => {
|
||||
if (!interactive) return;
|
||||
|
||||
if (mouseMoveTimeout) return;
|
||||
|
||||
mouseMoveTimeout = window.setTimeout(() => {
|
||||
mouseMoveTimeout = null;
|
||||
}, 16);
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
||||
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
||||
const x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
const y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
mouseRef.current.set(x, y);
|
||||
};
|
||||
|
||||
if (interactive) {
|
||||
container.addEventListener("mousemove", handleMouseMove, {
|
||||
passive: true,
|
||||
});
|
||||
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
||||
}
|
||||
|
||||
let lastTime = performance.now();
|
||||
@@ -280,39 +267,31 @@ const LightPillar = ({
|
||||
return;
|
||||
|
||||
const deltaTime = currentTime - lastTime;
|
||||
|
||||
if (deltaTime >= frameTime) {
|
||||
timeRef.current += 0.016 * rotationSpeed;
|
||||
const t = timeRef.current;
|
||||
materialRef.current.uniforms.uTime.value = t;
|
||||
materialRef.current.uniforms.uRotCos.value = Math.cos(t * 0.3);
|
||||
materialRef.current.uniforms.uRotSin.value = Math.sin(t * 0.3);
|
||||
|
||||
if (!interactive) {
|
||||
materialRef.current.uniforms.uRotCos.value = Math.cos(t * 0.3);
|
||||
materialRef.current.uniforms.uRotSin.value = Math.sin(t * 0.3);
|
||||
}
|
||||
|
||||
rendererRef.current.render(sceneRef.current, cameraRef.current);
|
||||
lastTime = currentTime - (deltaTime % frameTime);
|
||||
}
|
||||
|
||||
rafRef.current = requestAnimationFrame(animate);
|
||||
};
|
||||
rafRef.current = requestAnimationFrame(animate);
|
||||
|
||||
let resizeTimeout = null;
|
||||
const handleResize = () => {
|
||||
if (resizeTimeout) {
|
||||
clearTimeout(resizeTimeout);
|
||||
}
|
||||
if (!rendererRef.current || !materialRef.current || !containerRef.current)
|
||||
return;
|
||||
const newWidth = containerRef.current.clientWidth;
|
||||
const newHeight = containerRef.current.clientHeight;
|
||||
|
||||
resizeTimeout = window.setTimeout(() => {
|
||||
if (
|
||||
!rendererRef.current ||
|
||||
!materialRef.current ||
|
||||
!containerRef.current
|
||||
)
|
||||
return;
|
||||
const newWidth = containerRef.current.clientWidth;
|
||||
const newHeight = containerRef.current.clientHeight;
|
||||
rendererRef.current.setSize(newWidth, newHeight);
|
||||
materialRef.current.uniforms.uResolution.value.set(newWidth, newHeight);
|
||||
}, 150);
|
||||
rendererRef.current.setSize(newWidth, newHeight);
|
||||
materialRef.current.uniforms.uResolution.value.set(newWidth, newHeight);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize, { passive: true });
|
||||
@@ -320,11 +299,9 @@ const LightPillar = ({
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
if (interactive) {
|
||||
container.removeEventListener("mousemove", handleMouseMove);
|
||||
}
|
||||
if (rafRef.current) {
|
||||
cancelAnimationFrame(rafRef.current);
|
||||
window.removeEventListener("mousemove", handleMouseMove);
|
||||
}
|
||||
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
||||
if (rendererRef.current) {
|
||||
rendererRef.current.dispose();
|
||||
rendererRef.current.forceContextLoss();
|
||||
@@ -332,19 +309,8 @@ const LightPillar = ({
|
||||
container.removeChild(rendererRef.current.domElement);
|
||||
}
|
||||
}
|
||||
if (materialRef.current) {
|
||||
materialRef.current.dispose();
|
||||
}
|
||||
if (geometryRef.current) {
|
||||
geometryRef.current.dispose();
|
||||
}
|
||||
|
||||
rendererRef.current = null;
|
||||
materialRef.current = null;
|
||||
sceneRef.current = null;
|
||||
cameraRef.current = null;
|
||||
geometryRef.current = null;
|
||||
rafRef.current = null;
|
||||
if (materialRef.current) materialRef.current.dispose();
|
||||
if (geometryRef.current) geometryRef.current.dispose();
|
||||
};
|
||||
}, [
|
||||
topColor,
|
||||
@@ -376,7 +342,14 @@ const LightPillar = ({
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={`light-pillar-container ${className}`}
|
||||
style={{ mixBlendMode }}
|
||||
style={{
|
||||
mixBlendMode,
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user