How to debug Puzzles: Difference between revisions

From Verge3D Wiki
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
This short but important how-to explains how to find and fix bugs in your Puzzles scenarios.
This short but very important how-to explains how to find and fix bugs in your Puzzles scenarios.


== Look for errors in the browser console ==
== 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 [https://www.soft8soft.com/docs/manual/en/introduction/FAQ.html#browser_console here] for instructions to open it).
If you execute Puzzles incorrectly, e.g. by passing invalid inputs, they will fail to work and print the explanation in the browser console. To open it just press '''F12''' and switch to the '''Console''' tab (works in most cases, if not, refer to the [https://www.soft8soft.com/docs/manual/en/introduction/FAQ.html#browser_console instructions]).


Check out the following example that explain the idea. Consider you need to replace texture on some of your models with the [https://www.soft8soft.com/docs/manual/en/puzzles/Materials.html#replace_texture 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:
Check out the following example that explain the idea. Consider you need to replace texture on some of your models with the [https://www.soft8soft.com/docs/manual/en/puzzles/Materials.html#replace_texture 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:


[[File:invalid_texture.webp|1000px]]
[[File:invalid_texture.webp|1000px]]
Line 15: Line 17:
Your scenario behaves odd, but there is no errors in the browser console? Just insert the [https://www.soft8soft.com/docs/manual/en/puzzles/System.html#print_to_console print to console] puzzle in the places you need to check with some meaningful data passed as input.
Your scenario behaves odd, but there is no errors in the browser console? Just insert the [https://www.soft8soft.com/docs/manual/en/puzzles/System.html#print_to_console 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 [https://www.soft8soft.com/docs/manual/en/puzzles/Objects.html#set_transform 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:
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 [https://www.soft8soft.com/docs/manual/en/puzzles/Objects.html#set_transform 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:


[[File:debugging_with_print_to_console_before.webp|1000px]]
[[File:debugging_with_print_to_console_before.webp|1000px]]
Line 27: Line 31:
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.
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, don't forget to remove the "print to console" puzzle(s) to prevent cluttering of the browser console.
Once you've done with bug fixing, don't forget to remove the "print to console" puzzle(s) to prevent cluttering of the browser console.


== Summary ==
== Summary ==
Line 33: Line 37:
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:


# [https://www.soft8soft.com/docs/manual/en/introduction/FAQ.html#browser_console open] the browser console and look for errors
# open ('''F12''') the browser console and look for errors. Not helpful? Go to step 2.
# insert [https://www.soft8soft.com/docs/manual/en/puzzles/System.html#print_to_console print to console] in the right place/places and carefully read their output
# insert [https://www.soft8soft.com/docs/manual/en/puzzles/System.html#print_to_console print to console] in the right place/places and carefully read their output



Revision as of 12:56, 23 March 2026

This short but very important 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. To open it just press F12 and switch to the Console tab (works in most cases, if not, refer to the instructions).

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, don't forget to remove the "print to console" puzzle(s) 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 (F12) the browser console and look for errors. Not helpful? Go to step 2.
  2. insert print to console in the right place/places and carefully read their output