
Security News
Google’s OSV Fix Just Added 500+ New Advisories — All Thanks to One Small Policy Change
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
spinning-ball
Advanced tools
Simulate the position and motion of a camera above the Earth
Camera position above a spherical Earth is represented as a 3-vector of longitude, latitude, altitude, with associated angular and vertical velocities.
Accelerations can be induced by user interaction with the HTML div where the sphere will be rendered. Handled interactions include:
Velocities are damped, with weak damping when there are no active touches or clicks, to allow coasting. With an active touch/click/zoom, the damping constant is chosen for critical damping of the relevant induced spring force, to avoid any oscillation.
Note that the camera and the spherical Earth as modeled by spinning-ball are both purely conceptual. To display what would be seen by the camera, a separate renderer is required. See the example for a demo with a simple D3 renderer.
A spinning-ball instance can be initialized as follows:
import * as spinningBall from 'spinning-ball';
const ball = spinningBall.init(parameters);
The supplied parameters object has the following properties:
display
(REQUIRED): An HTML element where the globe will be represented,
and where the user's client will generate interaction eventsunits
: Specify "degrees" or "radians" as the units of any supplied or
returned longitude and latitude coordinates. Default: "degrees"position
: The initial position of the camera. Longitude and latitude
must be in the specified units. Altitude must be in kilometers, and between
minAltitude and maxAltitude.
Default: [0.0, 0.0, 4 * earthRadius]
where earthRadius == 6371.0
minAltitude
: The minimum altitude of the camera, in kilometers.
Default: 0.0001 * earthRadius
maxAltitude
: The maximum altitude of the camera, in kilometers.
Default: 8.0 * earthRadius
minLongitude
: The minimum longitude of the camera, in the specified units.
Default: -180 degrees (or -PI radians)maxLongitude
: The maximum longitude of the camera, in the specified units.
Default: +180 degrees (or +PI radians).
Note: if both minLongitude
and maxLongitude
are set to their defaults,
the globe can be spun freely (it will not stop at the antimeridian)minLatitude
: The minimum latitude of the camera, in the specified units.
Default: -90 degrees (or -PI / 2 radians)maxLatitude
: The maximum latitude of the camera, in the specified units.
Default: +90 degrees (or +PI / 2 radians)Initialization returns an object with the following properties and methods:
view
: Pointer to a view object as generated by the initView
method of
yawgl. This can compute ray parameters at a point on the displayradius()
: Returns the (floating point) radius of the sphere, in kilometersproject(xy, geodetic)
: Projects a given position to the [x,y] pair of
display pixel coordinates where that position would be renderedcameraPos()
: Returns the current position of the cameracursorPos()
: Returns the position that would be rendered at the current
screen position of the cursorcamMoving()
: Returns a (Boolean) flag indicating whether the camera is
movingisOnScene()
: Returns a (Boolean) flag indicating whether a ray shot from
the current cursor position would intersect the globewasTapped()
: Returns a (Boolean) flag indicating whether the globe has been
tapped or clicked since the last updatecursorChanged()
: Returns a (Boolean) flag indicating whether there has been
any change in the position or status of the cursor relative to the globeupdate(time)
: Updates the position and velocity of the camera, taking into
account any current velocities, and computing new accelerations induced by
mouse or touch interactions.
flyTo(position)
: Starts an animated flight that moves the camera to the
provided position. The supplied position MUST be in the units
specified
on initialization, and within the specified bounds on longitude, latitude,
and altitude. Note: the flight will be stepped through on subsequent
calls to .update
, and canceled by any subsequent click/touch action.spinning-ball represents positions on the globe as 3-element arrays, of [longitude, latitude, altitude]. Longitude and latitude are in the units specified on initialization. Altitude is in kilometers.
This convention is assumed for the initial camera position
(on initialization)
and for the second argument of the API .project
method. It is also the format
of the values returned by .cameraPos()
and .cursorPos()
.
Some functions include math for an ellipsoid, with different values for the polar and equatorial radius. However, the two radii MUST be kept equal for now, until the remaining functions are updated to handle a non-spherical Earth.
FAQs
Simulate the position and motion of a camera above the Earth
We found that spinning-ball demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
Research
/Security News
175 malicious npm packages (26k+ downloads) used unpkg CDN to host redirect scripts for a credential-phishing campaign targeting 135+ organizations worldwide.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.