@kitschpatrol/tweakpane-plugin-rotation
v0.2.1-fork.2
Published
Fork of tweakpane-plugin-rotation with build optimizations.
Maintainers
Readme
@kitschpatrol/tweakpane-plugin-rotation
Fork of tweakpane-plugin-rotation with build optimizations.
Overview
This is a fork of 0b5vr's @0b5vr/tweakpane-plugin-rotation with externalized dependencies.
This allows for smaller bundled file sizes in projects using multiple Tweakpane plugins.
It is published to NPM primarily for the Svelte Tweakpane UI project, and will be kept in sync with the upstream version of the plugin, with minimal changes other than dependency externalization.
See the upstream readme for details on the original plugin and its usage.
Fork changes
- Publishes as
@kitschpatrol/tweakpane-plugin-rotationinstead of@0b5vr/tweakpane-plugin-rotation. - Adds a
/liteexport that imports@tweakpane/coreinstead of bundling it so projects can share one copy ofcoreacross multiple plugins. - Exports public parameter types.
- Migrates the repository structure to align with the Tweakpane plugin template provided by @kitschpatrol/create-project, which includes:
Getting started
Dependencies
The plugin requires Tweakpane 4.
The /lite export path imports @tweakpane/core rather than bundling it. It is installed as a dependency of this plugin, so only projects without a bundler need to provide it directly.
If you're using Svelte 4 or 5 as a front-end library, take a look at Svelte Tweakpane UI, which wraps Tweakpane in a set of Svelte-friendly components, including the <RotationEuler> and <RotationQuaternion> controls from this plugin.
Installation
Add it to your project:
npm install @kitschpatrol/tweakpane-plugin-rotationUsage
import * as TweakpanePluginRotation from '@kitschpatrol/tweakpane-plugin-rotation'
import { Pane } from 'tweakpane'
const pane = new Pane()
pane.registerPlugin(TweakpanePluginRotation)
const parameters = { rotation: { x: 0, y: 0, z: 0 } }
pane.addBinding(parameters, 'rotation', {
rotationMode: 'euler',
unit: 'deg',
view: 'rotation',
})To share core through your bundler, import @kitschpatrol/tweakpane-plugin-rotation/lite instead.
Implementation notes
The Rollup configuration provided in the Tweakpane plugin template does not externalize @tweakpane/core as a production dependency.
Instead, it gets built into the single-file plugin artifact, which is what's published to NPM and imported by plugin consumers. This makes it easy to import as an ES module from a URL, but means that larger projects importing multiple Tweakpane plugins end up with duplicate copies of the @tweakpane/core code, adding about ~100 Kb to the final minified build for each plugin after the first.
Externalizing this dependency allows build tools like vite to share a single instance of the @tweakpane/core code across multiple plugins.
If you're not using a bundler, direct ESM imports from URLs can still work by defining the @tweakpane/core dependency in an importmap.
Versioning
In addition to the dependency externalization change, this fork also includes dependency updates. In an effort to stay in sync with future upstream versions, release version numbers are tagged with a "fork" suffix and an incrementing number.
This fork releases from main; upstream uses dev.
Contributing
Issues are welcome and appreciated.
Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs (especially AI-generated ones) are unlikely to be merged.
This repository uses @kitschpatrol/shared-config (via its ksc CLI) for linting and formatting, plus MDAT for readme placeholder expansion.
License
Original plugin: MIT © 0b5vr
