@@ -28,13 +28,32 @@ const FloatingShapes = () => {
2828 const shapes = useMemo ( ( ) => {
2929 const shapeArray = [ ]
3030 const shapeTypes = [ 'sphere' , 'cube' ]
31- const materialTypes = [ 'glass' , 'metal' , 'neon' , 'hologram' , 'crystal' ]
31+ const materialTypes = [ 'matte' , 'wireframe' ] // 80% matte, 20% wireframe
32+ const primaryColors = [
33+ '#ff0000' , // Red
34+ '#00ff00' , // Green
35+ '#0000ff' , // Blue
36+ '#ffff00' , // Yellow
37+ '#ff00ff' , // Magenta
38+ '#00ffff' , // Cyan
39+ '#ff8000' , // Orange
40+ '#8000ff' , // Purple
41+ '#80ff00' , // Lime
42+ '#ff0080' , // Pink
43+ '#0080ff' , // Light Blue
44+ '#ff8080' // Light Red
45+ ]
3246
33- for ( let i = 0 ; i < 200 ; i ++ ) { // Doubled from 100 to 200 balls
47+ // Reduce shapes on mobile for better performance
48+ const isMobile = window . innerWidth <= 768
49+ const shapeCount = isMobile ? 100 : 200
50+
51+ for ( let i = 0 ; i < shapeCount ; i ++ ) {
52+ const isWireframe = Math . random ( ) < 0.2 // 20% chance of wireframe
3453 shapeArray . push ( {
3554 id : i ,
3655 type : shapeTypes [ Math . floor ( Math . random ( ) * shapeTypes . length ) ] , // Random sphere or cube
37- materialType : materialTypes [ Math . floor ( Math . random ( ) * materialTypes . length ) ] , // Random material
56+ materialType : isWireframe ? 'wireframe' : 'matte' ,
3857 position : [
3958 ( Math . random ( ) - 0.5 ) * 30 , // Even wider spread for more balls
4059 ( Math . random ( ) - 0.5 ) * 20 , // Higher spread
@@ -49,10 +68,7 @@ const FloatingShapes = () => {
4968 ( Math . random ( ) - 0.5 ) * 1 // Reduced direction intensity
5069 ] ,
5170 scrollSensitivity : 0.3 + Math . random ( ) * 0.5 , // Reduced sensitivity
52- color : [
53- '#ec4899' , '#8b5cf6' , '#3b82f6' , '#06b6d4' ,
54- '#a855f7' , '#d946ef' , '#f59e0b' , '#10b981'
55- ] [ Math . floor ( Math . random ( ) * 8 ) ]
71+ color : primaryColors [ Math . floor ( Math . random ( ) * primaryColors . length ) ]
5672 } )
5773 }
5874 return shapeArray
@@ -116,65 +132,29 @@ const FloatingShapes = () => {
116132 }
117133 } , [ shape . type ] )
118134
119- // Different material types for variety
135+ // Choose material based on type
120136 const material = useMemo ( ( ) => {
121- switch ( shape . materialType ) {
122- case 'glass' :
123- return (
124- < meshPhysicalMaterial
125- color = { shape . color }
126- metalness = { 0.0 }
127- roughness = { 0.0 }
128- transmission = { 0.9 }
129- transparent = { true }
130- opacity = { 0.6 }
131- />
132- )
133- case 'metal' :
134- return (
135- < meshStandardMaterial
136- color = { shape . color }
137- metalness = { 1.0 }
138- roughness = { 0.2 }
139- />
140- )
141- case 'neon' :
142- return (
143- < meshBasicMaterial
144- color = { shape . color }
145- transparent = { true }
146- opacity = { 0.8 }
147- />
148- )
149- case 'hologram' :
150- return (
151- < meshPhongMaterial
152- color = { shape . color }
153- transparent = { true }
154- opacity = { 0.4 }
155- shininess = { 100 }
156- />
157- )
158- case 'crystal' :
159- return (
160- < meshPhysicalMaterial
161- color = { shape . color }
162- metalness = { 0.1 }
163- roughness = { 0.0 }
164- transparent = { true }
165- opacity = { 0.7 }
166- />
167- )
168- default :
169- return (
170- < meshStandardMaterial
171- color = { shape . color }
172- metalness = { 0.2 }
173- roughness = { 0.1 }
174- transparent = { true }
175- opacity = { 0.8 }
176- />
177- )
137+ if ( shape . materialType === 'wireframe' ) {
138+ return (
139+ < meshBasicMaterial
140+ color = { shape . color }
141+ wireframe = { true }
142+ transparent = { true }
143+ opacity = { 0.8 }
144+ />
145+ )
146+ } else {
147+ return (
148+ < meshPhysicalMaterial
149+ color = { shape . color }
150+ metalness = { 0.0 }
151+ roughness = { 0.2 }
152+ clearcoat = { 1.0 }
153+ clearcoatRoughness = { 0.1 }
154+ transparent = { true }
155+ opacity = { 0.9 }
156+ />
157+ )
178158 }
179159 } , [ shape . materialType , shape . color ] )
180160
0 commit comments