Germanyrawify/Trackball.js
The RAW library to add a virtual Trackball to your DOM
🎛️ Spin Your DOM Elements with a Virtual Trackball
Turn pointer drags into smooth 3D rotations.
Trackball.js is a small JavaScript library built on top of Quaternion.js that lets you add a virtual trackball to any DOM element. It captures pointer input, computes a quaternion representing the rotation, and calls your callback so you can apply the transform. This frees you from writing your own rotation math while giving you full control over styling.
✨ Highlights
- Virtual trackball: translates pointer drags into natural 3D rotation.
- Quaternion math: built on Quaternion.js for stable, gimbal‑free rotations.
- CSS transform output: provides
toCSSTransform()for direct application. - Active area: restrict interaction to a sub‑rectangle of the scene.
- Inertia: optional damping simulates continued motion after release.
- Axis locking:
limitAxiscan lock rotation to X or Y.
💡 Why it matters
Unlike libraries that bundle styling, Trackball.js only computes the rotation quaternion, letting you design the UI exactly as you wish. This separation makes it easy to integrate into existing projects without overriding your CSS.
Because it works with any DOM element and outputs a standard quaternion, it fits well for 3D product viewers, interactive diagrams, or any site that needs intuitive rotation controls.
#JavaScript #3D #Trackball #TiniX
Similar Projects
Discover other similar projects and AI models.
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Coding articles to level up your development skills
24 Lessons, 12 Weeks, Get Started as a Web Developer