@antv/g 5.0.21 → 5.0.22-alpha.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/dist/index.umd.min.js +2 -2
- package/es/Canvas.js +6 -8
- package/es/camera/Camera.d.ts +12 -7
- package/es/camera/Camera.js +53 -21
- package/es/camera/Landmark.d.ts +2 -0
- package/es/camera/Landmark.js +9 -3
- package/es/display-objects/DisplayObject.js +7 -2
- package/es/plugins/EventPlugin.js +4 -1
- package/es/services/EventService.js +23 -2
- package/es/services/RenderingContext.d.ts +2 -1
- package/es/services/RenderingContext.js +3 -1
- package/es/services/SceneGraphService.d.ts +2 -1
- package/es/services/SceneGraphService.js +2 -2
- package/es/services/aabb/interfaces.d.ts +3 -2
- package/es/services/aabb/interfaces.js +3 -2
- package/es/types.d.ts +2 -1
- package/es/types.js +2 -1
- package/es/utils/custom-easing.d.ts +0 -9
- package/es/utils/custom-easing.js +37 -53
- package/lib/Canvas.js +6 -8
- package/lib/camera/Camera.d.ts +12 -7
- package/lib/camera/Camera.js +57 -21
- package/lib/camera/Landmark.d.ts +2 -0
- package/lib/camera/Landmark.js +9 -3
- package/lib/display-objects/DisplayObject.js +6 -1
- package/lib/plugins/EventPlugin.js +4 -1
- package/lib/services/EventService.js +23 -2
- package/lib/services/RenderingContext.d.ts +2 -1
- package/lib/services/RenderingContext.js +4 -1
- package/lib/services/SceneGraphService.d.ts +2 -1
- package/lib/services/SceneGraphService.js +2 -1
- package/lib/services/aabb/interfaces.d.ts +3 -2
- package/lib/services/aabb/interfaces.js +8 -2
- package/lib/types.d.ts +2 -1
- package/lib/types.js +5 -1
- package/lib/utils/custom-easing.d.ts +0 -9
- package/lib/utils/custom-easing.js +41 -65
- package/package.json +3 -3
package/es/Canvas.js
CHANGED
|
@@ -89,20 +89,18 @@ function (_super) {
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
_this.devicePixelRatio = dpr;
|
|
92
|
-
_this.requestAnimationFrame = requestAnimationFrame
|
|
93
|
-
_this.cancelAnimationFrame = cancelAnimationFrame
|
|
92
|
+
_this.requestAnimationFrame = requestAnimationFrame !== null && requestAnimationFrame !== void 0 ? requestAnimationFrame : rAF.bind(globalThis);
|
|
93
|
+
_this.cancelAnimationFrame = cancelAnimationFrame !== null && cancelAnimationFrame !== void 0 ? cancelAnimationFrame : cancelRAF.bind(globalThis);
|
|
94
94
|
/**
|
|
95
95
|
* limits query
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
|
-
_this.supportTouchEvent = supportTouchEvent
|
|
99
|
-
_this.supportPointerEvent = supportPointerEvent
|
|
100
|
-
|
|
101
|
-
_this.isTouchEvent = isTouchEvent || function (event) {
|
|
98
|
+
_this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
|
|
99
|
+
_this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
|
|
100
|
+
_this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
|
|
102
101
|
return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
|
|
103
102
|
};
|
|
104
|
-
|
|
105
|
-
_this.isMouseEvent = isMouseEvent || function (event) {
|
|
103
|
+
_this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
|
|
106
104
|
return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
|
|
107
105
|
};
|
|
108
106
|
|
package/es/camera/Camera.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import type { vec2 } from 'gl-matrix';
|
|
2
3
|
import { mat4, vec3 } from 'gl-matrix';
|
|
3
4
|
import { Landmark } from './Landmark';
|
|
4
5
|
import { Frustum } from '../shapes';
|
|
5
6
|
import type { Canvas } from '../Canvas';
|
|
6
|
-
|
|
7
|
+
import { Syringe } from 'mana-syringe';
|
|
8
|
+
export declare const DefaultCamera: Syringe.DefinedToken;
|
|
7
9
|
export declare enum CAMERA_TYPE {
|
|
8
10
|
ORBITING = "ORBITING",
|
|
9
11
|
EXPLORING = "EXPLORING",
|
|
@@ -114,7 +116,6 @@ export declare class Camera extends EventEmitter {
|
|
|
114
116
|
private projectionMatrixInverse;
|
|
115
117
|
private jitteredProjectionMatrix;
|
|
116
118
|
private view;
|
|
117
|
-
private following;
|
|
118
119
|
private type;
|
|
119
120
|
private trackingMode;
|
|
120
121
|
private projectionMode;
|
|
@@ -239,13 +240,17 @@ export declare class Camera extends EventEmitter {
|
|
|
239
240
|
* 沿 n 轴移动,当距离视点远时移动速度较快,离视点越近速度越慢
|
|
240
241
|
*/
|
|
241
242
|
dolly(value: number): this;
|
|
242
|
-
createLandmark(name: string, params
|
|
243
|
-
position: vec3;
|
|
244
|
-
focalPoint: vec3;
|
|
243
|
+
createLandmark(name: string, params?: Partial<{
|
|
244
|
+
position: vec3 | vec2;
|
|
245
|
+
focalPoint: vec3 | vec2;
|
|
246
|
+
zoom?: number;
|
|
245
247
|
roll?: number;
|
|
246
|
-
}): Landmark;
|
|
248
|
+
}>): Landmark;
|
|
247
249
|
setLandmark(name: string): this;
|
|
248
|
-
gotoLandmark(name: string,
|
|
250
|
+
gotoLandmark(name: string | Landmark, options?: number | Partial<{
|
|
251
|
+
easing: string;
|
|
252
|
+
duration: number;
|
|
253
|
+
}>): void;
|
|
249
254
|
/**
|
|
250
255
|
* 根据相机矩阵重新计算各种相机参数
|
|
251
256
|
*/
|
package/es/camera/Camera.js
CHANGED
|
@@ -4,7 +4,10 @@ import { mat3, mat4, quat, vec3, vec4 } from 'gl-matrix';
|
|
|
4
4
|
import { Landmark } from './Landmark';
|
|
5
5
|
import { Frustum } from '../shapes';
|
|
6
6
|
import { createVec3, getAngle, makePerspective } from '../utils/math';
|
|
7
|
-
|
|
7
|
+
import { parseEasingFunction } from '../utils/animation';
|
|
8
|
+
import { isNumber, isString, isUndefined } from '@antv/util';
|
|
9
|
+
import { Syringe } from 'mana-syringe';
|
|
10
|
+
export var DefaultCamera = Syringe.defineToken('DefaultCamera');
|
|
8
11
|
export var CAMERA_TYPE;
|
|
9
12
|
|
|
10
13
|
(function (CAMERA_TYPE) {
|
|
@@ -139,8 +142,8 @@ function (_super) {
|
|
|
139
142
|
_this.aspect = 1;
|
|
140
143
|
_this.projectionMatrix = mat4.create();
|
|
141
144
|
_this.projectionMatrixInverse = mat4.create();
|
|
142
|
-
_this.jitteredProjectionMatrix = undefined;
|
|
143
|
-
|
|
145
|
+
_this.jitteredProjectionMatrix = undefined; // private following = undefined;
|
|
146
|
+
|
|
144
147
|
_this.type = CAMERA_TYPE.EXPLORING;
|
|
145
148
|
_this.trackingMode = CAMERA_TRACKING_MODE.DEFAULT;
|
|
146
149
|
_this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
|
|
@@ -729,12 +732,24 @@ function (_super) {
|
|
|
729
732
|
};
|
|
730
733
|
|
|
731
734
|
Camera.prototype.createLandmark = function (name, params) {
|
|
735
|
+
if (params === void 0) {
|
|
736
|
+
params = {};
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
var position = params.position,
|
|
740
|
+
focalPoint = params.focalPoint,
|
|
741
|
+
roll = params.roll,
|
|
742
|
+
zoom = params.zoom;
|
|
732
743
|
var camera = this.clone();
|
|
733
|
-
camera.setPosition(
|
|
734
|
-
camera.setFocalPoint(
|
|
744
|
+
camera.setPosition(vec3.fromValues(position[0], position[1], position[2] || this.position[2]));
|
|
745
|
+
camera.setFocalPoint(vec3.fromValues(focalPoint[0], focalPoint[1], focalPoint[2] || this.focalPoint[2]));
|
|
746
|
+
|
|
747
|
+
if (!isUndefined(roll)) {
|
|
748
|
+
camera.setRoll(roll);
|
|
749
|
+
}
|
|
735
750
|
|
|
736
|
-
if (
|
|
737
|
-
camera.
|
|
751
|
+
if (!isUndefined(zoom)) {
|
|
752
|
+
camera.setZoom(zoom);
|
|
738
753
|
}
|
|
739
754
|
|
|
740
755
|
var landmark = new Landmark(name, camera);
|
|
@@ -748,19 +763,29 @@ function (_super) {
|
|
|
748
763
|
return this;
|
|
749
764
|
};
|
|
750
765
|
|
|
751
|
-
Camera.prototype.gotoLandmark = function (name,
|
|
766
|
+
Camera.prototype.gotoLandmark = function (name, options) {
|
|
752
767
|
var _this = this;
|
|
753
768
|
|
|
754
|
-
if (
|
|
755
|
-
|
|
769
|
+
if (options === void 0) {
|
|
770
|
+
options = {};
|
|
756
771
|
}
|
|
757
772
|
|
|
758
|
-
var landmark = this.landmarks.find(function (l) {
|
|
773
|
+
var landmark = isString(name) ? this.landmarks.find(function (l) {
|
|
759
774
|
return l.name === name;
|
|
760
|
-
});
|
|
775
|
+
}) : name;
|
|
761
776
|
|
|
762
777
|
if (landmark) {
|
|
763
|
-
|
|
778
|
+
var _a = isNumber(options) ? {
|
|
779
|
+
duration: options
|
|
780
|
+
} : options,
|
|
781
|
+
_b = _a.easing,
|
|
782
|
+
easing = _b === void 0 ? 'ease' : _b,
|
|
783
|
+
_c = _a.duration,
|
|
784
|
+
duration_1 = _c === void 0 ? 1000 : _c;
|
|
785
|
+
|
|
786
|
+
var epsilon_1 = 0.01;
|
|
787
|
+
|
|
788
|
+
if (duration_1 === 0) {
|
|
764
789
|
landmark.retrieve(this);
|
|
765
790
|
return;
|
|
766
791
|
}
|
|
@@ -773,7 +798,9 @@ function (_super) {
|
|
|
773
798
|
|
|
774
799
|
var destPosition_1 = landmark.getPosition();
|
|
775
800
|
var destFocalPoint_1 = landmark.getFocalPoint();
|
|
801
|
+
var destZoom_1 = landmark.getZoom();
|
|
776
802
|
var destRoll_1 = landmark.getRoll();
|
|
803
|
+
var easingFunction_1 = parseEasingFunction(easing);
|
|
777
804
|
var timeStart_1;
|
|
778
805
|
|
|
779
806
|
var animate_1 = function animate_1(timestamp) {
|
|
@@ -781,15 +808,17 @@ function (_super) {
|
|
|
781
808
|
timeStart_1 = timestamp;
|
|
782
809
|
}
|
|
783
810
|
|
|
784
|
-
var elapsed = timestamp - timeStart_1; //
|
|
811
|
+
var elapsed = timestamp - timeStart_1; // use the same ease function in animatio system
|
|
785
812
|
|
|
786
|
-
var t = (
|
|
813
|
+
var t = easingFunction_1(elapsed / duration_1);
|
|
787
814
|
var interFocalPoint = vec3.create();
|
|
788
815
|
var interPosition = vec3.create();
|
|
816
|
+
var interZoom = 1;
|
|
789
817
|
var interRoll = 0;
|
|
790
818
|
vec3.lerp(interFocalPoint, _this.focalPoint, destFocalPoint_1, t);
|
|
791
819
|
vec3.lerp(interPosition, _this.position, destPosition_1, t);
|
|
792
820
|
interRoll = _this.roll * (1 - t) + destRoll_1 * t;
|
|
821
|
+
interZoom = _this.zoom * (1 - t) + destZoom_1 * t;
|
|
793
822
|
|
|
794
823
|
_this.setFocalPoint(interFocalPoint);
|
|
795
824
|
|
|
@@ -797,19 +826,22 @@ function (_super) {
|
|
|
797
826
|
|
|
798
827
|
_this.setRoll(interRoll);
|
|
799
828
|
|
|
829
|
+
_this.setZoom(interZoom);
|
|
830
|
+
|
|
800
831
|
_this.computeMatrix();
|
|
801
832
|
|
|
802
833
|
_this.triggerUpdate();
|
|
803
834
|
|
|
804
835
|
var dist = vec3.dist(interFocalPoint, destFocalPoint_1) + vec3.dist(interPosition, destPosition_1);
|
|
805
836
|
|
|
806
|
-
if (dist
|
|
807
|
-
|
|
808
|
-
|
|
837
|
+
if (dist <= epsilon_1) {
|
|
838
|
+
_this.setFocalPoint(destFocalPoint_1);
|
|
839
|
+
|
|
840
|
+
_this.setPosition(destPosition_1);
|
|
809
841
|
|
|
810
|
-
_this.
|
|
842
|
+
_this.setRoll(destRoll_1);
|
|
811
843
|
|
|
812
|
-
_this.
|
|
844
|
+
_this.setZoom(destZoom_1);
|
|
813
845
|
|
|
814
846
|
_this.computeMatrix(); // this.interactor.connect();
|
|
815
847
|
|
|
@@ -817,7 +849,7 @@ function (_super) {
|
|
|
817
849
|
return;
|
|
818
850
|
}
|
|
819
851
|
|
|
820
|
-
if (elapsed <
|
|
852
|
+
if (elapsed < duration_1) {
|
|
821
853
|
_this.landmarkAnimationID = _this.canvas.requestAnimationFrame(animate_1);
|
|
822
854
|
}
|
|
823
855
|
};
|
package/es/camera/Landmark.d.ts
CHANGED
|
@@ -20,9 +20,11 @@ export declare class Landmark {
|
|
|
20
20
|
private relAzimuth;
|
|
21
21
|
private relElevation;
|
|
22
22
|
private relRoll;
|
|
23
|
+
private zoom;
|
|
23
24
|
constructor(name: string, c: Camera);
|
|
24
25
|
getPosition(): vec3;
|
|
25
26
|
getFocalPoint(): vec3;
|
|
26
27
|
getRoll(): number;
|
|
28
|
+
getZoom(): number;
|
|
27
29
|
retrieve(c: Camera): void;
|
|
28
30
|
}
|
package/es/camera/Landmark.js
CHANGED
|
@@ -6,7 +6,6 @@ import { mat4, vec3 } from 'gl-matrix';
|
|
|
6
6
|
var Landmark =
|
|
7
7
|
/** @class */
|
|
8
8
|
function () {
|
|
9
|
-
// private zoom = 1;
|
|
10
9
|
function Landmark(name, c) {
|
|
11
10
|
this.azimuth = 0;
|
|
12
11
|
this.elevation = 0;
|
|
@@ -14,6 +13,7 @@ function () {
|
|
|
14
13
|
this.relAzimuth = 0;
|
|
15
14
|
this.relElevation = 0;
|
|
16
15
|
this.relRoll = 0;
|
|
16
|
+
this.zoom = 1;
|
|
17
17
|
this.name = name;
|
|
18
18
|
this.matrix = mat4.clone(c.matrix);
|
|
19
19
|
this.right = vec3.clone(c.right);
|
|
@@ -29,7 +29,8 @@ function () {
|
|
|
29
29
|
this.relElevation = c.relElevation;
|
|
30
30
|
this.relRoll = c.relRoll;
|
|
31
31
|
this.dollyingStep = c.dollyingStep;
|
|
32
|
-
this.distance = c.distance;
|
|
32
|
+
this.distance = c.distance;
|
|
33
|
+
this.zoom = c.zoom;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
Landmark.prototype.getPosition = function () {
|
|
@@ -44,6 +45,10 @@ function () {
|
|
|
44
45
|
return this.roll;
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
Landmark.prototype.getZoom = function () {
|
|
49
|
+
return this.zoom;
|
|
50
|
+
};
|
|
51
|
+
|
|
47
52
|
Landmark.prototype.retrieve = function (c) {
|
|
48
53
|
c.matrix = mat4.copy(c.matrix, this.matrix);
|
|
49
54
|
c.right = vec3.copy(c.right, this.right);
|
|
@@ -59,7 +64,8 @@ function () {
|
|
|
59
64
|
c.relElevation = this.relElevation;
|
|
60
65
|
c.relRoll = this.relRoll;
|
|
61
66
|
c.dollyingStep = this.dollyingStep;
|
|
62
|
-
c.distance = this.distance;
|
|
67
|
+
c.distance = this.distance;
|
|
68
|
+
c.zoom = this.zoom;
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
return Landmark;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __extends, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { GlobalContainer } from 'mana-syringe';
|
|
3
|
-
import { isEqual, isNil, isObject } from '@antv/util';
|
|
3
|
+
import { isEqual, isNil, isObject, isUndefined } from '@antv/util';
|
|
4
4
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
5
5
|
import { DisplayObjectPool } from '../DisplayObjectPool';
|
|
6
6
|
import { KeyframeEffect } from '../dom/KeyframeEffect';
|
|
@@ -186,7 +186,12 @@ function (_super) {
|
|
|
186
186
|
|
|
187
187
|
var _a = __read(formatAttribute(name, value), 2),
|
|
188
188
|
attributeName = _a[0],
|
|
189
|
-
attributeValue = _a[1];
|
|
189
|
+
attributeValue = _a[1]; // ignore undefined value
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
if (isUndefined(value)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
190
195
|
|
|
191
196
|
if (force || !isEqual(attributeValue, this.attributes[attributeName])) {
|
|
192
197
|
this.internalSetAttribute(attributeName, attributeValue);
|
|
@@ -305,7 +305,10 @@ function () {
|
|
|
305
305
|
if (isUndefined(touch.twist)) touch.twist = 0;
|
|
306
306
|
if (isUndefined(touch.tangentialPressure)) touch.tangentialPressure = 0;
|
|
307
307
|
touch.isNormalized = true;
|
|
308
|
-
touch.type = event.type;
|
|
308
|
+
touch.type = event.type; // ref to nativeEvent
|
|
309
|
+
// touch.nativeEvent = event;
|
|
310
|
+
// touch.isLast = event.changedTouches.length - 1 === i;
|
|
311
|
+
|
|
309
312
|
normalizedEvents.push(touch);
|
|
310
313
|
}
|
|
311
314
|
} else if (canvas.isMouseEvent(event)) {
|
|
@@ -49,7 +49,9 @@ function (_super) {
|
|
|
49
49
|
this.dispatchEvent(e, 'pointerdown');
|
|
50
50
|
|
|
51
51
|
if (e.pointerType === 'touch') {
|
|
52
|
-
|
|
52
|
+
// only the
|
|
53
|
+
// if (e.isLast) {
|
|
54
|
+
this.dispatchEvent(e, 'touchstart'); // }
|
|
53
55
|
} else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
|
|
54
56
|
isRightButton = e.button === 2;
|
|
55
57
|
this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
|
|
@@ -665,8 +667,27 @@ function (_super) {
|
|
|
665
667
|
};
|
|
666
668
|
|
|
667
669
|
EventService.prototype.isNativeEventFromCanvas = function (event) {
|
|
670
|
+
var _a;
|
|
671
|
+
|
|
668
672
|
var $el = this.contextService.getDomElement();
|
|
669
|
-
|
|
673
|
+
var target = (_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.target;
|
|
674
|
+
|
|
675
|
+
if (target) {
|
|
676
|
+
if (target === $el) {
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if ($el && $el.contains) {
|
|
681
|
+
return $el.contains(target);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (event.nativeEvent.composedPath) {
|
|
686
|
+
return event.nativeEvent.composedPath().indexOf($el) > -1;
|
|
687
|
+
} // account for Touch
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
return false;
|
|
670
691
|
};
|
|
671
692
|
|
|
672
693
|
EventService.prototype.createPointerEvent = function (from, type, target) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
import type { Group } from '../display-objects';
|
|
2
3
|
/**
|
|
3
4
|
* why we need re-render
|
|
@@ -7,7 +8,7 @@ export declare enum RenderReason {
|
|
|
7
8
|
DISPLAY_OBJECT_CHANGED = 1,
|
|
8
9
|
NONE = 2
|
|
9
10
|
}
|
|
10
|
-
export declare const RenderingContext
|
|
11
|
+
export declare const RenderingContext: Syringe.DefinedToken;
|
|
11
12
|
export interface RenderingContext {
|
|
12
13
|
/**
|
|
13
14
|
* root of scenegraph
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
/**
|
|
2
3
|
* why we need re-render
|
|
3
4
|
*/
|
|
5
|
+
|
|
4
6
|
export var RenderReason;
|
|
5
7
|
|
|
6
8
|
(function (RenderReason) {
|
|
@@ -9,4 +11,4 @@ export var RenderReason;
|
|
|
9
11
|
RenderReason[RenderReason["NONE"] = 2] = "NONE";
|
|
10
12
|
})(RenderReason || (RenderReason = {}));
|
|
11
13
|
|
|
12
|
-
export var RenderingContext = 'RenderingContext';
|
|
14
|
+
export var RenderingContext = Syringe.defineToken('RenderingContext');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
import type { Transform } from '../components';
|
|
2
3
|
import type { vec2 } from 'gl-matrix';
|
|
3
4
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
@@ -5,7 +6,7 @@ import { AABB, Rectangle } from '../shapes';
|
|
|
5
6
|
import type { IElement, INode, IParentNode } from '../dom/interfaces';
|
|
6
7
|
export declare function sortByZIndex(o1: IElement, o2: IElement): number;
|
|
7
8
|
export declare function dirtifyToRoot(element: INode, affectChildren?: boolean): void;
|
|
8
|
-
export declare const SceneGraphService
|
|
9
|
+
export declare const SceneGraphService: Syringe.DefinedToken;
|
|
9
10
|
export interface SceneGraphService {
|
|
10
11
|
matches: <T extends IElement>(query: string, root: T) => boolean;
|
|
11
12
|
querySelector: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata, __read } from "tslib";
|
|
2
|
-
import { inject, singleton } from 'mana-syringe';
|
|
2
|
+
import { inject, singleton, Syringe } from 'mana-syringe';
|
|
3
3
|
import { isNil } from '@antv/util';
|
|
4
4
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
5
5
|
import { AABB, Rectangle } from '../shapes';
|
|
@@ -45,7 +45,7 @@ export function dirtifyToRoot(element, affectChildren) {
|
|
|
45
45
|
affectChildren: affectChildren
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
export var SceneGraphService = 'SceneGraphService';
|
|
48
|
+
export var SceneGraphService = Syringe.defineToken('SceneGraphService');
|
|
49
49
|
/**
|
|
50
50
|
* update transform in scene graph
|
|
51
51
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
2
3
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
3
|
-
export declare const GeometryUpdaterFactory
|
|
4
|
-
export declare const GeometryAABBUpdater
|
|
4
|
+
export declare const GeometryUpdaterFactory: Syringe.DefinedToken;
|
|
5
|
+
export declare const GeometryAABBUpdater: Syringe.DefinedToken;
|
|
5
6
|
export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
|
|
6
7
|
update: (parsedStyle: T, object: DisplayObject) => {
|
|
7
8
|
width: number;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export var
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
2
|
+
export var GeometryUpdaterFactory = Syringe.defineToken('GeometryUpdaterFactory');
|
|
3
|
+
export var GeometryAABBUpdater = Syringe.defineToken('GeometryAABBUpdater');
|
package/es/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-o
|
|
|
4
4
|
import type { DisplayObject } from './display-objects';
|
|
5
5
|
import type { IRenderer } from './AbstractRenderer';
|
|
6
6
|
import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
|
|
7
|
+
import { Syringe } from 'mana-syringe';
|
|
7
8
|
export declare enum Shape {
|
|
8
9
|
GROUP = "g",
|
|
9
10
|
CIRCLE = "circle",
|
|
@@ -209,7 +210,7 @@ export interface RendererConfig {
|
|
|
209
210
|
*/
|
|
210
211
|
enableTAA: boolean;
|
|
211
212
|
}
|
|
212
|
-
export declare const CanvasConfig
|
|
213
|
+
export declare const CanvasConfig: Syringe.DefinedToken;
|
|
213
214
|
export interface CanvasConfig {
|
|
214
215
|
/**
|
|
215
216
|
* Renderer
|
package/es/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
export var Shape;
|
|
2
3
|
|
|
3
4
|
(function (Shape) {
|
|
@@ -49,4 +50,4 @@ export var TextAlign;
|
|
|
49
50
|
TextAlign["RIGHT"] = "right";
|
|
50
51
|
})(TextAlign || (TextAlign = {}));
|
|
51
52
|
|
|
52
|
-
export var CanvasConfig = 'CanvasConfig';
|
|
53
|
+
export var CanvasConfig = Syringe.defineToken('CanvasConfig');
|
|
@@ -38,7 +38,6 @@ export declare const parseEasingParameters: (str: string) => (string | number)[]
|
|
|
38
38
|
* easing functions, because of the nature of the function it can sometimes create an infinite loop, I suggest only using
|
|
39
39
|
* `getEasingDuration` for `spring`, specifically 'out-spring' and 'spring'
|
|
40
40
|
*/
|
|
41
|
-
export declare const getEasingDuration: (easing?: string | TypeEasingFunction) => number;
|
|
42
41
|
/**
|
|
43
42
|
These Easing Functions are based off of the Sozi Project's easing functions
|
|
44
43
|
https://github.com/sozi-projects/Sozi/blob/d72e44ebd580dc7579d1e177406ad41e632f961d/src/js/player/Timing.js
|
|
@@ -63,11 +62,3 @@ export declare const EasingFunctions: Record<string, TypeEasingFunction>;
|
|
|
63
62
|
export declare const complexEasingSyntax: (ease: string) => string;
|
|
64
63
|
/** Re-maps a number from one range to another. Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. */
|
|
65
64
|
export declare const getEasingFunction: (ease: string) => TypeEasingFunction;
|
|
66
|
-
/**
|
|
67
|
-
* Allows you to register new easing functions
|
|
68
|
-
*/
|
|
69
|
-
export declare const registerEasingFunction: (key: string, fn: TypeEasingFunction) => void;
|
|
70
|
-
/**
|
|
71
|
-
* Allows you to register multiple new easing functions
|
|
72
|
-
*/
|
|
73
|
-
export declare const registerEasingFunctions: (...obj: (typeof EasingFunctions)[]) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __read
|
|
1
|
+
import { __read } from "tslib";
|
|
2
2
|
/**
|
|
3
3
|
* ported from https://github.com/okikio/native/blob/master/packages/animate/src/custom-easing.ts
|
|
4
4
|
*/
|
|
@@ -128,36 +128,29 @@ export var parseEasingParameters = function parseEasingParameters(str) {
|
|
|
128
128
|
* easing functions, because of the nature of the function it can sometimes create an infinite loop, I suggest only using
|
|
129
129
|
* `getEasingDuration` for `spring`, specifically 'out-spring' and 'spring'
|
|
130
130
|
*/
|
|
131
|
+
// export const getEasingDuration = (easing: string | TypeEasingFunction = 'spring') => {
|
|
132
|
+
// if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing);
|
|
133
|
+
// // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
134
|
+
// const easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing as string);
|
|
135
|
+
// const params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
|
|
136
|
+
// const frame = 1 / 6;
|
|
137
|
+
// let elapsed = 0;
|
|
138
|
+
// let rest = 0;
|
|
139
|
+
// let count = 0;
|
|
140
|
+
// while (++count < INTINITE_LOOP_LIMIT) {
|
|
141
|
+
// elapsed += frame;
|
|
142
|
+
// if (easingFunction(elapsed, params, undefined) === 1) {
|
|
143
|
+
// rest++;
|
|
144
|
+
// if (rest >= 16) break;
|
|
145
|
+
// } else {
|
|
146
|
+
// rest = 0;
|
|
147
|
+
// }
|
|
148
|
+
// }
|
|
149
|
+
// const duration = elapsed * frame * 1000;
|
|
150
|
+
// EasingDurationCache.set(easing, duration);
|
|
151
|
+
// return duration;
|
|
152
|
+
// };
|
|
131
153
|
|
|
132
|
-
export var getEasingDuration = function getEasingDuration(easing) {
|
|
133
|
-
if (easing === void 0) {
|
|
134
|
-
easing = 'spring';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing); // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
138
|
-
|
|
139
|
-
var easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing);
|
|
140
|
-
var params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
|
|
141
|
-
var frame = 1 / 6;
|
|
142
|
-
var elapsed = 0;
|
|
143
|
-
var rest = 0;
|
|
144
|
-
var count = 0;
|
|
145
|
-
|
|
146
|
-
while (++count < INTINITE_LOOP_LIMIT) {
|
|
147
|
-
elapsed += frame;
|
|
148
|
-
|
|
149
|
-
if (easingFunction(elapsed, params, undefined) === 1) {
|
|
150
|
-
rest++;
|
|
151
|
-
if (rest >= 16) break;
|
|
152
|
-
} else {
|
|
153
|
-
rest = 0;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
var duration = elapsed * frame * 1000;
|
|
158
|
-
EasingDurationCache.set(easing, duration);
|
|
159
|
-
return duration;
|
|
160
|
-
};
|
|
161
154
|
/**
|
|
162
155
|
These Easing Functions are based off of the Sozi Project's easing functions
|
|
163
156
|
https://github.com/sozi-projects/Sozi/blob/d72e44ebd580dc7579d1e177406ad41e632f961d/src/js/player/Timing.js
|
|
@@ -308,26 +301,17 @@ export var complexEasingSyntax = function complexEasingSyntax(ease) {
|
|
|
308
301
|
|
|
309
302
|
export var getEasingFunction = function getEasingFunction(ease) {
|
|
310
303
|
return EasingFunctions[complexEasingSyntax(ease)] || EasingFunctions.linear;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
export var registerEasingFunctions = function registerEasingFunctions() {
|
|
326
|
-
var obj = [];
|
|
327
|
-
|
|
328
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
329
|
-
obj[_i] = arguments[_i];
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
Object.assign.apply(Object, __spreadArray([EasingFunctions], __read(obj), false));
|
|
333
|
-
};
|
|
304
|
+
}; // /**
|
|
305
|
+
// * Allows you to register new easing functions
|
|
306
|
+
// */
|
|
307
|
+
// export const registerEasingFunction = (key: string, fn: TypeEasingFunction) => {
|
|
308
|
+
// Object.assign(EasingFunctions, {
|
|
309
|
+
// [key]: fn,
|
|
310
|
+
// });
|
|
311
|
+
// };
|
|
312
|
+
// /**
|
|
313
|
+
// * Allows you to register multiple new easing functions
|
|
314
|
+
// */
|
|
315
|
+
// export const registerEasingFunctions = (...obj: typeof EasingFunctions[]) => {
|
|
316
|
+
// Object.assign(EasingFunctions, ...obj);
|
|
317
|
+
// };
|
package/lib/Canvas.js
CHANGED
|
@@ -111,20 +111,18 @@ function (_super) {
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
_this.devicePixelRatio = dpr;
|
|
114
|
-
_this.requestAnimationFrame = requestAnimationFrame
|
|
115
|
-
_this.cancelAnimationFrame = cancelAnimationFrame
|
|
114
|
+
_this.requestAnimationFrame = requestAnimationFrame !== null && requestAnimationFrame !== void 0 ? requestAnimationFrame : _requestAnimationFramePolyfill.requestAnimationFrame.bind(globalThis);
|
|
115
|
+
_this.cancelAnimationFrame = cancelAnimationFrame !== null && cancelAnimationFrame !== void 0 ? cancelAnimationFrame : _requestAnimationFramePolyfill.cancelAnimationFrame.bind(globalThis);
|
|
116
116
|
/**
|
|
117
117
|
* limits query
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
|
-
_this.supportTouchEvent = supportTouchEvent
|
|
121
|
-
_this.supportPointerEvent = supportPointerEvent
|
|
122
|
-
|
|
123
|
-
_this.isTouchEvent = isTouchEvent || function (event) {
|
|
120
|
+
_this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
|
|
121
|
+
_this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
|
|
122
|
+
_this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
|
|
124
123
|
return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
|
|
125
124
|
};
|
|
126
|
-
|
|
127
|
-
_this.isMouseEvent = isMouseEvent || function (event) {
|
|
125
|
+
_this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
|
|
128
126
|
return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
|
|
129
127
|
};
|
|
130
128
|
|