@pluot/react 0.1.2 → 0.1.3

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.
Files changed (55) hide show
  1. package/dist/index.js +1029 -934
  2. package/dist-tsc/Pluot.d.ts.map +1 -1
  3. package/dist-tsc/Pluot.js +36 -27
  4. package/package.json +3 -3
  5. package/src/Pluot.jsx +54 -34
  6. package/dist/C059-BdIta.ttf-Bdc938Uh.js +0 -4
  7. package/dist/C059-Bold.ttf-D54yVEIG.js +0 -4
  8. package/dist/C059-Italic.ttf-DLWXDpX2.js +0 -4
  9. package/dist/C059-Roman.ttf-B_4E2VG-.js +0 -4
  10. package/dist/D050000L.ttf-DThw2vhA.js +0 -4
  11. package/dist/NimbusMonoPS-Bold.ttf-DaeY0qBr.js +0 -4
  12. package/dist/NimbusMonoPS-BoldItalic.ttf-BWf8L4h2.js +0 -4
  13. package/dist/NimbusMonoPS-Italic.ttf-B6sVyRe1.js +0 -4
  14. package/dist/NimbusMonoPS-Regular.ttf-4U95hi4W.js +0 -4
  15. package/dist/NimbusRoman-Bold.ttf-CYfJBZ-D.js +0 -4
  16. package/dist/NimbusRoman-BoldItalic.ttf-IKgFHn3u.js +0 -4
  17. package/dist/NimbusRoman-Italic.ttf-DphHuaaV.js +0 -4
  18. package/dist/NimbusRoman-Regular.ttf-CyDfJ_2L.js +0 -4
  19. package/dist/NimbusSans-Bold.ttf-BgToHb0k.js +0 -4
  20. package/dist/NimbusSans-BoldItalic.ttf-DBTyNZML.js +0 -4
  21. package/dist/NimbusSans-BoldOblique.ttf-BsmbX-RQ.js +0 -4
  22. package/dist/NimbusSans-Italic.ttf-DXn1aKmU.js +0 -4
  23. package/dist/NimbusSans-Oblique.ttf-BnOkISci.js +0 -4
  24. package/dist/NimbusSans-Regular.ttf-BPUWfSNR.js +0 -4
  25. package/dist/NimbusSansNarrow-BdOblique.ttf-pMMXNfDW.js +0 -4
  26. package/dist/NimbusSansNarrow-Bold.ttf-CTqrnZ6z.js +0 -4
  27. package/dist/NimbusSansNarrow-BoldOblique.ttf-CDZKzRWR.js +0 -4
  28. package/dist/NimbusSansNarrow-Oblique.ttf-CmqouKBN.js +0 -4
  29. package/dist/NimbusSansNarrow-Regular.ttf-DOZi8TRM.js +0 -4
  30. package/dist/P052-Bold.ttf-F7VVlUHU.js +0 -4
  31. package/dist/P052-BoldItalic.ttf-CTaOaPJC.js +0 -4
  32. package/dist/P052-Italic.ttf-CfqenRHn.js +0 -4
  33. package/dist/P052-Roman.ttf-B-tZ3T0p.js +0 -4
  34. package/dist/StandardSymbolsPS.ttf-DQ9k8vPT.js +0 -4
  35. package/dist/URWBookman-Demi.ttf-gvfD6bGd.js +0 -4
  36. package/dist/URWBookman-DemiItalic.ttf-CTYueWh5.js +0 -4
  37. package/dist/URWBookman-Light.ttf-DK879rFB.js +0 -4
  38. package/dist/URWBookman-LightItalic.ttf-BWVZJTZv.js +0 -4
  39. package/dist/URWGothic-Book.ttf-BjKm3X4s.js +0 -4
  40. package/dist/URWGothic-BookOblique.ttf-UGkGTKkJ.js +0 -4
  41. package/dist/URWGothic-Demi.ttf-CUhEK02w.js +0 -4
  42. package/dist/URWGothic-DemiOblique.ttf-CP_D_bVd.js +0 -4
  43. package/dist/Z003-MediumItalic.ttf-BXc6HvHA.js +0 -4
  44. package/dist-tsc/3d-view-controls.d.ts +0 -17
  45. package/dist-tsc/3d-view-controls.d.ts.map +0 -1
  46. package/dist-tsc/3d-view-controls.js +0 -223
  47. package/dist-tsc/dom-2d-camera.d.ts +0 -26
  48. package/dist-tsc/dom-2d-camera.d.ts.map +0 -1
  49. package/dist-tsc/dom-2d-camera.js +0 -303
  50. package/dist-tsc/feature-detection.d.ts +0 -5
  51. package/dist-tsc/feature-detection.d.ts.map +0 -1
  52. package/dist-tsc/feature-detection.js +0 -6
  53. package/dist-tsc/lru-store.d.ts +0 -4
  54. package/dist-tsc/lru-store.d.ts.map +0 -1
  55. package/dist-tsc/lru-store.js +0 -137
@@ -1,17 +0,0 @@
1
- export default function createCamera(element: any, options: any): {
2
- view: any;
3
- element: any;
4
- delay: any;
5
- rotateSpeed: any;
6
- zoomSpeed: any;
7
- translateSpeed: any;
8
- flipX: boolean;
9
- flipY: boolean;
10
- modes: any;
11
- tick: () => boolean;
12
- lookAt: (center: any, eye: any, up: any) => void;
13
- rotate: (pitch: any, yaw: any, roll: any) => void;
14
- pan: (dx: any, dy: any, dz: any) => void;
15
- translate: (dx: any, dy: any, dz: any) => void;
16
- };
17
- //# sourceMappingURL=3d-view-controls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"3d-view-controls.d.ts","sourceRoot":"","sources":["../src/3d-view-controls.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;EAgOC"}
@@ -1,223 +0,0 @@
1
- // Reference: https://github.com/mikolalysenko/3d-view-controls/blob/0e59c2ae4a891ce3c7bb83aa4291f89d99366037/camera.js
2
- import createView from '3d-view';
3
- import mouseChange from 'mouse-change';
4
- import mouseWheel from 'mouse-wheel';
5
- import mouseOffset from 'mouse-event-offset';
6
- import hasPassive from 'has-passive-events';
7
- // Updated right-now implementation to avoid `global` usage.
8
- // Reference: https://github.com/hughsk/right-now/blob/master/browser.js
9
- const now = performance && performance.now
10
- ? function now() {
11
- return performance.now();
12
- }
13
- : Date.now ||
14
- function now() {
15
- return +new Date();
16
- };
17
- export default function createCamera(element, options) {
18
- element = element || document.body;
19
- options = options || {};
20
- var limits = [0.01, Infinity];
21
- if ('distanceLimits' in options) {
22
- limits[0] = options.distanceLimits[0];
23
- limits[1] = options.distanceLimits[1];
24
- }
25
- if ('zoomMin' in options) {
26
- limits[0] = options.zoomMin;
27
- }
28
- if ('zoomMax' in options) {
29
- limits[1] = options.zoomMax;
30
- }
31
- var view = createView({
32
- center: options.center || [0, 0, 0],
33
- up: options.up || [0, 1, 0],
34
- eye: options.eye || [0, 0, 10],
35
- mode: options.mode || 'orbit',
36
- distanceLimits: limits
37
- });
38
- var pmatrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
39
- var distance = 0.0;
40
- var width = element.clientWidth;
41
- var height = element.clientHeight;
42
- var camera = {
43
- view: view,
44
- element: element,
45
- delay: options.delay || 16,
46
- rotateSpeed: options.rotateSpeed || 1,
47
- zoomSpeed: options.zoomSpeed || 1,
48
- translateSpeed: options.translateSpeed || 1,
49
- flipX: !!options.flipX,
50
- flipY: !!options.flipY,
51
- modes: view.modes,
52
- tick: function () {
53
- var t = now();
54
- var delay = this.delay;
55
- view.idle(t - delay);
56
- view.flush(t - (100 + delay * 2));
57
- var ctime = t - 2 * delay;
58
- view.recalcMatrix(ctime);
59
- var allEqual = true;
60
- var matrix = view.computedMatrix;
61
- for (var i = 0; i < 16; ++i) {
62
- allEqual = allEqual && (pmatrix[i] === matrix[i]);
63
- pmatrix[i] = matrix[i];
64
- }
65
- var sizeChanged = element.clientWidth === width &&
66
- element.clientHeight === height;
67
- width = element.clientWidth;
68
- height = element.clientHeight;
69
- if (allEqual) {
70
- return !sizeChanged;
71
- }
72
- distance = Math.exp(view.computedRadius[0]);
73
- return true;
74
- },
75
- lookAt: function (center, eye, up) {
76
- view.lookAt(view.lastT(), center, eye, up);
77
- },
78
- rotate: function (pitch, yaw, roll) {
79
- view.rotate(view.lastT(), pitch, yaw, roll);
80
- },
81
- pan: function (dx, dy, dz) {
82
- view.pan(view.lastT(), dx, dy, dz);
83
- },
84
- translate: function (dx, dy, dz) {
85
- view.translate(view.lastT(), dx, dy, dz);
86
- }
87
- };
88
- Object.defineProperties(camera, {
89
- matrix: {
90
- get: function () {
91
- return view.computedMatrix;
92
- },
93
- set: function (mat) {
94
- view.setMatrix(view.lastT(), mat);
95
- return view.computedMatrix;
96
- },
97
- enumerable: true
98
- },
99
- mode: {
100
- get: function () {
101
- return view.getMode();
102
- },
103
- set: function (mode) {
104
- view.setMode(mode);
105
- return view.getMode();
106
- },
107
- enumerable: true
108
- },
109
- center: {
110
- get: function () {
111
- return view.computedCenter;
112
- },
113
- set: function (ncenter) {
114
- view.lookAt(view.lastT(), ncenter);
115
- return view.computedCenter;
116
- },
117
- enumerable: true
118
- },
119
- eye: {
120
- get: function () {
121
- return view.computedEye;
122
- },
123
- set: function (neye) {
124
- view.lookAt(view.lastT(), null, neye);
125
- return view.computedEye;
126
- },
127
- enumerable: true
128
- },
129
- up: {
130
- get: function () {
131
- return view.computedUp;
132
- },
133
- set: function (nup) {
134
- view.lookAt(view.lastT(), null, null, nup);
135
- return view.computedUp;
136
- },
137
- enumerable: true
138
- },
139
- distance: {
140
- get: function () {
141
- return distance;
142
- },
143
- set: function (d) {
144
- view.setDistance(view.lastT(), d);
145
- return d;
146
- },
147
- enumerable: true
148
- },
149
- distanceLimits: {
150
- get: function () {
151
- return view.getDistanceLimits(limits);
152
- },
153
- set: function (v) {
154
- view.setDistanceLimits(v);
155
- return v;
156
- },
157
- enumerable: true
158
- }
159
- });
160
- element.addEventListener('contextmenu', function (ev) {
161
- //ev.preventDefault()
162
- //return false
163
- });
164
- var lastX = 0, lastY = 0, lastMods = { shift: false, control: false, alt: false, meta: false };
165
- mouseChange(element, handleInteraction);
166
- //enable simple touch interactions
167
- element.addEventListener('touchstart', function (ev) {
168
- var xy = mouseOffset(ev.changedTouches[0], element);
169
- handleInteraction(0, xy[0], xy[1], lastMods);
170
- handleInteraction(1, xy[0], xy[1], lastMods);
171
- ev.preventDefault();
172
- }, hasPassive ? { passive: false } : false);
173
- element.addEventListener('touchmove', function (ev) {
174
- var xy = mouseOffset(ev.changedTouches[0], element);
175
- handleInteraction(1, xy[0], xy[1], lastMods);
176
- ev.preventDefault();
177
- }, hasPassive ? { passive: false } : false);
178
- element.addEventListener('touchend', function (ev) {
179
- var xy = mouseOffset(ev.changedTouches[0], element);
180
- handleInteraction(0, lastX, lastY, lastMods);
181
- ev.preventDefault();
182
- }, hasPassive ? { passive: false } : false);
183
- function handleInteraction(buttons, x, y, mods) {
184
- var scale = 1.0 / element.clientHeight;
185
- var dx = scale * (x - lastX);
186
- var dy = scale * (y - lastY);
187
- var flipX = camera.flipX ? 1 : -1;
188
- var flipY = camera.flipY ? 1 : -1;
189
- var drot = Math.PI * camera.rotateSpeed;
190
- var t = now();
191
- if (buttons & 1) {
192
- if (mods.shift) {
193
- view.rotate(t, 0, 0, -dx * drot);
194
- }
195
- else {
196
- view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0);
197
- }
198
- }
199
- else if (buttons & 2) {
200
- view.pan(t, -camera.translateSpeed * dx * distance, camera.translateSpeed * dy * distance, 0);
201
- }
202
- else if (buttons & 4) {
203
- var kzoom = camera.zoomSpeed * dy / window.innerHeight * (t - view.lastT()) * 50.0;
204
- view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
205
- }
206
- lastX = x;
207
- lastY = y;
208
- lastMods = mods;
209
- }
210
- mouseWheel(element, function (dx, dy, dz) {
211
- var flipX = camera.flipX ? 1 : -1;
212
- var flipY = camera.flipY ? 1 : -1;
213
- var t = now();
214
- if (Math.abs(dx) > Math.abs(dy)) {
215
- view.rotate(t, 0, 0, -dx * flipX * Math.PI * camera.rotateSpeed / window.innerWidth);
216
- }
217
- else {
218
- var kzoom = camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0;
219
- view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
220
- }
221
- }, true);
222
- return camera;
223
- }
@@ -1,26 +0,0 @@
1
- export default dom2dCamera;
2
- declare function dom2dCamera(element: any, { distance, target, rotation, isNdc, isFixed, isPan, isPanInverted, panSpeed, isRotate, rotateSpeed, defaultMouseDownMoveAction, mouseDownMoveModKey, isZoom, zoomSpeed, viewCenter, scaleBounds, translationBounds, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onMouseMove, onWheel, aspectRatioMode, aspectRatioAlignmentMode, }?: {
3
- distance?: number | undefined;
4
- target?: number[] | undefined;
5
- rotation?: number | undefined;
6
- isNdc?: boolean | undefined;
7
- isFixed?: boolean | undefined;
8
- isPan?: boolean | undefined;
9
- isPanInverted?: boolean[] | undefined;
10
- panSpeed?: number | undefined;
11
- isRotate?: boolean | undefined;
12
- rotateSpeed?: number | undefined;
13
- defaultMouseDownMoveAction?: string | undefined;
14
- mouseDownMoveModKey?: string | undefined;
15
- isZoom?: boolean | undefined;
16
- zoomSpeed?: number | undefined;
17
- onKeyDown?: (() => void) | undefined;
18
- onKeyUp?: (() => void) | undefined;
19
- onMouseDown?: (() => void) | undefined;
20
- onMouseUp?: (() => void) | undefined;
21
- onMouseMove?: (() => void) | undefined;
22
- onWheel?: (() => void) | undefined;
23
- aspectRatioMode?: string | undefined;
24
- aspectRatioAlignmentMode?: string | undefined;
25
- }): any;
26
- //# sourceMappingURL=dom-2d-camera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom-2d-camera.d.ts","sourceRoot":"","sources":["../src/dom-2d-camera.js"],"names":[],"mappings":";AAeA;;;;;;;;;;;;;;;;;;;;;;;QAkZC"}
@@ -1,303 +0,0 @@
1
- // Copied from https://github.com/flekschas/dom-2d-camera/blob/cd59ea035a0ea72c2c0535fa3721f8127946576c/src/index.js
2
- // TODO: fork and make PR if the changes are successful
3
- import { vec2 } from "gl-matrix";
4
- import createCamera from "camera-2d-simple";
5
- const MOUSE_DOWN_MOVE_ACTIONS = ["pan", "rotate"];
6
- const KEY_MAP = {
7
- alt: "altKey",
8
- cmd: "metaKey",
9
- ctrl: "ctrlKey",
10
- meta: "metaKey",
11
- shift: "shiftKey"
12
- };
13
- const dom2dCamera = (element, { distance = 1.0, target = [0, 0], rotation = 0, isNdc = true, isFixed = false, isPan = true, isPanInverted = [false, true], panSpeed = 1, isRotate = true, rotateSpeed = 1, defaultMouseDownMoveAction = "pan", mouseDownMoveModKey = "alt", isZoom = true, zoomSpeed = 1, viewCenter, scaleBounds, translationBounds, onKeyDown = () => { }, onKeyUp = () => { }, onMouseDown = () => { }, onMouseUp = () => { }, onMouseMove = () => { }, onWheel = () => { }, aspectRatioMode = "Ignore", aspectRatioAlignmentMode = "Center", } = {}) => {
14
- let camera = createCamera(target, distance, rotation, viewCenter, scaleBounds, translationBounds);
15
- let mouseX = 0;
16
- let mouseY = 0;
17
- let mouseRelX = 0;
18
- let mouseRelY = 0;
19
- let prevMouseX = 0;
20
- let prevMouseY = 0;
21
- let isLeftMousePressed = false;
22
- let scrollDist = 0;
23
- let width = 1;
24
- let height = 1;
25
- let aspectRatio = 1;
26
- let isInteractivelyChanged = false;
27
- let isProgrammaticallyChanged = false;
28
- let isMouseDownMoveModActive = false;
29
- let panOnMouseDownMove = defaultMouseDownMoveAction === "pan";
30
- let isPanX = isPan;
31
- let isPanY = isPan;
32
- let isPanXInverted = isPanInverted;
33
- let isPanYInverted = isPanInverted;
34
- let isZoomX = isZoom;
35
- let isZoomY = isZoom;
36
- const spreadXYSettings = () => {
37
- isPanX = Array.isArray(isPan) ? Boolean(isPan[0]) : isPan;
38
- isPanY = Array.isArray(isPan) ? Boolean(isPan[1]) : isPan;
39
- isPanXInverted = Array.isArray(isPanInverted)
40
- ? Boolean(isPanInverted[0])
41
- : isPanInverted;
42
- isPanYInverted = Array.isArray(isPanInverted)
43
- ? Boolean(isPanInverted[1])
44
- : isPanInverted;
45
- isZoomX = Array.isArray(isZoom) ? Boolean(isZoom[0]) : isZoom;
46
- isZoomY = Array.isArray(isZoom) ? Boolean(isZoom[1]) : isZoom;
47
- };
48
- spreadXYSettings();
49
- let xAspectRatioModeFactor = 1.0;
50
- let yAspectRatioModeFactor = 1.0;
51
- let xAlignmentTranslation = 0.0;
52
- let yAlignmentTranslation = 0.0;
53
- /*
54
- // Logic for aspect ratio handling in point_layer.wgsl
55
- if (aspect_ratio_mode == 1u) {
56
- // fit/contain
57
- if (layer_aspect_ratio > 1.0) {
58
- // Wide rectangle
59
- // Show more than (0, 1) in x direction. Show exactly (0, 1) in y direction.
60
- x_scale_for_aspect_ratio_mode = 1.0 / layer_aspect_ratio;
61
- } else if(layer_aspect_ratio < 1.0) {
62
- // Tall layer
63
- // Show exactly (0, 1) in x direction. Show more than (0, 1) in y direction.
64
- y_scale_for_aspect_ratio_mode = layer_aspect_ratio;
65
- } else {
66
- // Square layer; no change needed.
67
- // Show exactly (0, 1) in both directions.
68
- }
69
- } else if (aspect_ratio_mode == 2u) {
70
- // fill/cover
71
- if(layer_aspect_ratio > 1.0) {
72
- // Wide rectangle
73
- // Show exactly (0, 1) in x direction. Show less than (0, 1) in y direction.
74
- y_scale_for_aspect_ratio_mode = layer_aspect_ratio;
75
- } else if(layer_aspect_ratio < 1.0) {
76
- // Tall layer
77
- // Show less than (0, 1) in x direction. Show exactly (0, 1) in y direction.
78
- x_scale_for_aspect_ratio_mode = 1.0 / layer_aspect_ratio;
79
- } else {
80
- // Square layer; no change needed.
81
- // Show exactly (0, 1) in both directions.
82
- }
83
- }
84
- */
85
- const updateAspectRatioModeFactors = () => {
86
- xAspectRatioModeFactor = 1.0;
87
- yAspectRatioModeFactor = 1.0;
88
- if (aspectRatioMode === "Contain") {
89
- if (aspectRatio > 1.0) {
90
- xAspectRatioModeFactor = 1.0 / aspectRatio;
91
- }
92
- else if (aspectRatio < 1.0) {
93
- yAspectRatioModeFactor = aspectRatio;
94
- }
95
- }
96
- else if (aspectRatioMode === "Cover") {
97
- if (aspectRatio > 1.0) {
98
- yAspectRatioModeFactor = aspectRatio;
99
- }
100
- else if (aspectRatio < 1.0) {
101
- xAspectRatioModeFactor = 1.0 / aspectRatio;
102
- }
103
- }
104
- xAlignmentTranslation = 0.0;
105
- yAlignmentTranslation = 0.0;
106
- if (aspectRatioAlignmentMode === "Start") {
107
- xAlignmentTranslation = xAspectRatioModeFactor - 1.0;
108
- yAlignmentTranslation = yAspectRatioModeFactor - 1.0;
109
- }
110
- else if (aspectRatioAlignmentMode === "End") {
111
- xAlignmentTranslation = 1.0 - xAspectRatioModeFactor;
112
- yAlignmentTranslation = 1.0 - yAspectRatioModeFactor;
113
- }
114
- };
115
- updateAspectRatioModeFactors();
116
- const transformPanX = isNdc
117
- ? dX => (dX / width) * 2 * (1.0 / xAspectRatioModeFactor) // to normalized device coords
118
- : dX => dX;
119
- const transformPanY = isNdc
120
- ? dY => (dY / height) * 2 * (1.0 / yAspectRatioModeFactor) // to normalized device coords
121
- : dY => -dY;
122
- const transformScaleX = isNdc
123
- ? x => ((-1 + (x / width) * 2) - xAlignmentTranslation) * (1.0 / xAspectRatioModeFactor)
124
- : x => x;
125
- const transformScaleY = isNdc
126
- ? y => ((1 - (y / height) * 2) - yAlignmentTranslation) * (1.0 / yAspectRatioModeFactor)
127
- : y => y;
128
- const tick = () => {
129
- if (isFixed) {
130
- const isChanged = isProgrammaticallyChanged;
131
- isProgrammaticallyChanged = false;
132
- return isChanged;
133
- }
134
- isInteractivelyChanged = false;
135
- const currentMouseX = mouseX;
136
- const currentMouseY = mouseY;
137
- if ((isPanX || isPanY) &&
138
- isLeftMousePressed &&
139
- ((panOnMouseDownMove && !isMouseDownMoveModActive) ||
140
- (!panOnMouseDownMove && isMouseDownMoveModActive))) {
141
- const dX = isPanXInverted
142
- ? prevMouseX - currentMouseX
143
- : currentMouseX - prevMouseX;
144
- const transformedPanX = isPanX ? transformPanX(panSpeed * dX) : 0;
145
- const dY = isPanYInverted
146
- ? prevMouseY - currentMouseY
147
- : currentMouseY - prevMouseY;
148
- const transformedPanY = isPanY ? transformPanY(panSpeed * dY) : 0;
149
- if (transformedPanX !== 0 || transformedPanY !== 0) {
150
- camera.pan([transformedPanX, transformedPanY]);
151
- isInteractivelyChanged = true;
152
- }
153
- }
154
- if ((isZoomX || isZoomY) && scrollDist) {
155
- const dZ = zoomSpeed * Math.exp(scrollDist / height);
156
- const transformedX = transformScaleX(mouseRelX);
157
- const transformedY = transformScaleY(mouseRelY);
158
- camera.scale([isZoomX ? 1 / dZ : 1, isZoomY ? 1 / dZ : 1], [transformedX, transformedY]);
159
- isInteractivelyChanged = true;
160
- }
161
- if (isRotate &&
162
- isLeftMousePressed &&
163
- ((panOnMouseDownMove && isMouseDownMoveModActive) ||
164
- (!panOnMouseDownMove && !isMouseDownMoveModActive)) &&
165
- Math.abs(prevMouseX - currentMouseX) +
166
- Math.abs(prevMouseY - currentMouseY) >
167
- 0) {
168
- const wh = width / 2;
169
- const hh = height / 2;
170
- const x1 = prevMouseX - wh;
171
- const y1 = hh - prevMouseY;
172
- const x2 = currentMouseX - wh;
173
- const y2 = hh - currentMouseY;
174
- // Angle between the start and end mouse position with respect to the
175
- // viewport center
176
- const radians = vec2.angle([x1, y1], [x2, y2]);
177
- // Determine the orientation
178
- const cross = x1 * y2 - x2 * y1;
179
- camera.rotate(rotateSpeed * radians * Math.sign(cross));
180
- isInteractivelyChanged = true;
181
- }
182
- // Reset scroll delta and mouse position
183
- scrollDist = 0;
184
- prevMouseX = currentMouseX;
185
- prevMouseY = currentMouseY;
186
- const isChanged = isInteractivelyChanged || isProgrammaticallyChanged;
187
- isProgrammaticallyChanged = false;
188
- return isChanged;
189
- };
190
- const config = ({ defaultMouseDownMoveAction: newDefaultMouseDownMoveAction = null, isFixed: newIsFixed = null, isPan: newIsPan = null, isPanInverted: newIsPanInverted = null, isRotate: newIsRotate = null, isZoom: newIsZoom = null, panSpeed: newPanSpeed = null, rotateSpeed: newRotateSpeed = null, zoomSpeed: newZoomSpeed = null, mouseDownMoveModKey: newMouseDownMoveModKey = null } = {}) => {
191
- defaultMouseDownMoveAction =
192
- newDefaultMouseDownMoveAction !== null &&
193
- MOUSE_DOWN_MOVE_ACTIONS.includes(newDefaultMouseDownMoveAction)
194
- ? newDefaultMouseDownMoveAction
195
- : defaultMouseDownMoveAction;
196
- panOnMouseDownMove = defaultMouseDownMoveAction === "pan";
197
- isFixed = newIsFixed !== null ? newIsFixed : isFixed;
198
- isPan = newIsPan !== null ? newIsPan : isPan;
199
- isPanInverted =
200
- newIsPanInverted !== null ? newIsPanInverted : isPanInverted;
201
- isRotate = newIsRotate !== null ? newIsRotate : isRotate;
202
- isZoom = newIsZoom !== null ? newIsZoom : isZoom;
203
- panSpeed = +newPanSpeed > 0 ? newPanSpeed : panSpeed;
204
- rotateSpeed = +newRotateSpeed > 0 ? newRotateSpeed : rotateSpeed;
205
- zoomSpeed = +newZoomSpeed > 0 ? newZoomSpeed : zoomSpeed;
206
- spreadXYSettings();
207
- mouseDownMoveModKey =
208
- newMouseDownMoveModKey !== null &&
209
- Object.keys(KEY_MAP).includes(newMouseDownMoveModKey)
210
- ? newMouseDownMoveModKey
211
- : mouseDownMoveModKey;
212
- };
213
- const refresh = () => {
214
- const bBox = element.getBoundingClientRect();
215
- width = bBox.width;
216
- height = bBox.height;
217
- aspectRatio = width / height;
218
- updateAspectRatioModeFactors();
219
- };
220
- const keyUpHandler = event => {
221
- isMouseDownMoveModActive = false;
222
- onKeyUp(event);
223
- };
224
- const keyDownHandler = event => {
225
- isMouseDownMoveModActive = event[KEY_MAP[mouseDownMoveModKey]];
226
- onKeyDown(event);
227
- };
228
- const mouseUpHandler = event => {
229
- isLeftMousePressed = false;
230
- onMouseUp(event);
231
- };
232
- const mouseDownHandler = event => {
233
- isLeftMousePressed = event.buttons === 1;
234
- onMouseDown(event);
235
- };
236
- const offsetXSupport = document.createEvent("MouseEvent").offsetX !== undefined;
237
- const updateMouseRelXY = offsetXSupport
238
- ? event => {
239
- mouseRelX = event.offsetX;
240
- mouseRelY = event.offsetY;
241
- }
242
- : event => {
243
- const bBox = element.getBoundingClientRect();
244
- mouseRelX = event.clientX - bBox.left;
245
- mouseRelY = event.clientY - bBox.top;
246
- };
247
- const updateMouseXY = event => {
248
- mouseX = event.clientX;
249
- mouseY = event.clientY;
250
- };
251
- const mouseMoveHandler = event => {
252
- updateMouseXY(event);
253
- onMouseMove(event);
254
- };
255
- const wheelHandler = event => {
256
- if ((isZoomX || isZoomY) && !isFixed) {
257
- event.preventDefault();
258
- updateMouseXY(event);
259
- updateMouseRelXY(event);
260
- const scale = event.deltaMode === 1 ? 12 : 1;
261
- scrollDist += scale * (event.deltaY || event.deltaX || 0);
262
- }
263
- onWheel(event);
264
- };
265
- const dispose = () => {
266
- camera = undefined;
267
- element.removeEventListener("keydown", keyDownHandler);
268
- element.removeEventListener("keyup", keyUpHandler);
269
- element.removeEventListener("mousedown", mouseDownHandler);
270
- element.removeEventListener("mouseup", mouseUpHandler);
271
- element.removeEventListener("mousemove", mouseMoveHandler);
272
- element.removeEventListener("wheel", wheelHandler);
273
- };
274
- element.addEventListener("keydown", keyDownHandler, { passive: true });
275
- element.addEventListener("keyup", keyUpHandler, { passive: true });
276
- element.addEventListener("mousedown", mouseDownHandler, { passive: true });
277
- element.addEventListener("mouseup", mouseUpHandler, { passive: true });
278
- element.addEventListener("mousemove", mouseMoveHandler, { passive: true });
279
- element.addEventListener("wheel", wheelHandler, { passive: false });
280
- camera.config = config;
281
- camera.dispose = dispose;
282
- camera.refresh = refresh;
283
- camera.tick = tick;
284
- const withProgrammaticChange = fn => function () {
285
- fn.apply(null, arguments);
286
- isProgrammaticallyChanged = true;
287
- };
288
- camera.lookAt = withProgrammaticChange(camera.lookAt);
289
- camera.translate = withProgrammaticChange(camera.translate);
290
- camera.pan = withProgrammaticChange(camera.pan);
291
- camera.rotate = withProgrammaticChange(camera.rotate);
292
- camera.scale = withProgrammaticChange(camera.scale);
293
- camera.zoom = withProgrammaticChange(camera.zoom);
294
- camera.reset = withProgrammaticChange(camera.reset);
295
- camera.set = withProgrammaticChange(camera.set);
296
- camera.setScaleBounds = withProgrammaticChange(camera.setScaleBounds);
297
- camera.setTranslationBounds = withProgrammaticChange(camera.setTranslationBounds);
298
- camera.setView = withProgrammaticChange(camera.setView);
299
- camera.setViewCenter = withProgrammaticChange(camera.setViewCenter);
300
- refresh();
301
- return camera;
302
- };
303
- export default dom2dCamera;
@@ -1,5 +0,0 @@
1
- export function useWebGpuFeatureDetection(): {
2
- supportsWebGpu: any;
3
- supportsWebGpuMessage: any;
4
- };
5
- //# sourceMappingURL=feature-detection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature-detection.d.ts","sourceRoot":"","sources":["../src/feature-detection.js"],"names":[],"mappings":"AAGA;;;EAGC"}
@@ -1,6 +0,0 @@
1
- import { useMemo } from "react";
2
- import { checkWebGpuFeatureDetection } from "@pluot/core";
3
- export function useWebGpuFeatureDetection() {
4
- const [supportsWebGpu, supportsWebGpuMessage] = useMemo(checkWebGpuFeatureDetection, []);
5
- return { supportsWebGpu, supportsWebGpuMessage };
6
- }
@@ -1,4 +0,0 @@
1
- import type { AsyncReadable } from 'zarrita';
2
- export declare function createGetRange<S extends AsyncReadable>(store: S): (...args: Parameters<NonNullable<S["getRange"]>>) => Promise<Uint8Array | undefined>;
3
- export declare function lru(inner_store: AsyncReadable, maxSize?: number): AsyncReadable;
4
- //# sourceMappingURL=lru-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lru-store.d.ts","sourceRoot":"","sources":["../src/lru-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,aAAa,EAAgB,MAAM,SAAS,CAAC;AAavE,wBAAgB,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,CAAC,IAEhD,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmBhG;AAoHD,wBAAgB,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,OAAO,SAAM,GAAG,aAAa,CAE5E"}