spatial-ui-universe 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spatial-ui-universe",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/src/Scene.tsx CHANGED
@@ -5,9 +5,9 @@ import { Canvas, useFrame } from "@react-three/fiber";
5
5
  import { Environment, Sparkles, Stars, Sphere, MeshDistortMaterial, Clouds, Cloud } from "@react-three/drei";
6
6
  import * as THREE from "three";
7
7
 
8
- // Supernova Easter Egg Component
8
+ // Supernova Easter Egg Component - OPTIMIZED for performance
9
9
  function SupernovaEasterEgg({ active, color, onComplete }: { active: boolean, color: string, onComplete: () => void }) {
10
- const count = 75; // Even less particles, but thicker bridging
10
+ const count = 40; // Reduced from 75 for better performance
11
11
  const meshRef = useRef<THREE.InstancedMesh>(null);
12
12
 
13
13
  const dummy = useMemo(() => new THREE.Object3D(), []);
@@ -20,7 +20,7 @@ function SupernovaEasterEgg({ active, color, onComplete }: { active: boolean, co
20
20
  (Math.random() - 0.5) * 2,
21
21
  (Math.random() - 0.5) * 2,
22
22
  (Math.random() - 0.5) * 2
23
- ).normalize().multiplyScalar(1.5); // Start exactly on the Coreradius
23
+ ).normalize().multiplyScalar(1.5);
24
24
  pts.push(p);
25
25
  }
26
26
  return pts;
@@ -170,7 +170,7 @@ function SupernovaEasterEgg({ active, color, onComplete }: { active: boolean, co
170
170
  return (
171
171
  <group>
172
172
  <instancedMesh ref={meshRef} args={[undefined, undefined, count]}>
173
- <sphereGeometry args={[0.5, 32, 32]} />
173
+ <sphereGeometry args={[0.5, 16, 16]} />
174
174
  <meshStandardMaterial
175
175
  color="#0ea5e9"
176
176
  emissive="#0369a1"
@@ -183,7 +183,7 @@ function SupernovaEasterEgg({ active, color, onComplete }: { active: boolean, co
183
183
  />
184
184
  </instancedMesh>
185
185
  <instancedMesh ref={bondsMeshRef} args={[undefined, undefined, maxBonds]} frustumCulled={false}>
186
- <sphereGeometry args={[1, 32, 32]} />
186
+ <cylinderGeometry args={[0.05, 0.05, 1, 8]} />
187
187
  <meshStandardMaterial
188
188
  color="#38bdf8"
189
189
  transparent
@@ -195,7 +195,7 @@ function SupernovaEasterEgg({ active, color, onComplete }: { active: boolean, co
195
195
  blending={THREE.NormalBlending}
196
196
  />
197
197
  </instancedMesh>
198
- <Sphere ref={centralBlobRef} args={[1.0, 64, 64]} scale={0}>
198
+ <Sphere ref={centralBlobRef} args={[1.0, 32, 32]} scale={0}>
199
199
  <MeshDistortMaterial
200
200
  color="#0ea5e9"
201
201
  emissive="#0369a1"
@@ -277,8 +277,8 @@ export function BlackHoleCore({ color = "#312e81" }: { color?: string }) {
277
277
  <SupernovaEasterEgg active={easterEggActive} color={color} onComplete={() => setEasterEggActive(false)} />
278
278
 
279
279
  <group ref={visualsGroupRef}>
280
- <Sphere args={[1.5, 64, 64]}>
281
- <MeshDistortMaterial color={color} emissive={color} emissiveIntensity={0.5} distort={0.4} speed={3} roughness={0.1} metalness={0.8} envMapIntensity={2.0} />
280
+ <Sphere args={[1.5, 32, 32]}>
281
+ <MeshDistortMaterial color={color} emissive={color} emissiveIntensity={0.5} distort={0.3} speed={2} roughness={0.1} metalness={0.8} envMapIntensity={1.5} />
282
282
  </Sphere>
283
283
 
284
284
  <mesh ref={shockwaveRef} rotation={[Math.PI / 2, 0, 0]}>
@@ -340,13 +340,16 @@ export function AsteroidField({ count = 150, color = "#6366f1", shape = "dodecah
340
340
  }));
341
341
  }, [warpLinesCount]);
342
342
 
343
+ // Pre-allocate vectors to avoid GC pressure during useFrame
344
+ const mouse3D = useMemo(() => new THREE.Vector3(), []);
345
+ const pushDir = useMemo(() => new THREE.Vector3(), []);
346
+
343
347
  useFrame((state, delta) => {
344
348
  // Warp speed smooth logic
345
349
  const targetWarp = isPressing ? 1 : 0;
346
350
  warpSpeedRef.current += (targetWarp - warpSpeedRef.current) * 0.05;
347
351
 
348
- const mouse3D = new THREE.Vector3(state.pointer.x * 12, state.pointer.y * 12, 2);
349
- const pushDir = new THREE.Vector3();
352
+ mouse3D.set(state.pointer.x * 12, state.pointer.y * 12, 2);
350
353
 
351
354
  // 1. Update Asteroids (Rocks) -> No stretching anymore!
352
355
  if (meshRef.current) {
@@ -502,6 +505,12 @@ export function NebulaClouds() {
502
505
  return new THREE.CanvasTexture(canvas);
503
506
  }, []);
504
507
 
508
+ useEffect(() => {
509
+ return () => {
510
+ if (particleTexture) particleTexture.dispose();
511
+ };
512
+ }, [particleTexture]);
513
+
505
514
  const count = 400;
506
515
 
507
516
  // Use useMemo to generate organic nebula shapes (Perlin/Simplex noise-like clusters)
@@ -599,7 +608,7 @@ export function NebulaClouds() {
599
608
  export default function Scene({
600
609
  coreColor = "#312e81",
601
610
  particleColor = "#6366f1",
602
- particleCount = 150,
611
+ particleCount = 100,
603
612
  particleShape = "dodecahedron",
604
613
  children
605
614
  }: {
@@ -611,12 +620,12 @@ export default function Scene({
611
620
  }) {
612
621
  return (
613
622
  <div className="absolute inset-0 w-full h-full z-0 pointer-events-auto bg-[#020205]">
614
- <Canvas camera={{ position: [0, 0, 12], fov: 45 }} gl={{ alpha: true }}>
623
+ <Canvas camera={{ position: [0, 0, 12], fov: 45 }} gl={{ alpha: true, antialias: false, powerPreference: "high-performance", stencil: false, depth: true }}>
615
624
  <color attach="background" args={['#020205']} />
616
625
  <React.Suspense fallback={null}>
617
- <ambientLight intensity={0.5} />
618
- <directionalLight position={[10, 10, 5]} intensity={3} color="#818cf8" />
619
- <directionalLight position={[-10, -10, -5]} intensity={2} color="#c084fc" />
626
+ <ambientLight intensity={0.4} />
627
+ <directionalLight position={[10, 10, 5]} intensity={2.5} color="#818cf8" />
628
+ <directionalLight position={[-10, -10, -5]} intensity={1.5} color="#c084fc" />
620
629
 
621
630
  <CameraController />
622
631
  <BlackHoleCore color={coreColor} />
@@ -626,11 +635,10 @@ export default function Scene({
626
635
  {/* Render User's Custom 3D/4D Models Here */}
627
636
  {children}
628
637
 
629
- {/* Dense Universe Stars & Sparkles */}
630
- <Stars radius={150} depth={100} count={8000} factor={6} saturation={1} fade speed={2} />
631
- <Sparkles count={300} scale={25} size={3} speed={0.2} opacity={0.4} color="#818cf8" />
632
- <Sparkles count={200} scale={20} size={1} speed={0.4} opacity={0.6} color="#c084fc" />
633
- <Sparkles count={100} scale={30} size={6} speed={0.1} opacity={0.2} color="#2dd4bf" />
638
+ {/* Dense Universe Stars & Sparkles - OPTIMIZED */}
639
+ <Stars radius={150} depth={100} count={4000} factor={6} saturation={1} fade speed={2} />
640
+ <Sparkles count={150} scale={25} size={3} speed={0.2} opacity={0.3} color="#818cf8" />
641
+ <Sparkles count={100} scale={20} size={1} speed={0.4} opacity={0.4} color="#c084fc" />
634
642
 
635
643
  <Environment preset="city" />
636
644
  </React.Suspense>
package/src/lib/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default as Scene } from '../components/Scene';
2
- export { Button, TextBox, Dropdown, Card, Badge, Switch } from '../components/UI';
1
+ export { default as Scene } from '../Scene';
2
+ export { Button, TextBox, Dropdown, Card, Badge, Switch } from '../UI';