r3-v2/dist/r3-node/r3-another-class.js

205 lines
4.2 KiB
JavaScript
Raw Normal View History

2021-06-19 11:27:32 +02:00
const R3Object = require('r3-r3-object.js');
const Event = require('r3-event');
const Utils = require('r3-utils');
/**
OPTIONS_START
2021-06-20 08:13:06 +02:00
x=1
y=2
z=3
2021-06-19 13:40:22 +02:00
register=true
2021-06-19 11:27:32 +02:00
OPTIONS_END
INSTANCE_OPTIONS_MAPPING_START
2021-06-20 08:13:06 +02:00
x=side.x
y=side.y
z=side.z
2021-06-19 11:27:32 +02:00
INSTANCE_OPTIONS_MAPPING_END
LINKED_OBJECTS_START
LINKED_OBJECTS_END
2021-06-19 13:40:22 +02:00
EXCLUDED_FROM_INSTANCE_OPTIONS_START
2021-06-20 08:13:06 +02:00
register
2021-06-19 13:40:22 +02:00
EXCLUDED_FROM_INSTANCE_OPTIONS_END
2021-06-19 11:27:32 +02:00
**/
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
2021-06-19 13:40:22 +02:00
if (Utils.UndefinedOrNull(options.x)) {
2021-06-20 08:13:06 +02:00
options.x = 1;
2021-06-19 13:40:22 +02:00
}
if (Utils.UndefinedOrNull(options.y)) {
2021-06-20 08:13:06 +02:00
options.y = 2;
2021-06-19 13:40:22 +02:00
}
if (Utils.UndefinedOrNull(options.z)) {
2021-06-20 08:13:06 +02:00
options.z = 3;
2021-06-19 13:40:22 +02:00
}
if (Utils.UndefinedOrNull(options.register)) {
options.register = true;
}
//OPTIONS_INIT_END
2021-06-19 11:27:32 +02:00
//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);
2021-06-19 13:40:22 +02:00
if (this.runtime === 'graphics') {
this.graphics.createInstance(
{
//CREATE_INSTANCE_OPTIONS_START
2021-06-20 08:13:06 +02:00
'side.x': this.x,
'side.y': this.y,
'side.z': this.z
2021-06-19 13:40:22 +02:00
//CREATE_INSTANCE_OPTIONS_END
},
this
)
}
2021-06-19 11:27:32 +02:00
//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
2021-06-19 13:40:22 +02:00
updateInstance(property) {
2021-06-19 11:27:32 +02:00
//UPDATE_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//UPDATE_INSTANCE_BEFORE_END
//UPDATE_INSTANCE_OPTIONS_START
2021-06-19 13:40:22 +02:00
if (property === 'x') {
2021-06-20 08:13:06 +02:00
this.instance.side.x = this.x;
2021-06-19 13:40:22 +02:00
return;
}
if (property === 'y') {
2021-06-20 08:13:06 +02:00
this.instance.side.y = this.y;
2021-06-19 13:40:22 +02:00
return;
}
if (property === 'z') {
2021-06-20 08:13:06 +02:00
this.instance.side.z = this.z;
2021-06-19 13:40:22 +02:00
return;
}
//UPDATE_INSTANCE_OPTIONS_END
2021-06-19 11:27:32 +02:00
//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
2021-06-19 13:40:22 +02:00
updateFromInstance(property) {
2021-06-19 11:27:32 +02:00
//UPDATE_FROM_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//UPDATE_FROM_INSTANCE_BEFORE_END
//UPDATE_FROM_INSTANCE_OPTIONS_START
2021-06-19 13:40:22 +02:00
if (property === 'x') {
2021-06-20 08:13:06 +02:00
this.x = this.instance.side.x;
2021-06-19 13:40:22 +02:00
return;
}
if (property === 'y') {
2021-06-20 08:13:06 +02:00
this.y = this.instance.side.y;
2021-06-19 13:40:22 +02:00
return;
}
if (property === 'z') {
2021-06-20 08:13:06 +02:00
this.z = this.instance.side.z;
2021-06-19 13:40:22 +02:00
return;
}
//UPDATE_FROM_INSTANCE_OPTIONS_END
2021-06-19 11:27:32 +02:00
//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
}