Changing textures with Javascript #1904
Replies: 13 comments
-
In fact the PR I'm about to merge addresses exactly this: #1302. This 3DOM API is still fairly unstable, which is why it's not yet publicly documented, but you're welcome to be an early user and give us feedback. However, none of this customization is available through scene-viewer, as that is a separate native app like quick look. However, we've changed the default AR experience to webXR, which stays in the browser and enables all of these kinds of customization through HTML, CSS and JS. |
Beta Was this translation helpful? Give feedback.
-
Fantastic, I would love to test this out if at all possible! It's too bad that we do not have a way to access usdz attributes, but I think updating the usdz model's ios-src in model-viewer should work just fine. Currently I'm swapping the source links between different .glb models using a js function that targets model-viewer's "src" attribute, but cannot seem to also update the "ios-src" You can view a demo here: https://www.lockheimers.com/lm/jsui/ Any recommendations on how to update the link to the usdz files using onClick events would be very helpful, thanks! |
Beta Was this translation helpful? Give feedback.
-
Looking at your source, it appears you've commented out the lines that update ios-src. When you put those back in, does it still have the problem? |
Beta Was this translation helpful? Give feedback.
-
Yes, I unfortunately get the following console error: ..And upon click, all of the buttons render: You can text the errors here: |
Beta Was this translation helpful? Give feedback.
-
Thank again for your help! I cleaned up the first error, but I'm still not able to link the "ios-src". Please the following issue when I click on the first (yellow) button -- this happens respectively to each link:-script.js:20 Uncaught ReferenceError: src is not defined
|
Beta Was this translation helpful? Give feedback.
-
Instead of
You want something like
|
Beta Was this translation helpful? Give feedback.
-
That should technically work, thank you very much... unfortunately, the console keeps saying it cannot find the source; even if I link directly using ios-src=='assets/model.usdz'; We are so close to getting this to work =/-script.js:11 Uncaught ReferenceError: src is not defined |
Beta Was this translation helpful? Give feedback.
-
You can see the latest code here: https://www.lockheimers.com/lm/jsui2/-index.html |
Beta Was this translation helpful? Give feedback.
-
I think you're confusing |
Beta Was this translation helpful? Give feedback.
-
Gotcha, however if I use single "=", I end up with an error:Uncaught SyntaxError: Invalid left-hand side in assignmentI updated to using "===" but it still renders "src is not defined" even when I link directly to the usdz model. The .glb models all load perfectly, so it must be something to do with the ios-src |
Beta Was this translation helpful? Give feedback.
-
Ah, I finally noticed the problem. The standard naming conventions on the web are attributes use dashes with lower case, like |
Beta Was this translation helpful? Give feedback.
-
This is very exciting! Changing "iso-src" to "iosSrc" fixed the console errors! So close... Now the only issue I have is when I try to preview the models in AR QuickLook I get: Although it's the same usdz files that opened before. I do get a single warning:DevTools failed to load SourceMap: Could not load content for https://unpkg.com/@google/[email protected]/dist/model-viewer.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE |
Beta Was this translation helpful? Give feedback.
-
Thanks again for all of your help! I am moving my issue on to the apple Developer forum. Please let me know if I can help test any new features with texture attributes or other future updates. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to change the textures of a glb or glTF in AR using scene-viewer and javascripted buttons? Looking to showcase a product in multiple colors and styles, but need to build a javascript UI for users to control the different texture options using fixed buttons.
Beta Was this translation helpful? Give feedback.
All reactions