I understand. Could you please show us the effect which your programmer was able to create ?
@wojtek , i tried to the test the HandleHover script on a carpet in shapespark example scene, i created a script extension and added the emissive part/code of the script in it and assigned the trigger as object type to carpet. But nothing worked, is there anything i am doing wrong or how to make it work?
Here is the scene where i tested it:
how to open the script editor ?
@Mahesh, the script doesnât seem to be complete. It lacks:
const viewer = WALK.getViewer();
at the beginning and
viewer.onMaterialHoverChanged('Rug', handleHoverChanged);
at the bottom.
Also, this script has to be executed when the scene is loaded, so the extension must not have a trigger.
The Script extension can be added in the âExtensionsâ panel of the âViewerâ tab. However, the primary and advised way to insert own JavaScript code is through a body-end.html
file located in the scene directory.
Thank you so much @wojtek, This seems to work perfectly now , Greatly appriciate your quick feedback
Yes, this script works very fine! Thanks @wojtek!
In my opinion it may be a lower value for emissive materials, for example 0.5
Codes should be placed between <script>
and </script>
before saving in body-end.html
So this is the content of body-end.html
file:
<script>
const viewer = WALK.getViewer();
function handleHoverChanged(material, hoverActive) {
if (hoverActive) {
document.body.style.cursor = 'pointer';
material.emissive = true;
material.emissionStrength = 0.5;
viewer.requestFrame();
} else {
document.body.style.cursor = '';
material.emissive = false;
viewer.requestFrame();
}
}
viewer.onMaterialHoverChanged('Rug', handleHoverChanged);
</script>
In most cases where the trigger object in the scene has only one material with a unique name (for example art painting) this is a great solution. What happens when the trigger has more material?
Can the emission of material be related to the camera approaching the trigger? Maybe this would be a good solution for mobile devices and tablets?
For such a case you can try to wrap a trigger into a transparent/semi-transparent object having just one material, and modify the opacity/emission properties of the wrapping material.
We donât have plans to add such a built-in behavior for now, but the Viewer.getCameraPosition API function makes implementing it possible.
Hello,
iâve tried this with the example-room and the code above (copy paste from Vladanâs post) in the body-end.html file (located in the scene directory, same folder as the index.html) but it doesnât do anything at all ⌠3D scene
Can someone help me?
Thank you !
Hi @Thyronia,
your script is not included in index.html
Try moving body-end.html to the â2020-09-27-13-39-39â folder.
Regards!
Hi @Vladan,
thanks a lot for your help ! Moving body-end.html didnât worked at all ⌠(i tried almost every folder âŚ)
But thanks to you, i wrote the script in the index.html and it works fine now !
The âexample-roomâ scene folder is easily located by searching the computer.
body-end.html
files can be added to this folder for testing.
After packing the files for self hosting, a difference is noticed in the index.html
file when the working folder is without and with body-end.html
@wojtek,
Is
body-end.file
unnecessary in the self-hosting folder if it was in the working directory?
Sorry for the troubles, the âexample-roomâ is tricky to test HTML modifications. This is because this scene is bundled and updated together with Shapespark, unlike all other scenes it is not located in Documents\Shapespark and there are some custom rules for handling it. Could you rename the scene to any other name, for example example-room2, put it in Documents\Shapespark together with your body-end.html
file and try again?
Hi! Iâd like to know if there is any way to have a hover effect that would play a video assigned to a material once the mouse is over that given surface - and also stop once the mouse moves elsewhere?
Iâm looking for an interactive portal that would work as a trigger between scenes.
Try solution provided in Wojtekâs post: MouseOver effect - #5 by wojtek
But instead of changing emissive properties of the material, call material.play()
and material.pause()
Thanks, Iâll try this!
Hello! I really like this style. Can you share this example document with me?
My gmail is kimi8studio@gmail.com
Thank you very much!
Hello everything is fine? Iâm following the steps, but the script doesnât work
First I created a scene with an Object called Rug, and I applied a Material also called Rug to it. extracts the Body-End.html of my scene straight from shapespark.
I copied this file to the Documents > File Name folder.
I added the Script.
but it doesnât work, mouse âarrowâ doesnât change when hovering over material/object
@paulocp39 Could you upload the scene and share a link to it ? Do you test it outside of the Shapespark editor? The editor doesnât apply customizations done through the body-end.html
, you need to open the scene in the preview mode instead.
This is a scene i use to test some scripts
https://3d.younion.me/cena_teste/
Script - Print Screen > Ok
Script - Welcome > Ok
Script - Chat > In progress ( if there is a model to give me, thank you, Iâm lost in this )
Script - MouseOver Effect > Don´t Work