I'll create a React component that sets up a scene with a perspective camera viewing from above, along with directional light to simulate sunlight and cast shadows. This will help emphasize the depth in the scene.
Here's the implementation:
scene.tsx
Let's break down the key elements of this scene:
PerspectiveCamera from drei, positioned at [5, 5, 5]. This places it above and to the side of the scene, looking down at an angle.Lighting:
directionalLight is positioned at [-5, 5, -5], which places it above and to the left of the scene. This simulates sunlight.castShadow and has its shadow map size increased for better quality shadows.ambientLight is added to provide some overall illumination to the scene.Objects:
Box and a Sphere are added to the scene to demonstrate depth and shadow casting.Plane is used as the ground to receive shadows.Animation:
OrbitControls are added to allow the user to rotate and zoom the camera, exploring the scene from different angles.This setup creates a scene that emphasizes depth through the camera angle, object placement, and shadow casting. The directional light coming from the top left creates long shadows that help illustrate the spatial relationships between objects.
Feel free to adjust the camera position, light intensity, or add more objects to further explore the depth and lighting in the scene!
I'll create a 3D hero section with a rotating product model and a call-to-action button using React Three Fiber (R3F) for the 3D content and HTML for the call-to-action button. We'll use a placeholder 3D model of a duck for this example.
Here's the implementation:
hero-section.tsx
Let's break down the key components of this hero section:
3D Scene:
DuckModel component loads the 3D model and applies a continuous rotation animation.OrbitControls for limited interactivity, allowing users to rotate the view but not zoom or pan.Environment component is added to create a realistic lighting setup.Layout:
Content:
shadow-text) to ensure readability against the 3D background.Call-to-Action:
Button component from shadcn/ui.Responsiveness:
Loading State:
This hero section creates an engaging 3D experience with a rotating product model, combined with traditional web elements like text and a call-to-action button. The design is visually appealing and should work well on both desktop and mobile devices.
To further improve this component, you could:
Remember to replace the placeholder text and adjust the styling to match your brand's design language.