Back to the Shapespark home page

2 action on one click possible?

Hi,
wanted to have two actions happening when clicking on an object. Is that possible? I added two extensions, one opening an url when clicking on an armchair and another extension moving the camera to the armchair when clicking on it. Sadly that does not work. Shaespark viewer always only uses the first trigger and does not check for the same trigger which is next in the list.

Any ideas? Can this only be solved by a script extension?

Best regards,
Mischa

1 Like

Unfortunately this isn’t possible. Without any triggers clicking an object moves the camera in this object directions. Extensions stop propagation of the click events no prevent this default action. The way the extensions are now structured, it is not possible to determine if there is any other extension with the same trigger object and to propagate the click event in such case.

Sad news. How can multiple events than be triggered?

1 Like

In your case a single script extension with a trigger should be able to do it. The script code would be something like:

WALK.getViewer().switchToView(‘THE_NAME_OF_THE_VIEW_THAT_SHOWS_THE_CHAIR’);
window.open(‘https://a-url-that-you-would-like-to-open’);

cool, will give that a try!

wasnt succesfull, what is wrong in my script:

WALK.getViewer().switchToView(‘Sessel‘);
window.open(‘https://www.google.de‘);

The camera is named Sessel and I replaced the webadress to a simply adress to be sure that there is no error.

Any help appreciated,
Mischa

Which kind of quotation marks do you use? Both "" and '' should work, but for example `` will fail.

I copied them from your reply… will reedit an use "

Sorry about this, looks like forum formatting replaced them.

Works great, thx a lot! If I wanna achieve a mouse over effect, I cant achieve that with an extension right?

I achieved the mouseover effect by adding a script in the body-end.html.

sorry one more question, if I want to open the webpage as an iframe and not as an extra tab, how must I modify your code?

iframe is more difficult. You would need to add and position a hiden iframe in your body-end.html and make it visible from the script extension. For this to be usable you would also need some close button for the user to be able to close the iframe, so it would be quite a bit of HTML, CSS and JavaScript work.

wow, that sounds too complicate for me, thx a lot for your help jan!