Scenes
The puzzles from this category perform various operations with scenes and rendering.

Contents
Puzzles Reference
load scene + percentage
When this puzzle is triggered, the current scene is unloaded and a new scene is loaded from a specified .gltf file.

For usage example, check out the Load Unload demo (source files available in the Asset Store).
After loading is finished, the puzzles in the when loaded do slot are triggered. Also, there is an optional on progress do slot. Puzzles placed in this slot are continuously triggered during the loading and can utilize the percentage puzzle. Once the scene is loaded it's assigned a name which can be used to access and manipulate the scene via various object-related puzzles. By default the assigned name equals to the specified scene URL (e.g. "path/to/scene.gltf"
). The alias option if enabled allows to set the name manually.
Another optional on error do slot triggers in case of load errors (such as missing .gltf file).

append scene + percentage
When this puzzle is triggered, a new scene is loaded from a specified .gltf file and appended to the current scene.

For usage example, check out the Load Unload demo (source files available in the Asset Store).
After loading is finished, the puzzles in the when loaded do slot are triggered. Also there can be enabled the on progress do slot. Puzzles placed in this slot are continuously triggered during the loading and can utilize the percentage puzzle. The "append scene" puzzle doesn't load cameras and lights from a new scene by default. This behavior can be changed in the puzzle's options.
Once the scene is appended it's assigned a name which can be used to access and manipulate the scene via various object-related puzzles. By default the assigned name equals to the specified scene URL (e.g. "path/to/scene.gltf"
). The alias option, if enabled, allows to set the name manually.
Another optional on error do slot triggers in case of load errors (such as missing .gltf file).

unload scene
Unloads the specified scene or its part from the application. Use the empty text value in order to unload all scenes.

is scene loaded
Checks if the specified scene loaded. Use the empty text value in order to check the main scene.

enable rendering
Resumes previously disabled rendering.

disable rendering
Disables rendering. The graphics won't be updated but the user events will be captured and animation timelines will progress.

You can use disable rendering for the purpose of saving batteries on mobile devices or laptops, and getting rid of cooler noise on desktops. You can also enable the anti-alias option to significantly increase the rendering quality and compensate the loss of performance. This option targets the next frame after the rendering stops.

create environment
Create a new image-based lighting and assign a background to the scene. This puzzle also creates a new material with the name specified as the first parameter and adds it to the scene. You can use this material to replace textures or colors of the environment.
The second parameter can be ether:
- color — the environment lighting will be based on the default 256×128 HDR image, the background will be based on the default grey color value.
- texture — both the environment lighting and background will be based on the default 256×128 HDR image.

batch geometry
Merge geometry of a specified group of meshes to improve rendering performance. Upon execution, the puzzle collects meshes with similar properties, such as material in use, shadow settings, rendering order, etc, then creates and appends a new batch to the scene. Objects that can't be merged together are left intact.

To observe how batching works, just open the browser console:

In each "Adding batch object..." line you can see the name of the created batch object. This name consists of the name of the material forming the batch, the 'x' factor representing the number of meshes merged together and the "_batch" postfix.
For example:
Adding batch object: big_table_wood_x6_batch
line says that 6 meshes with the "big_table_wood" material were merged to a new batch object "big_table_wood_x6_batch".
Since the batch parts become "fixed" together (this operation is undoable), make sure you don't batch objects which you plan to move around, animate, or change individually from the batch.
export to gltf
Export your scene, model or a group of models to the glTF 2.0 format. Specify the only visible option to export only visible objects while the binary option is used to export to GLB (glTF Binary) format.

For best results we recommend you to have the glTF-compatible materials assigned on the exported models. See how to create them in Blender, 3ds Max, or Maya.
For usage example, check out the GLTF Compat demo (source files available in the Asset Store).
export to usdz
Export your scene or model to the Universal Scene Description (USDZ) format.

By using this puzzle, you can preview your scene on Apple devices in the AR mode. To do that, create the <a>
HTML element on your app page and assign the link to the exported USDZ asset as its href
parameter.
For usage example, check out the Augmented Reality demo (source files available in the Asset Store).
For best results we recommend you to have the glTF-compatible materials assigned on the exported models. See how to create them in Blender, 3ds Max, or Maya.
raycast
Cast a ray from the source point (or object) in the given direction and return a list of all intersections (if any). The third parameter of the puzzle is used to reduce a set of the intersected objects. Leave <none>
or specify the name of your scene to intersect all objects located in the loaded scene.
The returned list contains a sequence of dictionaries with the following information:
- object — name of the interected object
- distance — distance to the point of intersection
- point — XYZ coordinates (vector) of the point of intersection
- normal — XYZ coordinates (vector) of the normal at the point of intersection
- uv — UV coordiates of the point of intersection
The list of intersections is sorted by distance, closest first.

add fog
Add the distance fog effect to the scene. This effect is typically used in large outdoor environments to enhance visual perception of distance objects, hide objects (LOD), or cover up scene inconsistencies (such as edges of the terrain mesh).

Exponential fog specified using the density value. Use zero as density to disable the added fog.
Linear fog specified using the near and far properties. Use zero as near and any negative value as far to disable the added fog.
Having Troubles with Puzzles?
Seek help on the forums!