google-ar / codelab-webxr

Building an augmented reality application with the WebXR Device API
https://codelabs.developers.google.com/codelabs/ar-with-webxr/
Apache License 2.0
171 stars 85 forks source link

Trying to rotate obj #6

Closed lajune1 closed 6 years ago

lajune1 commented 6 years ago

Hi! I am pretty new to three.js and google ar and I have been trying to find a way to animate the obj's that I import into the final example. I have mainly been looking at three.js tutorials on how to do this, however none of the tutorials I view have quite the same syntax as was used in the tutorial making it a little hard for me to translate the code to fit my needs. Are there any other resources to learn more about how rotate and translate the objs on the reticle? I know that I cannot export the animation already on the obj, as obj's do not support that. I am trying to use the code to animate.

Thanks so much!

lajune1 commented 6 years ago

Also, is there a way to upload the .gltf so that I can just have the animation baked in to the object instead?

jsantell commented 6 years ago

You can use a gltf instead of an obj model, here's a three.js demo doing that: https://threejs.org/examples/?q=gltf#webgl_loader_gltf

If you want to do things like translate and rotate, see this example of updating a mesh in a render loop: https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_cube.html

Stack overflow and the three.js examples are good resources to learn from. Hope this helps!

lajune1 commented 6 years ago

Thank you!

I realize now that the code was written with async functions. So I am trying to convert the code from the examples you provided to be that as well.

Best, LaJune

On Wed, Jun 27, 2018 at 3:40 PM, Jordan Santell notifications@github.com wrote:

You can use a gltf instead of an obj model, here's a three.js demo doing that: https://threejs.org/examples/?q=gltf#webgl_loader_gltf

If you want to do things like translate and rotate, see this example of updating a mesh in a render loop: https://github.com/mrdoob/ three.js/blob/master/examples/webgl_geometry_cube.html

Stack overflow and the three.js examples are good resources to learn from. Hope this helps!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googlecodelabs/ar-with-webxr/issues/6#issuecomment-400804719, or mute the thread https://github.com/notifications/unsubscribe-auth/AmurqcS4SrGxa_uyVTXKT3pPZvVGcF0Nks5uA9-ZgaJpZM4U4f_z .

alanhzh commented 5 years ago

Can you give an example of how to load GLTF instead of OBJ, because I can only get endless errors when I try to load GLTF objects.