Skip to main content

scene.js

Classes

Scene

The Scene class is responsible for managing the scene state and displayingmeta and DDB data. It uses a singleton pattern, ensuring only one instanceis ever created. It supports initializing the scene with meta and optionally with DDB and eScriptorium data through the method initScene. This method is the only way to create an object of this class and can also only be called once. There is no way to access the instance of this class directly, but it can be interacted with through the static methods.If the instance is initialized with meta, DDB and eScriptorium data, thescene can toggle between displaying meta and DDB data using checkboxes, displayed over the actual scene.

Functions

setAttributes(element, attributes)void

This function sets multiple attributes for a given HTMLElement.

Typedefs

StringPair : Array.<string>

A tuple containing two strings, e.g., ["hello", "there"].

Scene

The Scene class is responsible for managing the scene state and displaying meta and DDB data. It uses a singleton pattern, ensuring only one instance is ever created. It supports initializing the scene with meta and optionally with DDB and eScriptorium data through the method initScene. This method is the only way to create an object of this class and can also only be called once. There is no way to access the instance of this class directly, but it can be interacted with through the static methods. If the instance is initialized with meta, DDB and eScriptorium data, the scene can toggle between displaying meta and DDB data using checkboxes, displayed over the actual scene.

Kind: global class
Singleton:

new Scene(meta, ddb, eScript)

Constructor for the Scene class. It is private and cannot be called directly. Use Scene.initScene() to create the instance.

Throws:

  • TypeError Throws an error if this is called without the #isConstructing flag being set.
ParamTypeDefaultDescription
metaArray.<StringPair>Meta data to display in the scene.
ddbstringnullOptional DDB data to display.
eScriptArray.<string>Optional eScriptorium data for positioning.

Example

const scene = new Scene(metaData);

Example

const scene = new Scene(metaData, ddbData, eScriptData);

scene.buildMeta() ⇒ void

This method builds up the scene by adding the meta data as text. The method first constructs the text and then adds a TextBox element to the data marker of the AScene instance.

Kind: instance method of Scene
Returns: void - This method does not return anything.

scene.buildDdb() ⇒ void

This method builds up the scene by adding every DDB data line as text. The method first constructs the text and then adds one TextBox element for each line to the data marker of the AScene instance.

Kind: instance method of Scene
Returns: void - This method does not return anything.

Scene.initScene(meta, ddb, eScript) ⇒ void

This method initializes the scene by calling the constructor after setting the #isConstructing flag. The method should only be called once and won't do anything if there is an instance of the Scene class already. Meta data should have the form [ [name, text], [name2, text2], ... ]. DDB data should have the form "line1 \n line2 \n ...". eScriptorium data should have the form [ "Trismegistos identifier", "maxWidth", "maxHeight", "line1Width!line1X!line1Y!line1Angle", line2, ... ].

Kind: static method of Scene
Returns: void - This method does not return anything.

ParamTypeDefaultDescription
metaArray.<StringPair>Meta data to display in the scene.
ddbstringnullOptional DDB data to display.
eScriptArray.<string>Optional eScriptorium data for positioning.

Example

Scene.initScene(metaData);

Example

Scene.initScene(metaData, ddbData, eScriptData);

Scene.update(newDist) ⇒ void

This method is static and can be called to update the scene with a new distance between the two marker of the scene.

Kind: static method of Scene
Returns: void - This method does not return anything.
Throws:

  • Error Will throw an error if there is no Scene instance.
ParamTypeDescription
newDistnumberNew Distance.

setAttributes(element, attributes) ⇒ void

This function sets multiple attributes for a given HTMLElement.

Kind: global function
Returns: void - This function does not return anything.

ParamType
elementHTMLElement
attributesObject.<string, string>

Example

const div = document.createElement("div");
setAttributes(div, {"text": ":-)", "id": "div0"});

StringPair : Array.<string>

A tuple containing two strings, e.g., ["hello", "there"].

Kind: global typedef