Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post effect sketches without root properly reload #473

Open
wants to merge 2 commits into
base: alpha
Choose a base branch
from

Conversation

cale-bradbury
Copy link
Contributor

If a sketch does not have an object named root, it fires an error when a code change is detected, requiring the user to manually remove and read the sketch.

This change checks to see if the refreshing sketch is one of the current post effects, and breaks early if so

accidentally added this off #471 so review that first 😬

Copy link
Member

@funwithtriangles funwithtriangles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it's a great catch when it comes to the postprocessing stuff. Generally I like this approach but i've left a few comments below. The most important being a big question of whether we want to be able to mix 3D object sketches with post processing sketches? I can imagine a sketch having both combined, but maybe that's a bad idea. Curious to hear your thoughts.


if (!oldSketch) {
const pass = engineScene.getPassesByName(instanceId)
if (pass?.length) {
pass.forEach((p) => engineScene.removePass(p))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would also work 😉

Suggested change
pass.forEach((p) => engineScene.removePass(p))
pass.forEach(engineScene.removePass)


if (!oldSketch) {
const pass = engineScene.getPassesByName(instanceId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method? Can we not just do this.sketchInstances[instanceId].getPasses? Maybe you have a good reason for doing it this way though, curious to know.

Comment on lines +46 to +52
delete this.sketchInstances[instanceId]
return
}
throw new Error(`couldn't find sketch to remove: ${instanceId}`)
}

scene.remove(oldSketch)
threeScene.remove(oldSketch)
Copy link
Member

@funwithtriangles funwithtriangles Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we may need to still call threeScene.remove sometimes even when there are passes on the sketch?

Is it not quite likely that some sketches may have both postprocessing and 3D objects? Rather than immediately returning at the end of the passes stuff, I'm wondering if it makes sense to shuffle the logic a bit so the code keeps keeps executing to the end of the method. You could optionally call threeScene.remove(oldSketch). Also wouldn't need to repeat the delete this.sketchInstances[instanceId] as it will just naturally get there anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants