svelte-tweakpane-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/control/ButtonGrid.svelte +49 -0
- package/dist/control/ButtonGrid.svelte.d.ts +190 -0
- package/dist/control/Checkbox.svelte +6 -0
- package/dist/control/Checkbox.svelte.d.ts +113 -0
- package/dist/control/Color.svelte +79 -0
- package/dist/control/Color.svelte.d.ts +177 -0
- package/dist/control/CubicBezier.svelte +74 -0
- package/dist/control/CubicBezier.svelte.d.ts +204 -0
- package/dist/control/Image.svelte +23 -0
- package/dist/control/Image.svelte.d.ts +177 -0
- package/dist/control/IntervalSlider.svelte +37 -0
- package/dist/control/IntervalSlider.svelte.d.ts +196 -0
- package/dist/control/List.svelte +69 -0
- package/dist/control/List.svelte.d.ts +122 -0
- package/dist/control/Point.svelte +100 -0
- package/dist/control/Point.svelte.d.ts +374 -0
- package/dist/control/RadioGrid.svelte +42 -0
- package/dist/control/RadioGrid.svelte.d.ts +231 -0
- package/dist/control/Ring.svelte +19 -0
- package/dist/control/Ring.svelte.d.ts +220 -0
- package/dist/control/RotationEuler.svelte +67 -0
- package/dist/control/RotationEuler.svelte.d.ts +273 -0
- package/dist/control/RotationQuaternion.svelte +65 -0
- package/dist/control/RotationQuaternion.svelte.d.ts +276 -0
- package/dist/control/Slider.svelte +6 -0
- package/dist/control/Slider.svelte.d.ts +165 -0
- package/dist/control/Text.svelte +25 -0
- package/dist/control/Text.svelte.d.ts +129 -0
- package/dist/control/Textarea.svelte +47 -0
- package/dist/control/Textarea.svelte.d.ts +149 -0
- package/dist/control/Wheel.svelte +15 -0
- package/dist/control/Wheel.svelte.d.ts +186 -0
- package/dist/core/Binding.svelte +68 -0
- package/dist/core/Binding.svelte.d.ts +116 -0
- package/dist/core/Blade.svelte +61 -0
- package/dist/core/Blade.svelte.d.ts +90 -0
- package/dist/core/Button.svelte +59 -0
- package/dist/core/Button.svelte.d.ts +65 -0
- package/dist/core/Folder.svelte +69 -0
- package/dist/core/Folder.svelte.d.ts +78 -0
- package/dist/core/Pane.svelte +51 -0
- package/dist/core/Pane.svelte.d.ts +500 -0
- package/dist/core/Separator.svelte +14 -0
- package/dist/core/Separator.svelte.d.ts +85 -0
- package/dist/core/TabGroup.svelte +64 -0
- package/dist/core/TabGroup.svelte.d.ts +72 -0
- package/dist/core/TabPage.svelte +85 -0
- package/dist/core/TabPage.svelte.d.ts +82 -0
- package/dist/extra/AutoObject.svelte +46 -0
- package/dist/extra/AutoObject.svelte.d.ts +108 -0
- package/dist/extra/AutoValue.svelte +11 -0
- package/dist/extra/AutoValue.svelte.d.ts +123 -0
- package/dist/extra/Element.svelte +53 -0
- package/dist/extra/Element.svelte.d.ts +170 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +39 -0
- package/dist/internal/ClsPad.svelte +34 -0
- package/dist/internal/ClsPad.svelte.d.ts +95 -0
- package/dist/internal/GenericBinding.svelte +22 -0
- package/dist/internal/GenericBinding.svelte.d.ts +116 -0
- package/dist/internal/GenericBladeFolding.svelte +38 -0
- package/dist/internal/GenericBladeFolding.svelte.d.ts +95 -0
- package/dist/internal/GenericInput.svelte +19 -0
- package/dist/internal/GenericInput.svelte.d.ts +116 -0
- package/dist/internal/GenericInputFolding.svelte +40 -0
- package/dist/internal/GenericInputFolding.svelte.d.ts +140 -0
- package/dist/internal/GenericMonitor.svelte +24 -0
- package/dist/internal/GenericMonitor.svelte.d.ts +139 -0
- package/dist/internal/GenericPane.svelte +100 -0
- package/dist/internal/GenericPane.svelte.d.ts +84 -0
- package/dist/internal/GenericSlider.svelte +27 -0
- package/dist/internal/GenericSlider.svelte.d.ts +146 -0
- package/dist/internal/InternalMonitorBoolean.svelte +17 -0
- package/dist/internal/InternalMonitorBoolean.svelte.d.ts +154 -0
- package/dist/internal/InternalMonitorNumber.svelte +31 -0
- package/dist/internal/InternalMonitorNumber.svelte.d.ts +178 -0
- package/dist/internal/InternalMonitorString.svelte +23 -0
- package/dist/internal/InternalMonitorString.svelte.d.ts +162 -0
- package/dist/internal/InternalPaneDraggable.svelte +368 -0
- package/dist/internal/InternalPaneDraggable.svelte.d.ts +178 -0
- package/dist/internal/InternalPaneFixed.svelte +28 -0
- package/dist/internal/InternalPaneFixed.svelte.d.ts +119 -0
- package/dist/internal/InternalPaneInline.svelte +29 -0
- package/dist/internal/InternalPaneInline.svelte.d.ts +106 -0
- package/dist/monitor/FpsGraph.svelte +86 -0
- package/dist/monitor/FpsGraph.svelte.d.ts +230 -0
- package/dist/monitor/Monitor.svelte +14 -0
- package/dist/monitor/Monitor.svelte.d.ts +526 -0
- package/dist/monitor/Profiler.svelte +72 -0
- package/dist/monitor/Profiler.svelte.d.ts +265 -0
- package/dist/monitor/WaveformMonitor.svelte +26 -0
- package/dist/monitor/WaveformMonitor.svelte.d.ts +176 -0
- package/dist/theme.d.ts +91 -0
- package/dist/theme.js +332 -0
- package/dist/utils.d.ts +157 -0
- package/dist/utils.js +238 -0
- package/package.json +280 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { RingSeries } from '@tweakpane/plugin-camerakit/dist/types/util.js';
|
|
3
|
+
type RingUnit = {
|
|
4
|
+
/**
|
|
5
|
+
* The value for the unit.
|
|
6
|
+
*
|
|
7
|
+
* This sets the interval between each `value` labeled on the ring. For example a `value` of
|
|
8
|
+
* `20` will show value labels 0, 20, 40... etc. spaced according to the `pixels` value.
|
|
9
|
+
*/
|
|
10
|
+
value: number;
|
|
11
|
+
/**
|
|
12
|
+
* The number of pixels per unit.
|
|
13
|
+
*
|
|
14
|
+
* This is the amount of space in pixels between each `value` labeled on the ring. For
|
|
15
|
+
* example, if `pixels` is 100 and `value` is 10, you will see a value label on the ring in
|
|
16
|
+
* the form of 10...(100 pixels)...20...(100 pixels)...30... etc.
|
|
17
|
+
*/
|
|
18
|
+
pixels: number;
|
|
19
|
+
/**
|
|
20
|
+
* The number of vertical tick marks between each `value` label on the ring.
|
|
21
|
+
*
|
|
22
|
+
* For example, if `pixels` is `100`, `value` is `10, and `ticks` is `10`, you will have a
|
|
23
|
+
* vertical tick mark every 10 pixels, and a value label every 100 pixels.
|
|
24
|
+
*/
|
|
25
|
+
ticks: number;
|
|
26
|
+
};
|
|
27
|
+
export type { RingSeries, RingUnit };
|
|
28
|
+
declare const __propDef: {
|
|
29
|
+
props: Omit<
|
|
30
|
+
Omit<
|
|
31
|
+
{
|
|
32
|
+
/**
|
|
33
|
+
* The binding's target object with values to manipulate.
|
|
34
|
+
* @bindable
|
|
35
|
+
*/
|
|
36
|
+
object: import('@tweakpane/core').Bindable & {
|
|
37
|
+
[x: string]: number;
|
|
38
|
+
};
|
|
39
|
+
/** The key for the value in the target `object` that the control should manipulate. */
|
|
40
|
+
key: string | number;
|
|
41
|
+
/**
|
|
42
|
+
* Prevent interactivity and gray out the control.
|
|
43
|
+
* @default `false`
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Text displayed next to control.
|
|
48
|
+
* @default `undefined`
|
|
49
|
+
*/
|
|
50
|
+
label?: string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Tweakpane's internal options object.
|
|
53
|
+
*
|
|
54
|
+
* See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
|
|
55
|
+
*
|
|
56
|
+
* Valid types are contingent on the type of the value `key` points to in `object`.
|
|
57
|
+
*
|
|
58
|
+
* This is intended internal use, when implementing convenience components wrapping Binding's
|
|
59
|
+
* functionality. Options of interest are instead exposed as top-level props in _Svelte
|
|
60
|
+
* Tweakpane UI_.
|
|
61
|
+
* @default `undefined`
|
|
62
|
+
*/
|
|
63
|
+
options?: import('tweakpane').NumberInputParams | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Custom color scheme.
|
|
66
|
+
*
|
|
67
|
+
* @default `undefined` \
|
|
68
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
69
|
+
* set with `setGlobalDefaultTheme()`.
|
|
70
|
+
*/
|
|
71
|
+
theme?: import('..').Theme | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Reference to internal Tweakpane
|
|
74
|
+
* [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
|
|
75
|
+
* this control.
|
|
76
|
+
*
|
|
77
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
78
|
+
* Binding's functionality.
|
|
79
|
+
* @bindable
|
|
80
|
+
* @readonly
|
|
81
|
+
*/
|
|
82
|
+
ref?: import('tweakpane').SliderInputBindingApi | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
|
|
85
|
+
* the binding's containing `<Pane>`.
|
|
86
|
+
*
|
|
87
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
88
|
+
* Binding's functionality in combination with a Tweakpane plugin.
|
|
89
|
+
* @default `undefined`
|
|
90
|
+
*/
|
|
91
|
+
plugin?: import('tweakpane').TpPluginBundle | undefined;
|
|
92
|
+
},
|
|
93
|
+
'object' | 'key'
|
|
94
|
+
> & {
|
|
95
|
+
/**
|
|
96
|
+
* A `number` value to control.
|
|
97
|
+
* @bindable
|
|
98
|
+
*/
|
|
99
|
+
value: number;
|
|
100
|
+
} & {
|
|
101
|
+
/**
|
|
102
|
+
* Minimum value.
|
|
103
|
+
*
|
|
104
|
+
* Specifying both a `min` and a `max` prop turns the control into a slider.
|
|
105
|
+
* @default `undefined`
|
|
106
|
+
*/
|
|
107
|
+
min?: number | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Maximum value.
|
|
110
|
+
*
|
|
111
|
+
* Specifying both a `min` and a `max` prop turns the control into a slider.
|
|
112
|
+
* @default `undefined`
|
|
113
|
+
*/
|
|
114
|
+
max?: number | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* A function to customize the point value's formatting (e.g. rounding, etc.).
|
|
117
|
+
* @default `undefined` \
|
|
118
|
+
* Normal `.toString()` formatting.
|
|
119
|
+
*/
|
|
120
|
+
format?: ((value: number) => string) | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* The unit scale for key-based input for all dimensions (e.g. the up and down arrow keys).
|
|
123
|
+
* @default `1` \
|
|
124
|
+
* Or `stepValue` if defined.
|
|
125
|
+
*/
|
|
126
|
+
keyScale?: number | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* The unit scale for pointer-based input for all dimensions.
|
|
129
|
+
* @default `undefined` \
|
|
130
|
+
* [Dynamic based on magnitude of
|
|
131
|
+
* `value`](https://github.com/cocopon/tweakpane/blob/66dfbea04bfe9b7f031673c955ceda1f92356e75/packages/core/src/common/number/util.ts#L54).
|
|
132
|
+
*/
|
|
133
|
+
pointerScale?: number | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* The minimum step interval.
|
|
136
|
+
* @default `undefined` \
|
|
137
|
+
* No step constraint.
|
|
138
|
+
*/
|
|
139
|
+
step?: number | undefined;
|
|
140
|
+
},
|
|
141
|
+
'options' | 'ref' | 'plugin'
|
|
142
|
+
> & {
|
|
143
|
+
/**
|
|
144
|
+
* A `number` value to control.
|
|
145
|
+
* @bindable
|
|
146
|
+
* */
|
|
147
|
+
value: number;
|
|
148
|
+
/**
|
|
149
|
+
* Style variations.
|
|
150
|
+
* @default `0`
|
|
151
|
+
* */
|
|
152
|
+
series?: RingSeries | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Density and value mapping of the ring's tick marks.
|
|
155
|
+
* @default `{ ticks: 5, pixels: 40, value: 10 }`
|
|
156
|
+
* */
|
|
157
|
+
unit?: RingUnit | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* When `true`, expand the width of the ring control at the expense of the numerical input
|
|
160
|
+
* field.
|
|
161
|
+
* @default `false`
|
|
162
|
+
* */
|
|
163
|
+
wide?: boolean | undefined;
|
|
164
|
+
};
|
|
165
|
+
events: {
|
|
166
|
+
[evt: string]: CustomEvent<any>;
|
|
167
|
+
};
|
|
168
|
+
slots: {};
|
|
169
|
+
};
|
|
170
|
+
export type RingProps = typeof __propDef.props;
|
|
171
|
+
export type RingEvents = typeof __propDef.events;
|
|
172
|
+
export type RingSlots = typeof __propDef.slots;
|
|
173
|
+
/**
|
|
174
|
+
* A control evoking the focus ring on a proper camera lens.
|
|
175
|
+
*
|
|
176
|
+
* Similar in functionality to a `<Slider>`.
|
|
177
|
+
*
|
|
178
|
+
* Integrates the [Ring](https://github.com/tweakpane/plugin-camerakit/blob/main/src/plugin-ring.ts)
|
|
179
|
+
* control from Tweakpane-creator [Hiroki Kokubun's](https://cocopon.me) [Camerakit
|
|
180
|
+
* plugin](https://github.com/tweakpane/plugin-camerakit).
|
|
181
|
+
*
|
|
182
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the ring in `<Pane position='inline'>`.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```svelte
|
|
186
|
+
* <script lang="ts">
|
|
187
|
+
* import { Ring, type RingUnit } from 'svelte-tweakpane-ui';
|
|
188
|
+
*
|
|
189
|
+
* let unitConfig: RingUnit = {
|
|
190
|
+
* value: 20,
|
|
191
|
+
* pixels: 40,
|
|
192
|
+
* ticks: 5
|
|
193
|
+
* };
|
|
194
|
+
*
|
|
195
|
+
* let angle = 45;
|
|
196
|
+
* </script>
|
|
197
|
+
*
|
|
198
|
+
* <Ring
|
|
199
|
+
* bind:value={angle}
|
|
200
|
+
* format={(v) => `${(Math.abs(v) % 360).toFixed(0)}°`}
|
|
201
|
+
* pointerScale={-2.5}
|
|
202
|
+
* unit={unitConfig}
|
|
203
|
+
* wide={true}
|
|
204
|
+
* />
|
|
205
|
+
*
|
|
206
|
+
* <div class="demo" style:--a="{angle}deg" />
|
|
207
|
+
*
|
|
208
|
+
* <style>
|
|
209
|
+
* div.demo {
|
|
210
|
+
* aspect-ratio: 1;
|
|
211
|
+
* width: 100%;
|
|
212
|
+
* background: linear-gradient(var(--a), magenta, orange);
|
|
213
|
+
* }
|
|
214
|
+
* </style>
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @sourceLink
|
|
218
|
+
* [Ring.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Ring.svelte)
|
|
219
|
+
*/
|
|
220
|
+
export default class Ring extends SvelteComponent<RingProps, RingEvents, RingSlots> {}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import * as pluginModule from '@0b5vr/tweakpane-plugin-rotation';
|
|
5
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
6
|
+
import GenericInputFolding from '../internal/GenericInputFolding.svelte';
|
|
7
|
+
import { BROWSER } from 'esm-env';
|
|
8
|
+
export let value;
|
|
9
|
+
export let order = void 0;
|
|
10
|
+
export let unit = void 0;
|
|
11
|
+
export let optionsX = void 0;
|
|
12
|
+
export let optionsY = void 0;
|
|
13
|
+
export let optionsZ = void 0;
|
|
14
|
+
export let expanded = void 0;
|
|
15
|
+
let options;
|
|
16
|
+
let internalValue;
|
|
17
|
+
const buttonClass = 'tp-rotationswatchv_b';
|
|
18
|
+
function updateInternalValue() {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
const [x, y, z] = value;
|
|
21
|
+
internalValue = { x, y, z };
|
|
22
|
+
} else {
|
|
23
|
+
internalValue = value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function updateValue() {
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
const { x, y, z } = internalValue;
|
|
29
|
+
value = [x, y, z];
|
|
30
|
+
} else {
|
|
31
|
+
value = internalValue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
$: value, updateInternalValue();
|
|
35
|
+
$: internalValue, updateValue();
|
|
36
|
+
$: options = {
|
|
37
|
+
x: optionsX,
|
|
38
|
+
y: optionsY,
|
|
39
|
+
z: optionsZ,
|
|
40
|
+
order,
|
|
41
|
+
rotationMode: 'euler',
|
|
42
|
+
unit,
|
|
43
|
+
view: 'rotation'
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<GenericInputFolding
|
|
48
|
+
bind:value={internalValue}
|
|
49
|
+
bind:expanded
|
|
50
|
+
{buttonClass}
|
|
51
|
+
{options}
|
|
52
|
+
plugin={pluginModule}
|
|
53
|
+
{...$$restProps}
|
|
54
|
+
/>
|
|
55
|
+
{#if !BROWSER && expanded && $$props.picker === 'inline'}
|
|
56
|
+
{#if $$props.label !== undefined}
|
|
57
|
+
<ClsPad
|
|
58
|
+
keysAdd={['bladeValueWidth']}
|
|
59
|
+
keysSubtract={[`containerUnitSize`]}
|
|
60
|
+
theme={$$props.theme}
|
|
61
|
+
/>
|
|
62
|
+
{:else}
|
|
63
|
+
<!-- Without a label, the grid takes the full width of the control -->
|
|
64
|
+
<!-- TODO remove magic number -->
|
|
65
|
+
<div style="aspect-ratio: 1; width: calc(100% - 28px);" />
|
|
66
|
+
{/if}
|
|
67
|
+
{/if}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { EulerOrder } from '@0b5vr/tweakpane-plugin-rotation/dist/types/EulerOrder.js';
|
|
3
|
+
import type { EulerUnit } from '@0b5vr/tweakpane-plugin-rotation/dist/types/EulerUnit.js';
|
|
4
|
+
import type { PointDimensionParams } from '@tweakpane/core';
|
|
5
|
+
import type { Simplify } from '../utils';
|
|
6
|
+
export type RotationEulerOptions = Simplify<PointDimensionParams>;
|
|
7
|
+
export type RotationEulerOrder = EulerOrder;
|
|
8
|
+
export type RotationEulerUnit = EulerUnit;
|
|
9
|
+
export type RotationEulerValueObject = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
};
|
|
14
|
+
export type RotationEulerValueTuple = [x: number, y: number, z: number];
|
|
15
|
+
export type RotationEulerValue = Simplify<RotationEulerValueObject | RotationEulerValueTuple>;
|
|
16
|
+
import type { RotationInputPluginEulerParams as RotationEulerOptionsInternal } from '@0b5vr/tweakpane-plugin-rotation/dist/types/RotationInputPluginEulerParams';
|
|
17
|
+
declare const __propDef: {
|
|
18
|
+
props: Omit<
|
|
19
|
+
Omit<
|
|
20
|
+
{
|
|
21
|
+
/**
|
|
22
|
+
* The binding's target object with values to manipulate.
|
|
23
|
+
* @bindable
|
|
24
|
+
*/
|
|
25
|
+
object: import('@tweakpane/core').Bindable & {
|
|
26
|
+
[x: string]: RotationEulerValue;
|
|
27
|
+
};
|
|
28
|
+
/** The key for the value in the target `object` that the control should manipulate. */
|
|
29
|
+
key: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* Prevent interactivity and gray out the control.
|
|
32
|
+
* @default `false`
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Text displayed next to control.
|
|
37
|
+
* @default `undefined`
|
|
38
|
+
*/
|
|
39
|
+
label?: string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Tweakpane's internal options object.
|
|
42
|
+
*
|
|
43
|
+
* See [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
|
|
44
|
+
*
|
|
45
|
+
* Valid types are contingent on the type of the value `key` points to in `object`.
|
|
46
|
+
*
|
|
47
|
+
* This is intended internal use, when implementing convenience components wrapping Binding's
|
|
48
|
+
* functionality. Options of interest are instead exposed as top-level props in _Svelte
|
|
49
|
+
* Tweakpane UI_.
|
|
50
|
+
* @default `undefined`
|
|
51
|
+
*/
|
|
52
|
+
options?: RotationEulerOptionsInternal | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Custom color scheme.
|
|
55
|
+
*
|
|
56
|
+
* @default `undefined` \
|
|
57
|
+
* Inherits default Tweakpane theme equivalent to `ThemeUtils.presets.standard`, or the theme
|
|
58
|
+
* set with `setGlobalDefaultTheme()`.
|
|
59
|
+
*/
|
|
60
|
+
theme?: import('..').Theme | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Reference to internal Tweakpane
|
|
63
|
+
* [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html) for
|
|
64
|
+
* this control.
|
|
65
|
+
*
|
|
66
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
67
|
+
* Binding's functionality.
|
|
68
|
+
* @bindable
|
|
69
|
+
* @readonly
|
|
70
|
+
*/
|
|
71
|
+
ref?: import('../internal/GenericInput.svelte').GenericInputRef | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to automatically register in
|
|
74
|
+
* the binding's containing `<Pane>`.
|
|
75
|
+
*
|
|
76
|
+
* This is primarily for internal use, when implementing convenience components wrapping
|
|
77
|
+
* Binding's functionality in combination with a Tweakpane plugin.
|
|
78
|
+
* @default `undefined`
|
|
79
|
+
*/
|
|
80
|
+
plugin?: import('@tweakpane/core').TpPluginBundle | undefined;
|
|
81
|
+
},
|
|
82
|
+
'object' | 'key'
|
|
83
|
+
> & {
|
|
84
|
+
/**
|
|
85
|
+
* The rotation value to control.
|
|
86
|
+
*
|
|
87
|
+
* Tuple values are a convenience added by _Svelte Tweakpane UI_, and are not part of the
|
|
88
|
+
* original TweakpaneRotationPlugin API.
|
|
89
|
+
*
|
|
90
|
+
* See the `order` prop to specify the sequence in which rotations are applied.
|
|
91
|
+
* @bindable
|
|
92
|
+
*/
|
|
93
|
+
value: RotationEulerValue;
|
|
94
|
+
} & {
|
|
95
|
+
/**
|
|
96
|
+
* DOM class name of the button used to expand and collapse the input's picker.
|
|
97
|
+
* @default `undefined`
|
|
98
|
+
*/
|
|
99
|
+
buttonClass?: string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Expand or collapse the input's picker.
|
|
102
|
+
* @default `false`
|
|
103
|
+
* @bindable
|
|
104
|
+
*/
|
|
105
|
+
expanded?: boolean | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The style of value "picker" to use in the input.
|
|
108
|
+
* @default `'popup'`
|
|
109
|
+
*/
|
|
110
|
+
picker?: 'inline' | 'popup' | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Allow users to interactively expand / contract the picker.
|
|
113
|
+
* @default `true`
|
|
114
|
+
*/
|
|
115
|
+
userExpandable?: boolean | undefined;
|
|
116
|
+
},
|
|
117
|
+
'options' | 'ref' | 'plugin' | 'buttonClass'
|
|
118
|
+
> & {
|
|
119
|
+
/**
|
|
120
|
+
* The rotation value to control.
|
|
121
|
+
*
|
|
122
|
+
* Tuple values are a convenience added by _Svelte Tweakpane UI_, and are not part of the
|
|
123
|
+
* original TweakpaneRotationPlugin API.
|
|
124
|
+
*
|
|
125
|
+
* See the `order` prop to specify the sequence in which rotations are applied.
|
|
126
|
+
* @bindable
|
|
127
|
+
* */
|
|
128
|
+
value: RotationEulerValue;
|
|
129
|
+
/**
|
|
130
|
+
* Input parameters specific to the X dimension.
|
|
131
|
+
*
|
|
132
|
+
* Renamed from `x` in the original TweakpaneRotationPlugin API to clarify that it is an
|
|
133
|
+
* object of options, not a value.
|
|
134
|
+
* @default `undefined`
|
|
135
|
+
* */
|
|
136
|
+
optionsX?:
|
|
137
|
+
| {
|
|
138
|
+
format?: import('@tweakpane/core').Formatter<number> | undefined;
|
|
139
|
+
keyScale?: number | undefined;
|
|
140
|
+
max?: number | undefined;
|
|
141
|
+
min?: number | undefined;
|
|
142
|
+
pointerScale?: number | undefined;
|
|
143
|
+
step?: number | undefined;
|
|
144
|
+
}
|
|
145
|
+
| undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Input parameters specific to the Y dimension.
|
|
148
|
+
*
|
|
149
|
+
* Renamed from `y` in the original TweakpaneRotationPlugin API to clarify that it is an
|
|
150
|
+
* object of options, not a value.
|
|
151
|
+
* @default `undefined`
|
|
152
|
+
* */
|
|
153
|
+
optionsY?:
|
|
154
|
+
| {
|
|
155
|
+
format?: import('@tweakpane/core').Formatter<number> | undefined;
|
|
156
|
+
keyScale?: number | undefined;
|
|
157
|
+
max?: number | undefined;
|
|
158
|
+
min?: number | undefined;
|
|
159
|
+
pointerScale?: number | undefined;
|
|
160
|
+
step?: number | undefined;
|
|
161
|
+
}
|
|
162
|
+
| undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Input parameters specific to the Z dimension.
|
|
165
|
+
*
|
|
166
|
+
* Renamed from `z` in the original TweakpaneRotationPlugin API to clarify that it is an
|
|
167
|
+
* object of options, not a value.
|
|
168
|
+
* @default `undefined`
|
|
169
|
+
* */
|
|
170
|
+
optionsZ?:
|
|
171
|
+
| {
|
|
172
|
+
format?: import('@tweakpane/core').Formatter<number> | undefined;
|
|
173
|
+
keyScale?: number | undefined;
|
|
174
|
+
max?: number | undefined;
|
|
175
|
+
min?: number | undefined;
|
|
176
|
+
pointerScale?: number | undefined;
|
|
177
|
+
step?: number | undefined;
|
|
178
|
+
}
|
|
179
|
+
| undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Order of in which rotations are applied.
|
|
182
|
+
*
|
|
183
|
+
* Note that this is extrinsic rotations (used by Blender, Maya, and Unity). Three.js uses
|
|
184
|
+
* intrinsic rotations, so you have to reverse the order if you want to match Three.js'
|
|
185
|
+
* behavior.
|
|
186
|
+
* @default `'XYZ'`
|
|
187
|
+
* */
|
|
188
|
+
order?: EulerOrder | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Units of rotation.
|
|
191
|
+
* @default `'rad'`
|
|
192
|
+
*/
|
|
193
|
+
unit?: EulerUnit | undefined;
|
|
194
|
+
};
|
|
195
|
+
events: {
|
|
196
|
+
[evt: string]: CustomEvent<any>;
|
|
197
|
+
};
|
|
198
|
+
slots: {};
|
|
199
|
+
};
|
|
200
|
+
export type RotationEulerProps = typeof __propDef.props;
|
|
201
|
+
export type RotationEulerEvents = typeof __propDef.events;
|
|
202
|
+
export type RotationEulerSlots = typeof __propDef.slots;
|
|
203
|
+
/**
|
|
204
|
+
* Integrates the [euler
|
|
205
|
+
* rotation](https://github.com/0b5vr/tweakpane-plugin-rotation/blob/dev/src/RotationInputPluginEuler.ts)
|
|
206
|
+
* control from [0b5vr's](https://0b5vr.com)
|
|
207
|
+
* [tweakpane-plugin-rotation](https://github.com/0b5vr/tweakpane-plugin-rotation).
|
|
208
|
+
*
|
|
209
|
+
* _Svelte Tweakpane UI_ extends the original API to support tuple values in addition to object values.
|
|
210
|
+
* (Useful when working with frameworks like [three.js](https://threejs.org) /
|
|
211
|
+
* [threlte](https://threlte.xyz).)
|
|
212
|
+
*
|
|
213
|
+
* A utility function `Utils.eulerToCssTransform()` is also provided to easily convert a quaternion
|
|
214
|
+
* value object or tuple into a CSS transform string.
|
|
215
|
+
*
|
|
216
|
+
* See also <RotationQuaternion> if you're feeling gimbal locked.
|
|
217
|
+
*
|
|
218
|
+
* Usage outside of a `<Pane>` component will implicitly wrap the profiler in `<Pane
|
|
219
|
+
* position='inline'>`.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```svelte
|
|
223
|
+
* <script lang="ts">
|
|
224
|
+
* import {
|
|
225
|
+
* Button,
|
|
226
|
+
* RotationEuler,
|
|
227
|
+
* type RotationEulerValueObject,
|
|
228
|
+
* Utils
|
|
229
|
+
* } from 'svelte-tweakpane-ui';
|
|
230
|
+
*
|
|
231
|
+
* // Value could also be a tuple
|
|
232
|
+
* // e.g. [0, 0, 0]
|
|
233
|
+
* let value: RotationEulerValueObject = { x: 0, y: 0, z: 0 };
|
|
234
|
+
*
|
|
235
|
+
* $: transform = Utils.eulerToCssTransform(value);
|
|
236
|
+
* $: valueRows = Object.values(value)
|
|
237
|
+
* .map((v) => `${v >= 0 ? '+' : ''}${v.toFixed(6)}`)
|
|
238
|
+
* .join('\n');
|
|
239
|
+
* </script>
|
|
240
|
+
*
|
|
241
|
+
* <RotationEuler
|
|
242
|
+
* bind:value
|
|
243
|
+
* expanded={true}
|
|
244
|
+
* label="CSS Rotation"
|
|
245
|
+
* picker={'inline'}
|
|
246
|
+
* />
|
|
247
|
+
* <Button on:click={() => (value = { x: 0, y: 0, z: 0 })} title="Reset" />
|
|
248
|
+
*
|
|
249
|
+
* <div class="billboard" style:transform>
|
|
250
|
+
* <pre>{valueRows}</pre>
|
|
251
|
+
* </div>
|
|
252
|
+
*
|
|
253
|
+
* <style>
|
|
254
|
+
* div.billboard {
|
|
255
|
+
* display: flex;
|
|
256
|
+
* align-items: center;
|
|
257
|
+
* justify-content: center;
|
|
258
|
+
* aspect-ratio: 1;
|
|
259
|
+
* width: 100%;
|
|
260
|
+
* background: linear-gradient(45deg, magenta, orange);
|
|
261
|
+
* }
|
|
262
|
+
* </style>
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @sourceLink
|
|
266
|
+
* [RotationEuler.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/RotationEuler.svelte)
|
|
267
|
+
*/
|
|
268
|
+
export default class RotationEuler extends SvelteComponent<
|
|
269
|
+
RotationEulerProps,
|
|
270
|
+
RotationEulerEvents,
|
|
271
|
+
RotationEulerSlots
|
|
272
|
+
> {}
|
|
273
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import * as pluginModule from '@0b5vr/tweakpane-plugin-rotation';
|
|
5
|
+
import ClsPad from '../internal/ClsPad.svelte';
|
|
6
|
+
import GenericInputFolding from '../internal/GenericInputFolding.svelte';
|
|
7
|
+
import { BROWSER } from 'esm-env';
|
|
8
|
+
export let value;
|
|
9
|
+
export let optionsX = void 0;
|
|
10
|
+
export let optionsY = void 0;
|
|
11
|
+
export let optionsZ = void 0;
|
|
12
|
+
export let optionsW = void 0;
|
|
13
|
+
export let expanded = void 0;
|
|
14
|
+
let options;
|
|
15
|
+
let internalValue;
|
|
16
|
+
const buttonClass = 'tp-rotationswatchv_b';
|
|
17
|
+
function updateInternalValue() {
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
const [x, y, z, w] = value;
|
|
20
|
+
internalValue = { x, y, z, w };
|
|
21
|
+
} else {
|
|
22
|
+
internalValue = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function updateValue() {
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
const { x, y, z, w } = internalValue;
|
|
28
|
+
value = [x, y, z, w];
|
|
29
|
+
} else {
|
|
30
|
+
value = internalValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
$: value, updateInternalValue();
|
|
34
|
+
$: internalValue, updateValue();
|
|
35
|
+
$: options = {
|
|
36
|
+
x: optionsX,
|
|
37
|
+
y: optionsY,
|
|
38
|
+
z: optionsZ,
|
|
39
|
+
w: optionsW,
|
|
40
|
+
rotationMode: 'quaternion',
|
|
41
|
+
view: 'rotation'
|
|
42
|
+
};
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<GenericInputFolding
|
|
46
|
+
bind:value={internalValue}
|
|
47
|
+
bind:expanded
|
|
48
|
+
{buttonClass}
|
|
49
|
+
{options}
|
|
50
|
+
plugin={pluginModule}
|
|
51
|
+
{...$$restProps}
|
|
52
|
+
/>
|
|
53
|
+
{#if !BROWSER && expanded && $$props.picker === 'inline'}
|
|
54
|
+
{#if $$props.label !== undefined}
|
|
55
|
+
<ClsPad
|
|
56
|
+
keysAdd={['bladeValueWidth']}
|
|
57
|
+
keysSubtract={[`containerUnitSize`]}
|
|
58
|
+
theme={$$props.theme}
|
|
59
|
+
/>
|
|
60
|
+
{:else}
|
|
61
|
+
<!-- Without a label, the grid takes the full width of the control -->
|
|
62
|
+
<!-- TODO remove magic number -->
|
|
63
|
+
<div style="aspect-ratio: 1; width: calc(100% - 28px);" />
|
|
64
|
+
{/if}
|
|
65
|
+
{/if}
|