Scene.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var game = Atomic.game;
  2. var node = self.node;
  3. function start() {
  4. var scene = game.scene;
  5. var cache = game.cache;
  6. // zone
  7. var zoneNode = scene.createChild("Zone")
  8. var zone = zoneNode.createComponent("Zone");
  9. zone.boundingBox = [-1000, -1000, -1000, 1000, 1000 , 1000];
  10. zone.ambientColor = [0.15, 0.15, 0.15];
  11. zone.fogColor = [0.5, 0.5, 0.7, 1.0];
  12. zone.fogStart = 10;
  13. zone.fogEnd = 100;
  14. var lightNode = scene.createChild("Directional Light");
  15. lightNode.direction = [0.6, -1.0, 0.8];
  16. var light = lightNode.createComponent("Light")
  17. light.lightType = Atomic.LIGHT_DIRECTIONAL;
  18. light.castShadows = true;
  19. // If we're running on android tweak the shadows
  20. if (Atomic.platform == "Android") {
  21. light.setShadowCascade(20.0, 50.0, 200.0, 0.0, 0.9);
  22. light.shadowIntensity = 0.33;
  23. } else {
  24. light.setShadowCascade(10.0, 50.0, 200.0, 0.0, 0.8);
  25. }
  26. light.setShadowBias(0.00025, 0.5);
  27. light.specularIntensity = 8;
  28. // create the grid plane
  29. var planeNode = scene.createChild("Plane");
  30. planeNode.scale = [100.0, 1.0, 100.0];
  31. var planeObject = planeNode.createComponent("StaticModel");
  32. var model = cache.getResource("Model", "Models/Plane.mdl");
  33. var material = cache.getResource("Material", "Materials/BlueGrid.xml");
  34. planeObject.model = model;
  35. planeObject.material = material;
  36. // add the roboman
  37. var roboman = node.createChild("TheRoboMan");
  38. roboman.createJSComponent("RoboMan");
  39. }
  40. // we need an update or it doesn't run the start, fix in JSVM
  41. function update(timeStep) {
  42. }