Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-spring/three

Package Overview
Dependencies
Maintainers
0
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-spring/three

[`react-three-fiber`](https://github.com/drcmda/react-three-fiber) support. This package is for version 6 of react-three-fiber

  • 9.7.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
652K
decreased by-2.44%
Maintainers
0
Weekly downloads
 
Created

What is @react-spring/three?

@react-spring/three is a library that provides animations for React Three Fiber using the react-spring library. It allows you to create smooth and interactive animations for 3D objects in a React application.

What are @react-spring/three's main functionalities?

Basic Animation

This code demonstrates a basic animation where a box scales up from its original size to 1.5 times its size using @react-spring/three.

import { useSpring, animated } from '@react-spring/three';
import { Canvas } from '@react-three/fiber';

function AnimatedBox() {
  const props = useSpring({ scale: [1.5, 1.5, 1.5], from: { scale: [1, 1, 1] } });
  return (
    <animated.mesh scale={props.scale}>
      <boxBufferGeometry args={[1, 1, 1]} />
      <meshStandardMaterial color='orange' />
    </animated.mesh>
  );
}

function App() {
  return (
    <Canvas>
      <ambientLight />
      <AnimatedBox />
    </Canvas>
  );
}

export default App;

Animating Position

This code demonstrates animating the position of a box from the origin to the coordinates (2, 2, 2) using @react-spring/three.

import { useSpring, animated } from '@react-spring/three';
import { Canvas } from '@react-three/fiber';

function AnimatedBox() {
  const props = useSpring({ position: [2, 2, 2], from: { position: [0, 0, 0] } });
  return (
    <animated.mesh position={props.position}>
      <boxBufferGeometry args={[1, 1, 1]} />
      <meshStandardMaterial color='blue' />
    </animated.mesh>
  );
}

function App() {
  return (
    <Canvas>
      <ambientLight />
      <AnimatedBox />
    </Canvas>
  );
}

export default App;

Animating Rotation

This code demonstrates animating the rotation of a box from 0 to 90 degrees on the X and Y axes using @react-spring/three.

import { useSpring, animated } from '@react-spring/three';
import { Canvas } from '@react-three/fiber';

function AnimatedBox() {
  const props = useSpring({ rotation: [Math.PI / 2, Math.PI / 2, 0], from: { rotation: [0, 0, 0] } });
  return (
    <animated.mesh rotation={props.rotation}>
      <boxBufferGeometry args={[1, 1, 1]} />
      <meshStandardMaterial color='green' />
    </animated.mesh>
  );
}

function App() {
  return (
    <Canvas>
      <ambientLight />
      <AnimatedBox />
    </Canvas>
  );
}

export default App;

Other packages similar to @react-spring/three

Keywords

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc