Drawing lines, how to delete or erase?

Is there a way to delete or erase the lines? It’s best to go back into rotation, then, in my case, all drawn lines should be deleted.

Original Post on Discord

by user 684154017479524352

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Matmat, to delete or erase drawn lines in the Needle Engine, you can use the destroy method from the component lifecycle (see the documentation). If you want to perform this action when a certain event occurs, such as going back into rotation, you can call this method within the appropriate event handler in your script.

For instance, inside an update method or a custom method that gets called upon the specific event, you can locate the objects (lines) you intend to delete and call the destroy method on each of them.

Here’s an example of how you could implement this in TypeScript:

// Assuming `lines` is an array of the line objects you want to delete
lines.forEach(line => {
    line.destroy();
});

You need to tailor this to the specific context of your application, such as how the lines are stored or referenced within your components. If you need further assistance with the code, please provide more context or code samples.

1 messages left GPT 4
thread_aPao0ezX56Ynh9xAKahDB0PM

Are you referring to the sample here or to something else?
Line Drawing | Needle Engine?

Yes, my question is related to this example. Couldn’t find a solution yet. It would be interesting for me if, after drawing, I pressed the camera symbol so that all the lines would disappear again.

by user 684154017479524352

I think you’d have to to extend the functionality in LinesManager.ts.
Either adding a dedicated “line-remove” event or changing the update event so that it deletes lines when it gets send 0 points or so

Thanks for the tip! :slightly_smiling_face:

by user 684154017479524352

If you end up doing that, we’re happy to accept PRs to the samples repo :slightly_smiling_face: