Google's <model-viewer> provides all the key features I need without having write a custom solution via something like react-three-fiber
or directly in three.js.
I am struggling with how to properly integrate it into a Reagent (and React for that matter) structure.
In order to make it easy to use with vanilla JS, is built as a web component and is largely controlled via the attributes on its html element. Normally that wouldn't be much of a problem, but with the overhead of 3D and loading large models re-rendering this is expensive and in many cases functionality-breaking.
I've tried to naively use it inside a component and trying to eliminate the possibility of re-rendering. Using a ref to mutate it directly.
I have also tried setting it up as a manually created html element from the Reagent/React controlled application and reference it in various events via its dom element.
Both of these options introduced a lot of hacks and were not ideal in a single page application.
I am wondering if anyone has any tips on how to best wrap this in a React/Reagent shell, while still having access to the core element to use their underlying JS api.
Answers don't have to be in ClojureScript.
Here is the example of its usage from their page:
<model-viewer
alt="Neil Armstrong's Spacesuit from the Smithsonian Digitization Programs Office and National Air and Space Museum"
src="shared-assets/models/NeilArmstrong.glb"
ar ar-modes="webxr scene-viewer quick-look" environment-image="shared-assets/environments/moon_1k.hdr"
poster="shared-assets/models/NeilArmstrong.webp"
seamless-poster
shadow-intensity="1"
camera-controls>
</model-viewer>
Thanks for any tips.
Additional discussion on Clojurians Slack (link requires access to Slack)
Additional discussion on Clojureverse
positionAndNormalFromPoint
This is probably the only way to interact with it in React since it is not a "react" component. does this help? codesandbox.io/s/lingering-tree-d41cr?file=/src/App.js – Finzer