waytale - v0.3.0
    Preparing search index...

    Class WaytaleGadgetController

    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.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    gadgetTypeLoaders: {}

    A map of promises created for each gadget type (gadget type nmae) that resolves to the default export of gadget's source file.

    view: any

    Methods

    • 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.

      Parameters

      • map: WaytaleMap

        loaded map

      • gadgetType: object

        the gadget class

      • config: object

        complete gadget configuration

      Returns Promise<void>

    • 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.

      Parameters

      • map: WaytaleMap

        Waytale map instance

      • avatar: WaytaleAvatar

        Waytale avatar instance

      Returns void

    • After a map is loaded, create all gadgets.

      Parameters

      • map: WaytaleMap

        Waytale map instance

      Returns void

    • On space load, get all enabled gadgets and load classes for each gadget.

      Parameters

      • space: WaytaleSpace

        Waytale space instance

      Returns void

      Planned feature: Ask human whether gadgets are being trusted. Compare with stored SHA digests in browser. Use subresource integrity if possible (likely not in this case).