r3-v2/dist/r3.js

6614 lines
144 KiB
JavaScript
Raw Normal View History

2021-07-05 10:21:36 +02:00
class R3 {
2021-09-19 21:28:53 +02:00
static version = '2.0.784';
static compileDate = '2021 Sep 19 - 21:28:13 pm';
2021-07-05 10:21:36 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-10 14:03:19 +02:00
class Runtime {
2021-09-13 09:57:21 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 14:03:19 +02:00
2021-09-13 09:57:21 +02:00
Object.assign(this, options);
2021-09-18 08:52:21 +02:00
2021-09-10 14:03:19 +02:00
}
}
2021-09-18 08:52:21 +02:00
Runtime.BASE_CODER = 0x0;
Runtime.BASE_DOM = 0x1;
Runtime.BASE_GUI = 0x2;
Runtime.BASE_GRAPHICS = 0x3;
Runtime.BASE_IMAGE = 0x4;
Runtime.BASE_PHYSICS = 0x5;
Runtime.BASE_SOCKET = 0x6;
Runtime.BASE_STATISTICS = 0x7;
2021-09-18 11:06:19 +02:00
Runtime.CODE_MIRROR = 0x8;
Runtime.DOCUMENT = 0x9;
Runtime.CONTROL_KIT = 0xa;
Runtime.THREE = 0xb;
Runtime.NODE_JS_IMAGE = 0xc;
Runtime.WEB_IMAGE = 0xd;
Runtime.BULLET = 0xe;
Runtime.STATS = 0xf;
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeCoder extends Runtime {
2021-07-04 20:32:41 +02:00
constructor(options) {
2021-08-04 10:50:28 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
/**
2021-09-08 05:44:51 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.Coder.CodeMirror
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-08-04 10:50:28 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-09-09 17:59:33 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeCoder]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeCodeMirror]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeCodeMirror extends RuntimeCoder {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-09-07 06:01:07 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
*/
buildInstance(component) {
2021-09-07 06:01:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeDOM extends Runtime {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
}
2021-09-14 06:13:26 +02:00
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
/**
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.DOM.Document
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-08-04 10:50:28 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeDOM]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeDocument]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeDocument extends RuntimeDOM {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
/**
2021-09-18 11:06:19 +02:00
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
2021-07-04 20:32:41 +02:00
*/
2021-09-18 11:06:19 +02:00
buildInstance(component) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (component instanceof R3.Component.DOM.Canvas) {
let canvas = document.createElement('canvas');
canvas.setAttribute('width', component.width);
canvas.setAttribute('height', component.height);
canvas.setAttribute('style', component.style);
return canvas;
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeGUI extends Runtime {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.GUI.ControlKit
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeGUI]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeControlKit]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeControlKit extends RuntimeGUI {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
/**
2021-09-18 11:06:19 +02:00
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
2021-07-04 20:32:41 +02:00
*/
2021-09-18 11:06:19 +02:00
buildInstance(component) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeGraphics extends Runtime {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.Graphics.Three
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeGraphics]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeThree]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeThree extends RuntimeGraphics {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
super(options);
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
/**
2021-09-18 11:06:19 +02:00
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
2021-07-04 20:32:41 +02:00
*/
2021-09-18 11:06:19 +02:00
buildInstance(component) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeImage extends Runtime {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.Image.NodeJSImage
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeImage]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeNodeJSImage]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeNodeJSImage extends RuntimeImage {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
/**
2021-09-18 11:06:19 +02:00
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
2021-07-04 20:32:41 +02:00
*/
2021-09-18 11:06:19 +02:00
buildInstance(component) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.Image.WebImage
[Inherited from Runtime]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimeImage]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to RuntimeWebImage]
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static properties>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
**/
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeWebImage extends RuntimeImage {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
/**
2021-09-18 11:06:19 +02:00
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
2021-07-04 20:32:41 +02:00
*/
2021-09-18 11:06:19 +02:00
buildInstance(component) {
2021-07-04 20:32:41 +02:00
2021-09-19 21:28:53 +02:00
if (component instanceof R3.Component.Graphics.Image) {
let image = document.createElement('img');
image.setAttribute('src', component.src);
image.setAttribute('alt', component.alt);
return image;
}
2021-09-18 11:06:19 +02:00
}
2021-07-04 20:32:41 +02:00
}
2021-09-18 11:06:19 +02:00
class RuntimePhysics extends Runtime {
2021-09-08 08:46:38 +02:00
2021-09-18 08:52:21 +02:00
constructor(options) {
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
super(options);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
}
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Runtime.Physics.Bullet
[Inherited from Runtime]
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-09-08 08:46:38 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-09-13 10:14:09 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-09-13 10:14:09 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from RuntimePhysics]
2021-09-13 10:14:09 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-09-08 08:46:38 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-09-08 08:46:38 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-09-08 08:46:38 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to RuntimeBullet]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class RuntimeBullet extends RuntimePhysics {
2021-09-08 08:46:38 +02:00
2021-09-18 08:52:21 +02:00
constructor(options) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 11:06:19 +02:00
/**
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
*/
buildInstance(component) {
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
}
class RuntimeSocket extends Runtime {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
constructor(options) {
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
super(options);
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
}
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-06 08:00:04 +02:00
2021-09-18 11:06:19 +02:00
class RuntimeStatistics extends Runtime {
2021-09-06 09:38:54 +02:00
2021-09-18 08:52:21 +02:00
constructor(options) {
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
super(options);
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-18 11:06:19 +02:00
/**
Class R3.Runtime.Statistics.Stats
[Inherited from Runtime]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Inherited from RuntimeStatistics]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to RuntimeStats]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class RuntimeStats extends RuntimeStatistics {
2021-09-06 08:00:04 +02:00
2021-09-13 10:14:09 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
}
/**
* buildInstance()
2021-09-19 21:28:53 +02:00
* - Creates a runtime instance object based on the R3.Component representing it.
2021-09-18 11:06:19 +02:00
* @param component
*/
buildInstance(component) {
2021-09-06 08:00:04 +02:00
}
2021-09-18 08:52:21 +02:00
}
2021-09-18 11:06:19 +02:00
class System {
2021-09-18 08:52:21 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
2021-09-10 14:03:19 +02:00
}
2021-09-06 08:00:04 +02:00
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
2021-07-12 12:02:59 +02:00
}
2021-09-10 14:03:19 +02:00
}
2021-07-12 12:02:59 +02:00
2021-09-18 11:06:19 +02:00
System.DOM = 0x0;
System.INPUT = 0x1;
System.LINKING = 0x2;
System.RENDER = 0x3;
System.RUNTIME = 0x4;
System.SOCKET = 0x5;
System.STORAGE = 0x6;
System.MAX_SYSTEM = 0x7;
2021-09-18 08:52:21 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
Class R3.System.DOM
[Inherited from System]
2021-09-08 08:25:16 +02:00
2021-09-10 14:03:19 +02:00
Inherited Properties:
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
<no inherited properties>
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
Inherited Static Properties:
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
<no inherited static properties>
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
Inherited Methods:
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
<no inherited methods>
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
Inherited Static Methods:
2021-09-08 08:25:16 +02:00
2021-09-10 14:03:19 +02:00
<no inherited static methods>
2021-07-12 12:02:59 +02:00
2021-09-18 08:52:21 +02:00
[Belonging to SystemDOM]
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
Properties:
2021-09-06 08:51:26 +02:00
2021-09-10 14:03:19 +02:00
<no properties>
2021-07-12 12:02:59 +02:00
2021-09-10 14:03:19 +02:00
Static Properties:
2021-09-08 08:25:16 +02:00
2021-09-10 14:03:19 +02:00
<no static properties>
2021-09-08 08:25:16 +02:00
2021-09-10 14:03:19 +02:00
Methods:
2021-09-08 08:25:16 +02:00
2021-09-13 10:14:09 +02:00
<no methods>
2021-09-08 08:25:16 +02:00
2021-09-10 14:03:19 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 08:52:21 +02:00
class SystemDOM extends System {
2021-07-12 12:02:59 +02:00
2021-09-13 10:14:09 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
2021-07-12 12:02:59 +02:00
}
/**
2021-09-18 08:52:21 +02:00
* Start()
* - Starts the system by registering subscriptions to events
* @param options
2021-07-12 12:02:59 +02:00
*/
2021-09-18 08:52:21 +02:00
static Start(options) {
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
SystemDOM.Subscriptions['DOM_COMPONENT_INITIALIZED'] = Event.Subscribe(
Event.DOM_COMPONENT_INITIALIZED,
SystemDOM.OnDomComponentInitialized
);
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
SystemDOM.Started = true;
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
console.log('Started system: SystemDOM');
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
SystemDOM.Subscriptions['DOM_COMPONENT_INITIALIZED'].remove();
delete SystemDOM.Subscriptions['DOM_COMPONENT_INITIALIZED'];
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
SystemDOM.Started = false;
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
console.log('Stopped system: SystemDOM');
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-09 18:09:09 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* OnDomComponentInitialized()
* - Listens to events of type Event.DOM_COMPONENT_INITIALIZED and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
2021-09-10 14:03:19 +02:00
*/
2021-09-18 08:52:21 +02:00
static OnDomComponentInitialized(object) {
2021-09-09 18:09:09 +02:00
}
2021-09-10 14:03:19 +02:00
}
2021-09-09 18:09:09 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* static Started - Indicates whether or not this system is running or not
*/
SystemDOM.Started = false;
2021-09-10 10:59:34 +02:00
2021-09-18 08:52:21 +02:00
/**
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
*/
SystemDOM.Subscriptions = {};
/**
Class R3.System.Input
[Inherited from System]
2021-09-09 18:09:09 +02:00
2021-09-10 14:03:19 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
2021-09-09 18:09:09 +02:00
2021-09-10 14:03:19 +02:00
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
2021-09-18 08:52:21 +02:00
[Belonging to SystemInput]
2021-09-10 14:03:19 +02:00
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
2021-09-13 10:14:09 +02:00
<no methods>
2021-09-10 14:03:19 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 08:52:21 +02:00
class SystemInput extends System {
2021-09-10 14:03:19 +02:00
2021-09-13 10:14:09 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
2021-09-09 18:09:09 +02:00
}
/**
2021-09-18 08:52:21 +02:00
* Start()
* - Starts the system by registering subscriptions to events
* @param options
2021-09-09 18:09:09 +02:00
*/
2021-09-18 08:52:21 +02:00
static Start(options) {
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_START'] = Event.Subscribe(
Event.TOUCH_START,
SystemInput.OnTouchStart
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_END'] = Event.Subscribe(
Event.TOUCH_END,
SystemInput.OnTouchEnd
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_MOVE'] = Event.Subscribe(
Event.TOUCH_MOVE,
SystemInput.OnTouchMove
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_CANCEL'] = Event.Subscribe(
Event.TOUCH_CANCEL,
SystemInput.OnTouchCancel
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['KEYBOARD_DOWN'] = Event.Subscribe(
Event.KEYBOARD_DOWN,
SystemInput.OnKeyboardDown
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['KEYBOARD_UP'] = Event.Subscribe(
Event.KEYBOARD_UP,
SystemInput.OnKeyboardUp
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_DOWN'] = Event.Subscribe(
Event.MOUSE_DOWN,
SystemInput.OnMouseDown
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_UP'] = Event.Subscribe(
Event.MOUSE_UP,
SystemInput.OnMouseUp
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_MOVE'] = Event.Subscribe(
Event.MOUSE_MOVE,
SystemInput.OnMouseMove
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_WHEEL'] = Event.Subscribe(
Event.MOUSE_WHEEL,
SystemInput.OnMouseWheel
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Started = true;
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
console.log('Started system: SystemInput');
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_START'].remove();
delete SystemInput.Subscriptions['TOUCH_START'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_END'].remove();
delete SystemInput.Subscriptions['TOUCH_END'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_MOVE'].remove();
delete SystemInput.Subscriptions['TOUCH_MOVE'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['TOUCH_CANCEL'].remove();
delete SystemInput.Subscriptions['TOUCH_CANCEL'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['KEYBOARD_DOWN'].remove();
delete SystemInput.Subscriptions['KEYBOARD_DOWN'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['KEYBOARD_UP'].remove();
delete SystemInput.Subscriptions['KEYBOARD_UP'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_DOWN'].remove();
delete SystemInput.Subscriptions['MOUSE_DOWN'];
2021-09-09 18:09:09 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_UP'].remove();
delete SystemInput.Subscriptions['MOUSE_UP'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_MOVE'].remove();
delete SystemInput.Subscriptions['MOUSE_MOVE'];
2021-09-13 10:14:09 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Subscriptions['MOUSE_WHEEL'].remove();
delete SystemInput.Subscriptions['MOUSE_WHEEL'];
2021-09-13 10:14:09 +02:00
2021-09-18 08:52:21 +02:00
SystemInput.Started = false;
2021-09-13 10:14:09 +02:00
2021-09-18 08:52:21 +02:00
console.log('Stopped system: SystemInput');
2021-09-13 10:14:09 +02:00
2021-09-09 18:09:09 +02:00
}
2021-09-10 10:59:34 +02:00
/**
2021-09-18 08:52:21 +02:00
* OnTouchStart()
* - Listens to events of type Event.TOUCH_START and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
2021-09-10 10:59:34 +02:00
*/
2021-09-18 08:52:21 +02:00
static OnTouchStart(object) {
2021-09-10 12:11:16 +02:00
2021-09-10 10:59:34 +02:00
}
2021-09-18 08:52:21 +02:00
/**
* OnTouchEnd()
* - Listens to events of type Event.TOUCH_END and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnTouchEnd(object) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnTouchMove()
* - Listens to events of type Event.TOUCH_MOVE and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnTouchMove(object) {
2021-09-06 09:38:54 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-06 09:38:54 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnTouchCancel()
* - Listens to events of type Event.TOUCH_CANCEL and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnTouchCancel(object) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnKeyboardDown()
* - Listens to events of type Event.KEYBOARD_DOWN and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnKeyboardDown(object) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnKeyboardUp()
* - Listens to events of type Event.KEYBOARD_UP and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnKeyboardUp(object) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnMouseDown()
* - Listens to events of type Event.MOUSE_DOWN and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnMouseDown(object) {
2021-09-06 09:38:54 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-06 09:38:54 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnMouseUp()
* - Listens to events of type Event.MOUSE_UP and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnMouseUp(object) {
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-18 08:52:21 +02:00
/**
* OnMouseMove()
* - Listens to events of type Event.MOUSE_MOVE and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnMouseMove(object) {
}
/**
* OnMouseWheel()
* - Listens to events of type Event.MOUSE_WHEEL and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnMouseWheel(object) {
}
}
/**
* static Started - Indicates whether or not this system is running or not
*/
SystemInput.Started = false;
/**
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
*/
SystemInput.Subscriptions = {};
/**
Class R3.System.Linking
[Inherited from System]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to SystemLinking]
Properties:
<no properties>
Static Properties:
2021-09-19 21:28:53 +02:00
- BlacklistedComponents (Default value [] - A list of component constructors which should not be
permitted to create instances immediately)
2021-09-18 08:52:21 +02:00
Methods:
<no methods>
2021-07-04 20:32:41 +02:00
2021-07-05 10:21:36 +02:00
Static Methods:
2021-07-04 20:32:41 +02:00
2021-09-13 10:26:48 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
**/
2021-09-18 08:52:21 +02:00
class SystemLinking extends System {
2021-07-04 20:32:41 +02:00
constructor(options) {
2021-08-04 10:50:28 +02:00
if (typeof options === 'undefined') {
2021-07-04 20:32:41 +02:00
options = {};
}
super(options);
Object.assign(this, options);
2021-07-12 12:02:59 +02:00
}
/**
* Start()
2021-09-13 10:26:48 +02:00
* - Starts the system by registering subscriptions to events
* @param options
2021-07-12 12:02:59 +02:00
*/
2021-09-13 10:26:48 +02:00
static Start(options) {
2021-07-12 12:02:59 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['OBJECT_CREATED'] = Event.Subscribe(
Event.OBJECT_CREATED,
SystemLinking.OnObjectCreated
2021-09-10 14:03:19 +02:00
);
2021-07-12 12:02:59 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['OBJECT_INITIALIZED'] = Event.Subscribe(
Event.OBJECT_INITIALIZED,
SystemLinking.OnObjectInitialized
);
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['INSTANCE_CREATED'] = Event.Subscribe(
Event.INSTANCE_CREATED,
SystemLinking.OnInstanceCreated
);
2021-09-19 21:28:53 +02:00
SystemLinking.Subscriptions['CREATE_INSTANCE_BEFORE'] = Event.Subscribe(
Event.CREATE_INSTANCE_BEFORE,
SystemLinking.OnCreateInstanceBefore
);
2021-09-18 08:52:21 +02:00
SystemLinking.Started = true;
console.log('Started system: SystemLinking');
2021-07-12 12:02:59 +02:00
}
/**
* Stop()
2021-09-13 10:26:48 +02:00
* - Stops the system by removing these subscriptions to events
* @param options
2021-07-12 12:02:59 +02:00
*/
2021-09-13 10:26:48 +02:00
static Stop(options) {
2021-07-12 12:02:59 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['OBJECT_CREATED'].remove();
delete SystemLinking.Subscriptions['OBJECT_CREATED'];
2021-09-06 08:51:26 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['OBJECT_INITIALIZED'].remove();
delete SystemLinking.Subscriptions['OBJECT_INITIALIZED'];
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions['INSTANCE_CREATED'].remove();
delete SystemLinking.Subscriptions['INSTANCE_CREATED'];
2021-09-19 21:28:53 +02:00
SystemLinking.Subscriptions['CREATE_INSTANCE_BEFORE'].remove();
delete SystemLinking.Subscriptions['CREATE_INSTANCE_BEFORE'];
2021-09-18 08:52:21 +02:00
SystemLinking.Started = false;
console.log('Stopped system: SystemLinking');
2021-09-10 14:03:19 +02:00
}
/**
2021-09-18 08:52:21 +02:00
* OnObjectCreated()
2021-09-19 21:28:53 +02:00
* - Listens to events of type OBJECT_CREATED and executes this function.
2021-09-10 14:03:19 +02:00
* @param object (The event data passed as argument - typically an R3Object)
2021-09-19 21:28:53 +02:00
* @return
2021-09-10 14:03:19 +02:00
*/
2021-09-18 08:52:21 +02:00
static OnObjectCreated(object) {
2021-09-10 14:03:19 +02:00
2021-09-19 21:28:53 +02:00
console.log('object created');
2021-09-18 08:52:21 +02:00
}
/**
* OnObjectInitialized()
2021-09-19 21:28:53 +02:00
* - Listens to events of type OBJECT_INITIALIZED and executes this function.
2021-09-18 08:52:21 +02:00
* @param object (The event data passed as argument - typically an R3Object)
2021-09-19 21:28:53 +02:00
* @return
2021-09-18 08:52:21 +02:00
*/
static OnObjectInitialized(object) {
2021-09-19 21:28:53 +02:00
console.log('object initialized');
2021-09-18 08:52:21 +02:00
}
/**
* OnInstanceCreated()
2021-09-19 21:28:53 +02:00
* - Listens to events of type INSTANCE_CREATED and executes this function.
2021-09-18 08:52:21 +02:00
* @param object (The event data passed as argument - typically an R3Object)
2021-09-19 21:28:53 +02:00
* @return
2021-09-18 08:52:21 +02:00
*/
static OnInstanceCreated(object) {
2021-07-12 12:02:59 +02:00
2021-09-19 21:28:53 +02:00
console.log('instance created');
}
/**
* OnCreateInstanceBefore()
* - Listens to events of type CREATE_INSTANCE_BEFORE and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return boolean delayInstance which indicates whether or not instance creation is delayed (handled) by
* another system. (i.e. where instance creation order is of importance)
*/
static OnCreateInstanceBefore(object) {
for (let i = 0; i < SystemLinking.BlacklistedComponents.length; i++) {
if (object instanceof SystemLinking.BlacklistedComponents) {
return true;
}
}
return false;
2021-07-05 10:21:36 +02:00
}
2021-07-04 20:32:41 +02:00
2021-07-05 10:21:36 +02:00
}
2021-07-04 20:32:41 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
* static Started - Indicates whether or not this system is running or not
2021-09-13 09:39:38 +02:00
*/
2021-09-18 08:52:21 +02:00
SystemLinking.Started = false;
2021-09-14 06:13:26 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
2021-09-13 09:39:38 +02:00
*/
2021-09-18 08:52:21 +02:00
SystemLinking.Subscriptions = {};
2021-09-19 21:28:53 +02:00
/**
* static BlacklistedComponents - A list of component constructors which should not be permitted to create instances immediately
*/
SystemLinking.BlacklistedComponents = [];
2021-09-07 09:08:37 +02:00
/**
2021-09-18 08:52:21 +02:00
Class R3.System.Render
2021-09-10 14:03:19 +02:00
[Inherited from System]
2021-09-07 09:08:37 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 14:03:19 +02:00
<no inherited methods>
2021-09-07 09:08:37 +02:00
Inherited Static Methods:
2021-09-10 14:03:19 +02:00
<no inherited static methods>
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
[Belonging to SystemRender]
2021-09-07 09:08:37 +02:00
Properties:
<no properties>
Static Properties:
2021-09-13 10:26:48 +02:00
<no static properties>
2021-09-07 09:08:37 +02:00
Methods:
<no methods>
Static Methods:
2021-09-13 10:26:48 +02:00
<no static methods>
2021-09-10 14:03:19 +02:00
2021-09-07 09:08:37 +02:00
**/
2021-09-18 08:52:21 +02:00
class SystemRender extends System {
2021-09-07 09:08:37 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
}
2021-09-10 14:03:19 +02:00
/**
* Start()
2021-09-13 10:26:48 +02:00
* - Starts the system by registering subscriptions to events
* @param options
2021-09-10 14:03:19 +02:00
*/
2021-09-13 10:26:48 +02:00
static Start(options) {
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
SystemRender.Subscriptions['INSTANCE_CREATED'] = Event.Subscribe(
Event.INSTANCE_CREATED,
SystemRender.OnInstanceCreated
2021-09-10 14:03:19 +02:00
);
2021-06-20 20:46:13 +02:00
2021-09-18 08:52:21 +02:00
SystemRender.Started = true;
2021-06-20 20:46:13 +02:00
2021-09-18 08:52:21 +02:00
console.log('Started system: SystemRender');
2021-09-08 04:59:31 +02:00
2021-07-04 20:32:41 +02:00
}
2021-09-08 08:46:38 +02:00
/**
2021-09-10 14:03:19 +02:00
* Stop()
2021-09-13 10:26:48 +02:00
* - Stops the system by removing these subscriptions to events
* @param options
2021-09-08 08:46:38 +02:00
*/
2021-09-13 10:26:48 +02:00
static Stop(options) {
2021-08-04 09:01:06 +02:00
2021-09-18 08:52:21 +02:00
SystemRender.Subscriptions['INSTANCE_CREATED'].remove();
delete SystemRender.Subscriptions['INSTANCE_CREATED'];
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
SystemRender.Started = false;
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
console.log('Stopped system: SystemRender');
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* OnInstanceCreated()
* - Listens to events of type Event.INSTANCE_CREATED and executes this function.
2021-09-10 14:03:19 +02:00
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
2021-09-18 08:52:21 +02:00
static OnInstanceCreated(object) {
2021-09-08 04:59:31 +02:00
2021-09-18 08:52:21 +02:00
if (object instanceof R3.Component.DOM) {
if (object.runtime instanceof R3.Runtime.DOM.Document) {
document.body.appendChild(object.instance);
}
}
2021-09-07 09:08:37 +02:00
2021-09-19 21:28:53 +02:00
if (object instanceof R3.Component.Graphics.Image) {
if (object.runtime instanceof R3.Runtime.Image.WebImage) {
document.body.appendChild(object.instance);
}
}
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-08 04:59:31 +02:00
2021-09-18 08:52:21 +02:00
/**
* static Started - Indicates whether or not this system is running or not
*/
SystemRender.Started = false;
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
/**
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
*/
SystemRender.Subscriptions = {};
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
/**
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Class R3.System.Runtime
[Inherited from System]
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to SystemRuntime]
Properties:
<no properties>
Static Properties:
- Projects (Default value [])
- CurrentProject (Default value null)
- RuntimeCoder (Default value {})
- RuntimeDOM (Default value {})
- RuntimeGUI (Default value {})
- RuntimeGraphics (Default value {})
- RuntimePhysics (Default value {})
- RuntimeStatistics (Default value {})
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class SystemRuntime extends System {
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* Start()
* - Starts the system by registering subscriptions to events
* @param options
2021-09-10 14:03:19 +02:00
*/
2021-09-18 08:52:21 +02:00
static Start(options) {
SystemRuntime.Subscriptions['GET_RUNTIME'] = Event.Subscribe(
Event.GET_RUNTIME,
SystemRuntime.OnGetRuntime
);
SystemRuntime.Subscriptions['PROJECT_INITIALIZED'] = Event.Subscribe(
Event.PROJECT_INITIALIZED,
SystemRuntime.OnProjectInitialized
);
SystemRuntime.Started = true;
console.log('Started system: SystemRuntime');
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
2021-09-10 14:03:19 +02:00
*/
2021-09-18 08:52:21 +02:00
static Stop(options) {
SystemRuntime.Subscriptions['GET_RUNTIME'].remove();
delete SystemRuntime.Subscriptions['GET_RUNTIME'];
SystemRuntime.Subscriptions['PROJECT_INITIALIZED'].remove();
delete SystemRuntime.Subscriptions['PROJECT_INITIALIZED'];
SystemRuntime.Started = false;
console.log('Stopped system: SystemRuntime');
2021-09-09 17:59:33 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* OnGetRuntime()
* - Listens to events of type Event.GET_RUNTIME and executes this function.
2021-09-10 14:03:19 +02:00
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
2021-09-18 08:52:21 +02:00
static OnGetRuntime(object) {
if (object instanceof R3.Component.DOM) {
if (SystemRuntime.CurrentProject === null) {
2021-09-18 11:06:19 +02:00
return new R3.Runtime.DOM.Document();
2021-09-18 08:52:21 +02:00
} else {
console.log('TODO: implement a project based DOM runtime');
}
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
if (object instanceof R3.Image) {
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
if (SystemRuntime.CurrentProject === null) {
return new R3.Runtime.Image.WebImage();
} else {
console.log('TODO: implement a project based Image runtime');
}
}
}
/**
* OnProjectInitialized()
* - Listens to events of type Event.PROJECT_INITIALIZED and executes this function.
2021-09-10 14:03:19 +02:00
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
2021-09-18 08:52:21 +02:00
static OnProjectInitialized(object) {
Utils.PushUnique(SystemRuntime.Projects, object);
SystemRuntime.CurrentProject = object;
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
* static Started - Indicates whether or not this system is running or not
2021-09-13 09:39:38 +02:00
*/
2021-09-18 08:52:21 +02:00
SystemRuntime.Started = false;
2021-09-14 06:13:26 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
2021-09-13 09:39:38 +02:00
*/
2021-09-18 08:52:21 +02:00
SystemRuntime.Subscriptions = {};
/**
* static Projects - No comment
*/
SystemRuntime.Projects = [];
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* static CurrentProject - No comment
*/
SystemRuntime.CurrentProject = null;
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
/**
* static RuntimeCoder - No comment
*/
SystemRuntime.RuntimeCoder = {};
/**
* static RuntimeDOM - No comment
*/
SystemRuntime.RuntimeDOM = {};
/**
* static RuntimeGUI - No comment
*/
SystemRuntime.RuntimeGUI = {};
/**
* static RuntimeGraphics - No comment
*/
SystemRuntime.RuntimeGraphics = {};
/**
* static RuntimePhysics - No comment
*/
SystemRuntime.RuntimePhysics = {};
/**
* static RuntimeStatistics - No comment
*/
SystemRuntime.RuntimeStatistics = {};
/**
Class R3.System.Socket
2021-09-10 14:03:19 +02:00
[Inherited from System]
2021-09-07 09:08:37 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
2021-09-18 08:52:21 +02:00
[Belonging to SystemSocket]
2021-09-07 09:08:37 +02:00
Properties:
<no properties>
Static Properties:
2021-09-13 10:26:48 +02:00
<no static properties>
2021-09-07 09:08:37 +02:00
Methods:
<no methods>
Static Methods:
2021-09-13 10:26:48 +02:00
<no static methods>
2021-09-10 14:03:19 +02:00
2021-09-07 09:08:37 +02:00
**/
2021-09-18 08:52:21 +02:00
class SystemSocket extends System {
2021-09-07 09:08:37 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
2021-09-10 14:03:19 +02:00
}
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
2021-09-18 08:52:21 +02:00
SystemSocket.Started = true;
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
console.log('Started system: SystemSocket');
2021-09-08 04:59:31 +02:00
2021-09-07 09:08:37 +02:00
}
2021-09-10 14:03:19 +02:00
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
SystemSocket.Started = false;
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
console.log('Stopped system: SystemSocket');
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
/**
* static Started - Indicates whether or not this system is running or not
*/
SystemSocket.Started = false;
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
/**
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
*/
SystemSocket.Subscriptions = {};
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
/**
Class R3.System.Storage
[Inherited from System]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to SystemStorage]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class SystemStorage extends System {
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
super(options);
Object.assign(this, options);
}
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
2021-09-10 14:03:19 +02:00
*/
2021-09-18 08:52:21 +02:00
static Start(options) {
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
SystemStorage.Subscriptions['IMAGE_COMPONENT_INITIALIZED'] = Event.Subscribe(
Event.IMAGE_COMPONENT_INITIALIZED,
SystemStorage.OnImageComponentInitialized
);
SystemStorage.Started = true;
console.log('Started system: SystemStorage');
2021-09-09 17:59:33 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 08:52:21 +02:00
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
SystemStorage.Subscriptions['IMAGE_COMPONENT_INITIALIZED'].remove();
delete SystemStorage.Subscriptions['IMAGE_COMPONENT_INITIALIZED'];
SystemStorage.Started = false;
console.log('Stopped system: SystemStorage');
}
/**
* OnImageComponentInitialized()
* - Listens to events of type Event.IMAGE_COMPONENT_INITIALIZED and executes this function.
2021-09-10 14:03:19 +02:00
* @param object (The event data passed as argument - typically an R3Object)
* @return null
*/
2021-09-18 08:52:21 +02:00
static OnImageComponentInitialized(object) {
}
}
/**
* static Started - Indicates whether or not this system is running or not
*/
SystemStorage.Started = false;
/**
* static Subscriptions - An association object which hold the subscription handles for Events this system is listening
* to. The system can stop receiving events by calling remove() on a handle.
*/
SystemStorage.Subscriptions = {};
2021-09-18 11:06:19 +02:00
class Event {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* async()
* - Simply calls 'Async()' passing it the arguments
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
*/
async(
eventId,
data,
clientCallback,
clientErrorCallback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
return Event.Async(
eventId,
data,
clientCallback,
clientErrorCallback
);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* emit()
* - Simply calls 'Emit()' passing it the arguments
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
*/
emit(
eventId,
data,
clientCallback,
clientErrorCallback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
return Event.Emit(
eventId,
data,
clientCallback,
clientErrorCallback
);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* subscribe()
* - Simply calls 'Subscribe()' passing it the arguments
* @param eventId
* @param callback
*/
subscribe(
eventId,
callback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
return Event.Subscribe(eventId, callback.bind(this));
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* Async()
* - Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
* arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
* error as argument.
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
*/
static Async(
eventId,
data,
clientCallback,
clientErrorCallback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (Event.Subscriptions.hasOwnProperty(eventId)) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
let subscriptionIds = Object.keys(Event.Subscriptions[eventId]);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
subscriptionIds.map(
function(subscriptionId) {
try {
Event.Subscriptions[eventId][subscriptionId](data, clientCallback, clientErrorCallback);
} catch (error) {
if (clientErrorCallback) {
clientErrorCallback(error);
} else {
console.error(error);
throw error;
}
}
}
)
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* Emit()
* - Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
* the event result is obtained, passing it the result. If an exception occurs during execution, the
* clientErrorCallback is called with the error as argument.
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
*/
static Emit(
eventId,
data,
clientCallback,
clientErrorCallback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (Event.Subscriptions.hasOwnProperty(eventId)) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
let subscriptionIds = Object.keys(Event.Subscriptions[eventId]);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
subscriptionIds.map(
function(subscriptionId) {
try {
let result = Event.Subscriptions[eventId][subscriptionId](data);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (clientCallback) {
clientCallback(result);
}
} catch (error) {
if (clientErrorCallback) {
clientErrorCallback(error);
} else {
console.error(error);
throw error;
}
}
}
)
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* Subscribe()
* - Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
* @param eventId
* @param callback
* @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
*/
static Subscribe(
eventId,
callback
) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
let subscriptionId = Utils.RandomId(10);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (Event.Subscriptions.hasOwnProperty(eventId)) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (Event.Subscriptions[eventId][subscriptionId]) {
throw new Error('A component can only subscribe to a particular event ID once');
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
Event.Subscriptions[eventId][subscriptionId] = callback;
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
} else {
Event.Subscriptions[eventId] = {};
Event.Subscriptions[eventId][subscriptionId] = callback;
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* Return a handle to the caller to allow us to unsubscribe to this event
*/
return {
fn: callback,
remove: function (eventId, subscriptionId) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
return function () {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* Stop listening for this event from this component
*/
delete Event.Subscriptions[eventId][subscriptionId];
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
* If the length of listeners is 0, stop referencing this event
* @type {string[]}
*/
let listeners = Object.keys(Event.Subscriptions[eventId]);
if (listeners.length === 0) {
delete Event.Subscriptions[eventId];
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
return true;
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}(eventId, subscriptionId),
subscriptionId : subscriptionId
};
2021-09-18 08:52:21 +02:00
}
2021-09-18 11:06:19 +02:00
/**
* Some nice Events handling
* @type {{}}
*/
static Subscriptions = {};
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-18 08:52:21 +02:00
2021-09-19 21:28:53 +02:00
Event.BEFORE_RENDER = 0x1;
Event.COMPONENT_CREATED = 0x2;
Event.COMPONENT_INITIALIZED = 0x3;
Event.CREATE_INSTANCE_BEFORE = 0x4;
Event.DISPOSE_INSTANCE = 0x5;
Event.DISPOSE_OBJECT = 0x6;
Event.DOM_COMPONENT_INITIALIZED = 0x7;
Event.ENTITY_CREATED = 0x8;
Event.ENTITY_INITIALIZED = 0x9;
Event.GET_RUNTIME = 0xa;
Event.GET_WINDOW_SIZE = 0xb;
Event.GRAPHICS_COMPONENT_INITIALIZED = 0xc;
Event.IMAGE_COMPONENT_INITIALIZED = 0xd;
Event.IMAGE_INITIALIZED = 0xe;
Event.INPUT_COMPONENT_INITIALIZED = 0xf;
Event.INSTANCE_CREATED = 0x10;
Event.INSTANCE_DISPOSED = 0x11;
Event.KEYBOARD_DOWN = 0x12;
Event.KEYBOARD_UP = 0x13;
Event.MOUSE_DOWN = 0x14;
Event.MOUSE_MOVE = 0x15;
Event.MOUSE_UP = 0x16;
Event.MOUSE_WHEEL = 0x17;
Event.OBJECT_CREATED = 0x18;
Event.OBJECT_INITIALIZED = 0x19;
Event.PAUSE = 0x1a;
Event.PROJECT_INITIALIZED = 0x1b;
Event.RESTART = 0x1c;
Event.START = 0x1d;
Event.TOUCH_CANCEL = 0x1e;
Event.TOUCH_END = 0x1f;
Event.TOUCH_MOVE = 0x20;
Event.TOUCH_START = 0x21;
Event.UPDATE_FROM_INSTANCE_AFTER = 0x22;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0x23;
Event.UPDATE_INSTANCE_AFTER = 0x24;
Event.UPDATE_INSTANCE_BEFORE = 0x25;
Event.UPDATE_INSTANCE_PROPERTY = 0x26;
Event.UPDATE_PROPERTY_FROM_INSTANCE = 0x27;
Event.MAX_EVENTS = 0x28;
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
Event.GetEventName = function(eventId) {
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
switch(eventId) {
2021-09-19 21:28:53 +02:00
case 0x1 : return 'before_render';
case 0x2 : return 'component_created';
case 0x3 : return 'component_initialized';
case 0x4 : return 'create_instance_before';
case 0x5 : return 'dispose_instance';
case 0x6 : return 'dispose_object';
case 0x7 : return 'dom_component_initialized';
case 0x8 : return 'entity_created';
case 0x9 : return 'entity_initialized';
case 0xa : return 'get_runtime';
case 0xb : return 'get_window_size';
case 0xc : return 'graphics_component_initialized';
case 0xd : return 'image_component_initialized';
case 0xe : return 'image_initialized';
case 0xf : return 'input_component_initialized';
case 0x10 : return 'instance_created';
case 0x11 : return 'instance_disposed';
case 0x12 : return 'keyboard_down';
case 0x13 : return 'keyboard_up';
case 0x14 : return 'mouse_down';
case 0x15 : return 'mouse_move';
case 0x16 : return 'mouse_up';
case 0x17 : return 'mouse_wheel';
case 0x18 : return 'object_created';
case 0x19 : return 'object_initialized';
case 0x1a : return 'pause';
case 0x1b : return 'project_initialized';
case 0x1c : return 'restart';
case 0x1d : return 'start';
case 0x1e : return 'touch_cancel';
case 0x1f : return 'touch_end';
case 0x20 : return 'touch_move';
case 0x21 : return 'touch_start';
case 0x22 : return 'update_from_instance_after';
case 0x23 : return 'update_from_instance_before';
case 0x24 : return 'update_instance_after';
case 0x25 : return 'update_instance_before';
case 0x26 : return 'update_instance_property';
case 0x27 : return 'update_property_from_instance';
2021-09-18 11:06:19 +02:00
default :
throw new Error('Event type not defined : ' + eventId);
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object
[Inherited from Event]
2021-09-18 08:52:21 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 11:06:19 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-18 11:06:19 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Belonging to R3Object]
2021-09-18 08:52:21 +02:00
Properties:
2021-09-18 11:06:19 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- register (Default value true)
2021-09-18 08:52:21 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
- initialize()
Should raises an event(s) which indicates that this object initialized
2021-09-18 08:52:21 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class R3Object extends Event {
2021-09-18 08:52:21 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-18 08:52:21 +02:00
super(options);
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
/**
* id - Each Object receives an 10 digit random ID which uniquely identifies it everywhere (client and
* server side)
*/
if (typeof options.id === 'undefined') {
options.id = Utils.RandomId(10);
}
/**
* name - Each Object has a name
*/
if (typeof options.name === 'undefined') {
options.name = 'Object ' + options.id;
}
/**
* register - No comment
*/
if (typeof options.register === 'undefined') {
options.register = true;
}
2021-09-18 08:52:21 +02:00
Object.assign(this, options);
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
2021-09-10 14:03:19 +02:00
}
/**
2021-09-18 11:06:19 +02:00
* initialize()
* - Should raises an event(s) which indicates that this object initialized
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
initialize() {
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-19 21:28:53 +02:00
Event.Emit(Event.OBJECT_INITIALIZED, this);
this.createInstance();
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Entity
[Inherited from Event]
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 11:06:19 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-18 11:06:19 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
2021-09-11 06:53:30 +02:00
Inherited Properties:
2021-09-18 11:06:19 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- register (Default value true)
2021-09-11 06:53:30 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 11:06:19 +02:00
- initialize()
Should raises an event(s) which indicates that this object initialized
2021-09-11 06:53:30 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to Entity]
2021-09-11 06:53:30 +02:00
Properties:
<no properties>
Static Properties:
2021-09-13 10:26:48 +02:00
<no static properties>
2021-09-11 06:53:30 +02:00
Methods:
<no methods>
Static Methods:
2021-09-13 10:26:48 +02:00
<no static methods>
2021-09-11 06:53:30 +02:00
**/
2021-09-18 11:06:19 +02:00
class Entity extends R3Object {
2021-09-11 06:53:30 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-11 06:53:30 +02:00
super(options);
2021-09-18 11:06:19 +02:00
this.emit(Event.ENTITY_CREATED, this);
2021-09-11 06:53:30 +02:00
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
2021-09-11 06:53:30 +02:00
}
/**
2021-09-18 11:06:19 +02:00
* initialize()
* - Should raises an event(s) which indicates that this object initialized
2021-09-11 06:53:30 +02:00
*/
2021-09-18 11:06:19 +02:00
initialize() {
2021-09-11 06:53:30 +02:00
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-19 21:28:53 +02:00
this.createInstance();
2021-09-18 08:52:21 +02:00
}
2021-09-11 06:53:30 +02:00
2021-09-18 11:06:19 +02:00
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.ENTITY_INITIALIZED, this);
2021-09-11 06:53:30 +02:00
}
2021-09-18 08:52:21 +02:00
}
2021-09-11 06:53:30 +02:00
2021-09-18 11:06:19 +02:00
Entity.SLIDER = 0x0;
Entity.MAX_ENTITY = 0x1;
2021-09-18 08:52:21 +02:00
/**
2021-09-11 06:53:30 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Entity.Slider
[Inherited from Event]
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
<no inherited properties>
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Properties:
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static properties>
2021-09-11 06:53:30 +02:00
2021-09-18 08:52:21 +02:00
Inherited Methods:
2021-09-11 06:53:30 +02:00
2021-09-18 11:06:19 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-09-07 09:08:37 +02:00
Inherited Static Methods:
2021-09-18 11:06:19 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from R3Object]
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- register (Default value true)
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Properties:
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static properties>
2021-09-09 17:59:33 +02:00
2021-09-18 08:52:21 +02:00
Inherited Methods:
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- initialize()
Should raises an event(s) which indicates that this object initialized
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static methods>
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from Entity]
2021-09-10 14:26:03 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-10 14:26:03 +02:00
2021-09-18 08:52:21 +02:00
<no inherited properties>
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Properties:
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static properties>
2021-09-07 09:08:37 +02:00
2021-09-18 08:52:21 +02:00
Inherited Methods:
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
<no inherited methods>
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to EntitySlider]
2021-09-18 08:52:21 +02:00
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class EntitySlider extends Entity {
2021-09-18 08:52:21 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-18 08:52:21 +02:00
super(options);
2021-09-18 11:06:19 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* components - A list of components that this entity is composed of
*/
if (typeof options.components === 'undefined') {
options.components = [];
}
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-13 10:26:48 +02:00
2021-09-18 08:52:21 +02:00
}
2021-09-14 06:13:26 +02:00
2021-09-13 09:39:38 +02:00
/**
2021-09-14 06:13:26 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component
[Inherited from Event]
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
<no inherited properties>
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Properties:
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static properties>
2021-09-14 06:13:26 +02:00
2021-09-18 08:52:21 +02:00
Inherited Methods:
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-09-10 14:03:19 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-18 11:06:19 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-09-18 08:52:21 +02:00
2021-09-18 11:06:19 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
2021-09-07 09:08:37 +02:00
Inherited Properties:
2021-09-18 11:06:19 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- register (Default value true)
2021-09-07 09:08:37 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 11:06:19 +02:00
- initialize()
Should raises an event(s) which indicates that this object initialized
2021-09-07 09:08:37 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to Component]
2021-09-07 09:08:37 +02:00
Properties:
<no properties>
Static Properties:
2021-09-13 10:26:48 +02:00
<no static properties>
2021-09-07 09:08:37 +02:00
Methods:
2021-09-10 14:03:19 +02:00
<no methods>
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
Static Methods:
2021-09-07 09:08:37 +02:00
2021-09-13 10:26:48 +02:00
<no static methods>
2021-09-07 09:08:37 +02:00
**/
2021-09-18 11:06:19 +02:00
class Component extends R3Object {
2021-09-07 09:08:37 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-07 09:08:37 +02:00
super(options);
2021-09-18 11:06:19 +02:00
this.emit(Event.COMPONENT_CREATED, this);
/**
* register - No comment
*/
if (typeof options.register === 'undefined') {
options.register = true;
}
2021-09-07 09:08:37 +02:00
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
2021-09-07 09:08:37 +02:00
}
/**
2021-09-18 11:06:19 +02:00
* initialize()
* - Should raises an event(s) which indicates that this object initialized
2021-09-07 09:08:37 +02:00
*/
2021-09-18 11:06:19 +02:00
initialize() {
2021-09-07 09:08:37 +02:00
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-07 09:08:37 +02:00
2021-09-19 21:28:53 +02:00
Event.Emit(Event.COMPONENT_INITIALIZED, this);
this.createInstance();
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
/**
* createInstance()
* - Creates an instance of this object based on the current runtime
*/
createInstance() {
2021-09-08 05:33:01 +02:00
2021-09-19 21:28:53 +02:00
this.emit(
Event.CREATE_INSTANCE_BEFORE,
this,
function(delayInstance) {
if (delayInstance === true) {
console.log('Instance creation delayed for ' + this.name);
} else {
this.setRuntime();
this.instance = this.runtime.buildInstance(this);
this.emit(Event.INSTANCE_CREATED, this);
}
}
);
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
/**
* dispose()
* - Disposes of this object by disposing the instance first.
*/
dispose() {
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
this.disposeInstance();
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
/**
* disposeInstance()
* - Disposes of the runtime instance.
*/
disposeInstance() {
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
/**
* setRuntime()
* - Sets the runtime property of this component required for constructing an instance of this component.
*/
setRuntime() {
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
this.emit(
Event.GET_RUNTIME,
this,
function(runtime) {
this.runtime = runtime;
}.bind(this)
)
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Component.DOM = 0x0;
Component.CANVAS = 0x1;
Component.GRAPHICS = 0x2;
Component.IMAGE = 0x3;
Component.MATERIAL = 0x4;
Component.MESH = 0x5;
Component.TEXTURE = 0x6;
Component.INPUT = 0x7;
Component.TOUCH = 0x8;
Component.MAX_COMPONENT = 0x9;
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
/**
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.DOM
[Inherited from Event]
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from R3Object]
2021-09-17 11:28:07 +02:00
2021-09-18 08:52:21 +02:00
Inherited Properties:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- register (Default value true)
2021-09-17 11:56:58 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Properties:
2021-09-17 11:28:07 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static properties>
2021-09-17 11:28:07 +02:00
2021-09-18 08:52:21 +02:00
Inherited Methods:
2021-09-17 11:28:07 +02:00
2021-09-18 11:06:19 +02:00
- initialize()
Should raises an event(s) which indicates that this object initialized
2021-09-17 11:28:07 +02:00
2021-09-18 08:52:21 +02:00
Inherited Static Methods:
2021-09-17 11:28:07 +02:00
2021-09-18 08:52:21 +02:00
<no inherited static methods>
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from Component]
2021-09-07 09:08:37 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 08:52:21 +02:00
<no inherited methods>
2021-09-07 09:08:37 +02:00
Inherited Static Methods:
2021-09-18 08:52:21 +02:00
<no inherited static methods>
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to ComponentDOM]
2021-09-07 09:08:37 +02:00
2021-09-10 14:03:19 +02:00
Properties:
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
- instance (Default value null - Holds the current instance of this object as determined (built) by
the runtime object.)
2021-09-07 09:08:37 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
- initialize()
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.DOM_COMPONENT_INITIALIZED
2021-09-07 09:08:37 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentDOM extends Component {
2021-09-07 09:08:37 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-07 09:08:37 +02:00
super(options);
2021-09-18 11:06:19 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-07 09:08:37 +02:00
Object.assign(this, options);
2021-09-18 11:06:19 +02:00
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
2021-09-07 09:08:37 +02:00
}
2021-09-09 17:59:33 +02:00
/**
2021-09-18 11:06:19 +02:00
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
2021-09-09 17:59:33 +02:00
*/
2021-09-18 11:06:19 +02:00
updateInstance(property) {
2021-09-09 17:59:33 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
2021-09-09 17:59:33 +02:00
2021-09-18 11:06:19 +02:00
if (property === 'instance') {
this.instance.instance = this.instance;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'instance',
instanceProperty : 'instance'
}
);
if (property !== 'all') {
return;
}
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
if (property === 'instance' || property === 'all') {
this.instance = this.instance.instance;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'instance',
instanceProperty : 'instance'
}
);
if (property !== 'all') {
return;
}
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-07 09:08:37 +02:00
2021-09-18 11:06:19 +02:00
/**
* initialize()
* - In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
* Event.DOM_COMPONENT_INITIALIZED
*/
initialize() {
2021-09-07 09:08:37 +02:00
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-07 09:08:37 +02:00
2021-09-19 21:28:53 +02:00
Event.Emit(Event.DOM_COMPONENT_INITIALIZED, this);
this.createInstance();
}
2021-09-08 04:59:31 +02:00
2021-09-07 09:08:37 +02:00
}
}
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.DOM.Canvas
2021-09-17 14:42:18 +02:00
[Inherited from Event]
2021-09-07 09:08:37 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
2021-09-10 14:03:19 +02:00
[Inherited from R3Object]
2021-09-07 09:08:37 +02:00
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-10 14:03:19 +02:00
- register (Default value true)
2021-09-07 09:08:37 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 14:03:19 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-07 09:08:37 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from Component]
2021-09-08 08:25:16 +02:00
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-18 11:06:19 +02:00
<no inherited methods>
2021-09-08 08:25:16 +02:00
Inherited Static Methods:
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-09-08 08:25:16 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from ComponentDOM]
Inherited Properties:
2021-09-18 11:06:19 +02:00
- instance (Default value null - Holds the current instance of this object as determined (built) by
the runtime object.)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 14:03:19 +02:00
- initialize()
2021-09-18 11:06:19 +02:00
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.DOM_COMPONENT_INITIALIZED
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to ComponentCanvas]
Properties:
2021-09-18 11:06:19 +02:00
- type (Default value 'canvas')
- width (Default value 500 - The initial width of the canvas (You can override it with CSS))
- height (Default value 500 - The initial height of the canvas (You can override it with CSS))
- style (Default value 'border:1px solid #000000;')
Static Properties:
<no static properties>
Methods:
2021-09-13 09:39:38 +02:00
<no methods>
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentCanvas extends ComponentDOM {
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-18 11:06:19 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
2021-09-18 11:06:19 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-13 09:39:38 +02:00
/**
2021-09-18 11:06:19 +02:00
* type - No comment
2021-09-13 09:39:38 +02:00
*/
2021-09-18 11:06:19 +02:00
if (typeof options.type === 'undefined') {
options.type = 'canvas';
}
/**
* width - The initial width of the canvas (You can override it with CSS)
*/
if (typeof options.width === 'undefined') {
options.width = 500;
}
/**
* height - The initial height of the canvas (You can override it with CSS)
*/
if (typeof options.height === 'undefined') {
options.height = 500;
}
/**
* style - No comment
*/
if (typeof options.style === 'undefined') {
options.style = 'border:1px solid #000000;';
2021-09-13 09:39:38 +02:00
}
Object.assign(this, options);
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
} else {
options.callDepth--;
}
2021-09-08 08:46:38 +02:00
}
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
2021-09-13 09:39:38 +02:00
*/
2021-09-18 11:06:19 +02:00
updateInstance(property) {
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
if (property === 'width') {
this.instance.width = this.width;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'width',
instanceProperty : 'width'
2021-09-13 09:39:38 +02:00
}
2021-09-18 11:06:19 +02:00
);
if (property !== 'all') {
return;
2021-09-13 09:39:38 +02:00
}
2021-09-18 11:06:19 +02:00
}
if (property === 'height') {
this.instance.height = this.height;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'height',
instanceProperty : 'height'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'style') {
this.instance.style = this.style;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'style',
instanceProperty : 'style'
}
);
if (property !== 'all') {
return;
}
}
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
2021-09-13 09:39:38 +02:00
}
/**
2021-09-18 11:06:19 +02:00
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
2021-09-13 09:39:38 +02:00
*/
2021-09-18 11:06:19 +02:00
updateFromInstance(property) {
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
if (property === 'width' || property === 'all') {
this.width = this.instance.width;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'width',
instanceProperty : 'width'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'height' || property === 'all') {
this.height = this.instance.height;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'height',
instanceProperty : 'height'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'style' || property === 'all') {
this.style = this.instance.style;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'style',
instanceProperty : 'style'
}
);
if (property !== 'all') {
return;
}
}
2021-09-13 09:39:38 +02:00
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
2021-09-13 09:39:38 +02:00
}
}
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Graphics
2021-09-13 09:39:38 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-13 09:39:38 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-13 09:39:38 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from Component]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentGraphics]
2021-09-13 09:39:38 +02:00
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
- initialize()
2021-09-18 11:06:19 +02:00
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.GRAPHICS_COMPONENT_INITIALIZED
2021-09-13 09:39:38 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentGraphics extends Component {
2021-09-13 09:39:38 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
2021-09-18 11:06:19 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-13 09:39:38 +02:00
Object.assign(this, options);
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
}
2021-09-18 11:06:19 +02:00
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
2021-09-13 09:39:38 +02:00
/**
* initialize()
2021-09-18 11:06:19 +02:00
* - In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
* Event.GRAPHICS_COMPONENT_INITIALIZED
2021-09-10 14:03:19 +02:00
*/
initialize() {
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-10 14:03:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-19 21:28:53 +02:00
Event.Emit(Event.GRAPHICS_COMPONENT_INITIALIZED, this);
this.createInstance();
}
2021-09-10 14:03:19 +02:00
}
2021-09-07 07:58:29 +02:00
}
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
/**
2021-08-04 09:01:06 +02:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Graphics.Image
2021-09-07 07:58:29 +02:00
[Inherited from Event]
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
Inherited Properties:
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
<no inherited properties>
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
Inherited Static Properties:
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
<no inherited static properties>
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
Inherited Methods:
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
Inherited Static Methods:
2021-08-04 09:01:06 +02:00
2021-09-07 07:58:29 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-07 07:58:29 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-07 07:58:29 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from Component]
2021-09-07 07:58:29 +02:00
Inherited Properties:
2021-09-07 08:41:32 +02:00
<no inherited properties>
2021-09-07 07:58:29 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-13 09:46:12 +02:00
<no inherited methods>
2021-09-13 09:39:38 +02:00
Inherited Static Methods:
2021-09-08 08:46:38 +02:00
2021-09-13 09:39:38 +02:00
<no inherited static methods>
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
[Inherited from ComponentGraphics]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialize()
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.GRAPHICS_COMPONENT_INITIALIZED
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentImage]
2021-09-07 07:58:29 +02:00
2021-09-13 09:39:38 +02:00
Properties:
2021-09-07 08:41:32 +02:00
2021-09-19 21:28:53 +02:00
- src (Default value
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpSotDu0g4pChumhBVMRRq1CECqFWaNXB5NIvaNKQpLg4Cq4FBz8Wqw4uzro6uAqC4AeIm5uToouU+L+k0CLWg+N+vLv3uHsHCPUy06yucUDTbTOViIuZ7KoYeEUvwgghgFGZWcacJCXRcXzdw8fXuxjP6nzuzxFScxYDfCLxLDNMm3iDeHrTNjjvE0dYUVaJz4nHTLog8SPXFY/fOBdcFnhmxEyn5okjxGKhjZU2ZkVTI54ijqqaTvlCxmOV8xZnrVxlzXvyFwZz+soy12kOIYFFLEGCCAVVlFCGjRitOikWUrQf7+AfdP0SuRRylcDIsYAKNMiuH/wPfndr5ScnvKRgHOh+cZyPYSCwCzRqjvN97DiNE8D/DFzpLX+lDsx8kl5radEjoH8buLhuacoecLkDDDwZsim7kp+mkM8D72f0TVkgfAv0rXm9Nfdx+gCkqavkDXBwCIwUKHu9w7t72nv790yzvx9QEXKZwXQv9wAAAAZiS0dEADIANAAxUB4d7wAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+UJEw0JHX/9/lIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADUlEQVQI12Ng+M+gBgADKAEm2Ka93QAAAABJRU5ErkJggg)
- alt (Default value '15% opaque 1x1 green pixel' - The alt attribute of this image)
2021-09-18 11:06:19 +02:00
- fileName (Default value Utils.LowerUnderscore(options.name) - Name of the image under which it is
stored)
2021-09-19 21:28:53 +02:00
- extension (Default value '.png' - Extension of the file name including the '.' (ex. '.jpg'))
- external_path (Default value '/images/' + options.id + '.png' - Path to the image relative to the
project defined API URL)
- internal_path (Default value '/tmp/' + options.id + '.png' - Server side path on the server to the
file, excluding filename)
- contentType (Default value 'image/png' - Content type of the file (based on the extension, ex.
'image/jpeg'))
- size (Default value 565 - Size of the file in bytes)
- width (Default value 1 - Width of the image in pixels)
- height (Default value 1 - height of the image in pixels)
2021-09-18 11:06:19 +02:00
- orientation (Default value 'square' - The orientation of the image, one of 'square', 'landscape',
'portrait')
2021-09-13 09:39:38 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
- initialize()
Also raises Event.IMAGE_INITIALIZED
2021-09-13 09:39:38 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentImage extends ComponentGraphics {
2021-09-13 09:39:38 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
/**
2021-09-13 09:53:04 +02:00
* parent - The parent R3.Object of this component
2021-09-13 09:39:38 +02:00
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
2021-09-18 11:06:19 +02:00
* instance - Holds the current instance of this object as determined (built) by the runtime object.
2021-09-13 09:39:38 +02:00
*/
2021-09-18 11:06:19 +02:00
if (typeof options.instance === 'undefined') {
options.instance = null;
2021-09-13 09:39:38 +02:00
}
2021-09-19 21:28:53 +02:00
/**
* src - The src attribute of this image, defaults to a 15% opaque 1x1 green pixel
*/
if (typeof options.src === 'undefined') {
options.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpSotDu0g4pChumhBVMRRq1CECqFWaNXB5NIvaNKQpLg4Cq4FBz8Wqw4uzro6uAqC4AeIm5uToouU+L+k0CLWg+N+vLv3uHsHCPUy06yucUDTbTOViIuZ7KoYeEUvwgghgFGZWcacJCXRcXzdw8fXuxjP6nzuzxFScxYDfCLxLDNMm3iDeHrTNjjvE0dYUVaJz4nHTLog8SPXFY/fOBdcFnhmxEyn5okjxGKhjZU2ZkVTI54ijqqaTvlCxmOV8xZnrVxlzXvyFwZz+soy12kOIYFFLEGCCAVVlFCGjRitOikWUrQf7+AfdP0SuRRylcDIsYAKNMiuH/wPfndr5ScnvKRgHOh+cZyPYSCwCzRqjvN97DiNE8D/DFzpLX+lDsx8kl5radEjoH8buLhuacoecLkDDDwZsim7kp+mkM8D72f0TVkgfAv0rXm9Nfdx+gCkqavkDXBwCIwUKHu9w7t72nv790yzvx9QEXKZwXQv9wAAAAZiS0dEADIANAAxUB4d7wAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+UJEw0JHX/9/lIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADUlEQVQI12Ng+M+gBgADKAEm2Ka93QAAAABJRU5ErkJggg==';
}
/**
* alt - The alt attribute of this image
*/
if (typeof options.alt === 'undefined') {
options.alt = '15% opaque 1x1 green pixel';
}
2021-09-18 11:06:19 +02:00
/**
* fileName - Name of the image under which it is stored
*/
if (typeof options.fileName === 'undefined') {
options.fileName = Utils.LowerUnderscore(options.name);
2021-09-13 09:39:38 +02:00
}
2021-09-18 11:06:19 +02:00
/**
* extension - Extension of the file name including the '.' (ex. '.jpg')
*/
if (typeof options.extension === 'undefined') {
2021-09-19 21:28:53 +02:00
options.extension = '.png';
2021-09-18 11:06:19 +02:00
}
/**
2021-09-19 21:28:53 +02:00
* external_path - Path to the image relative to the project defined API URL
2021-09-18 11:06:19 +02:00
*/
2021-09-19 21:28:53 +02:00
if (typeof options.external_path === 'undefined') {
options.external_path = '/images/' + options.id + '.png';
}
/**
* internal_path - Server side path on the server to the file, excluding filename
*/
if (typeof options.internal_path === 'undefined') {
options.internal_path = '/tmp/' + options.id + '.png';
2021-09-18 11:06:19 +02:00
}
/**
* contentType - Content type of the file (based on the extension, ex. 'image/jpeg')
*/
if (typeof options.contentType === 'undefined') {
2021-09-19 21:28:53 +02:00
options.contentType = 'image/png';
2021-09-18 11:06:19 +02:00
}
/**
* size - Size of the file in bytes
*/
if (typeof options.size === 'undefined') {
2021-09-19 21:28:53 +02:00
options.size = 565;
2021-09-18 11:06:19 +02:00
}
/**
* width - Width of the image in pixels
*/
if (typeof options.width === 'undefined') {
2021-09-19 21:28:53 +02:00
options.width = 1;
2021-09-18 11:06:19 +02:00
}
/**
* height - height of the image in pixels
*/
if (typeof options.height === 'undefined') {
2021-09-19 21:28:53 +02:00
options.height = 1;
2021-09-18 11:06:19 +02:00
}
/**
* orientation - The orientation of the image, one of 'square', 'landscape', 'portrait'
*/
if (typeof options.orientation === 'undefined') {
options.orientation = 'square';
}
if (options.extension.match(/(png)$/i)) {
options.contentType = 'image/png';
}
if (options.extension.match(/(jpg|jpeg)$/i)) {
options.contentType = 'image/jpeg';
}
if (options.extension.match(/(gif)$/i)) {
options.contentType = 'image/gif';
}
Object.assign(this, options);
if (this.width > this.height) {
this.orientation = 'landscape';
}
if (this.width < this.height) {
this.orientation = 'portrait';
}
if (this.width === this.height) {
this.orientation = 'square';
}
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
}
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
2021-09-19 21:28:53 +02:00
if (property === 'src') {
this.instance.src = this.src;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'src',
instanceProperty : 'src'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'alt') {
this.instance.alt = this.alt;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'alt',
instanceProperty : 'alt'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'external_path') {
this.instance.external_path = this.external_path;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'external_path',
instanceProperty : 'external_path'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'internal_path') {
this.instance.internal_path = this.internal_path;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'internal_path',
instanceProperty : 'internal_path'
}
);
if (property !== 'all') {
return;
}
}
2021-09-18 11:06:19 +02:00
if (property === 'size') {
this.instance.size = this.size;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'size',
instanceProperty : 'size'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'width') {
this.instance.width = this.width;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'width',
instanceProperty : 'width'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'height') {
this.instance.height = this.height;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'height',
instanceProperty : 'height'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'orientation') {
this.instance.orientation = this.orientation;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'orientation',
instanceProperty : 'orientation'
}
);
if (property !== 'all') {
return;
}
}
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
2021-09-19 21:28:53 +02:00
if (property === 'src' || property === 'all') {
this.src = this.instance.src;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'src',
instanceProperty : 'src'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'alt' || property === 'all') {
this.alt = this.instance.alt;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'alt',
instanceProperty : 'alt'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'external_path' || property === 'all') {
this.external_path = this.instance.external_path;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'external_path',
instanceProperty : 'external_path'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'internal_path' || property === 'all') {
this.internal_path = this.instance.internal_path;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'internal_path',
instanceProperty : 'internal_path'
}
);
if (property !== 'all') {
return;
}
}
2021-09-18 11:06:19 +02:00
if (property === 'size' || property === 'all') {
this.size = this.instance.size;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'size',
instanceProperty : 'size'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'width' || property === 'all') {
this.width = this.instance.width;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'width',
instanceProperty : 'width'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'height' || property === 'all') {
this.height = this.instance.height;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'height',
instanceProperty : 'height'
}
);
if (property !== 'all') {
return;
}
}
if (property === 'orientation' || property === 'all') {
this.orientation = this.instance.orientation;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'orientation',
instanceProperty : 'orientation'
}
);
if (property !== 'all') {
return;
}
}
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
/**
* initialize()
* - Also raises Event.IMAGE_INITIALIZED
*/
initialize() {
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-19 21:28:53 +02:00
Event.Emit(Event.IMAGE_COMPONENT_INITIALIZED, this);
this.createInstance();
}
2021-09-13 09:39:38 +02:00
}
}
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Graphics.Material
2021-09-13 09:39:38 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-13 09:39:38 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-13 09:39:38 +02:00
Inherited Static Methods:
<no inherited static methods>
[Inherited from Component]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
2021-09-07 07:58:29 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from ComponentGraphics]
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
Inherited Properties:
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
<no inherited properties>
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Properties:
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static properties>
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
Inherited Methods:
2021-09-07 07:58:29 +02:00
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-09 17:59:33 +02:00
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
2021-09-18 11:06:19 +02:00
Event.GRAPHICS_COMPONENT_INITIALIZED
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
Inherited Static Methods:
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
<no inherited static methods>
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
[Belonging to ComponentMaterial]
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class ComponentMaterial extends ComponentGraphics {
2021-09-07 07:58:29 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
2021-08-04 09:01:06 +02:00
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-08 04:59:31 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-09-07 07:58:29 +02:00
super(options);
2021-09-13 09:39:38 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-07 07:58:29 +02:00
Object.assign(this, options);
2021-09-08 04:59:31 +02:00
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-08 05:08:48 +02:00
} else {
2021-09-08 04:59:31 +02:00
options.callDepth--;
}
2021-08-04 09:01:06 +02:00
}
2021-09-13 09:39:38 +02:00
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
2021-07-04 20:32:41 +02:00
}
2021-09-10 09:40:19 +02:00
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Graphics.Mesh
2021-09-10 09:40:19 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-10 09:40:19 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
[Inherited from Component]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
2021-09-13 09:39:38 +02:00
Inherited Methods:
2021-09-10 09:40:19 +02:00
2021-09-13 09:39:38 +02:00
<no inherited methods>
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from ComponentGraphics]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialize()
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.GRAPHICS_COMPONENT_INITIALIZED
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentMesh]
2021-09-10 09:40:19 +02:00
Properties:
2021-09-13 09:39:38 +02:00
<no properties>
2021-09-10 09:40:19 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
<no methods>
2021-09-10 09:40:19 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentMesh extends ComponentGraphics {
2021-09-10 09:40:19 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-10 09:40:19 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
2021-09-13 09:39:38 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-10 09:40:19 +02:00
Object.assign(this, options);
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-10 09:40:19 +02:00
} else {
options.callDepth--;
}
}
2021-09-13 09:39:38 +02:00
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
2021-09-10 09:40:19 +02:00
}
2021-07-04 20:32:41 +02:00
/**
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Graphics.Texture
2021-07-04 20:32:41 +02:00
[Inherited from Event]
2021-06-18 02:10:32 +02:00
2021-09-06 09:38:54 +02:00
Inherited Properties:
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
<no inherited properties>
2021-06-18 02:10:32 +02:00
2021-09-06 09:38:54 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-07-04 20:32:41 +02:00
- async(eventId, data, clientCallback, clientErrorCallback)
2021-07-05 10:21:36 +02:00
Simply calls 'Async()' passing it the arguments
2021-07-04 20:32:41 +02:00
- emit(eventId, data, clientCallback, clientErrorCallback)
2021-07-05 10:21:36 +02:00
Simply calls 'Emit()' passing it the arguments
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
- subscribe(eventId, callback)
2021-07-05 10:21:36 +02:00
Simply calls 'Subscribe()' passing it the arguments
2021-06-18 02:10:32 +02:00
2021-09-06 09:38:54 +02:00
Inherited Static Methods:
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
- Async(eventId, data, clientCallback, clientErrorCallback)
2021-07-05 10:21:36 +02:00
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
- Emit(eventId, data, clientCallback, clientErrorCallback)
2021-07-05 10:21:36 +02:00
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
- Subscribe(eventId, callback)
2021-07-05 10:21:36 +02:00
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
[Inherited from R3Object]
2021-06-18 02:10:32 +02:00
2021-09-06 09:38:54 +02:00
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-07-04 20:32:41 +02:00
- register (Default value true)
2021-09-06 09:38:54 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-06 09:38:54 +02:00
Inherited Static Methods:
2021-07-04 20:32:41 +02:00
<no inherited static methods>
2021-09-07 07:58:29 +02:00
[Inherited from Component]
Inherited Properties:
2021-09-07 08:41:32 +02:00
<no inherited properties>
2021-09-07 07:58:29 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-13 09:39:38 +02:00
<no inherited methods>
2021-09-07 07:58:29 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from ComponentGraphics]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialize()
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.GRAPHICS_COMPONENT_INITIALIZED
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentTexture]
2021-07-04 20:32:41 +02:00
Properties:
2021-06-18 02:10:32 +02:00
2021-09-13 09:39:38 +02:00
<no properties>
2021-09-06 09:38:54 +02:00
Static Properties:
2021-07-04 20:32:41 +02:00
<no static properties>
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
Methods:
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
<no methods>
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
Static Methods:
2021-06-18 02:10:32 +02:00
2021-07-04 20:32:41 +02:00
<no static methods>
2021-07-04 20:32:41 +02:00
**/
2021-09-18 11:06:19 +02:00
class ComponentTexture extends ComponentGraphics {
2021-07-04 20:32:41 +02:00
constructor(options) {
2021-08-04 10:50:28 +02:00
if (typeof options === 'undefined') {
2021-06-20 20:46:13 +02:00
options = {};
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-08 04:59:31 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
2021-07-04 20:32:41 +02:00
super(options);
2021-06-20 20:46:13 +02:00
2021-09-13 09:39:38 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-07-04 20:32:41 +02:00
Object.assign(this, options);
2021-09-08 04:59:31 +02:00
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-08 05:08:48 +02:00
} else {
2021-09-08 04:59:31 +02:00
options.callDepth--;
}
2021-09-09 17:59:33 +02:00
}
2021-09-13 09:39:38 +02:00
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
2021-07-04 20:32:41 +02:00
}
2021-09-08 08:25:16 +02:00
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Input
2021-09-08 08:25:16 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-08 08:25:16 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-08 08:25:16 +02:00
Inherited Static Methods:
<no inherited static methods>
[Inherited from Component]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-13 09:39:38 +02:00
<no inherited methods>
2021-09-08 08:25:16 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to ComponentInput]
2021-09-08 08:25:16 +02:00
Properties:
2021-09-18 11:06:19 +02:00
<no properties>
2021-09-08 08:25:16 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
- initialize()
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
Event.INPUT_COMPONENT_INITIALIZED
2021-09-08 08:25:16 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentInput extends Component {
2021-09-08 08:25:16 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-08 08:25:16 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
2021-09-13 09:39:38 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-13 09:39:38 +02:00
2021-09-08 08:25:16 +02:00
Object.assign(this, options);
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-08 08:25:16 +02:00
} else {
options.callDepth--;
}
}
2021-09-10 14:03:19 +02:00
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
2021-09-10 14:03:19 +02:00
*/
updateInstance(property) {
2021-09-10 14:03:19 +02:00
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
2021-09-10 14:03:19 +02:00
*/
updateFromInstance(property) {
2021-09-10 14:03:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
2021-09-18 11:06:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
/**
* initialize()
* - In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
* Event.INPUT_COMPONENT_INITIALIZED
*/
initialize() {
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-10 14:26:03 +02:00
2021-09-19 21:28:53 +02:00
Event.Emit(Event.INPUT_COMPONENT_INITIALIZED, this);
this.createInstance();
}
2021-09-10 14:03:19 +02:00
}
2021-09-08 08:25:16 +02:00
}
2021-09-10 09:40:19 +02:00
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Component.Input.Touch
2021-09-10 09:40:19 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-10 09:40:19 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
[Inherited from Component]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-13 09:39:38 +02:00
<no inherited methods>
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Inherited from ComponentInput]
2021-09-10 09:40:19 +02:00
Inherited Properties:
2021-09-13 09:39:38 +02:00
<no inherited properties>
2021-09-10 09:40:19 +02:00
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-10 09:40:19 +02:00
In addition to firing an Event.OBJECT_INITIALIZED and Event.COMPONENT_INITIALIZED, it also fires an
2021-09-18 11:06:19 +02:00
Event.INPUT_COMPONENT_INITIALIZED
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to ComponentTouch]
2021-09-10 09:40:19 +02:00
Properties:
2021-09-18 11:06:19 +02:00
<no properties>
2021-09-10 09:40:19 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
<no methods>
2021-09-10 09:40:19 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class ComponentTouch extends ComponentInput {
2021-09-10 09:40:19 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-10 09:40:19 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
2021-09-13 09:39:38 +02:00
/**
* parent - The parent R3.Object of this component
*/
if (typeof options.parent === 'undefined') {
options.parent = null;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
2021-09-10 09:40:19 +02:00
Object.assign(this, options);
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-10 09:40:19 +02:00
} else {
options.callDepth--;
}
2021-09-13 09:39:38 +02:00
}
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
2021-09-10 14:03:19 +02:00
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
2021-09-13 09:39:38 +02:00
* - Updates this object by copying the values of its instance into the current object.
* @param property
2021-09-10 14:03:19 +02:00
*/
2021-09-13 09:39:38 +02:00
updateFromInstance(property) {
2021-09-10 14:03:19 +02:00
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
2021-09-10 09:40:19 +02:00
}
/**
2021-09-18 11:06:19 +02:00
Class R3.Event.Object.Project
2021-09-10 09:40:19 +02:00
[Inherited from Event]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Inherited Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Inherited Properties:
2021-09-14 06:13:26 +02:00
- id (Default value Utils.RandomId(10) - Each Object receives an 10 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
2021-09-10 09:40:19 +02:00
- register (Default value true)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
2021-09-10 10:59:34 +02:00
- initialize()
2021-09-14 06:13:26 +02:00
Should raises an event(s) which indicates that this object initialized
2021-09-10 09:40:19 +02:00
Inherited Static Methods:
<no inherited static methods>
2021-09-18 11:06:19 +02:00
[Belonging to Project]
2021-09-10 09:40:19 +02:00
Properties:
2021-09-13 09:39:38 +02:00
<no properties>
2021-09-10 09:40:19 +02:00
Static Properties:
<no static properties>
Methods:
2021-09-18 11:06:19 +02:00
- initialize()
Overrides for R3.Event.R3Object.initialize()
2021-09-10 09:40:19 +02:00
Static Methods:
<no static methods>
**/
2021-09-18 11:06:19 +02:00
class Project extends R3Object {
2021-09-10 09:40:19 +02:00
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 10:59:34 +02:00
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
2021-09-10 09:40:19 +02:00
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
Object.assign(this, options);
if (options.callDepth === 0) {
2021-09-10 10:59:34 +02:00
this.initialize();
2021-09-10 09:40:19 +02:00
} else {
options.callDepth--;
}
}
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* initialize()
* - Should raises an event(s) which indicates that this object initialized
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
initialize() {
2021-09-10 14:03:19 +02:00
2021-09-19 21:28:53 +02:00
try {
super.initialize();
} catch (err) {
if (!(err instanceof TypeError)) {
//Another unexpected error occurred - and we are not inside a base class
throw err;
}
2021-09-18 11:06:19 +02:00
delete this.callDepth;
this.initialized = true;
2021-09-19 21:28:53 +02:00
this.createInstance();
2021-09-18 11:06:19 +02:00
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.PROJECT_INITIALIZED, this);
2021-09-10 14:03:19 +02:00
}
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
class Utils {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
constructor(options) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (typeof options === 'undefined') {
options = {};
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
Object.assign(this, options);
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static GetFirstParent(object, constructor) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(constructor)) {
throw new Error('You need to specify a constructor');
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (object.parent === null) {
return null;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (object.parent instanceof constructor) {
return object.parent;
} else {
return Utils.GetFirstParent(object.parent, constructor);
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static SyntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\u[a-zA-Z0-9]{4}|\[^u]|[^\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
let cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static GetParentProject(component) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(component.parent)) {
throw new Error('Parent not found');
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (component.parent instanceof R3.Project) {
return component.parent;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return Utils.GetParentProject(component.parent);
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static GetParents(component, parents) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(parents)) {
parents = [];
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(component.parent)) {
return parents;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
parents.push(component.parent);
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return Utils.GetParents(component.parent, parents);
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* @return {boolean}
*/
static Instance(component) {
return Utils.Defined(component) && Utils.Defined(component.instance);
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Utils.RemoveFromSelect
* @param select
* @param id
* @returns {boolean}
* @constructor
*/
static RemoveFromSelect(select, id) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let i;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
for (i = 0; i < select.options.length; i++) {
if (select.options[i].value === id) {
select.remove(i);
return true;
}
}
return false;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Utils.GetSelectIndex
*
* Get the select index of given id
*
* @param select
* @param id
* @returns boolean true if successful
*
* @constructor
*/
static SetSelectIndex(select, id) {
for (let i = 0; i < select.options.length; i++) {
if (select.options[i].value === id) {
select.selectedIndex = i;
return true;
}
}
return false;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static SortSelect(select) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let tmp = [];
let i;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
for (i = 1; i < select.options.length; i++) {
tmp[i-1] = [];
tmp[i-1][0] = select.options[i].text;
tmp[i-1][1] = select.options[i].value;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
tmp.sort();
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
select.options = [select.options[0]];
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
for (i = 0; i < tmp.length; i++) {
select.options[i+1] = new Option(tmp[i][0], tmp[i][1]);
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Gets the parent of object whith property of optional type constructor. If index is specified, get the parent of the
* object with property[index] - which means the property should be an array
* @param object
* @param property
* @param index
* @param constructor
* @returns {*}
* @constructor
*/
static GetParent(object, property, index, constructor) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(constructor)) {
constructor = null;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(index)) {
index = null;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (object.parent) {
/**
* Parent defined
*/
if (object.parent.hasOwnProperty(property)) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (constructor) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (index) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (object.parent[property][index] instanceof constructor) {
return object.parent[property][index];
} else {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
} else {
if (object.parent[property] instanceof constructor) {
return object.parent[property];
} else {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
}
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
} else {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (index) {
return object.parent[property][index];
} else {
return object.parent[property];
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
}
} else {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* This parent does not have the property - go a level higher
*/
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
} else {
/**
* No parent defined
*/
console.warn('property : ' + property + ' of type ' + constructor + ' was not found in the parent chain');
return null;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Strips image extension from given path
* @param imagePath
* @constructor
*/
static StripImageExtension(imagePath) {
return imagePath.replace(/(\.png$|\.gif$|\.jpeg$|\.jpg$)/,'')
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Returns true if unloaded
* @param component
* @returns {boolean}
* @constructor
*/
static Unloaded(component) {
if (
Utils.UndefinedOrNull(component) ||
Utils.UndefinedOrNull(component.instance)
) {
return true;
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
return false;
};
2021-09-10 10:59:34 +02:00
2021-09-18 11:06:19 +02:00
/**
*
* @param component
* @returns {boolean}
* @constructor
*/
static Loaded(component) {
if (component && component.instance) {
return true;
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
return false;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static BuildVectorSource(result, name, dimension) {
if (dimension === 2) {
result[name] = {};
result[name].x = false;
result[name].y = false;
return;
}
2021-09-18 11:06:19 +02:00
if (dimension === 3) {
result[name] = {};
result[name].x = false;
result[name].y = false;
result[name].y = false;
return;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (dimension === 4) {
result[name] = {};
result[name].x = false;
result[name].y = false;
result[name].z = false;
result[name].w = false;
return;
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
console.warn('unknown dimension : ' + dimension);
};
2021-09-10 09:40:19 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* Returns all 'instances' of the array, or null if an 'instance' is undefined
* @constructor
* @param array
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
static GetArrayInstances(array) {
return array.reduce(
function(result, object) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (result === null) {
return result;
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(object.instance)) {
result = null;
} else {
result.push(object.instance);
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
return result;
},
[]
);
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static SortFacesByMaterialIndex(faces) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Sorts faces according to material index because later we will create
* groups for each vertice group
*/
faces.sort(function(a, b) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (a.materialIndex < b.materialIndex) {
return -1;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (a.materialIndex > b.materialIndex) {
return 1;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return 0;
});
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return faces;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static BuildQuaternionSource(result, name) {
result[name] = {};
result[name].axis = {};
result[name].axis.x = false;
result[name].axis.y = false;
result[name].axis.z = false;
result[name].angle = false;
result[name].x = false;
result[name].y = false;
result[name].z = false;
result[name].w = false;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static ObjectPropertiesAsBoolean(object) {
return Object.keys(object).reduce(
function(result, propertyId) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (typeof object[propertyId] === 'function') {
return result;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
result[propertyId] = false;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
// if (object[propertyId] instanceof R3.Vector2) {
// Utils.BuildVectorSource(result, propertyId, 2);
// }
//
// if (object[propertyId] instanceof R3.Vector3) {
// Utils.BuildVectorSource(result, propertyId, 3);
// }
//
// if (object[propertyId] instanceof R3.Vector4) {
// Utils.BuildVectorSource(result, propertyId, 4);
// }
//
// if (object[propertyId] instanceof R3.Quaternion) {
// Utils.BuildQuaternionSource(result, propertyId);
// }
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return result;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
}.bind(this),
{}
);
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static GetRuntime() {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let result = null;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
R3.Event.Emit(
R3.Event.GET_RUNTIME,
null,
function(runtime) {
result = runtime;
}
);
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return result;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Returns the window size or null
* @returns {*}
* @constructor
*/
static GetWindowSize() {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let size = null;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
R3.Event.Emit(
R3.Event.GET_WINDOW_SIZE,
null,
function(data) {
size = data;
}.bind(this)
);
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return size;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Convenience function to update object width and height members with window size
* @param object
* @constructor
*/
static UpdateWindowSize(object) {
let size = Utils.GetWindowSize();
object.width = size.width;
object.height = size.height;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Returns id of object with the name if it exists in the array, otherwise null
* @param name
* @param array
* @returns {*}
* @constructor
*/
static ObjectIdWithNameInArray(name, array) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return array.reduce(
function(result, object) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (result) {
return result;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (name === object.name) {
return object.id;
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return null;
},
null
);
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static LoadIdsFromArrayToIdObject(array, idToObject) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static LoadIdsFromObjectToIdObject(object, idToObject) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Gets random int exclusive of maximum but inclusive of minimum
* @param min
* @param max
* @returns {*}
* @constructor
*/
static GetRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Gets random int inclusive of minimum and maximum
* @param min
* @param max
* @returns {*}
* @constructor
*/
static GetRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
static InterpolateArray(data, fitCount) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let linearInterpolate = function(before, after, atPoint) {
return before + (after - before) * atPoint;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let newData = [];
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let springFactor = Number((data.length - 1) / (fitCount - 1));
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
newData[0] = data[0]; // for new allocation
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
for ( let i = 1; i < fitCount - 1; i++) {
let tmp = i * springFactor;
let before = Number(Math.floor(tmp)).toFixed();
let after = Number(Math.ceil(tmp)).toFixed();
let atPoint = tmp - before;
newData[i] = linearInterpolate(data[before], data[after], atPoint);
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
newData[fitCount - 1] = data[data.length - 1]; // for new allocation
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
return newData;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Undefined or null check
* @param variable
* @returns {boolean}
* @constructor
*/
static UndefinedOrNull(
variable
) {
return typeof variable === 'undefined' || variable === null;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* The variable is not undefined and not null
* @param variable
* @returns {boolean}
* @constructor
*/
static Defined(
variable
) {
return typeof variable !== 'undefined' && variable !== null;
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Gets function parameters
* @param fn
* @constructor
*/
static GetParameters(fn) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
let FN_ARG_SPLIT = /,/;
let FN_ARG = /^\s*(_?)(.+?)\s*$/;
let STRIP_COMMENTS = /(\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s*=[^,\)]*(('(?:\'|[^'\r\n])*')|("(?:\"|[^"\r\n])*"))|(\s*=[^,\)]*))/mg;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let parameters,
fnText,
argDecl;
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
if (typeof fn !== 'function') {
parameters = [];
fnText = fn.toString().replace(STRIP_COMMENTS, '');
argDecl = fnText.match(FN_ARGS);
argDecl[1].split(FN_ARG_SPLIT).forEach(function(arg) {
arg.replace(FN_ARG, function(all, underscore, name) {
parameters.push(name);
});
});
} else {
throw Error("not a function")
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
return parameters;
};
2021-09-10 10:59:34 +02:00
2021-09-18 11:06:19 +02:00
/**
* Returns either an ID of the object or Null
* @param object
* @returns {null}
* @constructor
*/
static IdOrNull(object) {
if (Utils.UndefinedOrNull(object)) {
return null;
2021-09-10 09:40:19 +02:00
} else {
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(object.id)) {
console.warn('saving an object reference with no ID : ', object);
return null;
}
return object.id;
2021-09-10 09:40:19 +02:00
}
2021-09-18 11:06:19 +02:00
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Limit a property to values between -pi and +pi
* @param property
* @param objectProperty
* @returns {{configurable?: boolean, enumerable?: boolean, value?, writable?: boolean, get?: Function, set?: Function}}
* @constructor
*/
static LimitToPI(property, objectProperty) {
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
let store = objectProperty;
2021-09-18 11:06:19 +02:00
return {
get : function() {
return store;
},
set : function(value) {
while (value > Math.PI) {
value -= (Math.PI * 2);
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
while (value < -(Math.PI)) {
value += (Math.PI * 2);
}
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
store = value;
}
};
};
2021-09-10 09:40:19 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* Returns an array of IDs representing the objects
* @param array
* @returns []
* @constructor
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
static IdArrayOrEmptyArray(array) {
if (Utils.UndefinedOrNull(array)) {
return [];
} else {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
return array.map(function(item) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(item.id)) {
throw new Error('No ID found while trying to store IDs to array');
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
return item.id
});
}
};
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* Links an object to its parent through idToObject array
* @param propertyString
* @param idToObject
* @param parentObject
* @param id
* @constructor
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
static Link(propertyString, idToObject, parentObject, id) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (!Utils.UndefinedOrNull(parentObject[propertyString])) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
if (!idToObject.hasOwnProperty(id)) {
console.warn('Linking failed for object:' + parentObject.name);
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
parentObject[propertyString] = idToObject[id];
}
};
2021-09-10 09:40:19 +02:00
2021-09-18 11:06:19 +02:00
/**
* Generates a random ID
* @returns {string}
* @constructor
*/
static RandomId(length) {
2020-04-21 11:54:13 +02:00
2021-09-18 11:06:19 +02:00
if (Utils.UndefinedOrNull(length)) {
length = 10;
}
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
return Math.random().toString(36).substr(2, length);
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static InvertWindingOrder(triangles) {
2020-04-21 11:54:13 +02:00
2021-09-18 11:06:19 +02:00
for (let i = 0; i < triangles.length; i++) {
let v1 = triangles[i].v1;
triangles[i].v1 = triangles[i].v2;
triangles[i].v2 = v1;
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
let backupUV = triangles[i].triangle.v1uv;
triangles[i].triangle.v1uv = triangles[i].triangle.v2uv;
triangles[i].triangle.v2uv = backupUV;
}
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
return triangles;
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
/**
* Inverts a mesh winding order (and its instance)
* @param mesh R3.D3.Mesh
* @returns {*}
* @constructor
*/
static InvertMeshWindingOrder(mesh) {
2020-04-21 11:54:13 +02:00
2021-09-18 11:06:19 +02:00
mesh.faces.forEach(
function(face) {
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
let tmpV1 = face.v1;
face.v1 = face.v2;
face.v2 = tmpV1;
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
let tmpV1uv = face.v1uv;
face.v1uv = face.v2uv;
face.v2uv = tmpV1uv;
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
}.bind(this)
);
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
//mesh.computeNormals = true;
//mesh.createInstance();
};
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
/**
* This function resets a the winding order of a mesh from a reference point V (the average center of the mesh)
*/
static ResetWindingOrder(faces, vertices) {
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
let vertexList = new R3.API.Vector3.Points();
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
for (let v = 0; v < vertices.length; v++) {
vertexList.add(new R3.API.Vector3(
vertices[v].position.x,
vertices[v].position.y,
vertices[v].position.z
));
}
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
let V = vertexList.average();
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
let triangles = [];
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
for (let s = 0; s < faces.length; s += 3) {
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
let v0 = faces[s];
let v1 = faces[s+1];
let v2 = faces[s+2];
2021-09-18 11:06:19 +02:00
triangles.push(
{
v0 : v0,
v1 : v1,
v2 : v2,
edges : [
{v0: v0, v1: v1},
{v0: v1, v1: v2},
{v0: v2, v1: v0}
],
winding : 0,
edgeIndex : -1,
processed : false
}
);
}
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
for (let i = 0; i < triangles.length; i++) {
if (
R3.API.Vector3.clockwise(
vertices[triangles[i].v0].position,
vertices[triangles[i].v1].position,
vertices[triangles[i].v2].position,
V
)
) {
console.log('clockwise');
let bv1 = triangles[i].v1;
triangles[i].v1 = triangles[i].v2;
triangles[i].v2 = bv1;
} else {
console.log('not clockwise');
}
}
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
return triangles;
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
/**
* This function resets the winding order for triangles in faces, given an initial triangle and orientation edge
* used pseudocode from
* http://stackoverflow.com/questions/17036970/how-to-correct-winding-of-triangles-to-counter-clockwise-direction-of-a-3d-mesh
* We need to use a graph traversal algorithm,
* lets assume we have method that returns neighbor of triangle on given edge
*
* neighbor_on_egde( next_tria, edge )
*
* to_process = set of pairs triangle and orientation edge, initial state is one good oriented triangle with any edge on it
* processed = set of processed triangles; initial empty
*
* while to_process is not empty:
* next_tria, orientation_edge = to_process.pop()
* add next_tria in processed
* if next_tria is not opposite oriented than orientation_edge:
* change next_tria (ABC) orientation (B<->C)
* for each edge (AB) in next_tria:
* neighbor_tria = neighbor_on_egde( next_tria, edge )
* if neighbor_tria exists and neighbor_tria not in processed:
* to_process add (neighbor_tria, edge opposite oriented (BA))
* @param faces R3.D3.Face[]
* @param orientationEdge R3.API.Vector2
* @returns {Array}
*/
static FixWindingOrder(faces, orientationEdge) {
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
/**
* Checks if a Face belonging to a TriangleEdge has already been processed
* @param processed TriangleEdge[]
* @param triangle Face
* @returns {boolean}
*/
function inProcessed(processed, triangle) {
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
for (let i = 0; i < processed.length; i++) {
if (processed[i].triangle.equals(triangle)) {
return true;
}
}
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
return false;
}
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
/**
* Returns a neighbouring triangle on a specific edge - preserving the edge orientation
* @param edge R3.API.Vector2
* @param faces R3.D3.Face[]
* @param currentTriangle
* @returns {*}
*/
function neighbourOnEdge(edge, faces, currentTriangle) {
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
for (let i = 0; i < faces.length; i++) {
if (
(faces[i].v0 === edge.x && faces[i].v1 === edge.y) ||
(faces[i].v1 === edge.x && faces[i].v2 === edge.y) ||
(faces[i].v2 === edge.x && faces[i].v0 === edge.y) ||
(faces[i].v0 === edge.y && faces[i].v1 === edge.x) ||
(faces[i].v1 === edge.y && faces[i].v2 === edge.x) ||
(faces[i].v2 === edge.y && faces[i].v0 === edge.x)
) {
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
let triangle = new R3.D3.API.Face(
null,
null,
faces[i].v0index,
faces[i].v1index,
faces[i].v2index,
faces[i].materialIndex,
faces[i].uvs
);
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
if (triangle.equals(currentTriangle)) {
continue;
}
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
return new R3.D3.TriangleEdge(
triangle,
edge
);
}
}
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
return null;
}
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
let toProcess = [
new R3.D3.TriangleEdge(
new R3.D3.API.Face(
null,
null,
faces[0].v0index,
faces[0].v1index,
faces[0].v2index,
faces[0].materialIndex,
faces[0].uvs
),
orientationEdge
)
];
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
let processed = [];
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
while (toProcess.length > 0) {
let triangleEdge = toProcess.pop();
/**
* If edge is the same orientation (i.e. the edge order is the same as the given triangle edge) it needs to be reversed
* to have the same winding order)
*/
if (
(triangleEdge.triangle.v0index === triangleEdge.edge.x &&
triangleEdge.triangle.v1index === triangleEdge.edge.y) ||
(triangleEdge.triangle.v1index === triangleEdge.edge.x &&
triangleEdge.triangle.v2index === triangleEdge.edge.y) ||
(triangleEdge.triangle.v2index === triangleEdge.edge.x &&
triangleEdge.triangle.v0index === triangleEdge.edge.y)
) {
let backupV = triangleEdge.triangle.v1index;
triangleEdge.triangle.v1index = triangleEdge.triangle.v2index;
triangleEdge.triangle.v2index = backupV;
// let backupUV = triangleEdge.triangle.v1uv;
// triangleEdge.triangle.v1uv = triangleEdge.triangle.v2uv;
// triangleEdge.triangle.v2uv = backupUV;
//
let backupUV = triangleEdge.triangle.uvs[0][1];
triangleEdge.triangle.uvs[0][1] = triangleEdge.triangle.uvs[0][2];
triangleEdge.triangle.uvs[0][2] = backupUV;
}
processed.push(triangleEdge);
let edges = [
new R3.API.Vector2(
triangleEdge.triangle.v0index,
triangleEdge.triangle.v1index
),
new R3.API.Vector2(
triangleEdge.triangle.v1index,
triangleEdge.triangle.v2index
),
new R3.API.Vector2(
triangleEdge.triangle.v2index,
triangleEdge.triangle.v0index
)
];
for (let j = 0; j < edges.length; j++) {
let neighbour = neighbourOnEdge(edges[j], faces, triangleEdge.triangle);
if (neighbour && !inProcessed(processed, neighbour.triangle)) {
toProcess.push(neighbour);
}
}
}
/**
* In processed - we will have some duplicates - only add the unique ones
* @type {Array}
*/
let triangles = [];
for (let i = 0; i < processed.length; i++) {
let found = false;
for (let k = 0; k < triangles.length; k++) {
if (triangles[k].equals(processed[i].triangle)){
found = true;
break;
}
}
if (!found) {
triangles.push(processed[i].triangle);
}
}
return triangles;
};
/**
* This is a work-around function to fix polys which don't triangulate because
* they could lie on Z-plane (XZ or YZ)) - we translate the poly to the origin, systematically rotate the poly around
* Z then Y axis
* @param verticesFlat []
* @param grain is the amount to systematically rotate the poly by - a finer grain means a more accurate maximum XY
* @return []
*/
static FixPolyZPlane(verticesFlat, grain) {
if ((verticesFlat.length % 3) !== 0 && !(verticesFlat.length > 9)) {
console.log("The vertices are not in the right length : " + verticesFlat.length);
}
let vertices = [];
let points = new R3.API.Quaternion.Points();
for (let i = 0; i < verticesFlat.length; i += 3) {
points.add(new R3.API.Vector3(
verticesFlat[i],
verticesFlat[i + 1],
verticesFlat[i + 2]
));
}
points.toOrigin();
points.maximizeXDistance(grain);
points.maximizeYDistance(grain);
for (i = 0; i < points.vectors.length; i++) {
vertices.push(
[
points.vectors[i].x,
points.vectors[i].y
]
);
}
return vertices;
};
static MovingAverage(period) {
let nums = [];
return function(num) {
nums.push(num);
if (nums.length > period)
nums.splice(0,1); // remove the first element of the array
let sum = 0;
for (let i in nums)
sum += nums[i];
let n = period;
if (nums.length < period)
n = nums.length;
return(sum/n);
}
};
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
static Intersect(a, b) {
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
let t;
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
/**
* Loop over shortest array
*/
if (b.length > a.length) {
t = b;
b = a;
a = t;
}
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
return a.filter(
/**
* Check if exists
* @param e
* @returns {boolean}
*/
function(e) {
return (b.indexOf(e) > -1);
}
).filter(
/**
* Remove Duplicates
* @param e
* @param i
* @param c
* @returns {boolean}
*/
function(e, i, c) {
return c.indexOf(e) === i;
}
);
};
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
static Difference(a, b) {
2021-09-07 07:58:29 +02:00
2021-09-18 11:06:19 +02:00
let t;
2020-02-27 17:07:46 +01:00
2021-09-18 11:06:19 +02:00
/**
* Loop over shortest array
*/
if (b.length > a.length) {
t = b;
b = a;
a = t;
}
2020-04-23 15:26:54 +02:00
2021-09-18 11:06:19 +02:00
return a.filter(
/**
* Check if exists
* @param e
* @returns {boolean}
*/
function(e) {
return (b.indexOf(e) === -1);
}
).filter(
/**
* Remove Duplicates
* @param e
* @param i
* @param c
* @returns {boolean}
*/
function(e, i, c) {
return c.indexOf(e) === i;
}
);
};
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
/**
* Push only if not in there already
* @param array
* @param object
* @constructor
*/
static PushUnique(array, object) {
2021-09-06 09:38:54 +02:00
2021-09-18 11:06:19 +02:00
if (array.indexOf(object) === -1) {
array.push(object);
}
};
2020-04-23 15:26:54 +02:00
2021-09-18 11:06:19 +02:00
/**
* Checks whether or not the object is empty
* @param obj
* @returns {boolean}
* @constructor
*/
static IsEmpty(obj) {
return (Object.keys(obj).length === 0 && obj.constructor === Object);
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static IsString(member) {
return (typeof member === 'string');
};
2020-04-23 15:26:54 +02:00
2021-09-18 11:06:19 +02:00
static IsBoolean(member) {
return (member === true || member === false);
};
2020-04-23 15:26:54 +02:00
2021-09-18 11:06:19 +02:00
static IsColor(member) {
return (member instanceof R3.Color);
};
2020-04-23 15:26:54 +02:00
2021-09-18 11:06:19 +02:00
static IsNumber(member) {
return (typeof member === 'number');
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static IsVector2(member) {
return (
member instanceof R3.API.Vector2 ||
member instanceof R3.Vector2
);
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static IsVector3(member) {
return (
member instanceof R3.API.Vector3 ||
member instanceof R3.Vector3
);
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static IsVector4(member) {
return (
member instanceof R3.API.Vector4 ||
member instanceof R3.Vector4 ||
member instanceof R3.API.Quaternion ||
member instanceof R3.Quaternion
);
};
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
static IsObject(member) {
let type = typeof member;
return type === 'function' || type === 'object' && !!member;
};
2021-09-10 10:59:34 +02:00
2021-09-18 11:06:19 +02:00
/**
* @return {string}
*/
static LowerUnderscore(name) {
let string = name.toLowerCase().replace(/\s+/g, '_');
string = string.replace(/-/g, '_');
string = string.replace(/\_+/g, '_');
return string;
};
2021-09-08 04:59:31 +02:00
2021-09-18 11:06:19 +02:00
static UpperCaseWordsSpaces(input) {
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
let word = input.replace(/[-_]/g, ' ');
2021-09-18 11:06:19 +02:00
word = word.replace(/\s+/, ' ');
2021-06-18 02:10:32 +02:00
2021-09-18 11:06:19 +02:00
let words = word.split(' ');
2021-09-08 04:59:31 +02:00
2021-09-18 11:06:19 +02:00
return words.reduce(
function(result, word) {
result += word[0].toUpperCase() + word.substr(1);
return result + ' ';
},
''
).trim();
};
2021-07-04 20:32:41 +02:00
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* @return {string}
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
static UpperCaseUnderscore(word) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
let str = '';
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
word.split('').map(
function(letter){
if (letter === letter.toUpperCase()) {
str += '_' + letter;
} else {
str += letter.toUpperCase();
}
});
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
str = str.replace(new RegExp('^_'),'');
return str;
};
2021-09-10 14:03:19 +02:00
/**
2021-09-18 11:06:19 +02:00
* Returns Left Padded Text - ex. length 5, padchar 0, string abc = '00abc'
* @param length
* @param padChar
* @param string
* @returns {string}
* @constructor
2021-09-10 14:03:19 +02:00
*/
2021-09-18 11:06:19 +02:00
static PaddedText(length, padChar, string) {
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
let pad = "";
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
for (let x = 0; x < length; x++) {
pad += padChar;
}
2021-09-10 14:03:19 +02:00
2021-09-18 11:06:19 +02:00
return pad.substring(0, pad.length - string.length) + string;
};
2021-09-10 14:03:19 +02:00
2021-07-04 20:32:41 +02:00
}
2021-09-08 08:46:38 +02:00
System.DOM = SystemDOM;
2021-09-08 07:48:51 +02:00
System.Input = SystemInput;
System.Linking = SystemLinking;
2021-09-11 06:53:30 +02:00
System.Render = SystemRender;
2021-09-09 18:09:09 +02:00
System.Runtime = SystemRuntime;
2021-09-08 07:48:51 +02:00
System.Socket = SystemSocket;
2021-09-17 11:28:07 +02:00
System.Storage = SystemStorage;
2021-09-10 10:01:59 +02:00
Component.DOM = ComponentDOM;
Component.DOM.Canvas = ComponentCanvas;
Component.Graphics = ComponentGraphics;
Component.Graphics.Image = ComponentImage;
Component.Graphics.Material = ComponentMaterial;
Component.Graphics.Mesh = ComponentMesh;
Component.Graphics.Texture = ComponentTexture;
Component.Input = ComponentInput;
Component.Input.Touch = ComponentTouch;
2021-09-18 08:52:21 +02:00
Runtime.Coder = RuntimeCoder;
Runtime.Coder.CodeMirror = RuntimeCodeMirror;
Runtime.DOM = RuntimeDOM;
Runtime.DOM.Document = RuntimeDocument;
Runtime.GUI = RuntimeGUI;
Runtime.GUI.ControlKit = RuntimeControlKit;
2021-09-10 09:40:19 +02:00
Runtime.Graphics = RuntimeGraphics;
Runtime.Graphics.Three = RuntimeThree;
2021-09-18 08:52:21 +02:00
Runtime.Image = RuntimeImage;
Runtime.Image.NodeJSImage = RuntimeNodeJSImage;
Runtime.Image.WebImage = RuntimeWebImage;
Runtime.Physics = RuntimePhysics;
Runtime.Physics.Bullet = RuntimeBullet;
Runtime.Socket = RuntimeSocket;
Runtime.Statistics = RuntimeStatistics;
Runtime.Statistics.Stats = RuntimeStats;
2021-09-10 10:01:59 +02:00
Entity.Slider = EntitySlider;
2021-09-18 11:06:19 +02:00
R3.Runtime = Runtime;
R3.System = System;
R3.Event = Event;
R3.Utils = Utils;
R3.Object = R3Object;
R3.Entity = Entity;
R3.Component = Component;
R3.Project = Project;
R3.Canvas = Component.DOM.Canvas;
R3.Image = Component.Graphics.Image;
R3.Material = Component.Graphics.Material;
R3.Mesh = Component.Graphics.Mesh;
R3.Texture = Component.Graphics.Texture;
R3.Touch = Component.Input.Touch;
2021-09-14 06:13:26 +02:00
2021-07-05 10:21:36 +02:00
console.log('r3.js - version ' + R3.version + ' compiled ' + R3.compileDate);
2021-09-18 11:06:19 +02:00
R3.System.DOM.Start();
R3.System.Input.Start();
R3.System.Linking.Start();
R3.System.Render.Start();
R3.System.Runtime.Start();
R3.System.Socket.Start();
R3.System.Storage.Start();