226 lines
4.4 KiB
JavaScript
226 lines
4.4 KiB
JavaScript
const R3Object = require('r3-r3-object.js');
|
|
const Event = require('r3-event');
|
|
const Utils = require('r3-utils');
|
|
|
|
/**
|
|
|
|
|
|
|
|
OPTIONS_START
|
|
x=0
|
|
y=1
|
|
z=2
|
|
register=true
|
|
OPTIONS_END
|
|
|
|
|
|
|
|
INSTANCE_OPTIONS_MAPPING_START
|
|
INSTANCE_OPTIONS_MAPPING_END
|
|
|
|
|
|
|
|
LINKED_OBJECTS_START
|
|
LINKED_OBJECTS_END
|
|
|
|
|
|
|
|
EXCLUDED_FROM_INSTANCE_OPTIONS_START
|
|
EXCLUDED_FROM_INSTANCE_OPTIONS_END
|
|
|
|
**/
|
|
|
|
class AnotherClass extends R3Object {
|
|
|
|
//CONSTRUCTOR_EXTENDS_TEMPLATE_START
|
|
constructor(options) {
|
|
|
|
if (Utils.UndefinedOrNull(options)) {
|
|
options = {};
|
|
}
|
|
|
|
options.id = Utils.RandomId(10);
|
|
options.name = 'AnotherClass (' + options.id + ')';
|
|
|
|
super(options);
|
|
|
|
this.emit(Event.OBJECT_CREATED, this);
|
|
|
|
//OPTIONS_INIT_START
|
|
if (Utils.UndefinedOrNull(options.x)) {
|
|
options.x = 0;
|
|
}
|
|
if (Utils.UndefinedOrNull(options.y)) {
|
|
options.y = 1;
|
|
}
|
|
if (Utils.UndefinedOrNull(options.z)) {
|
|
options.z = 2;
|
|
}
|
|
if (Utils.UndefinedOrNull(options.register)) {
|
|
options.register = true;
|
|
}
|
|
//OPTIONS_INIT_END
|
|
|
|
|
|
//CUSTOM_OPTIONS_INIT_START
|
|
//CUSTOM_OPTIONS_INIT_END
|
|
|
|
Object.assign(this, options);
|
|
|
|
|
|
//CUSTOM_BEFORE_INIT_START
|
|
//CUSTOM_BEFORE_INIT_END
|
|
|
|
this.emit(Event.OBJECT_INITIALIZED, this);
|
|
}
|
|
//CONSTRUCTOR_EXTENDS_TEMPLATE_END
|
|
|
|
//CREATE_INSTANCE_TEMPLATE_START
|
|
createInstance() {
|
|
|
|
//CREATE_INSTANCE_BEFORE_START
|
|
super.createInstance();
|
|
this.emit(Event.CREATE_INSTANCE, this);
|
|
|
|
if (this.runtime === 'graphics') {
|
|
this.graphics.createInstance(
|
|
{
|
|
//CREATE_INSTANCE_OPTIONS_START
|
|
'x': this.x,
|
|
'y': this.y,
|
|
'z': this.z,
|
|
'register': this.register
|
|
//CREATE_INSTANCE_OPTIONS_END
|
|
},
|
|
this
|
|
)
|
|
}
|
|
//CREATE_INSTANCE_BEFORE_END
|
|
|
|
|
|
//CUSTOM_CREATE_INSTANCE_START
|
|
//CUSTOM_CREATE_INSTANCE_END
|
|
|
|
//CREATE_INSTANCE_AFTER_START
|
|
this.emit(Event.INSTANCE_CREATED, this);
|
|
//CREATE_INSTANCE_AFTER_END
|
|
|
|
}
|
|
//CREATE_INSTANCE_TEMPLATE_END
|
|
|
|
//UPDATE_INSTANCE_TEMPLATE_START
|
|
updateInstance(property) {
|
|
|
|
//UPDATE_INSTANCE_BEFORE_START
|
|
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
|
|
//UPDATE_INSTANCE_BEFORE_END
|
|
|
|
//UPDATE_INSTANCE_OPTIONS_START
|
|
if (property === 'x') {
|
|
this.instance.x = this.x;
|
|
return;
|
|
}
|
|
if (property === 'y') {
|
|
this.instance.y = this.y;
|
|
return;
|
|
}
|
|
if (property === 'z') {
|
|
this.instance.z = this.z;
|
|
return;
|
|
}
|
|
if (property === 'register') {
|
|
this.instance.register = this.register;
|
|
return;
|
|
}
|
|
//UPDATE_INSTANCE_OPTIONS_END
|
|
|
|
|
|
//CUSTOM_UPDATE_INSTANCE_START
|
|
//CUSTOM_UPDATE_INSTANCE_END
|
|
|
|
//UPDATE_INSTANCE_AFTER_START
|
|
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
|
|
//UPDATE_INSTANCE_AFTER_END
|
|
|
|
}
|
|
//UPDATE_INSTANCE_TEMPLATE_END
|
|
|
|
//UPDATE_FROM_INSTANCE_TEMPLATE_START
|
|
updateFromInstance(property) {
|
|
|
|
//UPDATE_FROM_INSTANCE_BEFORE_START
|
|
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
|
|
//UPDATE_FROM_INSTANCE_BEFORE_END
|
|
|
|
//UPDATE_FROM_INSTANCE_OPTIONS_START
|
|
if (property === 'x') {
|
|
this.x = this.instance.x;
|
|
return;
|
|
}
|
|
if (property === 'y') {
|
|
this.y = this.instance.y;
|
|
return;
|
|
}
|
|
if (property === 'z') {
|
|
this.z = this.instance.z;
|
|
return;
|
|
}
|
|
if (property === 'register') {
|
|
this.register = this.instance.register;
|
|
return;
|
|
}
|
|
//UPDATE_FROM_INSTANCE_OPTIONS_END
|
|
|
|
|
|
//CUSTOM_UPDATE_FROM_INSTANCE_START
|
|
//CUSTOM_UPDATE_FROM_INSTANCE_END
|
|
|
|
//UPDATE_FROM_INSTANCE_AFTER_START
|
|
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
|
|
//UPDATE_FROM_INSTANCE_AFTER_END
|
|
|
|
}
|
|
//UPDATE_FROM_INSTANCE_TEMPLATE_END
|
|
|
|
//DISPOSE_TEMPLATE_START
|
|
dispose() {
|
|
|
|
//DISPOSE_BEFORE_START
|
|
this.emit(Event.DISPOSE_OBJECT, this);
|
|
//DISPOSE_BEFORE_END
|
|
|
|
|
|
//CUSTOM_DISPOSE_START
|
|
//CUSTOM_DISPOSE_END
|
|
|
|
//DISPOSE_AFTER_START
|
|
this.emit(Event.OBJECT_DISPOSED, this);
|
|
//DISPOSE_AFTER_END
|
|
|
|
}
|
|
//DISPOSE_TEMPLATE_END
|
|
|
|
//DISPOSE_INSTANCE_TEMPLATE_START
|
|
disposeInstance() {
|
|
|
|
//DISPOSE_INSTANCE_BEFORE_START
|
|
super.disposeInstance();
|
|
this.emit(Event.DISPOSE_INSTANCE, this);
|
|
//DISPOSE_INSTANCE_BEFORE_END
|
|
|
|
|
|
//CUSTOM_DISPOSE_INSTANCE_START
|
|
//CUSTOM_DISPOSE_INSTANCE_END
|
|
|
|
//DISPOSE_INSTANCE_AFTER_START
|
|
this.emit(Event.INSTANCE_DISPOSED, this);
|
|
//DISPOSE_INSTANCE_AFTER_END
|
|
|
|
}
|
|
//DISPOSE_INSTANCE_TEMPLATE_END
|
|
|
|
|
|
//CUSTOM_IMPLEMENTATION_START
|
|
//CUSTOM_IMPLEMENTATION_END
|
|
|
|
} |