Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. //---------------------------------------------------------------------------------------------
  2. // VERSION ONE
  3. //
  4. // - Properties are objects, with get() and set() methods to update their values.
  5.  
  6. // - Listen for changes on a property value by registering a change listener
  7. // on the property's on() method.
  8. //---------------------------------------------------------------------------------------------
  9.  
  10.  
  11. // Create a scene
  12. var scene = new XEO.Scene();
  13.  
  14. // Create a 'lookat' viewing transform
  15. var lookat = new XEO.Lookat(scene, {
  16. eye: [0, 0, -10],
  17. look: [0, 0, 0],
  18. up: [0, 1, 0]
  19. });
  20.  
  21. // Subscribe to changes on the lookat's eye
  22. lookat.eye.on(function (value) {
  23. console.log("eye updated: " + value[0] + ", " + value[1] + ", " + value[2]);
  24. });
  25.  
  26. // Set the lookat's eye, which fires our change listener
  27. lookat.eye.set([-5, 0, -10]);
  28.  
  29. // Get the lookat's eye
  30. var value = lookat.eye.get();
  31.  
  32.  
  33. //---------------------------------------------------------------------------------------------
  34. // VERSION TWO
  35. //
  36. // - Properties are raw values that you can read or write directly.
  37. //
  38. // - Listen for changes to a property's value by registering a listener on the owner object, to
  39. // listen for an event matching the property name, that will be fired by the owner object when
  40. // you set the property equal to a new value.
  41. //---------------------------------------------------------------------------------------------
  42.  
  43. // Create a scene
  44. var scene = new XEO.Scene();
  45.  
  46. // Create a 'lookat' viewing transform
  47. var lookat = new XEO.Lookat(scene, {
  48. eye: [0, 0, -10],
  49. look: [0, 0, 0],
  50. up: [0, 1, 0]
  51. });
  52.  
  53. // Subscribe to changes on the lookat's eye
  54. lookat.on("eye", function (value) {
  55. console.log("eye updated: " + value[0] + ", " + value[1] + ", " + value[2]);
  56. });
  57.  
  58. // Set the lookat's eye, which fires our change listener
  59. lookat.eye = [-5, 0, -10];
  60.  
  61. // Get the lookat's eye
  62. var value = lookat.eye;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement