Hi all,
I want to rotate a 3D object using GSAP.
I imported my 3D model using gltfjsx so it became a JavaScript script
Now I do not know what to select and rotate it.
In the following code I was able to get the rotation of <group> and change it, but unfortunately it does not re-render
Because I work at React.
const SpinnigMesh = ({pos , args , color , speed=1 ,...props })=>{
const [startRotate , setStartRotate] = useState(false)
const [value , setValue] = useState(0)
useEffect(() => {
ScrollMagicPluginGsap(ScrollMagic, gsap);
gsap.registerPlugin()
const tl = new TimelineMax();
TimelineMax.defaultOverwrite = false
var controller = new ScrollMagic.Controller();
tl.to(grp.props.rotation ,
{
1: 122,
duration:0.5,
}
);
const scene = new ScrollMagic.Scene({
triggerElement: ".s2",
triggerHook: "onLeave",
})
.setTween(tl)
.addTo(controller)
.reverse(true)
})
const mesh = useRef(null);
const group = useRef()
const { nodes, materials } = useGLTF('../../../../wine.glb')
const grp =
<group rotation={[Math.PI / 2, 0, 0]}>
<mesh geometry={nodes.defaultMaterial.geometry} material={materials.bottle} />
<mesh geometry={nodes.defaultMaterial_1.geometry} material={materials.wrap} />
</group>
return(
<group rotation={[0,15.2,-0.3]} scale={1.5,1.4,1.4} ref={group} {...props} dispose={null}>
<group ref={mesh} rotation={[-Math.PI / 2, 0, 0]}>
{grp}
</group>
</group>
)
}