entities become transient systems

master
Theunis J. Botha 2021-09-22 13:07:05 +02:00
parent 0c5701aa1c
commit ecc7b71380
27 changed files with 1392 additions and 208 deletions

View File

@ -40,3 +40,4 @@ r3 create RuntimeImage runtime_base ./r3-runtime/
r3 create RuntimeWebImage runtime_extends RuntimeImage ./r3-runtime/
r3 create RuntimeNodeJSImage runtime_extends RuntimeImage ./r3-runtime/
r3 create Runtime base ./r3-runtime/
r3 create ComponentCode component_extends Component

6
dist/index.html vendored
View File

@ -30,6 +30,12 @@
window.addEventListener("load", function(){
let canvas = new R3.Canvas();
let image = new R3.Image();
let slider = new R3.Entity.Slider(
{
canvas : canvas,
images : [image]
}
);
});
</script>
</body>

660
dist/r3.js vendored
View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.851';
static compileDate = '2021 Sep 21 - 14:45:57 pm';
static version = '2.0.869';
static compileDate = '2021 Sep 22 - 13:06:11 pm';
}
class Runtime {
@ -1323,6 +1323,11 @@ class SystemLinking extends System {
SystemLinking.OnComponentInitialized
);
SystemLinking.Subscriptions['ENTITY_INITIALIZED'] = Event.Subscribe(
Event.ENTITY_INITIALIZED,
SystemLinking.OnEntityInitialized
);
SystemLinking.Subscriptions['INSTANCE_CREATED'] = Event.Subscribe(
Event.INSTANCE_CREATED,
SystemLinking.OnInstanceCreated
@ -1352,6 +1357,9 @@ class SystemLinking extends System {
SystemLinking.Subscriptions['COMPONENT_INITIALIZED'].remove();
delete SystemLinking.Subscriptions['COMPONENT_INITIALIZED'];
SystemLinking.Subscriptions['ENTITY_INITIALIZED'].remove();
delete SystemLinking.Subscriptions['ENTITY_INITIALIZED'];
SystemLinking.Subscriptions['INSTANCE_CREATED'].remove();
delete SystemLinking.Subscriptions['INSTANCE_CREATED'];
@ -1384,12 +1392,19 @@ class SystemLinking extends System {
*/
static OnComponentInitialized(object) {
//GENERATED_STATIC_ON_COMPONENT_INITIALIZED_METHOD_START
//GENERATED_STATIC_ON_COMPONENT_INITIALIZED_METHOD_END
//CUSTOM_STATIC_ON_COMPONENT_INITIALIZED_METHOD_START
console.log('component initialized');
//CUSTOM_STATIC_ON_COMPONENT_INITIALIZED_METHOD_END
}
/**
* OnEntityInitialized()
* - Listens to events of type Event.ENTITY_INITIALIZED and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return
*/
static OnEntityInitialized(object) {
console.log('entity initialized');
}
@ -2256,91 +2271,95 @@ class Event {
}
Event.BLACKLISTED_COMPONENT_INSTANCE_REQUEST = 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_API_URL = 0xa;
Event.GET_RUNTIME = 0xb;
Event.GET_WINDOW_SIZE = 0xc;
Event.GRAPHICS_COMPONENT_INITIALIZED = 0xd;
Event.IMAGE_COMPONENT_INITIALIZED = 0xe;
Event.IMAGE_INSTANCE_CREATED = 0xf;
Event.INPUT_COMPONENT_INITIALIZED = 0x10;
Event.INSTANCE_CREATED = 0x11;
Event.INSTANCE_DISPOSED = 0x12;
Event.KEYBOARD_DOWN = 0x13;
Event.KEYBOARD_UP = 0x14;
Event.MOUSE_DOWN = 0x15;
Event.MOUSE_MOVE = 0x16;
Event.MOUSE_UP = 0x17;
Event.MOUSE_WHEEL = 0x18;
Event.OBJECT_CREATED = 0x19;
Event.OBJECT_INITIALIZED = 0x1a;
Event.PAUSE = 0x1b;
Event.PROJECT_INITIALIZED = 0x1c;
Event.RESTART = 0x1d;
Event.START = 0x1e;
Event.TOUCH_CANCEL = 0x1f;
Event.TOUCH_END = 0x20;
Event.TOUCH_MOVE = 0x21;
Event.TOUCH_START = 0x22;
Event.UPDATE_FROM_INSTANCE_AFTER = 0x23;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0x24;
Event.UPDATE_INSTANCE_AFTER = 0x25;
Event.UPDATE_INSTANCE_BEFORE = 0x26;
Event.UPDATE_INSTANCE_PROPERTY = 0x27;
Event.UPDATE_PROPERTY_FROM_INSTANCE = 0x28;
Event.MAX_EVENTS = 0x29;
Event.BEFORE_RENDER = 0x1;
Event.BLACKLISTED_COMPONENT_INSTANCE_REQUEST = 0x2;
Event.COMPONENT_CREATED = 0x3;
Event.COMPONENT_INITIALIZED = 0x4;
Event.CREATE_INSTANCE_BEFORE = 0x5;
Event.DISPOSE_INSTANCE = 0x6;
Event.DISPOSE_OBJECT = 0x7;
Event.DOM_COMPONENT_INITIALIZED = 0x8;
Event.ENTITY_CREATED = 0x9;
Event.ENTITY_INITIALIZED = 0xa;
Event.GET_API_URL = 0xb;
Event.GET_RUNTIME = 0xc;
Event.GET_WINDOW_SIZE = 0xd;
Event.GRAPHICS_COMPONENT_INITIALIZED = 0xe;
Event.IMAGE_COMPONENT_INITIALIZED = 0xf;
Event.IMAGE_INSTANCE_CREATED = 0x10;
Event.INPUT_COMPONENT_INITIALIZED = 0x11;
Event.INSTANCE_CREATED = 0x12;
Event.INSTANCE_DISPOSED = 0x13;
Event.KEYBOARD_DOWN = 0x14;
Event.KEYBOARD_UP = 0x15;
Event.MOUSE_DOWN = 0x16;
Event.MOUSE_MOVE = 0x17;
Event.MOUSE_UP = 0x18;
Event.MOUSE_WHEEL = 0x19;
Event.OBJECT_CREATED = 0x1a;
Event.OBJECT_INITIALIZED = 0x1b;
Event.PAUSE = 0x1c;
Event.PROJECT_INITIALIZED = 0x1d;
Event.RESTART = 0x1e;
Event.SLIDER_ENTITY_INITIALIZED = 0x1f;
Event.START = 0x20;
Event.TOUCH_CANCEL = 0x21;
Event.TOUCH_END = 0x22;
Event.TOUCH_MOVE = 0x23;
Event.TOUCH_START = 0x24;
Event.UPDATE_FROM_INSTANCE_AFTER = 0x25;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0x26;
Event.UPDATE_INSTANCE_AFTER = 0x27;
Event.UPDATE_INSTANCE_BEFORE = 0x28;
Event.UPDATE_INSTANCE_PROPERTY = 0x29;
Event.UPDATE_PROPERTY_FROM_INSTANCE = 0x2a;
Event.MAX_EVENTS = 0x2b;
Event.GetEventName = function(eventId) {
switch(eventId) {
case 0x1 : return 'blacklisted_component_instance_request';
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_api_url';
case 0xb : return 'get_runtime';
case 0xc : return 'get_window_size';
case 0xd : return 'graphics_component_initialized';
case 0xe : return 'image_component_initialized';
case 0xf : return 'image_instance_created';
case 0x10 : return 'input_component_initialized';
case 0x11 : return 'instance_created';
case 0x12 : return 'instance_disposed';
case 0x13 : return 'keyboard_down';
case 0x14 : return 'keyboard_up';
case 0x15 : return 'mouse_down';
case 0x16 : return 'mouse_move';
case 0x17 : return 'mouse_up';
case 0x18 : return 'mouse_wheel';
case 0x19 : return 'object_created';
case 0x1a : return 'object_initialized';
case 0x1b : return 'pause';
case 0x1c : return 'project_initialized';
case 0x1d : return 'restart';
case 0x1e : return 'start';
case 0x1f : return 'touch_cancel';
case 0x20 : return 'touch_end';
case 0x21 : return 'touch_move';
case 0x22 : return 'touch_start';
case 0x23 : return 'update_from_instance_after';
case 0x24 : return 'update_from_instance_before';
case 0x25 : return 'update_instance_after';
case 0x26 : return 'update_instance_before';
case 0x27 : return 'update_instance_property';
case 0x28 : return 'update_property_from_instance';
case 0x1 : return 'before_render';
case 0x2 : return 'blacklisted_component_instance_request';
case 0x3 : return 'component_created';
case 0x4 : return 'component_initialized';
case 0x5 : return 'create_instance_before';
case 0x6 : return 'dispose_instance';
case 0x7 : return 'dispose_object';
case 0x8 : return 'dom_component_initialized';
case 0x9 : return 'entity_created';
case 0xa : return 'entity_initialized';
case 0xb : return 'get_api_url';
case 0xc : return 'get_runtime';
case 0xd : return 'get_window_size';
case 0xe : return 'graphics_component_initialized';
case 0xf : return 'image_component_initialized';
case 0x10 : return 'image_instance_created';
case 0x11 : return 'input_component_initialized';
case 0x12 : return 'instance_created';
case 0x13 : return 'instance_disposed';
case 0x14 : return 'keyboard_down';
case 0x15 : return 'keyboard_up';
case 0x16 : return 'mouse_down';
case 0x17 : return 'mouse_move';
case 0x18 : return 'mouse_up';
case 0x19 : return 'mouse_wheel';
case 0x1a : return 'object_created';
case 0x1b : return 'object_initialized';
case 0x1c : return 'pause';
case 0x1d : return 'project_initialized';
case 0x1e : return 'restart';
case 0x1f : return 'slider_entity_initialized';
case 0x20 : return 'start';
case 0x21 : return 'touch_cancel';
case 0x22 : return 'touch_end';
case 0x23 : return 'touch_move';
case 0x24 : return 'touch_start';
case 0x25 : return 'update_from_instance_after';
case 0x26 : return 'update_from_instance_before';
case 0x27 : return 'update_instance_after';
case 0x28 : return 'update_instance_before';
case 0x29 : return 'update_instance_property';
case 0x2a : return 'update_property_from_instance';
default :
throw new Error('Event type not defined : ' + eventId);
}
@ -2567,11 +2586,14 @@ class Entity extends R3Object {
this.initialized = true;
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.ENTITY_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -2666,7 +2688,10 @@ Entity.MAX_ENTITY = 0x1;
Properties:
<no properties>
- canvas (Default value null - The Canvas Component to which this entity binds its custom code
components)
- images (Default value [] - The Image Components which will be used to slide from one image to the
next)
Static Properties:
@ -2714,6 +2739,32 @@ class EntitySlider extends Entity {
if (typeof options.components === 'undefined') {
options.components = [];
}
/**
* started - Indicates whether or not this entity is active (subscribing to events) or not
*/
if (typeof options.started === 'undefined') {
options.started = false;
}
/**
* 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.
*/
if (typeof options.subscriptions === 'undefined') {
options.subscriptions = {};
}
/**
* canvas - The Canvas Component to which this entity binds its custom code components
*/
if (typeof options.canvas === 'undefined') {
options.canvas = null;
}
/**
* images - The Image Components which will be used to slide from one image to the next
*/
if (typeof options.images === 'undefined') {
options.images = [];
}
Object.assign(this, options);
@ -2725,6 +2776,128 @@ class EntitySlider extends Entity {
}
/**
* initialize()
* - Notifies all systems listening that this component initialized.
*/
initialize() {
super.initialize();
Event.Emit(Event.SLIDER_ENTITY_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
if (this instanceof R3.Component) {
this.createInstance();
}
if (this instanceof R3.Entity) {
this.start();
}
} else {
this.initializeDepth++;
}
}
/**
* start()
* - Starts the entity by subscribing to all events
*/
start() {
this.subscriptions['BEFORE_RENDER'] = this.subscribe(
Event.BEFORE_RENDER,
this.OnBeforeRender
);
this.subscriptions['TOUCH_START'] = this.subscribe(
Event.TOUCH_START,
this.OnTouchStart
);
this.subscriptions['TOUCH_MOVE'] = this.subscribe(
Event.TOUCH_MOVE,
this.OnTouchMove
);
this.subscriptions['TOUCH_END'] = this.subscribe(
Event.TOUCH_END,
this.OnTouchEnd
);
this.started = true;
console.log('Started transient system: EntitySlider');
}
/**
* stop()
* - Stops this entity by removing all subscriptions to events
*/
stop() {
this.subscriptions['BEFORE_RENDER'].remove();
delete this.subscriptions['BEFORE_RENDER'];
this.subscriptions['TOUCH_START'].remove();
delete this.subscriptions['TOUCH_START'];
this.subscriptions['TOUCH_MOVE'].remove();
delete this.subscriptions['TOUCH_MOVE'];
this.subscriptions['TOUCH_END'].remove();
delete this.subscriptions['TOUCH_END'];
this.started = false;
console.log('Stopped transient system: EntitySlider');
}
/**
* OnBeforeRender()
* - Listens to events of type Event.BEFORE_RENDER and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnBeforeRender(data) {
}
/**
* OnTouchStart()
* - Listens to events of type Event.TOUCH_START and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchStart(data) {
}
/**
* OnTouchMove()
* - Listens to events of type Event.TOUCH_MOVE and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchMove(data) {
}
/**
* OnTouchEnd()
* - Listens to events of type Event.TOUCH_END and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchEnd(data) {
}
}
/**
@ -2849,7 +3022,11 @@ class Component extends R3Object {
Event.Emit(Event.COMPONENT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -2946,7 +3123,8 @@ Component.MESH = 0x5;
Component.TEXTURE = 0x6;
Component.INPUT = 0x7;
Component.TOUCH = 0x8;
Component.MAX_COMPONENT = 0x9;
Component.CODE = 0x9;
Component.MAX_COMPONENT = 0xa;
/**
@ -3123,7 +3301,11 @@ class ComponentDOM extends Component {
Event.Emit(Event.DOM_COMPONENT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -3430,7 +3612,11 @@ class ComponentCanvas extends ComponentDOM {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -3748,7 +3934,11 @@ class ComponentGraphics extends Component {
Event.Emit(Event.GRAPHICS_COMPONENT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -4105,7 +4295,11 @@ class ComponentImage extends ComponentGraphics {
Event.Emit(Event.IMAGE_COMPONENT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -4579,7 +4773,11 @@ class ComponentMaterial extends ComponentGraphics {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -4827,7 +5025,11 @@ class ComponentMesh extends ComponentGraphics {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -5075,7 +5277,11 @@ class ComponentTexture extends ComponentGraphics {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -5307,7 +5513,11 @@ class ComponentInput extends Component {
Event.Emit(Event.INPUT_COMPONENT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -5555,7 +5765,245 @@ class ComponentTouch extends ComponentInput {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
}
/**
* 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);
if (property === 'maxDepth') {
this.instance.maxDepth = this.maxDepth;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'maxDepth',
instanceProperty : 'maxDepth'
}
);
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);
if (property === 'maxDepth' || property === 'all') {
this.maxDepth = this.instance.maxDepth;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'maxDepth',
instanceProperty : 'maxDepth'
}
);
if (property !== 'all') {
return;
}
}
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
}
/**
Class R3.Event.Object.Component.Code
[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:
- id (Default value Utils.RandomId(15) - Each Object receives an 15 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- parent (Default value null - All objects could have a parent)
- children (Default value [] - All objects could have some children)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
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>
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentCode]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class ComponentCode extends Component {
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.maxDepth === 'undefined') {
options.maxDepth = 0;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
options.maxDepth = options.callDepth;
/**
* initialized - A boolean which indicates whether or not this component has initialized
*/
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
/**
* maxDepth - Indicates the maximum call depth of this component
*/
if (typeof options.maxDepth === 'undefined') {
options.maxDepth = options.callDepth;
}
/**
* initializeDepth - The amount of times this component passed through initialize() functions
*/
if (typeof options.initializeDepth === 'undefined') {
options.initializeDepth = 0;
}
super(options);
Object.assign(this, options);
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
}
/**
* initialize()
* - Notifies all systems listening that this component initialized.
*/
initialize() {
super.initialize();
if (this.initializeDepth === this.maxDepth) {
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -5724,7 +6172,11 @@ class Project extends R3Object {
Event.Emit(Event.PROJECT_INITIALIZED, this);
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -6993,6 +7445,7 @@ Component.Graphics.Mesh = ComponentMesh;
Component.Graphics.Texture = ComponentTexture;
Component.Input = ComponentInput;
Component.Input.Touch = ComponentTouch;
Component.Code = ComponentCode;
Runtime.Coder = RuntimeCoder;
Runtime.Coder.CodeMirror = RuntimeCodeMirror;
Runtime.DOM = RuntimeDOM;
@ -7024,6 +7477,7 @@ R3.Material = Component.Graphics.Material;
R3.Mesh = Component.Graphics.Mesh;
R3.Texture = Component.Graphics.Texture;
R3.Touch = Component.Input.Touch;
R3.Code = Component.Code;
console.log('r3.js - version ' + R3.version + ' compiled ' + R3.compileDate);
R3.System.DOM.Start();

View File

@ -1,6 +1,6 @@
{
"name": "r3",
"version" : "2.0.851",
"version" : "2.0.869",
"description": "",
"private": true,
"dependencies": {

364
src/r3/r3-component-code.js Normal file
View File

@ -0,0 +1,364 @@
const Event = require('./r3-event');
const Utils = require('./r3-utils');
const Component = require('./r3-component.js');
/**
GENERATED_INHERITED_START
Class R3.Event.Object.Component.Code
[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:
- id (Default value Utils.RandomId(15) - Each Object receives an 15 digit random ID which uniquely
identifies it everywhere (client and server side))
- name (Default value 'Object ' + options.id - Each Object has a name)
- parent (Default value null - All objects could have a parent)
- children (Default value [] - All objects could have some children)
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
<no inherited methods>
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>
Inherited Static Methods:
<no inherited static methods>
[Belonging to ComponentCode]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATED_INHERITED_END
TEMPLATE_OPTIONS_START
initialized=false - A boolean which indicates whether or not this component has initialized
instance=null - Holds the current instance of this object as determined (built) by the runtime object.
maxDepth=options.callDepth - Indicates the maximum call depth of this component
initializeDepth=0 - The amount of times this component passed through initialize() functions
TEMPLATE_OPTIONS_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
TEMPLATE_STATIC_OPTIONS_START
TEMPLATE_STATIC_OPTIONS_END
CUSTOM_STATIC_OPTIONS_START
CUSTOM_STATIC_OPTIONS_END
TEMPLATE_INSTANCE_OPTIONS_MAPPING_START
TEMPLATE_INSTANCE_OPTIONS_MAPPING_END
CUSTOM_INSTANCE_OPTIONS_MAPPING_START
CUSTOM_INSTANCE_OPTIONS_MAPPING_END
TEMPLATE_EXCLUDED_FROM_INSTANCE_OPTIONS_START
instance
initializeDepth
initialized
TEMPLATE_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_START
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
TEMPLATE_METHODS_START
initialize() - Notifies all systems listening that this component initialized.
updateInstance(property) - Updates this object by copying the values of the current object into it's instance object.
updateFromInstance(property) - Updates this object by copying the values of its instance into the current object.
TEMPLATE_METHODS_END
CUSTOM_METHODS_START
CUSTOM_METHODS_END
TEMPLATE_STATIC_METHODS_START
TEMPLATE_STATIC_METHODS_END
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
**/
class ComponentCode extends Component {
//GENERATED_CONSTRUCTOR_START
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.maxDepth === 'undefined') {
options.maxDepth = 0;
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
options.maxDepth = options.callDepth;
//GENERATED_TEMPLATE_OPTIONS_INIT_START
/**
* initialized - A boolean which indicates whether or not this component has initialized
*/
if (typeof options.initialized === 'undefined') {
options.initialized = false;
}
/**
* instance - Holds the current instance of this object as determined (built) by the runtime object.
*/
if (typeof options.instance === 'undefined') {
options.instance = null;
}
/**
* maxDepth - Indicates the maximum call depth of this component
*/
if (typeof options.maxDepth === 'undefined') {
options.maxDepth = options.callDepth;
}
/**
* initializeDepth - The amount of times this component passed through initialize() functions
*/
if (typeof options.initializeDepth === 'undefined') {
options.initializeDepth = 0;
}
//GENERATED_TEMPLATE_OPTIONS_INIT_END
super(options);
//GENERATED_OPTIONS_INIT_START
//GENERATED_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
//CUSTOM_BEFORE_INIT_END
if (options.callDepth === 0) {
this.initialize();
} else {
options.callDepth--;
}
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATED_CONSTRUCTOR_END
//GENERATED_TEMPLATE_METHODS_START
/**
* initialize()
* - Notifies all systems listening that this component initialized.
*/
initialize() {
//GENERATED_INITIALIZE_METHOD_START
super.initialize();
//GENERATED_INITIALIZE_METHOD_END
//CUSTOM_INITIALIZE_METHOD_START
//CUSTOM_INITIALIZE_METHOD_END
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
//GENERATED_INITIALIZE_METHOD_AFTER_END
}
/**
* updateInstance()
* - Updates this object by copying the values of the current object into it's instance object.
* @param property
*/
updateInstance(property) {
//GENERATED_UPDATE_INSTANCE_METHOD_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATED_UPDATE_INSTANCE_OPTIONS_START
//GENERATED_UPDATE_INSTANCE_OPTIONS_END
//GENERATED_TEMPLATE_UPDATE_INSTANCE_OPTIONS_START
if (property === 'maxDepth') {
this.instance.maxDepth = this.maxDepth;
this.emit(
Event.UPDATE_INSTANCE_PROPERTY,
{
component : this,
property : 'maxDepth',
instanceProperty : 'maxDepth'
}
);
if (property !== 'all') {
return;
}
}
//GENERATED_TEMPLATE_UPDATE_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATED_UPDATE_INSTANCE_METHOD_END
//CUSTOM_UPDATE_INSTANCE_METHOD_START
//CUSTOM_UPDATE_INSTANCE_METHOD_END
//GENERATED_UPDATE_INSTANCE_METHOD_AFTER_START
//GENERATED_UPDATE_INSTANCE_METHOD_AFTER_END
}
/**
* updateFromInstance()
* - Updates this object by copying the values of its instance into the current object.
* @param property
*/
updateFromInstance(property) {
//GENERATED_UPDATE_FROM_INSTANCE_METHOD_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATED_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATED_UPDATE_FROM_INSTANCE_OPTIONS_END
//GENERATED_TEMPLATE_UPDATE_FROM_INSTANCE_OPTIONS_START
if (property === 'maxDepth' || property === 'all') {
this.maxDepth = this.instance.maxDepth;
this.emit(
Event.UPDATE_PROPERTY_FROM_INSTANCE,
{
component : this,
property : 'maxDepth',
instanceProperty : 'maxDepth'
}
);
if (property !== 'all') {
return;
}
}
//GENERATED_TEMPLATE_UPDATE_FROM_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATED_UPDATE_FROM_INSTANCE_METHOD_END
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END
//GENERATED_UPDATE_FROM_INSTANCE_METHOD_AFTER_START
//GENERATED_UPDATE_FROM_INSTANCE_METHOD_AFTER_END
}
//GENERATED_TEMPLATE_METHODS_END
//GENERATED_METHODS_START
//GENERATED_METHODS_END
//GENERATED_TEMPLATE_STATIC_METHODS_START
//GENERATED_TEMPLATE_STATIC_METHODS_END
//GENERATED_STATIC_METHODS_START
//GENERATED_STATIC_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
}
//GENERATED_TEMPLATE_STATIC_OPTIONS_INIT_START
//GENERATED_TEMPLATE_STATIC_OPTIONS_INIT_END
//GENERATED_STATIC_OPTIONS_INIT_START
//GENERATED_STATIC_OPTIONS_INIT_END
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_START
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = ComponentCode;

View File

@ -9,6 +9,7 @@ const ComponentMesh = require('./r3-component-mesh.js');
const ComponentTexture = require('./r3-component-texture.js');
const ComponentInput = require('./r3-component-input.js');
const ComponentTouch = require('./r3-component-touch.js');
const ComponentCode = require('.-code.js');
//GENERATED_IMPORTS_END
//GENERATED_INDEX_BODY_START
@ -21,6 +22,7 @@ Component.Graphics.Mesh = ComponentMesh;
Component.Graphics.Texture = ComponentTexture;
Component.Input = ComponentInput;
Component.Input.Touch = ComponentTouch;
Component.Code = ComponentCode;
//GENERATED_INDEX_BODY_END
//GENERATED_EXPORTS_START

View File

@ -291,7 +291,11 @@ class ComponentCanvas extends ComponentDOM {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -249,7 +249,11 @@ class ComponentDOM extends Component {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -241,7 +241,11 @@ class ComponentGraphics extends Component {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -382,7 +382,11 @@ class ComponentImage extends ComponentGraphics {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -241,7 +241,11 @@ class ComponentInput extends Component {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -258,7 +258,11 @@ class ComponentMaterial extends ComponentGraphics {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -258,7 +258,11 @@ class ComponentMesh extends ComponentGraphics {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -258,7 +258,11 @@ class ComponentTexture extends ComponentGraphics {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -258,7 +258,11 @@ class ComponentTouch extends ComponentInput {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -180,7 +180,11 @@ class Component extends R3Object {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}
@ -331,7 +335,8 @@ Component.MESH = 0x5;
Component.TEXTURE = 0x6;
Component.INPUT = 0x7;
Component.TOUCH = 0x8;
Component.MAX_COMPONENT = 0x9;
Component.CODE = 0x9;
Component.MAX_COMPONENT = 0xa;
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START

View File

@ -87,7 +87,10 @@ const Entity = require('.././r3-entity.js');
Properties:
<no properties>
- canvas (Default value null - The Canvas Component to which this entity binds its custom code
components)
- images (Default value [] - The Image Components which will be used to slide from one image to the
next)
Static Properties:
@ -106,9 +109,13 @@ const Entity = require('.././r3-entity.js');
TEMPLATE_OPTIONS_START
parent=null - The parent R3.Object of this component
components=[] - A list of components that this entity is composed of
started=false - Indicates whether or not this entity is active (subscribing to events) or not
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.
TEMPLATE_OPTIONS_END
CUSTOM_OPTIONS_START
canvas=null - The Canvas Component to which this entity binds its custom code components
images=[] - The Image Components which will be used to slide from one image to the next
CUSTOM_OPTIONS_END
TEMPLATE_STATIC_OPTIONS_START
@ -118,6 +125,9 @@ const Entity = require('.././r3-entity.js');
CUSTOM_STATIC_OPTIONS_END
TEMPLATE_METHODS_START
initialize() - Notifies all systems listening that this component initialized.
start() - Starts the entity by subscribing to all events
stop() - Stops this entity by removing all subscriptions to events
TEMPLATE_METHODS_END
CUSTOM_METHODS_START
@ -129,6 +139,13 @@ const Entity = require('.././r3-entity.js');
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
CUSTOM_EVENT_LISTENERS_START
Event.BEFORE_RENDER
Event.TOUCH_START
Event.TOUCH_MOVE
Event.TOUCH_END
CUSTOM_EVENT_LISTENERS_END
**/
class EntitySlider extends Entity {
@ -165,9 +182,34 @@ class EntitySlider extends Entity {
if (typeof options.components === 'undefined') {
options.components = [];
}
/**
* started - Indicates whether or not this entity is active (subscribing to events) or not
*/
if (typeof options.started === 'undefined') {
options.started = false;
}
/**
* 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.
*/
if (typeof options.subscriptions === 'undefined') {
options.subscriptions = {};
}
//GENERATED_TEMPLATE_OPTIONS_INIT_END
//GENERATED_OPTIONS_INIT_START
/**
* canvas - The Canvas Component to which this entity binds its custom code components
*/
if (typeof options.canvas === 'undefined') {
options.canvas = null;
}
/**
* images - The Image Components which will be used to slide from one image to the next
*/
if (typeof options.images === 'undefined') {
options.images = [];
}
//GENERATED_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
@ -190,11 +232,208 @@ class EntitySlider extends Entity {
//GENERATED_CONSTRUCTOR_END
//GENERATED_TEMPLATE_METHODS_START
/**
* initialize()
* - Notifies all systems listening that this component initialized.
*/
initialize() {
//GENERATED_INITIALIZE_METHOD_START
super.initialize();
//GENERATED_INITIALIZE_METHOD_END
//CUSTOM_INITIALIZE_METHOD_START
Event.Emit(Event.SLIDER_ENTITY_INITIALIZED, this);
//CUSTOM_INITIALIZE_METHOD_END
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
if (this instanceof R3.Component) {
this.createInstance();
}
if (this instanceof R3.Entity) {
this.start();
}
} else {
this.initializeDepth++;
}
//GENERATED_INITIALIZE_METHOD_AFTER_END
}
/**
* start()
* - Starts the entity by subscribing to all events
*/
start() {
//GENERATED_START_METHOD_START
//GENERATED_EVENT_LISTENERS_START_START
this.subscriptions['BEFORE_RENDER'] = this.subscribe(
Event.BEFORE_RENDER,
this.OnBeforeRender
);
this.subscriptions['TOUCH_START'] = this.subscribe(
Event.TOUCH_START,
this.OnTouchStart
);
this.subscriptions['TOUCH_MOVE'] = this.subscribe(
Event.TOUCH_MOVE,
this.OnTouchMove
);
this.subscriptions['TOUCH_END'] = this.subscribe(
Event.TOUCH_END,
this.OnTouchEnd
);
//GENERATED_EVENT_LISTENERS_START_END
//CUSTOM_BEFORE_SYSTEM_START_START
//CUSTOM_BEFORE_SYSTEM_START_END
this.started = true;
console.log('Started transient system: EntitySlider');
//GENERATED_START_METHOD_END
//CUSTOM_START_METHOD_START
//CUSTOM_START_METHOD_END
//GENERATED_START_METHOD_AFTER_START
//GENERATED_START_METHOD_AFTER_END
}
/**
* stop()
* - Stops this entity by removing all subscriptions to events
*/
stop() {
//GENERATED_STOP_METHOD_START
//GENERATED_EVENT_LISTENERS_STOP_START
this.subscriptions['BEFORE_RENDER'].remove();
delete this.subscriptions['BEFORE_RENDER'];
this.subscriptions['TOUCH_START'].remove();
delete this.subscriptions['TOUCH_START'];
this.subscriptions['TOUCH_MOVE'].remove();
delete this.subscriptions['TOUCH_MOVE'];
this.subscriptions['TOUCH_END'].remove();
delete this.subscriptions['TOUCH_END'];
//GENERATED_EVENT_LISTENERS_STOP_END
//CUSTOM_BEFORE_SYSTEM_STOP_START
//CUSTOM_BEFORE_SYSTEM_STOP_END
this.started = false;
console.log('Stopped transient system: EntitySlider');
//GENERATED_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
//CUSTOM_STOP_METHOD_END
//GENERATED_STOP_METHOD_AFTER_START
//GENERATED_STOP_METHOD_AFTER_END
}
//GENERATED_TEMPLATE_METHODS_END
//GENERATED_METHODS_START
//GENERATED_METHODS_END
//GENERATED_EVENT_LISTENER_METHODS_START
/**
* OnBeforeRender()
* - Listens to events of type Event.BEFORE_RENDER and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnBeforeRender(data) {
//GENERATED_ON_BEFORE_RENDER_METHOD_START
//GENERATED_ON_BEFORE_RENDER_METHOD_END
//CUSTOM_ON_BEFORE_RENDER_METHOD_START
//CUSTOM_ON_BEFORE_RENDER_METHOD_END
//GENERATED_ON_BEFORE_RENDER_METHOD_AFTER_START
//GENERATED_ON_BEFORE_RENDER_METHOD_AFTER_END
}
/**
* OnTouchStart()
* - Listens to events of type Event.TOUCH_START and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchStart(data) {
//GENERATED_ON_TOUCH_START_METHOD_START
//GENERATED_ON_TOUCH_START_METHOD_END
//CUSTOM_ON_TOUCH_START_METHOD_START
//CUSTOM_ON_TOUCH_START_METHOD_END
//GENERATED_ON_TOUCH_START_METHOD_AFTER_START
//GENERATED_ON_TOUCH_START_METHOD_AFTER_END
}
/**
* OnTouchMove()
* - Listens to events of type Event.TOUCH_MOVE and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchMove(data) {
//GENERATED_ON_TOUCH_MOVE_METHOD_START
//GENERATED_ON_TOUCH_MOVE_METHOD_END
//CUSTOM_ON_TOUCH_MOVE_METHOD_START
//CUSTOM_ON_TOUCH_MOVE_METHOD_END
//GENERATED_ON_TOUCH_MOVE_METHOD_AFTER_START
//GENERATED_ON_TOUCH_MOVE_METHOD_AFTER_END
}
/**
* OnTouchEnd()
* - Listens to events of type Event.TOUCH_END and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTouchEnd(data) {
//GENERATED_ON_TOUCH_END_METHOD_START
//GENERATED_ON_TOUCH_END_METHOD_END
//CUSTOM_ON_TOUCH_END_METHOD_START
//CUSTOM_ON_TOUCH_END_METHOD_END
//GENERATED_ON_TOUCH_END_METHOD_AFTER_START
//GENERATED_ON_TOUCH_END_METHOD_AFTER_END
}
//GENERATED_EVENT_LISTENER_METHODS_END
//GENERATED_TEMPLATE_STATIC_METHODS_START
//GENERATED_TEMPLATE_STATIC_METHODS_END

View File

@ -169,13 +169,16 @@ class Entity extends R3Object {
//GENERATED_INITIALIZE_METHOD_END
//CUSTOM_INITIALIZE_METHOD_START
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.ENTITY_INITIALIZED, this);
//CUSTOM_INITIALIZE_METHOD_END
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -345,91 +345,95 @@ class Event {
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//GENERATED_EVENTS_START
Event.BLACKLISTED_COMPONENT_INSTANCE_REQUEST = 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_API_URL = 0xa;
Event.GET_RUNTIME = 0xb;
Event.GET_WINDOW_SIZE = 0xc;
Event.GRAPHICS_COMPONENT_INITIALIZED = 0xd;
Event.IMAGE_COMPONENT_INITIALIZED = 0xe;
Event.IMAGE_INSTANCE_CREATED = 0xf;
Event.INPUT_COMPONENT_INITIALIZED = 0x10;
Event.INSTANCE_CREATED = 0x11;
Event.INSTANCE_DISPOSED = 0x12;
Event.KEYBOARD_DOWN = 0x13;
Event.KEYBOARD_UP = 0x14;
Event.MOUSE_DOWN = 0x15;
Event.MOUSE_MOVE = 0x16;
Event.MOUSE_UP = 0x17;
Event.MOUSE_WHEEL = 0x18;
Event.OBJECT_CREATED = 0x19;
Event.OBJECT_INITIALIZED = 0x1a;
Event.PAUSE = 0x1b;
Event.PROJECT_INITIALIZED = 0x1c;
Event.RESTART = 0x1d;
Event.START = 0x1e;
Event.TOUCH_CANCEL = 0x1f;
Event.TOUCH_END = 0x20;
Event.TOUCH_MOVE = 0x21;
Event.TOUCH_START = 0x22;
Event.UPDATE_FROM_INSTANCE_AFTER = 0x23;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0x24;
Event.UPDATE_INSTANCE_AFTER = 0x25;
Event.UPDATE_INSTANCE_BEFORE = 0x26;
Event.UPDATE_INSTANCE_PROPERTY = 0x27;
Event.UPDATE_PROPERTY_FROM_INSTANCE = 0x28;
Event.MAX_EVENTS = 0x29;
Event.BEFORE_RENDER = 0x1;
Event.BLACKLISTED_COMPONENT_INSTANCE_REQUEST = 0x2;
Event.COMPONENT_CREATED = 0x3;
Event.COMPONENT_INITIALIZED = 0x4;
Event.CREATE_INSTANCE_BEFORE = 0x5;
Event.DISPOSE_INSTANCE = 0x6;
Event.DISPOSE_OBJECT = 0x7;
Event.DOM_COMPONENT_INITIALIZED = 0x8;
Event.ENTITY_CREATED = 0x9;
Event.ENTITY_INITIALIZED = 0xa;
Event.GET_API_URL = 0xb;
Event.GET_RUNTIME = 0xc;
Event.GET_WINDOW_SIZE = 0xd;
Event.GRAPHICS_COMPONENT_INITIALIZED = 0xe;
Event.IMAGE_COMPONENT_INITIALIZED = 0xf;
Event.IMAGE_INSTANCE_CREATED = 0x10;
Event.INPUT_COMPONENT_INITIALIZED = 0x11;
Event.INSTANCE_CREATED = 0x12;
Event.INSTANCE_DISPOSED = 0x13;
Event.KEYBOARD_DOWN = 0x14;
Event.KEYBOARD_UP = 0x15;
Event.MOUSE_DOWN = 0x16;
Event.MOUSE_MOVE = 0x17;
Event.MOUSE_UP = 0x18;
Event.MOUSE_WHEEL = 0x19;
Event.OBJECT_CREATED = 0x1a;
Event.OBJECT_INITIALIZED = 0x1b;
Event.PAUSE = 0x1c;
Event.PROJECT_INITIALIZED = 0x1d;
Event.RESTART = 0x1e;
Event.SLIDER_ENTITY_INITIALIZED = 0x1f;
Event.START = 0x20;
Event.TOUCH_CANCEL = 0x21;
Event.TOUCH_END = 0x22;
Event.TOUCH_MOVE = 0x23;
Event.TOUCH_START = 0x24;
Event.UPDATE_FROM_INSTANCE_AFTER = 0x25;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0x26;
Event.UPDATE_INSTANCE_AFTER = 0x27;
Event.UPDATE_INSTANCE_BEFORE = 0x28;
Event.UPDATE_INSTANCE_PROPERTY = 0x29;
Event.UPDATE_PROPERTY_FROM_INSTANCE = 0x2a;
Event.MAX_EVENTS = 0x2b;
Event.GetEventName = function(eventId) {
switch(eventId) {
case 0x1 : return 'blacklisted_component_instance_request';
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_api_url';
case 0xb : return 'get_runtime';
case 0xc : return 'get_window_size';
case 0xd : return 'graphics_component_initialized';
case 0xe : return 'image_component_initialized';
case 0xf : return 'image_instance_created';
case 0x10 : return 'input_component_initialized';
case 0x11 : return 'instance_created';
case 0x12 : return 'instance_disposed';
case 0x13 : return 'keyboard_down';
case 0x14 : return 'keyboard_up';
case 0x15 : return 'mouse_down';
case 0x16 : return 'mouse_move';
case 0x17 : return 'mouse_up';
case 0x18 : return 'mouse_wheel';
case 0x19 : return 'object_created';
case 0x1a : return 'object_initialized';
case 0x1b : return 'pause';
case 0x1c : return 'project_initialized';
case 0x1d : return 'restart';
case 0x1e : return 'start';
case 0x1f : return 'touch_cancel';
case 0x20 : return 'touch_end';
case 0x21 : return 'touch_move';
case 0x22 : return 'touch_start';
case 0x23 : return 'update_from_instance_after';
case 0x24 : return 'update_from_instance_before';
case 0x25 : return 'update_instance_after';
case 0x26 : return 'update_instance_before';
case 0x27 : return 'update_instance_property';
case 0x28 : return 'update_property_from_instance';
case 0x1 : return 'before_render';
case 0x2 : return 'blacklisted_component_instance_request';
case 0x3 : return 'component_created';
case 0x4 : return 'component_initialized';
case 0x5 : return 'create_instance_before';
case 0x6 : return 'dispose_instance';
case 0x7 : return 'dispose_object';
case 0x8 : return 'dom_component_initialized';
case 0x9 : return 'entity_created';
case 0xa : return 'entity_initialized';
case 0xb : return 'get_api_url';
case 0xc : return 'get_runtime';
case 0xd : return 'get_window_size';
case 0xe : return 'graphics_component_initialized';
case 0xf : return 'image_component_initialized';
case 0x10 : return 'image_instance_created';
case 0x11 : return 'input_component_initialized';
case 0x12 : return 'instance_created';
case 0x13 : return 'instance_disposed';
case 0x14 : return 'keyboard_down';
case 0x15 : return 'keyboard_up';
case 0x16 : return 'mouse_down';
case 0x17 : return 'mouse_move';
case 0x18 : return 'mouse_up';
case 0x19 : return 'mouse_wheel';
case 0x1a : return 'object_created';
case 0x1b : return 'object_initialized';
case 0x1c : return 'pause';
case 0x1d : return 'project_initialized';
case 0x1e : return 'restart';
case 0x1f : return 'slider_entity_initialized';
case 0x20 : return 'start';
case 0x21 : return 'touch_cancel';
case 0x22 : return 'touch_end';
case 0x23 : return 'touch_move';
case 0x24 : return 'touch_start';
case 0x25 : return 'update_from_instance_after';
case 0x26 : return 'update_from_instance_before';
case 0x27 : return 'update_instance_after';
case 0x28 : return 'update_instance_before';
case 0x29 : return 'update_instance_property';
case 0x2a : return 'update_property_from_instance';
default :
throw new Error('Event type not defined : ' + eventId);
}

View File

@ -161,7 +161,11 @@ class Project extends R3Object {
//GENERATED_INITIALIZE_METHOD_AFTER_START
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
} else {
this.initializeDepth++;
}

View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.851';
static compileDate = '2021 Sep 21 - 14:45:57 pm';
static version = '2.0.869';
static compileDate = '2021 Sep 22 - 13:06:11 pm';
}
//GENERATED_IMPORTS_START
@ -29,6 +29,7 @@ R3.Material = Component.Graphics.Material;
R3.Mesh = Component.Graphics.Mesh;
R3.Texture = Component.Graphics.Texture;
R3.Touch = Component.Input.Touch;
R3.Code = Component.Code;
//GENERATED_DEFINES_END
//CUSTOM_CONVENIENT_DEFINES_START

View File

@ -67,6 +67,7 @@ const System = require('.././r3-system.js');
CUSTOM_STATIC_EVENT_LISTENERS_START
Event.OBJECT_CREATED
Event.COMPONENT_INITIALIZED
Event.ENTITY_INITIALIZED
Event.INSTANCE_CREATED
Event.CREATE_INSTANCE_BEFORE - @returns boolean delayInstance which indicates whether or not instance creation is delayed (handled) by another system. (i.e. where instance creation order is of importance)
CUSTOM_STATIC_EVENT_LISTENERS_END
@ -142,6 +143,11 @@ class SystemLinking extends System {
SystemLinking.OnComponentInitialized
);
SystemLinking.Subscriptions['ENTITY_INITIALIZED'] = Event.Subscribe(
Event.ENTITY_INITIALIZED,
SystemLinking.OnEntityInitialized
);
SystemLinking.Subscriptions['INSTANCE_CREATED'] = Event.Subscribe(
Event.INSTANCE_CREATED,
SystemLinking.OnInstanceCreated
@ -184,6 +190,9 @@ class SystemLinking extends System {
SystemLinking.Subscriptions['COMPONENT_INITIALIZED'].remove();
delete SystemLinking.Subscriptions['COMPONENT_INITIALIZED'];
SystemLinking.Subscriptions['ENTITY_INITIALIZED'].remove();
delete SystemLinking.Subscriptions['ENTITY_INITIALIZED'];
SystemLinking.Subscriptions['INSTANCE_CREATED'].remove();
delete SystemLinking.Subscriptions['INSTANCE_CREATED'];
@ -249,6 +258,23 @@ class SystemLinking extends System {
}
/**
* OnEntityInitialized()
* - Listens to events of type Event.ENTITY_INITIALIZED and executes this function.
* @param object (The event data passed as argument - typically an R3Object)
* @return
*/
static OnEntityInitialized(object) {
//GENERATED_STATIC_ON_ENTITY_INITIALIZED_METHOD_START
//GENERATED_STATIC_ON_ENTITY_INITIALIZED_METHOD_END
//CUSTOM_STATIC_ON_ENTITY_INITIALIZED_METHOD_START
console.log('entity initialized');
//CUSTOM_STATIC_ON_ENTITY_INITIALIZED_METHOD_END
}
/**
* OnInstanceCreated()
* - Listens to events of type Event.INSTANCE_CREATED and executes this function.

View File

@ -11,6 +11,8 @@ const EXTEND_CLASS = require('INCLUDE_PATH/EXTEND_CLASS_FILE_NAME');
TEMPLATE_OPTIONS_START
parent=null - The parent R3.Object of this component
components=[] - A list of components that this entity is composed of
started=false - Indicates whether or not this entity is active (subscribing to events) or not
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.
TEMPLATE_OPTIONS_END
CUSTOM_OPTIONS_START
@ -23,6 +25,9 @@ const EXTEND_CLASS = require('INCLUDE_PATH/EXTEND_CLASS_FILE_NAME');
CUSTOM_STATIC_OPTIONS_END
TEMPLATE_METHODS_START
initialize() - Notifies all systems listening that this component initialized.
start() - Starts the entity by subscribing to all events
stop() - Stops this entity by removing all subscriptions to events
TEMPLATE_METHODS_END
CUSTOM_METHODS_START
@ -34,6 +39,9 @@ const EXTEND_CLASS = require('INCLUDE_PATH/EXTEND_CLASS_FILE_NAME');
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
CUSTOM_EVENT_LISTENERS_START
CUSTOM_EVENT_LISTENERS_END
**/
class CLASS_NAME extends EXTEND_CLASS {
@ -47,6 +55,9 @@ class CLASS_NAME extends EXTEND_CLASS {
//GENERATED_METHODS_START
//GENERATED_METHODS_END
//GENERATED_EVENT_LISTENER_METHODS_START
//GENERATED_EVENT_LISTENER_METHODS_END
//GENERATED_TEMPLATE_STATIC_METHODS_START
//GENERATED_TEMPLATE_STATIC_METHODS_END

View File

@ -1,5 +1,5 @@
this.subscriptions['EVENT_NAME'] = Event.Subscribe(
this.subscriptions['EVENT_NAME'] = this.subscribe(
FULL_EVENT_NAME,
SYSTEM_NAME.CALL_BACK
this.CALL_BACK
);

View File

@ -1,5 +1,13 @@
if (this.initializeDepth === this.maxDepth) {
this.createInstance();
if (this instanceof R3.Component) {
this.createInstance();
}
if (this instanceof R3.Entity) {
this.start();
}
} else {
this.initializeDepth++;
}

View File

@ -25,10 +25,20 @@ GENERATED_INITIALIZE_METHOD_AFTER
GENERATED_METHOD_NAME_UPPERCASE_METHOD
GENERATED_METHOD_NAME_UPPERCASE_METHOD_AFTER
GENERATED_METHODS
GENERATED_ON_BEFORE_RENDER_METHOD
GENERATED_ON_BEFORE_RENDER_METHOD_AFTER
GENERATED_ON_TOUCH_END_METHOD
GENERATED_ON_TOUCH_END_METHOD_AFTER
GENERATED_ON_TOUCH_MOVE_METHOD
GENERATED_ON_TOUCH_MOVE_METHOD_AFTER
GENERATED_ON_TOUCH_START_METHOD
GENERATED_ON_TOUCH_START_METHOD_AFTER
GENERATED_OPTIONS_INIT
GENERATED_OUT_OF_CLASS_IMPLEMENTATION
GENERATED_SET_RUNTIME_METHOD
GENERATED_SET_RUNTIME_METHOD_AFTER
GENERATED_START_METHOD
GENERATED_START_METHOD_AFTER
GENERATED_STATIC_ASYNC_METHOD
GENERATED_STATIC_EMIT_METHOD
GENERATED_STATIC_EVENT_LISTENER_METHODS
@ -36,8 +46,10 @@ GENERATED_STATIC_EVENT_LISTENERS_START
GENERATED_STATIC_EVENT_LISTENERS_STOP
GENERATED_STATIC_METHOD_NAME_UPPERCASE_METHOD
GENERATED_STATIC_METHODS
GENERATED_STATIC_ON_COMPONENT_INITIALIZED_METHOD
GENERATED_STATIC_ON_CREATE_INSTANCE_BEFORE_METHOD
GENERATED_STATIC_ON_DOM_COMPONENT_INITIALIZED_METHOD
GENERATED_STATIC_ON_ENTITY_INITIALIZED_METHOD
GENERATED_STATIC_ON_GET_API_URL_METHOD
GENERATED_STATIC_ON_GET_RUNTIME_METHOD
GENERATED_STATIC_ON_IMAGE_INSTANCE_CREATED_METHOD
@ -49,7 +61,6 @@ GENERATED_STATIC_ON_MOUSE_MOVE_METHOD
GENERATED_STATIC_ON_MOUSE_UP_METHOD
GENERATED_STATIC_ON_MOUSE_WHEEL_METHOD
GENERATED_STATIC_ON_OBJECT_CREATED_METHOD
GENERATED_STATIC_ON_OBJECT_INITIALIZED_METHOD
GENERATED_STATIC_ON_PROJECT_INITIALIZED_METHOD
GENERATED_STATIC_ON_TOUCH_CANCEL_METHOD
GENERATED_STATIC_ON_TOUCH_END_METHOD
@ -59,6 +70,8 @@ GENERATED_STATIC_OPTIONS_INIT
GENERATED_STATIC_START_METHOD
GENERATED_STATIC_STOP_METHOD
GENERATED_STATIC_SUBSCRIBE_METHOD
GENERATED_STOP_METHOD
GENERATED_STOP_METHOD_AFTER
GENERATED_SUBSCRIBE_METHOD
GENERATED_SUBSCRIBE_METHOD_AFTER
GENERATED_TEMPLATE_METHODS
@ -93,17 +106,24 @@ CUSTOM_INITIALIZE_METHOD
CUSTOM_INSTANCE_OPTIONS_MAPPING
CUSTOM_METHOD_NAME_UPPERCASE_METHOD
CUSTOM_METHODS
CUSTOM_ON_BEFORE_RENDER_METHOD
CUSTOM_ON_TOUCH_END_METHOD
CUSTOM_ON_TOUCH_MOVE_METHOD
CUSTOM_ON_TOUCH_START_METHOD
CUSTOM_OPTIONS
CUSTOM_OPTIONS_INIT
CUSTOM_OUT_OF_CLASS_IMPLEMENTATION
CUSTOM_SET_RUNTIME_METHOD
CUSTOM_START_METHOD
CUSTOM_STATIC_ASYNC_METHOD
CUSTOM_STATIC_EMIT_METHOD
CUSTOM_STATIC_EVENT_LISTENERS
CUSTOM_STATIC_METHOD_NAME_UPPERCASE_METHOD
CUSTOM_STATIC_METHODS
CUSTOM_STATIC_ON_COMPONENT_INITIALIZED_METHOD
CUSTOM_STATIC_ON_CREATE_INSTANCE_BEFORE_METHOD
CUSTOM_STATIC_ON_DOM_COMPONENT_INITIALIZED_METHOD
CUSTOM_STATIC_ON_ENTITY_INITIALIZED_METHOD
CUSTOM_STATIC_ON_GET_API_URL_METHOD
CUSTOM_STATIC_ON_GET_RUNTIME_METHOD
CUSTOM_STATIC_ON_IMAGE_INSTANCE_CREATED_METHOD
@ -115,7 +135,6 @@ CUSTOM_STATIC_ON_MOUSE_MOVE_METHOD
CUSTOM_STATIC_ON_MOUSE_UP_METHOD
CUSTOM_STATIC_ON_MOUSE_WHEEL_METHOD
CUSTOM_STATIC_ON_OBJECT_CREATED_METHOD
CUSTOM_STATIC_ON_OBJECT_INITIALIZED_METHOD
CUSTOM_STATIC_ON_PROJECT_INITIALIZED_METHOD
CUSTOM_STATIC_ON_TOUCH_CANCEL_METHOD
CUSTOM_STATIC_ON_TOUCH_END_METHOD
@ -125,6 +144,7 @@ CUSTOM_STATIC_OPTIONS
CUSTOM_STATIC_START_METHOD
CUSTOM_STATIC_STOP_METHOD
CUSTOM_STATIC_SUBSCRIBE_METHOD
CUSTOM_STOP_METHOD
CUSTOM_SUBSCRIBE_METHOD
CUSTOM_UPDATE_FROM_INSTANCE_METHOD
CUSTOM_UPDATE_INSTANCE_METHOD

View File

@ -1 +1 @@
2.0.851
2.0.869