Carousel of models not working. Problem with switcSrc #4097
Replies: 8 comments
-
I think it can't work locally. The files must be on the server. https://arguv.com/ar_viewer/custom/0/slider/ |
Beta Was this translation helpful? Give feedback.
-
I uploaded it to my server. Still no success. Also, for further examination, here's my code: <!doctype html> <title><model-viewer> template</title> <script src="https://unpkg.com/[email protected]/dist/focus-visible.js" defer></script>
modelViewer.src = base + '.glb';
|
Beta Was this translation helpful? Give feedback.
-
I've also changed the absolute path to a relative path, such as "./models", so it should not fetch from local directory. But still no succes. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Google Chrome F12 |
Beta Was this translation helpful? Give feedback.
-
Thank you very much, that solved my problem. Even thought it doesn't make sense to me, because thoese names are not in my code, so I don't know where and why it is trying to fetch them. But anyway, thanks again. |
Beta Was this translation helpful? Give feedback.
-
You are welcome. Your models are a bit heavy. Very long loading. It is advisable to fit into 5-10 MB for display on the web |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Discussed in #4092
Originally posted by Hexa93 February 3, 2023
Hello everyone. I'm having a hard time trying to find out why the file directory won't work. I've followed this example with a few tweaks. My problem is with the slider buttons at the bottom, when I try to change the file, the site freeze (i.e. switchSrc doesn't switch the src).
I've used this function:
window.switchSrc = (element, name) => {
const base = "C:/Users/User/Desktop/products" + name;
modelViewer.src = base + '.glb';
modelViewer.poster = base + '.webp';
const slides = document.querySelectorAll(".slide");
slides.forEach((element) => {element.classList.remove("selected");});
element.classList.add("selected");
};
As well as this one:
const baseURL = "C:/Users/User/Desktop/products/";
window.switchSrc = (element, name) => {
const src = baseURL + name + '.glb';
const poster = baseURL + name + '.webp';
modelViewer.src = src;
modelViewer.poster = poster;
const slides = document.querySelectorAll(".slide");
slides.forEach((element) => {element.classList.remove("selected");});
element.classList.add("selected");
};
Neither seems to work. It is not reading the directory correctly.
Thank you in advance for any further help.
Beta Was this translation helpful? Give feedback.
All reactions