Change model onClick of a button


#1

Hello,
I have found an A-frame component to switch between multiple 3d models onClick of a button but it does not seem to work, I also do not get any console errors.
here is a glitch for the same: https://glitch.com/edit/#!/zap-ar


#2

Hi @mihir!

I believe I have answered your ticket directly with more information about your specific case, but just in case this helps anybody, here is a light answer!

This is technically an A-Frame library specific query (not Universal AR); however, I can hopefully provide some helpful ideas.

For a very basic version of this sort of thing, you could use A-Frame’s visible attribute (documentation for that here) to render the appropriate model. You could start the model with visible="false", and then use logic which would edit the attribute to true on the press of a button in a script outside your scene using the JavaScript Element.setAttribute() method.

You could of course try to consolidate this and potentially use the asset manager to load your assets and then switch the model accordingly, (using only one entity in the process) but again this would need the help of the A-Frame documentation; and we’ve not really seen anybody try this out in conjunction with our tools before (we’d love to see it though)!

I hope you found this helpful,

Have a lovely day!
Francesca :blush:


#3

Thats a nice idea, may be I will give it a shot and update it here.