Create new gadget.
Waytale model instance
Waytale view instance
A map of promises created for each gadget type (gadget type nmae) that resolves to the default export of gadget's source file.
Gadgets are typically defined outside this code base. To avoid tedious imports and broken dependencies, yet allow base functionality for gadgets, a peculiar initialisation sequence for gadgets is used (lower forms of black magic).
There is no inheritence and the constructor of the specific gadget class is never called. Instead, each gadget is constructed as generic WaytaleGadget and initialised by means of an optional init() method the specific gadget class may define.
Within the specific gadget, lookup of instance variables and methods on the level of the generic gadget is supported by making the specific gadget class the first prototype to look up in the prototype chain of the gadget instance.
loaded map
the gadget class
complete gadget configuration
When an avatar changes position, check whether the interactive area of a gadget has been entered or exited and call respective functions of the gadget, if available.
Waytale map instance
Waytale avatar instance
After a map is loaded, create all gadgets.
Waytale map instance
On space load, get all enabled gadgets and load classes for each gadget.
Waytale space instance
Manage gadgets. Load gadget-specific sources (gadget classes) on demand. Create gadgets. Trigger gadget API callbacks like
onEnter()/onExit().Loading gadget classes from their respective source files is triggered when the space has loaded. Gadget creation is triggered when the map has loaded. To avoid a racing condition, loaded gadget classes are wrapped in promises.