76 lines
1.2 KiB
JavaScript
Executable File
76 lines
1.2 KiB
JavaScript
Executable File
/*
|
|
* 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}; |