UI.js 1007 B

123456789101112131415161718192021222324252627
  1. "atomic component";
  2. exports.component = function(self) {
  3. var camera = self.node.scene.getComponent("Camera", true);
  4. var octree = self.node.scene.getComponent("Octree", true);
  5. var model = self.node.getComponent("StaticModel");
  6. self.uiOsView = new Atomic.UIOffscreenView();
  7. model.material = self.uiOsView.material;
  8. self.uiOsView.registerInput(camera, octree, model);
  9. // The material property above creates a default material
  10. // that uses the UIOffscreenView's texture2D. Using the
  11. // texture2D in a custom material is also possible.
  12. var widget = new Atomic.UIWidget();
  13. widget.load("UI/stuff.tb.txt");
  14. widget.width = self.uiOsView.width;
  15. widget.height = self.uiOsView.height;
  16. widget.getWidget("stuff").onClick = function() {
  17. // Save a PNG of the UI to use as the texture in
  18. // a geometry editor to give depth to your UI!
  19. self.uiOsView.savePNG("stuff.png");
  20. };
  21. self.uiOsView.addChild(widget);
  22. };