var viewer = WALK.getViewer();
viewer.setAllMaterialsEditable();
var Material = viewer.findMaterial("Painting03");
Material.addEventListener("click", function () {
alert(1);
viewer.requestFrame();
});
‘findmaterial’ script doesn’t work…
How can i use it…
Thank you for your answer.
But it’s not working You must not create and insert triggers in an editor or script or in ‘body-end.html’. I’m testing it with “example-room”, so please react to two frames. I would appreciate it if you could send me the ‘body-end.html’ file by e-mail.
I’m sorry, I have a question.
I want to open a pop-up window after clicking on the picture to move to the ‘view’ position, but I’m not sure. Please correct the code.
There is one thing you must add at the end of the function → return true
Without it the viewer will try to move to the clicked point.
Also please double check name of the view (same as with materials, spaces must be included)
You should add callback to onViewSwitchDone and register it only once. We could call this callback handleViewSwitchDone. This callback will have access to name of the view that has been reached, so we can match the name of the view to your custom functionality.
<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("Painting 02", handleHoverChanged);
viewer.onMaterialHoverChanged("Painting 03", handleHoverChanged);
viewer.onMaterialHoverChanged("Book cover_01", handleHoverChanged);
viewer.onMaterialClicked("Painting 02", function () {
viewer.switchToView("p1");
return true;
});
viewer.onMaterialClicked("Painting 03", function () {
viewer.switchToView("p2");
return true;
});
viewer.onMaterialClicked("Book cover_01", function () {
viewer.switchToView("b_1");
return true;
});
function welcomeContent1() {
var welcomeContent = '<iframe src="https://www.shapespark.com/pricing">' + '</iframe>';
viewer.openPopup(welcomeContent, {
centerHorizontally: true,
centerVertically: true
});
}
function welcomeContent2() {
var welcomeContent = '<iframe src="https://www.shapespark.com/">' + '</iframe>';
viewer.openPopup(welcomeContent, {
centerHorizontally: true,
centerVertically: true
});
}
function welcomeContent3() {
viewer.switchToView('b_2');
return true;
}
function handleViewSwitchDone(viewName){
switch (viewName) {
case 'p1':
welcomeContent1();
break;
case 'p2':
welcomeContent2();
break;
case 'b_1':
welcomeContent3();
break;
}
}
viewer.onViewSwitchDone(handleViewSwitchDone);
</script>
Hello, I have an additional question while working on it. I attached the file by email. I’d appreciate it if you could check it.
check 1: Start full screen Onload
check 2: “Painting 03” Click the “>>” button created in the pop-up window to close the “Pop-up window” and go to “Next-View : laptop”.
And where should I input the cdn to use “JQuery”? And I want to connect (JavaScript file, css file) separately.