@pixi/3d
    Preparing search index...

    Class Spherical

    A point given as radius, phi and theta around the origin: its distance, its angle down from +Y, and its angle around +Y, measured from +Z toward +X

    Use it for anything that orbits: convert a position in, change the angles, then convert back with Vector3#setFromSpherical.

    const orbit = new Spherical().setFromPoint3D(camera.position);

    orbit.theta += 0.01;
    orbit.phi -= 0.005;
    orbit.makeSafe();
    camera.position.setFromSpherical(orbit);
    camera.lookAt({ x: 0, y: 0, z: 0 });
    Index
    • Creates a new Spherical

      Parameters

      • radius: number = 1

        Distance from origin

      • phi: number = 0

        Polar angle (radians) measured from +Y

      • theta: number = 0

        Azimuthal angle (radians) measured from +Z

      Returns Spherical

    phi: number = 0

    Angle in radians down from +Y: 0 points straight up, π / 2 lies level, π points straight down

    orbit.phi = Math.PI / 3;
    
    radius: number = 0

    Distance from the origin

    orbit.radius = Math.max(2, orbit.radius - wheelDelta * 0.01);
    
    theta: number = 0

    Angle in radians around +Y, measured from +Z toward +X

    orbit.theta += ticker.deltaMS * 0.0005;
    
    type: SHAPE_PRIMITIVE_3D = 'spherical'

    Names the shape without an instanceof check, like the type on pixi's 2D shapes

    'spherical'
    
    • Creates a copy of this spherical

      Returns Spherical

      A new Spherical with the same values

      const resetView = orbit.clone();
      
    • Copies other into this spherical

      Parameters

      • other: Spherical

        The spherical to copy from

      Returns this

      This spherical, for chaining

      savedView.copyFrom(orbit);
      
    • Copies this spherical into target

      Type Parameters

      Parameters

      • target: T

        The spherical to copy into

      Returns T

      The target with values updated

      orbit.copyTo(savedView);
      
    • Checks whether other matches this spherical

      Parameters

      • other: Spherical

        The spherical to compare with

      Returns boolean

      true when radius, phi and theta match exactly (no epsilon tolerance)

      if (!orbit.equals(lastOrbit)) saveCameraState(orbit);
      
    • Keeps phi a millionth of a radian away from both poles

      A camera that looks at its target with +Y up flips at a pole, so call this after changing phi and before converting back.

      Returns this

      This spherical, for chaining

      orbit.phi -= pointerDeltaY * 0.01;
      orbit.makeSafe();
    • Sets radius, phi and theta

      Parameters

      • radius: number

        Distance from origin

      • phi: number

        Polar angle (radians) measured from +Y

      • theta: number

        Azimuthal angle (radians) measured from +Z

      Returns this

      This spherical, for chaining

      const sunDirection = new Vector3().setFromSpherical(new Spherical().set(1, sunPolarAngle, sunAzimuth));
      
    • Sets this spherical from Cartesian (x, y, z)

      Zero-radius inputs collapse theta and phi to 0.

      Parameters

      • x: number

        Position on the x axis

      • y: number

        Position on the y axis

      • z: number

        Position on the z axis

      Returns this

      This spherical, for chaining

      orbit.setFromCartesianCoords(eye.x - target.x, eye.y - target.y, eye.z - target.z);
      
    • Sets this spherical from the Cartesian point v

      Parameters

      Returns this

      This spherical, for chaining

      const orbit = new Spherical().setFromPoint3D(camera.position);
      
    • Advanced

      Returns a readable string representation of this spherical

      Returns string

      A string in the form [@pixi/3d/math:Spherical radius=1 phi=0 theta=0]