clock, linking system updates, physics updates, animation system started

beta.r3js.org
-=yb4f310 2017-09-14 05:42:38 +02:00
parent 01b36238f9
commit 74ef87c6aa
22 changed files with 381 additions and 47 deletions

View File

@ -81,6 +81,7 @@ GameLib.Event.FETCH_COMPONENTS = 0x3f;
GameLib.Event.GET_API_URL = 0x40;
GameLib.Event.GET_PHYSICS_ENGINE = 0x41;
GameLib.Event.PARENT_WORLD_CHANGE = 0x42;
GameLib.Event.ANIMATE = 0x43;
/**
* Returns string name of event ID
@ -157,6 +158,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x40 : return 'get_api_url';
case 0x41 : return 'get_physics_engine';
case 0x42 : return 'parent_world_change';
case 0x43 : return 'animate';
break;
}
@ -378,6 +380,13 @@ GameLib.Event.Emit = function(
}
)
} else {
if (clientCallback) {
/**
* We execute the client callback immediately since there are no subscriptions to this event
*/
clientCallback();
}
if (clientErrorCallback) {
clientErrorCallback({
message : 'No subscriptions for event ' + eventName

View File

@ -150,6 +150,7 @@ GameLib.Component.COMPONENT_FRICTION_MATERIAL = 0x33;
GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL = 0x34;
GameLib.Component.COMPONENT_RAYCAST_VEHICLE = 0x35;
GameLib.Component.COMPONENT_RAYCAST_WHEEL = 0x36;
GameLib.Component.COMPONENT_CLOCK = 0x37;
/**
* Returns string name for component number
@ -213,6 +214,7 @@ GameLib.Component.GetComponentName = function(number) {
case 0x34 : return 'GameLib.D3.FrictionContactMaterial';
case 0x35 : return 'GameLib.D3.RaycastVehicle';
case 0x36 : return 'GameLib.D3.RaycastWheel';
case 0x37 : return 'GameLib.Clock';
break;
}

46
src/game-lib-api-clock.js Normal file
View File

@ -0,0 +1,46 @@
/**
* Raw Clock API object - should always correspond with the Clock Schema
* @constructor
* @param id
* @param name
* @param parentEntity
*/
GameLib.API.Clock = function(
id,
name,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Clock (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.API.Clock.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.Clock.prototype.constructor = GameLib.API.Clock;
/**
* Creates an API camera from an Object camera
* @param objectClock
* @constructor
*/
GameLib.API.Clock.FromObject = function(objectClock) {
return new GameLib.API.Clock(
objectClock.id,
objectClock.name,
objectClock.parentEntity
);
};

104
src/game-lib-clock.js Normal file
View File

@ -0,0 +1,104 @@
/**
* Creates a camera object
* @param implementation
* @param apiClock GameLib.API.Clock
* @constructor
*/
GameLib.Clock = function(
implementation,
apiClock
) {
this.implementation = implementation;
this.implementation.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiClock)) {
apiClock = {};
}
if (apiClock instanceof GameLib.Clock) {
return apiClock;
}
GameLib.API.Clock.call(
this,
apiClock.id,
apiClock.name,
apiClock.parentEntity
);
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_CLOCK
);
} ;
GameLib.Clock.prototype = Object.create(GameLib.API.Clock.prototype);
GameLib.Clock.prototype.constructor = GameLib.Clock;
/**
* Creates a camera instance of 'graphics' type (only THREE for now)
* @returns {THREE.Clock}
*/
GameLib.Clock.prototype.createInstance = function() {
var instance = new THREE.Clock();
return instance;
};
/**
* Updates the instance with the current state
*/
GameLib.Clock.prototype.updateInstance = function() {
};
GameLib.Clock.prototype.getDelta = function() {
var delta = this.instance.getDelta();
/**
* clamp the delta to 1/60
*/
if (delta > (1 / 30.0)) {
console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time');
delta = (1 / 30.0);
}
return delta;
};
/**
* Converts a GameLib.Clock to a new GameLib.API.Clock
* @returns {GameLib.API.Clock}
*/
GameLib.Clock.prototype.toApiObject = function() {
return new GameLib.API.Clock(
this.id,
this.name,
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
/**
* Converts from an Object camera to a GameLib.Clock
* @param graphics GameLib.Graphics
* @param objectClock Object
* @returns {GameLib.Clock}
* @constructor
*/
GameLib.Clock.FromObject = function(graphics, objectClock) {
var apiClock = GameLib.API.Clock.FromObject(objectClock);
return new GameLib.Clock(
graphics,
apiClock
);
};

View File

@ -16,8 +16,7 @@
GameLib.D3.API.FrictionContactMaterial = function(
id,
name,
material1,
material2,
materials,
friction,
restitution,
contactEquationStiffness,
@ -37,15 +36,10 @@ GameLib.D3.API.FrictionContactMaterial = function(
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(material1)) {
material1 = null;
if (GameLib.Utils.UndefinedOrNull(materials)) {
materials = [];
}
this.material1 = material1;
if (GameLib.Utils.UndefinedOrNull(material2)) {
material2 = null;
}
this.material2 = material2;
this.materials = materials;
if (GameLib.Utils.UndefinedOrNull(friction)) {
friction = 0.3;
@ -95,8 +89,7 @@ GameLib.D3.API.FrictionContactMaterial.FromObject = function(objectFrictionConta
return new GameLib.D3.API.FrictionContactMaterial(
objectFrictionContactMaterial.id,
objectFrictionContactMaterial.name,
objectFrictionContactMaterial.material1,
objectFrictionContactMaterial.material2,
objectFrictionContactMaterial.materials,
objectFrictionContactMaterial.friction,
objectFrictionContactMaterial.restitution,
objectFrictionContactMaterial.contactEquationStiffness,

View File

@ -98,7 +98,7 @@ GameLib.D3.API.Mesh = function(
}
this.skinWeights = skinWeights;
if (GameLib.Utils.UndefinedOrNull(materials)) {
if (GameLib.Utils.UndefinedOrNull(materials) || (materials instanceof Array && materials.length === 0)) {
materials = [new GameLib.D3.API.Material(null, GameLib.D3.Material.MATERIAL_TYPE_STANDARD, 'Material (' + this.name + ')')];
}
this.materials = materials;

View File

@ -7,6 +7,7 @@
* @param solver
* @param rigidBodies
* @param contactMaterials
* @param allowSleep
* @param parentEntity
* @constructor
*/
@ -18,6 +19,8 @@ GameLib.D3.API.PhysicsWorld = function(
solver,
rigidBodies,
contactMaterials,
allowSleep,
defaultContactMaterial,
parentEntity
) {
@ -62,6 +65,19 @@ GameLib.D3.API.PhysicsWorld = function(
}
this.contactMaterials = contactMaterials;
if (GameLib.Utils.UndefinedOrNull(allowSleep)) {
allowSleep = true;
}
this.allowSleep = allowSleep;
if (GameLib.Utils.UndefinedOrNull(defaultContactMaterial)) {
defaultContactMaterial = new GameLib.D3.API.FrictionContactMaterial(
null,
'Default Contact Material (Physics World ' + this.id + ')'
);
}
this.defaultContactMaterial = defaultContactMaterial;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
@ -85,6 +101,8 @@ GameLib.D3.API.PhysicsWorld.FromObject = function(objectWorld) {
objectWorld.solver,
objectWorld.rigidBodies,
objectWorld.contactMaterials,
objectWorld.allowSleep,
objectWorld.defaultContactMaterial,
objectWorld.parentEntity
);
};

View File

@ -24,8 +24,7 @@ GameLib.D3.FrictionContactMaterial = function (
this,
apiFrictionContactMaterial.id,
apiFrictionContactMaterial.name,
apiFrictionContactMaterial.material1,
apiFrictionContactMaterial.material2,
apiFrictionContactMaterial.materials,
apiFrictionContactMaterial.friction,
apiFrictionContactMaterial.restitution,
apiFrictionContactMaterial.contactEquationStiffness,
@ -39,8 +38,7 @@ GameLib.D3.FrictionContactMaterial = function (
this,
GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL,
{
material1 : GameLib.D3.FrictionMaterial,
material2 : GameLib.D3.FrictionMaterial
materials : [GameLib.D3.FrictionMaterial]
}
);
};
@ -55,14 +53,21 @@ GameLib.D3.FrictionContactMaterial.prototype.constructor = GameLib.D3.FrictionCo
GameLib.D3.FrictionContactMaterial.prototype.createInstance = function() {
var instance = new CANNON.ContactMaterial(
this.material1.instance,
this.material2.instance,
null,
null,
{
friction: this.friction,
restitution: this.restitution,
contactEquationStiffness: this.contactEquationStiffness
}
);
instance.materials = this.materials.map(
function(material){
return material.instance;
}
);
return instance;
};
@ -71,8 +76,11 @@ GameLib.D3.FrictionContactMaterial.prototype.createInstance = function() {
*/
GameLib.D3.FrictionContactMaterial.prototype.updateInstance = function() {
this.instance.material1 = this.material1.instance;
this.instance.material2 = this.material2.instance;
this.instance.materials = this.materials.map(
function(material) {
return material.instance;
}
);
this.instance.friction = this.friction;
this.instance.restitution = this.restitution;
@ -92,8 +100,11 @@ GameLib.D3.FrictionContactMaterial.prototype.toApiObject = function() {
var apiFrictionContactMaterial = new GameLib.D3.API.FrictionContactMaterial(
this.id,
this.name,
GameLib.Utils.IdOrNull(this.material1),
GameLib.Utils.IdOrNull(this.material2),
this.materials.map(
function(material) {
return GameLib.Utils.IdOrNull(material);
}
),
this.friction,
this.restitution,
this.contactEquationStiffness,

View File

@ -1046,6 +1046,10 @@ GameLib.D3.Mesh.prototype.applyLocalPositionRotationScale = function() {
this.scale.y = 1;
this.scale.z = 1;
this.localPosition.x = 0;
this.localPosition.y = 0;
this.localPosition.z = 0;
this.quaternion.axis.x = 0;
this.quaternion.axis.y = 0;
this.quaternion.axis.z = 0;
@ -1221,6 +1225,14 @@ GameLib.D3.Mesh.prototype.createHelper = function() {
};
GameLib.D3.Mesh.prototype.addMaterial = function(material) {
if (this.materials.length === 1) {
this.instance.material = material.instance;
} else {
this.instance.material.push(material.instance);
}
};
/**
* Convenience function for removing a helper for this Mesh - should be called from Systems only
*/

View File

@ -29,6 +29,8 @@ GameLib.D3.PhysicsWorld = function(
apiWorld.solver,
apiWorld.rigidBodies,
apiWorld.contactMaterials,
apiWorld.allowSleep,
apiWorld.defaultContactMaterial,
apiWorld.parentEntity
);
@ -78,6 +80,13 @@ GameLib.D3.PhysicsWorld = function(
}.bind(this)
);
if (this.defaultContactMaterial instanceof GameLib.D3.API.FrictionContactMaterial) {
this.defaultContactMaterial = new GameLib.D3.FrictionContactMaterial(
this.physics,
this.defaultContactMaterial
)
}
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_PHYSICS_WORLD,
@ -85,7 +94,8 @@ GameLib.D3.PhysicsWorld = function(
'broadphase' : GameLib.D3.Broadphase,
'solver' : GameLib.D3.Solver,
'rigidBodies' : [GameLib.D3.RigidBody],
'contactMaterials' : [GameLib.D3.FrictionContactMaterial]
'contactMaterials' : [GameLib.D3.FrictionContactMaterial],
'defaultContactMaterial' : GameLib.D3.FrictionContactMaterial
}
);
};
@ -106,6 +116,7 @@ GameLib.D3.PhysicsWorld.prototype.createInstance = function() {
instance.broadphase = this.broadphase.instance;
instance.solver = this.solver.instance;
instance.gravity = this.gravity.instance;
instance.allowSleep = this.allowSleep;
this.contactMaterials.map(
function(contactMaterial) {
@ -135,6 +146,13 @@ GameLib.D3.PhysicsWorld.prototype.createInstance = function() {
}
);
instance.defaultContactMaterial.friction = this.defaultContactMaterial.friction;
instance.defaultContactMaterial.restitution = this.defaultContactMaterial.restitution;
instance.defaultContactMaterial.contactEquationStiffness = this.defaultContactMaterial.contactEquationStiffness;
instance.defaultContactMaterial.contactEquationRelaxation = this.defaultContactMaterial.contactEquationRelaxation;
instance.defaultContactMaterial.frictionEquationStiffness = this.defaultContactMaterial.frictionEquationStiffness;
instance.defaultContactMaterial.frictionEquationRelaxation = this.defaultContactMaterial.frictionEquationRelaxation;
return instance;
} else {
@ -225,8 +243,15 @@ GameLib.D3.PhysicsWorld.prototype.updateInstance = function() {
this.instance.broadphase = this.broadphase.instance;
this.instance.solver = this.solver.instance;
this.instance.gravity = this.gravity.instance;
this.instance.allowSleep = this.allowSleep;
this.instance.defaultContactMaterial.friction = this.defaultContactMaterial.friction;
this.instance.defaultContactMaterial.restitution = this.defaultContactMaterial.restitution;
this.instance.defaultContactMaterial.contactEquationStiffness = this.defaultContactMaterial.contactEquationStiffness;
this.instance.defaultContactMaterial.contactEquationRelaxation = this.defaultContactMaterial.contactEquationRelaxation;
this.instance.defaultContactMaterial.frictionEquationStiffness = this.defaultContactMaterial.frictionEquationStiffness;
this.instance.defaultContactMaterial.frictionEquationRelaxation = this.defaultContactMaterial.frictionEquationRelaxation;
//TODO add contact materials and rigidbodies ? - this functionality is actually part of the physics system..
};
/**
@ -247,6 +272,8 @@ GameLib.D3.PhysicsWorld.prototype.toApiObject = function() {
this.contactMaterials.map(function(contactMaterial){
return GameLib.Utils.IdOrNull(contactMaterial);
}),
this.allowSleep,
GameLib.Utils.IdOrNull(this.defaultContactMaterial),
GameLib.Utils.IdOrNull(this.parentEntity)
);

View File

@ -69,6 +69,14 @@ GameLib.D3.RigidBody = function (
this
);
this.force = new GameLib.Vector3(
this.physics
);
this.forcePoint = new GameLib.Vector3(
this.physics
);
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_RIGID_BODY,
@ -109,6 +117,18 @@ GameLib.D3.RigidBody.prototype.createInstance = function() {
}
);
instance.addEventListener("sleepy",function(event){
console.log(this.name + " is feeling sleepy...");
}.bind(this));
instance.addEventListener("sleep",function(event){
console.log(this.name + " fell asleep!");
}.bind(this));
instance.addEventListener("wakeup",function(event){
console.log(this.name + " woke up!");
}.bind(this));
this.shapes.map(function(shape){
if (shape.loaded) {
@ -237,3 +257,18 @@ GameLib.D3.RigidBody.FromObject = function(physics, objectComponent) {
apiRigidBody
);
};
GameLib.D3.RigidBody.prototype.applyForce = function() {
this.instance.applyForce(
this.force.instance,
this.forcePoint.instance
)
};
GameLib.D3.RigidBody.prototype.applyLocalForce = function() {
this.instance.applyLocalForce(
this.force.instance,
this.forcePoint.instance
)
};

View File

@ -24,6 +24,8 @@ GameLib.System = function(
apiSystem.parentEntity
);
this.started = false;
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_SYSTEM
@ -56,17 +58,19 @@ GameLib.System.prototype.createInstance = function() {
*/
GameLib.System.prototype.start = function() {
this.started = true;
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
// this.pathFollowingObjects = GameLib.EntityManager.Instance.query([GameLib.D3.PathFollowing]);
// this.followObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Follow]);
// this.meshObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Mesh]);
// this.lookAtObjects = GameLib.EntityManager.Instance.query([GameLib.D3.LookAt]);
// this.cameraObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Camera]);
// this.lightObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Light]);
}
this.update();
// if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
// // this.pathFollowingObjects = GameLib.EntityManager.Instance.query([GameLib.D3.PathFollowing]);
// // this.followObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Follow]);
// // this.meshObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Mesh]);
// // this.lookAtObjects = GameLib.EntityManager.Instance.query([GameLib.D3.LookAt]);
// // this.cameraObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Camera]);
// // this.lightObjects = GameLib.EntityManager.Instance.query([GameLib.D3.Light]);
// }
//
// this.update();
};
@ -126,14 +130,17 @@ GameLib.System.prototype.update = function(deltaTime) {
*/
GameLib.System.prototype.stop = function() {
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
// this.pathFollowingObjects = [];
// this.followObjects = [];
// this.meshObjects = [];
// this.lookAtObjects = [];
// this.cameraObjects = [];
// this.lightObjects = [];
}
this.started = false;
//
// if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
// // this.pathFollowingObjects = [];
// // this.followObjects = [];
// // this.meshObjects = [];
// // this.lookAtObjects = [];
// // this.cameraObjects = [];
// // this.lightObjects = [];
// }
};
/**

View File

@ -16,11 +16,33 @@ GameLib.System.Animation.prototype = Object.create(GameLib.System.prototype);
GameLib.System.Animation.prototype.constructor = GameLib.System.Animation;
GameLib.System.Animation.prototype.start = function() {
console.log('todo: animation system start');
GameLib.System.prototype.start.call(this);
this.animateSubscription = GameLib.Event.Subscribe(
GameLib.Event.ANIMATE,
this.animate
);
};
GameLib.System.Animation.prototype.animate = function(data, clientCallback) {
this.renderSubscription = GameLib.Event.Subscribe(
GameLib.Event.BEFORE_RENDER,
function(data) {
if (clientCallback(data)) {
this.renderSubscription.remove();
}
}.bind(this)
)
};
GameLib.System.Animation.prototype.stop = function() {
console.log('todo: animation system stop');
GameLib.System.prototype.stop.call(this);
this.animateSubscription.remove();
};

View File

@ -26,6 +26,8 @@ GameLib.System.CustomCode.prototype.constructor = GameLib.System.CustomCode;
*/
GameLib.System.CustomCode.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.customCodeComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.CustomCode);
this.customCodeComponents.map(function(customCodeComponent){
@ -46,6 +48,8 @@ GameLib.System.CustomCode.prototype.start = function() {
*/
GameLib.System.CustomCode.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.subscriptions.map(function(subscription){
subscription.remove();
});

View File

@ -43,6 +43,8 @@ GameLib.System.GUI.prototype.constructor = GameLib.System.GUI;
GameLib.System.GUI.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.GUI);
/**
@ -188,8 +190,17 @@ GameLib.System.GUI.prototype.start = function() {
GameLib.System.GUI.prototype.onChange = function(property, subProperty, affected) {
return function(value) {
affected.map(function(component){
component[property][subProperty] = value;
component.updateInstance();
component[property][subProperty] = value;
if (typeof component[property].updateInstance === 'function') {
component[property].updateInstance();
} else if (typeof component[property][subProperty].updateInstance === 'function') {
component[property][subProperty].updateInstance();
} else {
component.updateInstance();
}
});
}
};
@ -1679,6 +1690,8 @@ GameLib.System.GUI.prototype.newEntity = function(data) {
GameLib.System.GUI.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.guis.map(function(gui){
gui.domElement.instance.parentElement.removeChild(gui.instance.domElement);
});

View File

@ -43,6 +43,8 @@ GameLib.System.Input.prototype.constructor = GameLib.System.Input;
*/
GameLib.System.Input.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Renderer);
this.renderers.map(
@ -374,6 +376,8 @@ GameLib.System.Input.prototype.deSelectMesh = function(mesh) {
*/
GameLib.System.Input.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
/**
* Now remove all input capabilities
*/

View File

@ -50,6 +50,8 @@ GameLib.System.Linking.prototype.constructor = GameLib.System.Linking;
GameLib.System.Linking.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.componentCreatedSubscription = this.subscribe(
GameLib.Event.COMPONENT_CREATED,
this.componentCreated.bind(this)
@ -700,6 +702,12 @@ GameLib.System.Linking.prototype.arrayItemAdded = function(data) {
) {
data.component.addRigidBody(data.item);
}
if (data.component instanceof GameLib.D3.Mesh &&
data.item instanceof GameLib.D3.Material
) {
data.component.addMaterial(data.item);
}
};
GameLib.System.Linking.prototype.instanceCreated = function(data) {
@ -999,6 +1007,7 @@ GameLib.System.Linking.prototype.meshDeleted = function(data) {
};
GameLib.System.Linking.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.imageNotFoundSubscription.remove();
this.componentCreatedSubscription.remove();
this.parentSceneChangeSubscription.remove();

View File

@ -32,6 +32,8 @@ GameLib.System.Physics.prototype.constructor = GameLib.System.Physics;
GameLib.System.Physics.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.worlds = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.PhysicsWorld);
// this.rigidBodies = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.RigidBody);
// this.wheels = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.RaycastWheel);
@ -130,6 +132,8 @@ GameLib.System.Physics.prototype.beforeRender = function(data) {
GameLib.System.Physics.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.worlds = [];
this.rigidBodies = [];
this.wheels = [];

View File

@ -24,6 +24,8 @@ GameLib.System.Render.prototype.constructor = GameLib.System.Render;
*/
GameLib.System.Render.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Renderer);
this.renderers.map(
@ -69,6 +71,8 @@ GameLib.System.Render.prototype.render = function(data) {
*/
GameLib.System.Render.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.renderers.map(
function(renderer) {
if (renderer.statistics) {

View File

@ -99,6 +99,8 @@ GameLib.System.Storage.prototype.constructor = GameLib.System.Storage;
GameLib.System.Storage.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.loginSubscription = this.subscribe(
GameLib.Event.LOGGED_IN,
function(data) {
@ -998,6 +1000,9 @@ GameLib.System.Storage.prototype.loadImage = function(data) {
};
GameLib.System.Storage.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.loginSubscription.remove();
this.loadSubscription.remove();
this.saveSubscription.remove();

View File

@ -34,6 +34,8 @@ GameLib.System.Visualization.prototype.constructor = GameLib.System.Visualizatio
GameLib.System.Visualization.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.visualizationSubscription = this.subscribe(
GameLib.Event.VISUALIZE,
this.visualize
@ -110,6 +112,8 @@ GameLib.System.Visualization.prototype.stopVisualize = function(data) {
GameLib.System.Visualization.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
if (this.visualizationSubscription) {
this.visualizationSubscription.remove();
}

View File

@ -43,7 +43,7 @@ GameLib.Vector3 = function (
);
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
parentObject = null;
parentObject = this;
}
this.parentObject = parentObject;
@ -93,6 +93,7 @@ GameLib.Vector3.prototype.updateInstance = function() {
this.instance.z = this.z;
if (this.parentObject &&
this.parentObject !== this &&
this.parentObject.updateInstance) {
this.parentObject.updateInstance();
}