Adds a listener to an event type.
When an event of the type pType fires, the callback pListener will be called. This function
returns a unique string id that may be used in removeEventListenerById to allow simple
listener removal.
It is possible to add an object that will be included in the callback to avoid creating too many closures.
Calling twice addEventListener with the same parameters results in the second call to be ignored,
only unique pairs callback / object are allowed, in order to avoid calling multiple times the same
thing.
The id of the inserted callback (actually an UUID).
Adds a listener to an event type.
When an event of the type pType fires, the callback pListener will be called. This function
returns a unique string id that may be used in removeEventListenerById to allow simple
listener removal.
The id of the inserted callback (actually an UUID).
Adds a log to be logged.
The log timestamp is the current time of the call.
Gets hardware information on the currently running instance.
This information may be useful for debugging and statistics. This is the JSON representation of the multiple properties.
A promise. This is the JSON representation of the hardware properties.
Gets the current browser type.
The current browser type.
Gets the font loader responsible to provide font data to the rendering of annotations.
There is only one font loader.
The resulting FontLoaderInterface.
Gets the current log level.
This is the value previously set by setLogLevel. Defaults to LogLevel.LL_UsingDisposedObject.
The current log level.
The infinite api is now using webworkers.
For security reasons, webworkers cannot be launched from CORS.
For this reason, the infinite api is shipped with a very small worker that needs to be included in the application, this worker then loads the actual updated webworker from the infinite directory.
This call gets the full path to the webworker loader script (e.g infiniteapi-webworker-loader.js).
The full path to the webworker loader script.
Tells if the EventDispatcher has such a callback registered for the given event type.
true if such a listener is installed for the given type of event.
Removes a listener from an event type.
If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.
The listener function that gets removed.
The listener object that was used when addEventListener was called.
true if the callback was removed else false.
Removes a listener from an event type.
If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.
The listener function that gets removed.
true if the callback was removed else false.
Removes a listener by its id.
If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.
true if the callback was removed else false.
Restores the default wheel event converter behavior.
Wheel events are not consistent from browser to browser. In order to have the same behavior from browsers to browsers, the Infinite api needs to translate a wheel event to a homogeneous value.
import { BrowserType, WheelConverterInterface } from 'generated_files/documentation/appinfiniteapi';
// Wheel events are not really consistent from browser to browser
// this default implementation runs on current usual browsers
class DefaultWheelConverter implements WheelConverterInterface
{
// convert wheel event depending on browser and version
convertWheelEvent(pEvent: WheelEvent, pBrowserTpe : BrowserType, pIsEdgeChromium: boolean, _pBrowserVersion : string) : number
{
switch (pBrowserTpe) {
// firefox
case BrowserType.firefox:
return pEvent.deltaY * -1; // wheel value 3
// safari
case BrowserType.safari:
// (pEvent['wheelDelta'] < 0 ? -1 : 1)
return Math.min(24, Math.abs(pEvent['wheelDelta'])) * (1 - 2 * (<any>(pEvent['wheelDelta'] < 0) | 0)) * -15; // wheel value 12
// edge
case BrowserType.edge:
if (pIsEdgeChromium) {
return pEvent['wheelDelta'];
}
return pEvent['wheelDelta'] * 1.5; // wheel value 120
// internet explorer
case BrowserType.ie:
return pEvent.deltaY * -0.9; // wheel value 198.3
// default, mainly chrome
default:
if (pEvent['wheelDelta'] !== undefined) {
return pEvent['wheelDelta']; // wheel value 180
}
if (pEvent.deltaY !== undefined) {
return pEvent.deltaY * -60;
}
return 0;
}
}
}
export { DefaultWheelConverter };
Sets the log level of the logger.
Any message with a criticality strictly lower than pLogLevel will be silently discarded.
You cannot set a criticality lower than LogLevel.LL_Debug and bigger than LogLevel.LL_Required.
true if pLogLevel is correct and that the log level has been set.
Customizes the way logging is handled for a specific criticality.
pLogLevel must be superior or equal to LogLevel.LL_Debug and strictly inferior to LogLevel.LL_Required.
Thus, the LogLevel.LL_Required level cannot be customized.
You may choose to :
When using LogBehavior.LB_LogToObject, pLogObject cannot be undefined, else pLogObject is ignored.
Optional pLogObject: InfiniteLoggertrue if the log level has been set (i.e. pLogLevel and pBehavior are correct and pLogObject is defined in case of LogBehavior.LB_LogToObject).
Enables/Disables power saving mode.
Power saving mode is used to save CPU usage when the browser tab is hidden by introducing some frame throttling. The WorkingSetInterface calculations will be slower if the tab is hidden.
Power saving is disabled (false) by default.
The infinite api is now using webworkers.
For security reasons, webworkers cannot be launched from CORS.
For this reason, the infinite api is shipped with a very small worker that needs to be included in the application, this worker then loads the actual updated webworker from the infinite directory.
This call sets the path to the correct script. If pPath does not end with .js, then pPath is considered
as a folder and the default loader script name is used (e.g. pPath + infiniteapi-webworker-loader.js).
true if the path was set.
Sets the wheel event converter behavior.
Wheel events are not consistent from browser to browser. In order to have the same behavior from browsers to browsers, the Infinite api needs to translate a wheel event to a homogeneous value.
Such behavior will depend on the browser type (getBrowserType) and optionally the browser version (getBrowserVersion).
import { BrowserType, WheelConverterInterface } from 'generated_files/documentation/appinfiniteapi';
// Wheel events are not really consistent from browser to browser
// this default implementation runs on current usual browsers
class DefaultWheelConverter implements WheelConverterInterface
{
// convert wheel event depending on browser and version
convertWheelEvent(pEvent: WheelEvent, pBrowserTpe : BrowserType, pIsEdgeChromium: boolean, _pBrowserVersion : string) : number
{
switch (pBrowserTpe) {
// firefox
case BrowserType.firefox:
return pEvent.deltaY * -1; // wheel value 3
// safari
case BrowserType.safari:
// (pEvent['wheelDelta'] < 0 ? -1 : 1)
return Math.min(24, Math.abs(pEvent['wheelDelta'])) * (1 - 2 * (<any>(pEvent['wheelDelta'] < 0) | 0)) * -15; // wheel value 12
// edge
case BrowserType.edge:
if (pIsEdgeChromium) {
return pEvent['wheelDelta'];
}
return pEvent['wheelDelta'] * 1.5; // wheel value 120
// internet explorer
case BrowserType.ie:
return pEvent.deltaY * -0.9; // wheel value 198.3
// default, mainly chrome
default:
if (pEvent['wheelDelta'] !== undefined) {
return pEvent['wheelDelta']; // wheel value 180
}
if (pEvent.deltaY !== undefined) {
return pEvent.deltaY * -60;
}
return 0;
}
}
}
export { DefaultWheelConverter };
true if the call succeeded.
The InfiniteApiControllerInterface interface is the core singleton of the 3djuump Infinite javascript API.
It provides access to the following services :
The Font loading mechanism is available through InfiniteApiControllerInterface.getFontLoader.
The font loading mechanism may be done with the following :
The logging system is based on string messages with a criticality and a timestamp (date). The 3djuump Infinite javascript API may log messages when key events occur.
You may :
The power saving system may be used to lower the CPU usage of the API when the browser is hidden. The 3djuump Infinite javascript API features an internal clock that ticks every 16 milliseconds if the browser has the focus, and every 1 second when the browser has not the focus and power saving is enabled. When the internal clock ticks, the Infinite objects are updated and calculated, and the InfiniteApiControllerInterfaceSignal.Tick signal is sent when all objects have been updated. Please note that the InfiniteEngineInterfaceSignal.DisplayDone signal is sent by the InfiniteEngineInterface when the **rendering** is done (this is not at the same moment than InfiniteApiControllerInterfaceSignal.Tick). Power saving is enabled with setPowerSavingEnabled.
The browser detection is based on bowser. At the start of the API, the running browser is detected and getBrowserName, getBrowserType, getBrowserVersion provide information about the current browser. The browser type is a BrowserType that helps identify the current browser.
NB : In case of Microsoft Edge, two versions exist, one is chromium based, the other not, and isEdgeChromium helps to disambiguate the two.
The wheel event conversion system helps having a consistent wheel event behavior depending on browser types. You may override/restore the default behavior with setWheelConverter / restoreDefaultWheelConverter by supplying a custom WheelConverterInterface implementation.
See