@antv/g 5.0.11 → 5.0.12
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 +41 -15
- package/es/display-objects/DisplayObject.d.ts +2 -0
- package/es/display-objects/DisplayObject.js +10 -0
- package/es/display-objects/Polygon.d.ts +2 -5
- package/es/display-objects/Polyline.d.ts +2 -6
- package/es/property-handlers/aabb.js +28 -24
- package/es/services/RenderingService.d.ts +2 -2
- package/es/services/RenderingService.js +2 -2
- package/es/services/SceneGraphService.d.ts +4 -0
- package/es/services/SceneGraphService.js +35 -1
- package/es/services/aabb/interfaces.d.ts +1 -0
- package/es/types.d.ts +2 -6
- package/es/utils/canvas.d.ts +1 -0
- package/es/utils/canvas.js +2 -1
- package/es/utils/raf.d.ts +6 -2
- package/es/utils/raf.js +15 -2
- package/lib/Canvas.js +39 -12
- package/lib/display-objects/DisplayObject.d.ts +2 -0
- package/lib/display-objects/DisplayObject.js +10 -0
- package/lib/display-objects/Polygon.d.ts +2 -5
- package/lib/display-objects/Polyline.d.ts +2 -6
- package/lib/property-handlers/aabb.js +28 -24
- package/lib/services/RenderingService.d.ts +2 -2
- package/lib/services/RenderingService.js +1 -1
- package/lib/services/SceneGraphService.d.ts +4 -0
- package/lib/services/SceneGraphService.js +41 -1
- package/lib/services/aabb/interfaces.d.ts +1 -0
- package/lib/types.d.ts +2 -6
- package/lib/utils/canvas.d.ts +1 -0
- package/lib/utils/canvas.js +5 -1
- package/lib/utils/raf.d.ts +6 -2
- package/lib/utils/raf.js +22 -13
- package/package.json +2 -2
|
@@ -30,6 +30,8 @@ export interface SceneGraphService {
|
|
|
30
30
|
rotateLocal: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
31
31
|
rotate: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
32
32
|
getRotation: (element: INode) => quat;
|
|
33
|
+
setRotation: (element: INode, rotation: quat | number, y?: number, z?: number, w?: number) => void;
|
|
34
|
+
setLocalRotation: (element: INode, rotation: quat | number, y?: number, z?: number, w?: number) => void;
|
|
33
35
|
getLocalRotation: (element: INode) => quat;
|
|
34
36
|
getWorldTransform: (element: INode, transform?: Transform) => mat4;
|
|
35
37
|
getLocalTransform: (element: INode, transform?: Transform) => mat4;
|
|
@@ -117,6 +119,8 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
117
119
|
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
118
120
|
*/
|
|
119
121
|
translate: (element: INode, translation: vec3 | number, y?: number, z?: number) => void;
|
|
122
|
+
setRotation: () => (element: INode, rotation: quat | number, y?: number, z?: number, w?: number) => void;
|
|
123
|
+
setLocalRotation(element: INode, rotation: quat | number, y?: number, z?: number, w?: number): void;
|
|
120
124
|
dirtifyLocal(element: INode, transform: Transform): void;
|
|
121
125
|
dirtifyWorld(element: INode, transform: Transform): void;
|
|
122
126
|
getPosition(element: INode): vec3;
|
|
@@ -180,7 +180,7 @@ function () {
|
|
|
180
180
|
|
|
181
181
|
_glMatrix.quat.invert(parentInvertRotation, parentInvertRotation);
|
|
182
182
|
|
|
183
|
-
_glMatrix.quat.multiply(
|
|
183
|
+
_glMatrix.quat.multiply(rotation, parentInvertRotation, rotation);
|
|
184
184
|
|
|
185
185
|
_glMatrix.quat.multiply(transform.localRotation, rotation, rot);
|
|
186
186
|
|
|
@@ -372,6 +372,34 @@ function () {
|
|
|
372
372
|
_this.setPosition(element, tr);
|
|
373
373
|
};
|
|
374
374
|
}();
|
|
375
|
+
|
|
376
|
+
this.setRotation = function () {
|
|
377
|
+
var parentInvertRotation = _glMatrix.quat.create();
|
|
378
|
+
|
|
379
|
+
return function (element, rotation, y, z, w) {
|
|
380
|
+
var transform = element.transformable;
|
|
381
|
+
|
|
382
|
+
if (typeof rotation === 'number') {
|
|
383
|
+
rotation = _glMatrix.quat.fromValues(rotation, y, z, w);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
387
|
+
_this.setLocalRotation(element, rotation);
|
|
388
|
+
} else {
|
|
389
|
+
var parentRot = _this.getRotation(element.parentNode);
|
|
390
|
+
|
|
391
|
+
_glMatrix.quat.copy(parentInvertRotation, parentRot);
|
|
392
|
+
|
|
393
|
+
_glMatrix.quat.invert(parentInvertRotation, parentInvertRotation);
|
|
394
|
+
|
|
395
|
+
_glMatrix.quat.multiply(transform.localRotation, parentInvertRotation, rotation);
|
|
396
|
+
|
|
397
|
+
_glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
398
|
+
|
|
399
|
+
_this.dirtifyLocal(element, transform);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
};
|
|
375
403
|
}
|
|
376
404
|
|
|
377
405
|
DefaultSceneGraphService.prototype.matches = function (query, root) {
|
|
@@ -552,6 +580,18 @@ function () {
|
|
|
552
580
|
this.dirtifyLocal(element, transform);
|
|
553
581
|
};
|
|
554
582
|
|
|
583
|
+
DefaultSceneGraphService.prototype.setLocalRotation = function (element, rotation, y, z, w) {
|
|
584
|
+
if (typeof rotation === 'number') {
|
|
585
|
+
rotation = _glMatrix.quat.fromValues(rotation, y, z, w);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
var transform = element.transformable;
|
|
589
|
+
|
|
590
|
+
_glMatrix.quat.copy(transform.localRotation, rotation);
|
|
591
|
+
|
|
592
|
+
this.dirtifyLocal(element, transform);
|
|
593
|
+
};
|
|
594
|
+
|
|
555
595
|
DefaultSceneGraphService.prototype.dirtifyLocal = function (element, transform) {
|
|
556
596
|
if (!transform.localDirtyFlag) {
|
|
557
597
|
transform.localDirtyFlag = true;
|
package/lib/types.d.ts
CHANGED
|
@@ -190,19 +190,15 @@ export interface CanvasConfig {
|
|
|
190
190
|
/**
|
|
191
191
|
* 画布宽度
|
|
192
192
|
*/
|
|
193
|
-
width
|
|
193
|
+
width?: number;
|
|
194
194
|
/**
|
|
195
195
|
* 画布高度
|
|
196
196
|
*/
|
|
197
|
-
height
|
|
197
|
+
height?: number;
|
|
198
198
|
/**
|
|
199
199
|
* 画布背景色
|
|
200
200
|
*/
|
|
201
201
|
background?: ColorType;
|
|
202
|
-
/**
|
|
203
|
-
* 是否可监听
|
|
204
|
-
*/
|
|
205
|
-
capture?: boolean;
|
|
206
202
|
/**
|
|
207
203
|
* 画布的 cursor 样式
|
|
208
204
|
*/
|
package/lib/utils/canvas.d.ts
CHANGED
package/lib/utils/canvas.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.cleanExistedCanvas = cleanExistedCanvas;
|
|
7
|
+
exports.isBrowser = void 0;
|
|
7
8
|
var canvasMap = {};
|
|
8
9
|
var defaultCanvasIdCounter = 0;
|
|
9
10
|
/**
|
|
@@ -20,4 +21,7 @@ function cleanExistedCanvas(container, canvas) {
|
|
|
20
21
|
|
|
21
22
|
canvasMap[id] = canvas;
|
|
22
23
|
}
|
|
23
|
-
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
27
|
+
exports.isBrowser = isBrowser;
|
package/lib/utils/raf.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* use user-defined raf instead of requestAnimationFrame
|
|
3
|
+
*/
|
|
4
|
+
export declare function patch(requestAFPatch: (callback: Function) => number, cancelAFPatch: (id: number) => void): void;
|
|
5
|
+
export declare const requestAnimationFrame: (callback: Function) => number;
|
|
6
|
+
export declare const cancelAnimationFrame: (id: number) => void;
|
package/lib/utils/raf.js
CHANGED
|
@@ -3,17 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
exports.cancelAnimationFrame = void 0;
|
|
7
|
+
exports.patch = patch;
|
|
8
|
+
exports.requestAnimationFrame = void 0;
|
|
9
|
+
|
|
10
|
+
var _requestAnimationFramePolyfill = require("request-animation-frame-polyfill");
|
|
11
|
+
|
|
12
|
+
// import { requestAnimationFrame, cancelAnimationFrame } from 'request-animation-frame-polyfill';
|
|
13
|
+
// export { requestAnimationFrame, cancelAnimationFrame };
|
|
14
|
+
var requestAF = _requestAnimationFramePolyfill.requestAnimationFrame;
|
|
15
|
+
var cancelAF = _requestAnimationFramePolyfill.cancelAnimationFrame;
|
|
16
|
+
/**
|
|
17
|
+
* use user-defined raf instead of requestAnimationFrame
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function patch(requestAFPatch, cancelAFPatch) {
|
|
21
|
+
requestAF = requestAFPatch;
|
|
22
|
+
cancelAF = cancelAFPatch;
|
|
23
|
+
}
|
|
18
24
|
|
|
19
|
-
var
|
|
25
|
+
var requestAnimationFrame = requestAF;
|
|
26
|
+
exports.requestAnimationFrame = requestAnimationFrame;
|
|
27
|
+
var cancelAnimationFrame = cancelAF;
|
|
28
|
+
exports.cancelAnimationFrame = cancelAnimationFrame;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.12",
|
|
4
4
|
"description": "A core module including ECS and DI container.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"scripts": {
|
|
53
53
|
"umd": "webpack"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3629d520aa7526df7818051898b5efa49d64bb91"
|
|
56
56
|
}
|