title: Creating a module for babylon.js scene
body: <p>This is the first external JavaScript "module" I've attempted to build. I"m using Babylon.js to create a space scene. I'm not having trouble with the library itself. This is relating to something I dont understand about using modules. What I want to do is put a constructor in another file. instances of this constructor will create this star mesh I've designed. If i keep the constructor in the file, it works. If i put it in another file called Star.js, then put that in a script tag in the header, the page loads white blank.</p>
  
  <p>I've also tried wrapping it in parentheses in the various patterns I've read about for anonymous functions...doesn't seem to matter, and I thought it should work anyway.</p>
  
  <p>Here's whats in the file...(unwrapped)</p>
  
  <pre><code>var Star = function (position) {
  this.sphere = BABYLON.Mesh.CreateSphere("sphere1", 50, 100, scene);
  this.mat = new BABYLON.StandardMaterial("white", scene);
  this.mat.diffuseTexture = new BABYLON.Texture("textures/suntexture.jpg", scene);
  this.mat.specularColor = new BABYLON.Color3(0, 0, 0);
  this.sphere.material = this.mat;
  this.sphere.position = position;
  
  this.particleSystem = new BABYLON.ParticleSystem("particles", 15000, scene);
  this.particleSystem.particleTexture = new BABYLON.Texture("textures/fireflare.jpg", scene);
  this.particleSystem.emitter = this.sphere;
  this.particleSystem.color1 = new BABYLON.Color4(0.984, 0.337, 0.047, 1);
  this.particleSystem.color2 = new BABYLON.Color4(0.984, 0.757, 0.047, 1);
  this.particleSystem.minSize = 8;
  this.particleSystem.maxSize = 30;
  this.particleSystem.minLifeTime = 0.5;
  this.particleSystem.maxLifeTime = 0.8;
  this.particleSystem.emitRate = 15000;
  this.particleSystem.direction1 = new BABYLON.Vector3(-120, -120, -120);
  this.particleSystem.direction2 = new BABYLON.Vector3(120, 120, 120);
  this.particleSystem.minAngularSpeed = 0;
  this.particleSystem.maxAngularSpeed = Math.PI;
  this.particleSystem.minEmitPower = 1;
  this.particleSystem.maxEmitPower = 3;
  this.particleSystem.updateSpeed = 0.01;
  this.particleSystem.start();
  };
  </code></pre>
  
  <p>Here's a clipped version of what the file looks like (relevant parts)</p>
  
  <pre><code>&lt;head&gt;
  &lt;script src="js/babylon.js" &gt;&lt;/script&gt;
  &lt;script src="js/star.js" &gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;canvas id="renderCanvas"&gt;&lt;/canvas&gt;
  &lt;script&gt;
  
  var star1 = new Star(new BABYLON.Vector3(500, 500, 1000));
  var star2 = new Star(new BABYLON.Vector3(0, -100, 200));
  var star3 = new Star(new BABYLON.Vector3(-600, 200, 1200));
  &lt;/script&gt;
  </code></pre>
  
  <p>I've read alot about JS modules...but as much as you can search and read and search and try to find the answer, it's different when you're trying to build it yourself because there's that one piece of information you didn't have.. I'm going to design the entire scene this way in different folders as my first major project, so my understanding here is pretty vital
  Thx</p>