Skip to content
Discussion options

You must be logged in to vote

same way you add anything in react. the view is just a reflection of state:

const [items, setItems] = useState([])
useEffect(() => {
  const interval = setIterval(() => setItems(state => [...state, { position: [...], ... }], 1000)
  return () => clearInterval(interval)
}, [])
return items.map((props, i) => (
  <mesh key={i} {...props}>
    <meshBasicMaterial />
    <sphereGeometry />

useState([new Mesh()])

you don't want to do that. you want to put the raw, serializable state that makes the mesh look or behave a certain way into the state model. the component then takes that state and forms a view.

setState([...objects, new Mesh()]) is very heavy operation.

i don't see what makes it …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aaabb733
Comment options

Answer selected by aaabb733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2087 on February 22, 2022 11:52.