awesome input system and editor controls component
parent
625fcfedb9
commit
be9b88503d
|
@ -53,11 +53,10 @@ GameLib.D3.Input.Editor = function (
|
|||
* window event handlers when we need to
|
||||
* @type {function()}
|
||||
*/
|
||||
this.resize = this.onWindowResize.bind(this);
|
||||
this.mouseMove = this.onMouseMove.bind(this);
|
||||
this.mouseDown = this.onMouseDown.bind(this);
|
||||
this.keyPress = this.onKeyPress.bind(this);
|
||||
this.contextMenu = this.onContextMenu.bind(this);
|
||||
this.mouseMove = null;
|
||||
this.mouseDown = null;
|
||||
this.keyDown = null;
|
||||
this.contextMenu = null;
|
||||
|
||||
this.raycaster = new GameLib.D3.Raycaster(
|
||||
this.graphics
|
||||
|
@ -76,51 +75,12 @@ GameLib.D3.Input.Editor.prototype = Object.create(GameLib.D3.API.Input.Editor.pr
|
|||
GameLib.D3.Input.Editor.prototype.constructor = GameLib.D3.Input.Editor;
|
||||
|
||||
GameLib.D3.Input.Editor.prototype.createInstance = function(update) {
|
||||
|
||||
var instance = null;
|
||||
|
||||
if (update) {
|
||||
instance = this.instance;
|
||||
instance.camera = this.camera.instance;
|
||||
return instance;
|
||||
} else {
|
||||
instance = new THREE.EditorControls(
|
||||
this.camera.instance,
|
||||
this.domElement.instance
|
||||
)
|
||||
}
|
||||
|
||||
// this.domElement.instance.addEventListener(
|
||||
// 'mousemove',
|
||||
// this.mouseMove,
|
||||
// false
|
||||
// );
|
||||
//
|
||||
// this.domElement.instance.addEventListener(
|
||||
// 'contextmenu',
|
||||
// this.contextMenu,
|
||||
// false
|
||||
// );
|
||||
//
|
||||
// this.domElement.instance.addEventListener(
|
||||
// 'mousedown',
|
||||
// this.mouseDown,
|
||||
// false
|
||||
// );
|
||||
|
||||
this.domElement.instance.addEventListener(
|
||||
'keydown',
|
||||
this.keyPress,
|
||||
false
|
||||
);
|
||||
|
||||
//TODO : window resize
|
||||
// this.dom.window.addEventListener(
|
||||
// 'resize',
|
||||
// this.resize,
|
||||
// false
|
||||
// );
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
|
@ -156,258 +116,87 @@ GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent
|
|||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Editor.prototype.onWindowResize = function() {
|
||||
//
|
||||
// this.domContainer.instance.style.height = (this.window.innerHeight - this.containerHeightOffset) + 'px';
|
||||
// this.domContainer.instance.style.width = (this.window.innerWidth - this.containerWidthOffset) + 'px';
|
||||
|
||||
var width = this.window.innerWidth - this.widthOffset;
|
||||
|
||||
var height = this.window.innerHeight - this.heightOffset;
|
||||
|
||||
//TODO: map the relative viewport sizes and offsets with the size differences
|
||||
|
||||
this.editor.viewports.map(
|
||||
function(viewport) {
|
||||
viewport.width = width;
|
||||
viewport.height = height;
|
||||
viewport.updateInstance();
|
||||
}
|
||||
);
|
||||
|
||||
this.editor.game.viewports.map(
|
||||
function(viewport) {
|
||||
viewport.width = width;
|
||||
viewport.height = height;
|
||||
viewport.updateInstance();
|
||||
}
|
||||
);
|
||||
//
|
||||
// this.scene.cameras[this.scene.activeCameraIndex].aspect = () / window.innerHeight;
|
||||
// this.scene.cameras[this.scene.activeCameraIndex].updateInstance();
|
||||
//
|
||||
// this.scene.renderers[this.scene.activeRendererIndex].width = window.innerWidth - 400;
|
||||
// this.scene.renderers[this.scene.activeRendererIndex].height = window.innerHeight;
|
||||
// this.scene.renderers[this.scene.activeRendererIndex].updateInstance();
|
||||
};
|
||||
|
||||
/**
|
||||
* Keypress events
|
||||
* @param event
|
||||
* @param entity
|
||||
* @returns {Function}
|
||||
*/
|
||||
GameLib.D3.Input.Editor.prototype.onKeyPress = function(event) {
|
||||
GameLib.D3.Input.Editor.prototype.onKeyDown = function(entity) {
|
||||
|
||||
console.log('keypressed ' + event.code);
|
||||
return function(event) {
|
||||
console.log('entity ' + entity.name + 'emitted keypress ' + event.code);
|
||||
|
||||
if (event.code === 'KeyV') {
|
||||
//todo - change view
|
||||
};
|
||||
|
||||
if (event.code == "KeyQ") {
|
||||
|
||||
this.editor.allSelected = !this.editor.allSelected;
|
||||
|
||||
this.editor.selectedObjects = [];
|
||||
|
||||
if (this.editor.allSelected) {
|
||||
for (var property in this.editor.idToObject) {
|
||||
if (this.editor.idToObject.hasOwnProperty(property)) {
|
||||
this.editor.selectedObjects.push(
|
||||
new GameLib.D3.SelectedObject(
|
||||
this.graphics,
|
||||
this.editor.idToObject(property)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
// BELOW is just a test to stop systems from keypress - it works nicely :)
|
||||
// but of course, when the system is stopped it can no longer be started by keypress
|
||||
// var inputSystem = entity.getComponent(GameLib.System).reduce(
|
||||
// function(result, system){
|
||||
// if (system.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
|
||||
// result = system;
|
||||
// }
|
||||
// return result;
|
||||
// },
|
||||
// null
|
||||
// );
|
||||
//
|
||||
// inputSystem.stop();
|
||||
}
|
||||
|
||||
if (this.editor.onSelectionChanged) {
|
||||
this.editor.onSelectionChanged(this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'KeyG') {
|
||||
if (!this.meshMoveMode) {
|
||||
console.log('move mode');
|
||||
this.meshMoveMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'KeyX') {
|
||||
if (this.meshMoveMode) {
|
||||
console.log('move along x');
|
||||
this.meshMoveXMode = true;
|
||||
this.meshMoveYMode = false;
|
||||
this.meshMoveZMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'KeyY') {
|
||||
if (this.meshMoveMode) {
|
||||
console.log('move along y');
|
||||
this.meshMoveXMode = false;
|
||||
this.meshMoveYMode = true;
|
||||
this.meshMoveZMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'KeyZ') {
|
||||
if (this.meshMoveMode) {
|
||||
console.log('move along z');
|
||||
this.meshMoveXMode = false;
|
||||
this.meshMoveYMode = false;
|
||||
this.meshMoveZMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'Escape') {
|
||||
if (this.meshMoveMode) {
|
||||
this.meshMoveMode = false;
|
||||
console.log('TODO: implement restore positions');
|
||||
}
|
||||
}
|
||||
|
||||
if (event.code == 'Enter') {
|
||||
if (this.meshMoveMode) {
|
||||
this.meshMoveMode = false;
|
||||
console.log('TODO: implement apply positions');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mouse click events
|
||||
* @param event
|
||||
* @returns {boolean}
|
||||
* MouseMove events
|
||||
* @param entity
|
||||
* @returns {Function}
|
||||
*/
|
||||
GameLib.D3.Input.Editor.prototype.onMouseDown = function(event) {
|
||||
GameLib.D3.Input.Editor.prototype.onMouseMove = function(entity) {
|
||||
|
||||
if (event.button == 2) {
|
||||
return function(event) {
|
||||
|
||||
event.cancelBubble = true;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (event.stopPropagation) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
var meshes = [];
|
||||
|
||||
for (var property in this.editor.idToObject) {
|
||||
if (this.editor.idToObject.hasOwnProperty(property)) {
|
||||
if (this.editor.idToObject[property] instanceof GameLib.D3.Mesh) {
|
||||
meshes.push(this.editor.idToObject[property]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var intersects = this.raycaster.getIntersectedObjects(meshes);
|
||||
|
||||
if (intersects.length > 0) {
|
||||
|
||||
var index = -1;
|
||||
|
||||
for (var s = 0; s < this.editor.selectedObjects.length; s++) {
|
||||
if (this.editor.selectedObjects[s].object == intersects[0]) {
|
||||
index = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
/**
|
||||
* The object is not selected, select it
|
||||
*/
|
||||
this.selectObject(intersects[0]);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* De-select the objec
|
||||
*/
|
||||
var delta = Date.now() - this.editor.selectedObjects[index].lastUpdate;
|
||||
if (delta > this.selectDelayMs) {
|
||||
this.unselectObject(intersects[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.editor.onSelectionChanged) {
|
||||
this.editor.onSelectionChanged(this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (event.button == 0) {
|
||||
if (this.meshMoveMode) {
|
||||
this.meshMoveMode = false;
|
||||
this.meshMoveXMode = false;
|
||||
this.meshMoveYMode = false;
|
||||
this.meshMoveZMode = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mouse move events
|
||||
* @param event
|
||||
* MouseDown events
|
||||
* @param entity
|
||||
* @returns {Function}
|
||||
*/
|
||||
GameLib.D3.Input.Editor.prototype.onMouseMove = function(event) {
|
||||
GameLib.D3.Input.Editor.prototype.onMouseDown = function(entity) {
|
||||
|
||||
var clientX = event.clientX - this.widthOffset;
|
||||
return function(event) {
|
||||
|
||||
this.mouse.x = ((clientX / (window.innerWidth - this.widthOffset))) * 2 - 1;
|
||||
this.mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
if (event.button === 2) {
|
||||
|
||||
var renderer = entity.getFirstComponent(GameLib.D3.Renderer);
|
||||
|
||||
this.mouse.x = (event.offsetX / renderer.instance.domElement.width) * 2 - 1;
|
||||
this.mouse.y = -(event.offsetY / renderer.instance.domElement.height) * 2 + 1;
|
||||
|
||||
this.raycaster.instance.setFromCamera(
|
||||
this.mouse,
|
||||
this.camera.instance
|
||||
);
|
||||
|
||||
if (this.meshMoveMode) {
|
||||
var meshes = entity.getComponent(GameLib.D3.Mesh);
|
||||
|
||||
var units = event.movementY;
|
||||
var intersects = this.raycaster.getIntersectedObjects(meshes);
|
||||
|
||||
if (this.meshMoveXMode) {
|
||||
this.moveSelectedObjects('x', units);
|
||||
}
|
||||
|
||||
if (this.meshMoveYMode) {
|
||||
this.moveSelectedObjects('y', units);
|
||||
}
|
||||
|
||||
if (this.meshMoveZMode) {
|
||||
this.moveSelectedObjects('z', units);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (intersects.length > 0) {
|
||||
|
||||
/**
|
||||
* Moves selected objects along an axis
|
||||
* @param alongAxis
|
||||
* @param units
|
||||
* Prevent default action (like context menu or whatever)
|
||||
*/
|
||||
GameLib.D3.Input.Editor.prototype.moveSelectedObjects = function(alongAxis, units) {
|
||||
event.preventDefault();
|
||||
|
||||
for (var s = 0; s < this.editor.selectedObjects.length; s++) {
|
||||
/**
|
||||
* Prevent other event listeners for 'mousedown' from executing their actions
|
||||
*/
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
var object = this.editor.selectedObjects[s].object;
|
||||
intersects[0].instance.material.wireframe = !intersects[0].instance.material.wireframe;
|
||||
|
||||
if (object.position) {
|
||||
if (alongAxis == 'x') {
|
||||
object.position.x += units;
|
||||
}
|
||||
if (alongAxis == 'y') {
|
||||
object.position.y += units;
|
||||
}
|
||||
if (alongAxis == 'z') {
|
||||
object.position.z += units;
|
||||
}
|
||||
|
||||
if (object.updateInstance) {
|
||||
object.updateInstance();
|
||||
console.log('object(s) instersected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -432,6 +221,231 @@ GameLib.D3.Input.Editor.prototype.onContextMenu = function(event){
|
|||
return false;
|
||||
};
|
||||
|
||||
GameLib.D3.Input.Editor.prototype.update = function(deltaTime) {
|
||||
return;
|
||||
};
|
||||
|
||||
//
|
||||
// console.log('keypressed ' + event.code);
|
||||
//
|
||||
// if (event.code === 'KeyV') {
|
||||
// //todo - change view
|
||||
// }
|
||||
//
|
||||
// if (event.code == "KeyQ") {
|
||||
//
|
||||
// this.editor.allSelected = !this.editor.allSelected;
|
||||
//
|
||||
// this.editor.selectedObjects = [];
|
||||
//
|
||||
// if (this.editor.allSelected) {
|
||||
// for (var property in this.editor.idToObject) {
|
||||
// if (this.editor.idToObject.hasOwnProperty(property)) {
|
||||
// this.editor.selectedObjects.push(
|
||||
// new GameLib.D3.SelectedObject(
|
||||
// this.graphics,
|
||||
// this.editor.idToObject(property)
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (this.editor.onSelectionChanged) {
|
||||
// this.editor.onSelectionChanged(this.editor);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'KeyG') {
|
||||
// if (!this.meshMoveMode) {
|
||||
// console.log('move mode');
|
||||
// this.meshMoveMode = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'KeyX') {
|
||||
// if (this.meshMoveMode) {
|
||||
// console.log('move along x');
|
||||
// this.meshMoveXMode = true;
|
||||
// this.meshMoveYMode = false;
|
||||
// this.meshMoveZMode = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'KeyY') {
|
||||
// if (this.meshMoveMode) {
|
||||
// console.log('move along y');
|
||||
// this.meshMoveXMode = false;
|
||||
// this.meshMoveYMode = true;
|
||||
// this.meshMoveZMode = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'KeyZ') {
|
||||
// if (this.meshMoveMode) {
|
||||
// console.log('move along z');
|
||||
// this.meshMoveXMode = false;
|
||||
// this.meshMoveYMode = false;
|
||||
// this.meshMoveZMode = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'Escape') {
|
||||
// if (this.meshMoveMode) {
|
||||
// this.meshMoveMode = false;
|
||||
// console.log('TODO: implement restore positions');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.code == 'Enter') {
|
||||
// if (this.meshMoveMode) {
|
||||
// this.meshMoveMode = false;
|
||||
// console.log('TODO: implement apply positions');
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// GameLib.D3.Input.Editor.prototype.onMouseDown = function(entity) {
|
||||
//
|
||||
// return function(event) {
|
||||
//
|
||||
// if (event.button === 2) {
|
||||
// event.cancelBubble = true;
|
||||
//
|
||||
// event.preventDefault();
|
||||
//
|
||||
// if (event.stopPropagation) {
|
||||
// event.stopPropagation();
|
||||
// }
|
||||
//
|
||||
// var meshes = entity.queryComponents(GameLib.D3.Mesh);
|
||||
//
|
||||
// var intersects = this.raycaster.getIntersectedObjects(meshes);
|
||||
//
|
||||
// if (intersects.length > 0) {
|
||||
//
|
||||
// console.log('object(s) instersected');
|
||||
//
|
||||
// // var index = -1;
|
||||
// //
|
||||
// // for (var s = 0; s < this.editor.selectedObjects.length; s++) {
|
||||
// // if (this.editor.selectedObjects[s].object == intersects[0]) {
|
||||
// // index = s;
|
||||
// // break;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // if (index == -1) {
|
||||
// // /**
|
||||
// // * The object is not selected, select it
|
||||
// // */
|
||||
// // this.selectObject(intersects[0]);
|
||||
// //
|
||||
// // } else {
|
||||
// // /**
|
||||
// // * De-select the objec
|
||||
// // */
|
||||
// // var delta = Date.now() - this.editor.selectedObjects[index].lastUpdate;
|
||||
// // if (delta > this.selectDelayMs) {
|
||||
// // this.unselectObject(intersects[0]);
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // if (this.editor.onSelectionChanged) {
|
||||
// // this.editor.onSelectionChanged(this.editor);
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Mouse click events
|
||||
// * @param event
|
||||
// * @returns {boolean}
|
||||
// */
|
||||
// GameLib.D3.Input.Editor.prototype.onMouseDown = function(event) {
|
||||
//
|
||||
// if (event.button === 2) {
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (event.button == 0) {
|
||||
// if (this.meshMoveMode) {
|
||||
// this.meshMoveMode = false;
|
||||
// this.meshMoveXMode = false;
|
||||
// this.meshMoveYMode = false;
|
||||
// this.meshMoveZMode = false;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Mouse move events
|
||||
// * @param event
|
||||
// */
|
||||
// GameLib.D3.Input.Editor.prototype.onMouseMove = function(event) {
|
||||
//
|
||||
// // var clientX = event.clientX - this.widthOffset;
|
||||
// // this.mouse.x = ((clientX / (window.innerWidth - this.widthOffset))) * 2 - 1;
|
||||
// // this.mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
//
|
||||
// this.mouse.x = event.clientX;
|
||||
// this.mouse.y = event.clientY;
|
||||
//
|
||||
// console.log("mouse (" + this.mouse.x + ", " + this.mouse.y + ")");
|
||||
//
|
||||
// this.raycaster.instance.setFromCamera(
|
||||
// this.mouse,
|
||||
// this.camera.instance
|
||||
// );
|
||||
//
|
||||
// if (this.meshMoveMode) {
|
||||
//
|
||||
// var units = event.movementY;
|
||||
//
|
||||
// if (this.meshMoveXMode) {
|
||||
// this.moveSelectedObjects('x', units);
|
||||
// }
|
||||
//
|
||||
// if (this.meshMoveYMode) {
|
||||
// this.moveSelectedObjects('y', units);
|
||||
// }
|
||||
//
|
||||
// if (this.meshMoveZMode) {
|
||||
// this.moveSelectedObjects('z', units);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Moves selected objects along an axis
|
||||
// * @param alongAxis
|
||||
// * @param units
|
||||
// */
|
||||
// GameLib.D3.Input.Editor.prototype.moveSelectedObjects = function(alongAxis, units) {
|
||||
//
|
||||
// for (var s = 0; s < this.editor.selectedObjects.length; s++) {
|
||||
//
|
||||
// var object = this.editor.selectedObjects[s].object;
|
||||
//
|
||||
// if (object.position) {
|
||||
// if (alongAxis == 'x') {
|
||||
// object.position.x += units;
|
||||
// }
|
||||
// if (alongAxis == 'y') {
|
||||
// object.position.y += units;
|
||||
// }
|
||||
// if (alongAxis == 'z') {
|
||||
// object.position.z += units;
|
||||
// }
|
||||
//
|
||||
// if (object.updateInstance) {
|
||||
// object.updateInstance();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
|
|
@ -154,18 +154,24 @@ GameLib.D3.Raycaster.prototype.getIntersectedObjects = function(meshes) {
|
|||
}
|
||||
);
|
||||
|
||||
var instanceIdToMesh = meshes.reduce(
|
||||
function (result, mesh) {
|
||||
result[mesh.instance.id] = mesh;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
var intersects = this.instance.intersectObjects(meshInstances);
|
||||
|
||||
return intersects.map(function (intersect) {
|
||||
return instanceIdToMesh[intersect.object.id];
|
||||
});
|
||||
return intersects.reduce(
|
||||
|
||||
function (result, intersect) {
|
||||
|
||||
meshes.map(
|
||||
function(mesh){
|
||||
if (mesh.instance === intersect.object){
|
||||
result.push(mesh);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -60,7 +60,30 @@ GameLib.System.SYSTEM_TYPE_ALL = 0x7;
|
|||
GameLib.System.prototype.start = function() {
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
|
||||
// this.driveInputObjects = this.entityManager.query([GameLib.D3.Input.Drive]);
|
||||
|
||||
/**
|
||||
* Hookup all editor input capabilities
|
||||
*/
|
||||
var entities = this.entityManager.query([GameLib.D3.Input.Editor]);
|
||||
|
||||
entities.map(function(entity){
|
||||
|
||||
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
||||
|
||||
component.mouseDown = component.onMouseDown(entity).bind(component);
|
||||
component.mouseMove = component.onMouseMove(entity).bind(component);
|
||||
component.keyDown = component.onKeyDown(entity).bind(component);
|
||||
// component.contextMenu = component.onContextMenu(entity).bind(component);
|
||||
|
||||
|
||||
component.domElement.instance.addEventListener('mousedown', component.mouseDown, false);
|
||||
component.domElement.instance.addEventListener('mousemove', component.mouseMove, false);
|
||||
component.domElement.instance.addEventListener('keydown', component.keyDown, false);
|
||||
component.controls = new THREE.EditorControls(component.camera.instance, component.domElement.instance);
|
||||
|
||||
// component.domElement.instance.addEventListener('contextmenu', component.contextMenu, false);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
|
||||
|
@ -115,11 +138,11 @@ GameLib.System.prototype.start = function() {
|
|||
GameLib.System.prototype.update = function(deltaTime) {
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
|
||||
this.driveInputObjects.forEach(
|
||||
function(object) {
|
||||
object.update(deltaTime);
|
||||
}
|
||||
);
|
||||
// this.driveInputObjects.forEach(
|
||||
// function(object) {
|
||||
// object.update(deltaTime);
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
|
||||
|
@ -191,7 +214,7 @@ GameLib.System.prototype.update = function(deltaTime) {
|
|||
scene.instance,
|
||||
camera.instance
|
||||
);
|
||||
renderer.instance.clearDepth();
|
||||
//renderer.instance.clearDepth();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -206,7 +229,22 @@ GameLib.System.prototype.update = function(deltaTime) {
|
|||
GameLib.System.prototype.stop = function() {
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
|
||||
// this.driveInputObjects = [];
|
||||
|
||||
/**
|
||||
* Now remove all editor input capabilities
|
||||
*/
|
||||
var entities = this.entityManager.query([GameLib.D3.Input.Editor]);
|
||||
|
||||
entities.map(function(entity){
|
||||
var component = entity.getFirstComponent(GameLib.D3.Input.Editor);
|
||||
component.domElement.instance.removeEventListener('mousedown', component.mouseDown, false);
|
||||
component.domElement.instance.removeEventListener('mousemove', component.mouseMove, false);
|
||||
component.domElement.instance.removeEventListener('keydown', component.keyDown, false);
|
||||
// component.domElement.instance.removeEventListener('contextmenu', component.contextMenu, false);
|
||||
component.controls.dispose();
|
||||
});
|
||||
|
||||
console.log('stopped all input systems');
|
||||
}
|
||||
|
||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
|
||||
|
|
Loading…
Reference in New Issue