Custom shader support for 3D scenes? #4120
Replies: 2 comments
-
Thanks for the suggestion, @phenolophthaleinum! Regarding your proposed API, I assume |
Beta Was this translation helpful? Give feedback.
-
As a follow-up, for someone who might be looking for a similar problem in the future - it is possible to make a rough workaround which involves adding html with scripts of a three.js app using ui.add_body_html('''
<div id="threejs-container" style="width: 100%; height: 500px;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.155.0/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three/examples/js/loaders/GLTFLoader.min.js"></script>
<script>
// any remaining three.js app code
// load model
function loadModel(url) {
if (currentModel) {
scene.remove(currentModel);
}
loader = new THREE.GLTFLoader();
loader.load(url, function (gltf) {
currentModel = gltf.scene;
scene.add(currentModel);
});
}
</script>
''')
ui.button("Load Model", on_click=lambda: ui.run_javascript(f"loadModel('/static/plane.glb');")) So generally it's an embedding of three.js app into nicegui app with some layer of communication. Not very nice, but I think it works... |
Beta Was this translation helpful? Give feedback.
-
Description
I've read the documentation and checked the issues, and there is no mention of using custom shaders. Just to make sure, I want to ask the question and get the confirmation: Is there actually any way to get custom shaders to work in the current state of the package?
I do not have any meaningful code, since there is nothing I know I can write to make it. However, if nothing is possible right now, as a suggestion, I would imagine the following interface (with similarities from three.js implementation) would be reasonable for custom shading:
Beta Was this translation helpful? Give feedback.
All reactions