Hello everyone,
I’m trying to optimize my Verge3D application by dynamically loading different texture resolutions based on the user’s device memory. The goal is to improve performance on low-end devices while providing a high-quality experience on more powerful machines.
My approach is to:
1. Use a run script
puzzle to get the value of navigator.deviceMemory
.
2. Store this value in a variable using the set
puzzle.
3. Use an if/else
puzzle to check if the value is greater than or equal to a specific threshold (e.g., 4 GB).
4. Load the appropriate texture resolution (e.g., 4K or 2K) based on the condition.
I’ve tried using the following JavaScript code in the run script
puzzle: return navigator.deviceMemory;
and then assigning its output to a variable with the set
puzzle. However, I am consistently running into the following error:
TypeError: Cannot set properties of undefined (setting 'deviceMemory')
It seems there might be a problem with how the run script
puzzle interacts with puzzle variables, or an issue with the timing of the variable creation.
What is the correct way to implement this logic? I would appreciate any guidance on how to get the deviceMemory
value via a script and use it reliably within the puzzle system.
Thank you !