First, you stop and breathe. Just put away the laptop, step away from it, and take slow and deep breaths. Focus on your breathing, if you need to, count slowly while you breathe. Keep going until your heart rate slows down.
Now… remember.. all things pass. This is not going to destroy your life and your future does not hinge on three hours of homework.
Breathe again, slowly. You’ve already done the work. It’s in your head, most of it will just be rewriting it. You’ve already done the math, or the research or whatever hard work goes into it. It will come back to you easier this time around. It’s okay. Even if you can’t find it all, it’s still okay. And it will be okay.
Keep breathing slowly, get a drink, breathe some more.
Then sit down and start from the beginning. It will be okay. you’ve got this. you’ve already done it once, so it will be even better this time around. First times are always rough drafts. It will be okay. You can do this.
haha, honestly I had a coworker who did this all the time, painting stuff on random pictures of food because he liked the color scheme and then piling on more random food pictures for texture. I saw him paint some sort of epic harpy girl out of ramen once.