Adding lines to the scene programatically

We’d like to draw some simple lines in the scene as a debug mode for our users who specify some movement bounds for nodes while dragging. Is there a way for us to do this?

We have access to THREE on the player, but based on this threejs tutorial we’d need access to the underlying threejs scene and renderer in order to accomplish this (or something exposed on the player scene). I saw that Clara IO had widgets that might allow for this and in Threekit docs there’s a widget result object, but nothing else about widgets.


Hi Mike,

I reached out to my team to learn more about what can be done when THREE is exposed and was told that it is not a supported feature - there is a chance it will be removed from future releases. In the meantime how can I help you achieve these boundaries you are trying to set?

My colleague @tone mentioned you have found our selectionSet API which can highlight parts in your 3D scenes, I believe this would be the closest thing currently available in Threekit to’s widgets.

You can create a mesh with the dimensions you want the boundary to be and have that highlighted when you need to indicate there is a limit. Please let me know how I can help further.

Hi Will, yes I found the selectionSet API and that’s been great for highlighting. We provide flexible support for our users to define the movement of a draggable node along a plane, such as a grid pattern where it will snap to the lines and only move along them and/or a bounding rectangle along a plane that the node must stay in for planar movements. It’d be helpful for them as they’re setting it up to be able to see the bounds or grid displayed in the scene as a ‘debug’ mode. We don’t know any information ahead of time so we need to be able to do it dynamically based on the information they give us.

For the mesh idea - can I create one dynamically or would it be the case where I need to create a mesh as an asset and then add it to the scene and apply transformations to it? For the planar bounding box, I could probably get by with that and highlighting it, but we’re looking at allowing polygon bounding geometry supporting n-sides as well. That’s where having the ability to just draw some lines with a color and thickness would be super helpful.

Let me know if there’s any more info that would help in coming up with a solution or if you need anything clarified. Any other ideas would be helpful - we’ll take a look at the mesh idea.

I believe this would be the case, you can manipulate the mesh you’ve created as an asset with conditional rules or custom scripts. Out of the box, selectionSet is the closest functionality we have to be able to do this.

Thank you for posting your feature requests, can I help with this more or provide any more resources?

Nope - I can’t think of anything else along these lines. For anyone who’s interested and viewing this, I posted a feature request here. Thanks for the help!

1 Like