How to debug Puzzles: Difference between revisions

From Verge3D Wiki
Jump to navigationJump to search
mNo edit summary
Line 33: Line 33:
Ability to find bugs in Puzzles and resolve them quickly is the first skill you should master. Let's repeat the algorithm:
Ability to find bugs in Puzzles and resolve them quickly is the first skill you should master. Let's repeat the algorithm:


# open the browser console and look for any errors
# open the browser console and look for errors
# insert '''print to console''' in the right place/places and carefully read their output
# insert '''print to console''' in the right place/places and carefully read their output


[[Category:Tutorials and How-Tos]]
[[Category:Tutorials and How-Tos]]
[[Category:Visual Programming]]
[[Category:Visual Programming]]

Revision as of 16:00, 21 March 2026

This short how-to explains how to find and fix bugs in your Puzzles scenarios.

Look for errors in the browser console

If you execute Puzzles incorrectly, e.g. by passing invalid inputs, they will fail to work and print the explanation in the browser console (see here on how to open one).

Check out the following example that explain the idea. Consider you need to replace texture on some of your models with the replace texture puzzle, but nothing happens once you execute this puzzle. By looking in the browser console you'll find the cause of this issue immediately:

It says you've specified invalid path to the texture! Fix the path and reload the app to see that the issue has gone.

Use print to console puzzle

Your scenario behaves odd, but there is no errors in the browser console? Just insert the print to console puzzle in the places you need to check with some meaningful data passed as input.

Let's explain it with the following example. Consider you need to calculate a position with some function ("calc object position") and then place some object to this position with the set transform puzzle. Once you've done with your scenario, you see that the object is not placed correctly. What should you do first? Yes, you should open the browser console! Unfortunately, there are no errors printed there:

This means you should switch to plan B and insert the "print to console" puzzle into your scenario. But where? At the first glance you should place it just before the actual object positioning takes place.

Here we go:

By running this code we finally see that the position returned by the "calc object position" is not correct. In our specific case it has zero values for all 3 coordinates (XYZ). Now it's time to review the "calc object position" and check for possible errors happening in that function. If necessary, insert as many "print to console" puzzle as needed to find the cause of the issue.

Once you've done with bug fixing, remove "print to console" puzzle to prevent cluttering of the browser console.

Summary

Ability to find bugs in Puzzles and resolve them quickly is the first skill you should master. Let's repeat the algorithm:

  1. open the browser console and look for errors
  2. insert print to console in the right place/places and carefully read their output