babylon.abstractScene.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. module BABYLON {
  2. /**
  3. * Defines how the parser contract is defined.
  4. */
  5. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  6. /**
  7. * Base class of the scene acting as a container for the different elements composing a scene.
  8. * This class is dynamically extended by the different components of the scene increasing
  9. * flexibility and reducing coupling.
  10. */
  11. export abstract class AbstractScene {
  12. /**
  13. * Stores the list of available parsers in the application.
  14. */
  15. private static _BabylonFileParsers: { [key: string]: BabylonFileParser } = { };
  16. /**
  17. * Adds a parser in the list of availables ones.
  18. * @param name Defines the name of the parser
  19. * @param parser Defines the parser to add
  20. */
  21. public static AddParser(name: string, parser: BabylonFileParser): void {
  22. this._BabylonFileParsers[name] = parser;
  23. }
  24. /**
  25. * Parser json data and populate both a scene and its associated container object
  26. * @param jsonData Defines the data to parse
  27. * @param scene Defines the scene to parse the data for
  28. * @param container Defines the container attached to the parsing sequence
  29. * @param rootUrl Defines the root url of the data
  30. */
  31. public static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void {
  32. for (let parserName in this._BabylonFileParsers) {
  33. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  34. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  35. }
  36. }
  37. }
  38. /** All of the cameras added to this scene
  39. * @see http://doc.babylonjs.com/babylon101/cameras
  40. */
  41. public cameras = new Array<Camera>();
  42. /**
  43. * All of the lights added to this scene
  44. * @see http://doc.babylonjs.com/babylon101/lights
  45. */
  46. public lights = new Array<Light>();
  47. /**
  48. * All of the (abstract) meshes added to this scene
  49. */
  50. public meshes = new Array<AbstractMesh>();
  51. /**
  52. * The list of skeletons added to the scene
  53. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  54. */
  55. public skeletons = new Array<Skeleton>();
  56. /**
  57. * All of the particle systems added to this scene
  58. * @see http://doc.babylonjs.com/babylon101/particles
  59. */
  60. public particleSystems = new Array<IParticleSystem>();
  61. /**
  62. * Gets a list of Animations associated with the scene
  63. */
  64. public animations: Animation[] = [];
  65. /**
  66. * All of the animation groups added to this scene
  67. * @see http://doc.babylonjs.com/how_to/group
  68. */
  69. public animationGroups = new Array<AnimationGroup>();
  70. /**
  71. * All of the multi-materials added to this scene
  72. * @see http://doc.babylonjs.com/how_to/multi_materials
  73. */
  74. public multiMaterials = new Array<MultiMaterial>();
  75. /**
  76. * All of the materials added to this scene
  77. * @see http://doc.babylonjs.com/babylon101/materials
  78. */
  79. public materials = new Array<Material>();
  80. /**
  81. * The list of morph target managers added to the scene
  82. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  83. */
  84. public morphTargetManagers = new Array<MorphTargetManager>();
  85. /**
  86. * The list of geometries used in the scene.
  87. */
  88. public geometries = new Array<Geometry>();
  89. /**
  90. * All of the tranform nodes added to this scene
  91. * @see http://doc.babylonjs.com/how_to/transformnode
  92. */
  93. public transformNodes = new Array<TransformNode>();
  94. /**
  95. * ActionManagers available on the scene.
  96. */
  97. public actionManagers = new Array<ActionManager>();
  98. /**
  99. * Sounds to keep.
  100. */
  101. public sounds = new Array<Sound>();
  102. /**
  103. * Textures to keep.
  104. */
  105. public textures = new Array<BaseTexture>();
  106. }
  107. }