anaglyphGamepadCamera.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. Node.AddNodeConstructor("AnaglyphGamepadCamera", (name, scene, options) => {
  2. return () => new AnaglyphGamepadCamera(name, Vector3.Zero(), options.interaxial_distance, scene);
  3. });
  4. /**
  5. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  7. */
  8. export class AnaglyphGamepadCamera extends GamepadCamera {
  9. /**
  10. * Creates a new AnaglyphGamepadCamera
  11. * @param name defines camera name
  12. * @param position defines initial position
  13. * @param interaxialDistance defines distance between each color axis
  14. * @param scene defines the hosting scene
  15. */
  16. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene) {
  17. super(name, position, scene);
  18. this.interaxialDistance = interaxialDistance;
  19. this.setCameraRigMode(Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  20. }
  21. /**
  22. * Gets camera class name
  23. * @returns AnaglyphGamepadCamera
  24. */
  25. public getClassName(): string {
  26. return "AnaglyphGamepadCamera";
  27. }
  28. }