Please help with this problem:
I need to implement a 3D editor that can be integrated into the Dash environment. The necessary functionality: moving 3D objects with the mouse, resizing and rotate also with the mouse.
I built a scene using the code below:
plane1 = pv.Plane(center=(1.0, 0.0, 0.0), direction=(1.0, 0.0, 0.0)) plane2 = pv.Plane(center=(1.0, 2.0, 0.0), direction=(0.0, 1.0, 0.0)) pointa = [10.0, 0.0, 0.0] pointb = [10.0, 10.0, 0.0] pointc = [0.0, 10.0, 0.0] pointd = [0.0, 0.0, 0.0] fracture1 = pv.Rectangle([pointa, pointb, pointc, pointd]) ring = pv.ParametricSuperToroid() content = dash_vtk.View( id="vtk-view", pickingModes=["click"], #or hover/click children=[ dash_vtk.GeometryRepresentation([ dash_vtk.Mesh(state=to_mesh_state(plane1)), ], id="pick-plane-1"), dash_vtk.GeometryRepresentation([ dash_vtk.Mesh(state=to_mesh_state(plane2)) ], id="pick-plane-2"), dash_vtk.GeometryRepresentation([ dash_vtk.Mesh(state=to_mesh_state(ring)) ], id="pick-ring-1"), dash_vtk.GeometryRepresentation([ dash_vtk.Mesh(state=to_mesh_state(fracture1)) ], id="pick-fracture-1"), ] )
Next, I look in the click function to see which object I clicked on:
if clickData['representationId'] == name_obj
Now I want to find an object with this ID on the scene and, for example, 1 - delete it, 2 - move it.
So, the question is in relation to point 1:
If I track as an input parameter to a function - ‘children’ from ‘dash_vtk. View’, then this list consists of the same number of objects as on the scene, ie in my case - there are 4, and the last object will be the object created by PyVista and converted into an object ‘Mesh’, then if I delete some object from the scene, for example ‘children’, then immediately after that, when the scene rotation in the browser, it starts to act unnaturally, ie rotate in different directions and very quickly, objects are displayed incorrectly when rotating, how to avoid this, how to remove objects?
On point 2:
If there, in ‘children’ look through the properties of the object, then, for example, for a rectangle shape, there is a parameter ‘points’, which has a ‘shape’ : (4, 3) - I think it is just four points at 3 coordinates, and there is a parameter ‘bvals’ : ‘AAAAAAAAJEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJEAAAAAAAAAkQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA’
I suspect that this is somehow encoded data, but how do I decode it? Or, if that’s not possible, how do I get the parameters of the object in the scene so that I can change them later and redraw the scene?
Or if it’s impossible to implement a full-fledged 3d edit using this library, is there any way to integrate the scene-graphics from VPython into Dash?
Thank you so much in advance for your feedback!