Open perceptualJonathan opened 7 years ago
I'm facing the same problem. I need to add a new 3d object on_touch_up event and can't find a way to do it. Has anyone found a solution to this?
I never did. The work around I came up with was creating a bunch of the objects that I knew I would need at some point, hide them out of sight, and then bring them into the frame when needed.
I thought about doing something like that, it's not elegant, but if it works. Did you 'hide' the objects positioning them outside of the viewing area?
Yes, I have a floor object, so I just put the other objects that I might need in the future under the floor.
Late but needed, as this post is still high up on google. The reason this is happening is that render(scene, camera) converts the given scene into kivy instructions and adds them. You can add new objects by doing this manually:
renderer._instructions.add(obj.as_instructions())
It does not appear possible to add extra objects to a scene after the initial Renderer.render() call. This is seen in a simple modification of example3.py. Here, when
myFlag=1
, all 4 of the box, sphere, cylinder, and pyramid should be visible, but only the first 2 are visible. The other 2 are inself.scene.children
, but do not appear on screen. WhenmyFlag=0
, the box is initially the only object in the scene, then the sphere is to appear whenbox.pos.z = -20
, and this repeats with the cylinder and pyramid. However, none of the sphere, cylinder, or pyramid become visible. Again,self.scene.children
contains all 4 objects, but only the box is visible. It's not clear to me why it would be required that all objects be created at the beginning, as opposed to allowing some to be created later. Is there a simple fix for this?