Back to the Shapespark home page

Click events on 3D Objects


#1

We need to collect the data as the user changes the material of the object in the scene. Are there any possibilities to detect that click event on which user clicks to change the material of an object?


#2

It is possible to detect from JavaScript which material was selected by the user in the material picker, but looking at the code I don’t see an easy way to detect which objects have the new material applied.

Material picker allows to replace all occurrences of one material in the scene with other material from the scene. Because objects with the same material in the scene are merged together for performance reasons, there is no easy way to determine which logical object was affected by the change. For example if a floor and a table use the same wood material, they will be merged together into a single object.


#3

Hey Jan,

Thanks for your quick response.
Can you please tell me how to detect which material was selected by the user?
Can you please point me to any tutorial or any example using which i can understand how to do that?


#4

We don’t yet have tutorial on this. You can start from placing a following body-end.html file in Documents\Shapespark\SCENE_NAME: https://gist.github.com/wrr/8d24a0004d2cf8d34537bcdcea3e2019

Material picker uses an setMaterialForNode API call, and this code snippet intercepts such calls to print to the console which material was selected.


#5

Hi jan,

Thanks for your help. Now we have to test it on our own local server first. Could you please tell us how to do it? Because shapespark is not allowing us to upload it with body-end.html file. We saw on one of the links that you have to whitelist us to access this feature. Here is the link: Configurator Commands
Username is cningoo

And we have found one more solution here : Hosting scenes on own servers , with the Bundle option, enabled.

So which one is the best method to approach?


#6

You can test locally by connecting to http://localhost:5000 with your browser while Shapespark is running. To upload body-end.html, you need at least the Standard plan. The reason is that during trial period and with the Starter plan, custom branding is disabled and body-end.html allows to brand the viewer.


#7

It works like a Charm…!!

Thank you so much for the quick help…!!


#8

Hi jan,

Is there any update going to come, in which we can change the 3d models at run time?
Like for example if we want to see different sofa option at run time.

Is there any possibility of it?


#9

Hi @cningoo, we don’t work on this now, but very likely will be adding such feature this year.