Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react three fiber cannon collision

import { Canvas } from '@react-three/fiber'
import { Physics, usePlane, useBox } from '@react-three/cannon'

function Plane(props) {
  const [ref] = usePlane(() => ({ rotation: [-Math.PI / 2, 0, 0], ...props }))
  return (
    <mesh ref={ref}>
      <planeGeometry args={[100, 100]} />
    </mesh>
  )
}

function Cube(props) {
  const [ref] = useBox(() => ({ mass: 1, position: [0, 5, 0], ...props }))
  return (
    <mesh ref={ref}>
      <boxGeometry />
    </mesh>
  )
}

ReactDOM.render(
  <Canvas>
    <Physics>
      <Plane />
      <Cube />
    </Physics>
  </Canvas>,
  document.getElementById('root'),
)
Comment

PREVIOUS NEXT
Code Example
Javascript :: find numeric Unicode value of the character with charCodeAt() method 
Javascript :: store reference of event listener inside a element 
Javascript :: get product 
Javascript :: iterate over array of html elements 
Javascript :: sadd in redis 
Javascript :: moment js with nodejs 
Javascript :: Using the forEach function In JavaScript 
Javascript :: usestate access previous state 
Javascript :: this javascript 
Javascript :: javascript map foreach 
Javascript :: disable input field javascript 
Javascript :: js filter example 
Javascript :: sort array method 
Javascript :: extract data from pdf nodejs 
Javascript :: regular function javascript 
Javascript :: react check if browser is in dark mode 
Javascript :: how to do subtraction in javascript 
Javascript :: How to acces props of a functional component 
Javascript :: age calculator moment js 
Javascript :: convert string to integer: 
Javascript :: disable js in chrome dev tools 
Javascript :: .unshift 
Javascript :: create responsive navbar without javascript 
Javascript :: destructuring assignment in javascript 
Javascript :: jquery edit href 
Javascript :: serializes to the same string 
Javascript :: Javascript: 
Javascript :: destructuring nested objects 
Javascript :: how to remove a character from a string in javascript 
Javascript :: add a string to list jquery 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =