I understand that you can implement Three.js as component using three library.
My question is whether I can make Three.js component (let’s say a cube animation) to show in my website that was fully build in React. It seems like Three.js’s canvas always takes 100% of screen.
Is it possible to make it tiny to manipulate like you would do to an img tag? I can’t seem to find the answer. Every Three.js implementation starts with a whole canvas being made of Three.js.
Sorry if the question is foolish. Thank you in advance.
the canvas fills its absolute/relative parent. scale the parent, it scales the canvas with a resize-observer. here’s a demo using the canvas scaled to 200/200px and a spinning cube: Basic demo (forked) - CodeSandbox
generally you can consider three an imperative system that’s cut off from the declarative world. r3f fixes that. but it’s not a wrapper that you have to rely on, it’s a custom renderer, it reconciles threejs just like react-dom reconciles html, <mesh /> simply becomes new THREE.Mesh(), just like <div /> becomes document.createElement('div').