First commit
This commit is contained in:
76
engine/sceneNode.js
Executable file
76
engine/sceneNode.js
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2013-2019, kaj dijkstra ,
|
||||
* Author, Kaj Dijkstra.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Scene Node
|
||||
**/
|
||||
class sceneNode{
|
||||
|
||||
rootEntity;
|
||||
entitys = [];
|
||||
|
||||
/**
|
||||
* add entity to sceneNode
|
||||
* @param {(entity)} entity
|
||||
**/
|
||||
addEntity(entity){
|
||||
|
||||
|
||||
this.entitys.push(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get entity's
|
||||
* @param {(entity)} entity
|
||||
**/
|
||||
getEntitys(entity){
|
||||
return this.entitys;
|
||||
}
|
||||
|
||||
getEntityByName(name){
|
||||
for(var c = 0; c<this.entitys.length;c++) {
|
||||
if(this.entitys[c].name == name)
|
||||
return this.entitys[c];
|
||||
}
|
||||
}
|
||||
getEntityByID(id){
|
||||
|
||||
for(var c = 0; c<this.entitys.length;c++) {
|
||||
if(this.entitys[c].id == id)
|
||||
return this.entitys[c];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getEntityByName(name){
|
||||
for(var c = 0; c<this.entitys.length;c++) {
|
||||
if(this.entitys[c].name == name)
|
||||
return this.entitys[c];
|
||||
}
|
||||
}
|
||||
|
||||
removeEntityByName(name){
|
||||
for(var c = 0; c<this.entitys.length;c++) {
|
||||
if(this.entitys[c].name == name)
|
||||
this.entitys.splice(c, 1);
|
||||
}
|
||||
|
||||
|
||||
var children = kepler.system.scene.rootEntity.children[0].children;
|
||||
for(var c = 0; c<children.length;c++) {
|
||||
if(children[c].name == name)
|
||||
children.splice(c, 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export {sceneNode as default};
|
||||
Reference in New Issue
Block a user