Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@react-three/drei
Advanced tools
@react-three/drei is a collection of useful helpers and abstractions for react-three-fiber, which is a React renderer for three.js. It provides a wide range of components and utilities to simplify the creation of 3D scenes in React applications.
Camera Controls
The OrbitControls component allows you to easily add camera controls to your 3D scene, enabling users to rotate, zoom, and pan the camera.
import { OrbitControls } from '@react-three/drei';
function Scene() {
return (
<Canvas>
<OrbitControls />
{/* other components */}
</Canvas>
);
}
Environment
The Environment component allows you to quickly set up a realistic lighting environment using HDRI images. You can choose from various presets like 'sunset', 'dawn', 'night', etc.
import { Environment } from '@react-three/drei';
function Scene() {
return (
<Canvas>
<Environment preset="sunset" />
{/* other components */}
</Canvas>
);
}
Loading Models
The useGLTF hook allows you to easily load and display GLTF models in your scene. It returns the loaded scene, which you can then use as a primitive object.
import { useGLTF } from '@react-three/drei';
function Model() {
const { scene } = useGLTF('/path/to/model.glb');
return <primitive object={scene} />;
}
function Scene() {
return (
<Canvas>
<Model />
{/* other components */}
</Canvas>
);
}
Text
The Text component allows you to easily add 3D text to your scene. You can customize the font, size, color, alignment, and other properties.
import { Text } from '@react-three/drei';
function Scene() {
return (
<Canvas>
<Text
color="black"
fontSize={1}
maxWidth={200}
lineHeight={1}
letterSpacing={0.02}
textAlign={'left'}
font="/path/to/font.woff"
anchorX="center"
anchorY="middle"
>
Hello World
</Text>
{/* other components */}
</Canvas>
);
}
Three.js is the core library for creating 3D graphics in the browser. While it provides a comprehensive set of features for 3D rendering, it requires more boilerplate code compared to @react-three/drei, which offers higher-level abstractions and components.
React-three-fiber is a React renderer for three.js. It allows you to build and manage 3D scenes using React components. @react-three/drei is built on top of react-three-fiber and provides additional helpers and components to simplify common tasks.
A-Frame is a web framework for building virtual reality experiences. It is built on top of three.js and provides a declarative, HTML-like syntax for creating 3D scenes. While it is not React-based, it offers similar functionalities for building 3D environments.
FAQs
useful add-ons for react-three-fiber
We found that @react-three/drei demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.