@antv/g 5.0.22-alpha.5 → 5.0.23-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 +30 -0
- package/es/AbstractRenderer.js +8 -1
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +5 -3
- package/es/DisplayObjectPool.js +3 -1
- package/es/camera/Camera.d.ts +105 -66
- package/es/camera/Camera.js +306 -170
- package/es/camera/Landmark.d.ts +18 -25
- package/es/camera/Landmark.js +1 -72
- package/es/canvas-module.js +2 -4
- package/es/components/Cullable.js +3 -1
- package/es/components/Geometry.js +3 -1
- package/es/components/Renderable.js +3 -1
- package/es/components/Sortable.js +3 -1
- package/es/components/Transform.js +3 -1
- package/es/css/LayoutRegistry.js +3 -1
- package/es/css/StyleValueRegistry.d.ts +8 -0
- package/es/css/StyleValueRegistry.js +24 -19
- package/es/css/cssom/CSSColorValue.js +3 -1
- package/es/css/cssom/CSSGradientValue.js +8 -6
- package/es/css/cssom/CSSKeywordValue.js +3 -1
- package/es/css/cssom/CSSMathInvert.js +3 -1
- package/es/css/cssom/CSSMathMax.js +3 -1
- package/es/css/cssom/CSSMathMin.js +3 -1
- package/es/css/cssom/CSSMathNegate.js +3 -1
- package/es/css/cssom/CSSMathProduct.js +3 -1
- package/es/css/cssom/CSSMathSum.js +3 -1
- package/es/css/cssom/CSSMathValue.js +3 -1
- package/es/css/cssom/CSSMathVariadic.js +3 -1
- package/es/css/cssom/CSSNumericValue.js +3 -1
- package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/es/css/cssom/CSSNumericValueType.js +3 -1
- package/es/css/cssom/CSSRGB.js +4 -2
- package/es/css/cssom/CSSStyleValue.d.ts +1 -1
- package/es/css/cssom/CSSStyleValue.js +3 -1
- package/es/css/cssom/CSSTransformComponent.js +3 -1
- package/es/css/cssom/CSSTransformValue.js +3 -1
- package/es/css/cssom/CSSTranslate.js +3 -1
- package/es/css/cssom/CSSUnitValue.js +4 -2
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.d.ts +1 -1
- package/es/css/parser/dimension.js +2 -3
- package/es/css/parser/numeric.js +1 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +1 -1
- package/es/css/parser/points.js +1 -1
- package/es/css/parser/transform-origin.js +1 -1
- package/es/css/properties/CSSPropertyAnchor.js +3 -1
- package/es/css/properties/CSSPropertyClipPath.js +3 -1
- package/es/css/properties/CSSPropertyColor.js +3 -1
- package/es/css/properties/CSSPropertyFilter.js +3 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.js +3 -1
- package/es/css/properties/CSSPropertyLineDash.js +3 -1
- package/es/css/properties/CSSPropertyLocalPosition.js +3 -1
- package/es/css/properties/CSSPropertyOffsetDistance.js +3 -1
- package/es/css/properties/CSSPropertyOffsetPath.js +3 -1
- package/es/css/properties/CSSPropertyOpacity.js +3 -1
- package/es/css/properties/CSSPropertyPath.d.ts +14 -2
- package/es/css/properties/CSSPropertyPath.js +3 -1
- package/es/css/properties/CSSPropertyPoints.js +3 -1
- package/es/css/properties/CSSPropertyShadowBlur.js +3 -1
- package/es/css/properties/CSSPropertyText.d.ts +1 -1
- package/es/css/properties/CSSPropertyText.js +4 -2
- package/es/css/properties/CSSPropertyTextTransform.d.ts +3 -3
- package/es/css/properties/CSSPropertyTextTransform.js +3 -1
- package/es/css/properties/CSSPropertyTransform.js +4 -3
- package/es/css/properties/CSSPropertyTransformOrigin.js +3 -1
- package/es/css/properties/CSSPropertyVisibility.js +3 -1
- package/es/css/properties/CSSPropertyZIndex.js +3 -1
- package/es/display-objects/Circle.js +3 -1
- package/es/display-objects/CustomElement.js +3 -1
- package/es/display-objects/DisplayObject.js +10 -8
- package/es/display-objects/Ellipse.js +3 -1
- package/es/display-objects/Group.js +3 -1
- package/es/display-objects/HTML.js +6 -3
- package/es/display-objects/Image.js +3 -1
- package/es/display-objects/Line.js +3 -1
- package/es/display-objects/Path.d.ts +15 -15
- package/es/display-objects/Path.js +5 -3
- package/es/display-objects/Polygon.d.ts +8 -1
- package/es/display-objects/Polygon.js +3 -1
- package/es/display-objects/Polyline.d.ts +7 -5
- package/es/display-objects/Polyline.js +3 -1
- package/es/display-objects/Rect.js +3 -1
- package/es/display-objects/Text.js +6 -3
- package/es/dom/Animation.js +4 -2
- package/es/dom/AnimationEffectTiming.js +3 -1
- package/es/dom/AnimationEvent.js +3 -1
- package/es/dom/AnimationTimeline.js +3 -1
- package/es/dom/CustomElementRegistry.js +3 -1
- package/es/dom/CustomEvent.js +3 -1
- package/es/dom/Document.js +5 -3
- package/es/dom/Element.js +7 -6
- package/es/dom/EventTarget.js +6 -4
- package/es/dom/FederatedEvent.js +3 -1
- package/es/dom/FederatedMouseEvent.js +3 -1
- package/es/dom/FederatedPointerEvent.js +3 -1
- package/es/dom/FederatedTouchEvent.d.ts +15 -0
- package/es/dom/FederatedTouchEvent.js +19 -0
- package/es/dom/FederatedWheelEvent.js +3 -1
- package/es/dom/KeyframeEffect.js +3 -1
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.js +3 -1
- package/es/dom/MutationObserver.js +10 -3
- package/es/dom/MutationRecord.js +3 -1
- package/es/dom/Node.js +4 -2
- package/es/plugins/CullingPlugin.d.ts +0 -1
- package/es/plugins/CullingPlugin.js +6 -9
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +12 -9
- package/es/plugins/EventPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.js +166 -149
- package/es/plugins/FrustumCullingStrategy.js +3 -1
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +18 -17
- package/es/services/EventService.d.ts +8 -0
- package/es/services/EventService.js +279 -23
- package/es/services/OffscreenCanvasCreator.js +3 -1
- package/es/services/RenderingService.d.ts +17 -16
- package/es/services/RenderingService.js +21 -18
- package/es/services/SceneGraphSelector.js +3 -1
- package/es/services/SceneGraphService.js +4 -2
- package/es/services/TextService.js +5 -3
- package/es/services/aabb/CircleUpdater.js +3 -1
- package/es/services/aabb/EllipseUpdater.js +3 -1
- package/es/services/aabb/LineUpdater.js +3 -1
- package/es/services/aabb/PathUpdater.d.ts +3 -3
- package/es/services/aabb/PathUpdater.js +3 -1
- package/es/services/aabb/PolylineUpdater.d.ts +3 -3
- package/es/services/aabb/PolylineUpdater.js +3 -1
- package/es/services/aabb/RectUpdater.js +4 -2
- package/es/services/aabb/TextUpdater.js +3 -1
- package/es/shapes/AABB.js +3 -1
- package/es/shapes/BoundingSphere.js +3 -1
- package/es/shapes/Frustum.js +3 -1
- package/es/shapes/Plane.js +3 -1
- package/es/shapes/Point.js +3 -1
- package/es/shapes/Ray.js +3 -1
- package/es/shapes/Rectangle.js +3 -1
- package/es/types.d.ts +9 -3
- package/es/utils/assert.d.ts +6 -0
- package/es/utils/assert.js +18 -0
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.d.ts +18 -16
- package/es/utils/hooks.d.ts +280 -0
- package/es/utils/hooks.js +753 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/math.d.ts +2 -2
- package/es/utils/math.js +22 -6
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +3 -3
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +8 -0
- package/es/utils/text.js +5 -4
- package/lib/AbstractRenderer.js +8 -1
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +5 -3
- package/lib/DisplayObjectPool.js +3 -1
- package/lib/camera/Camera.d.ts +105 -66
- package/lib/camera/Camera.js +313 -178
- package/lib/camera/Landmark.d.ts +18 -25
- package/lib/camera/Landmark.js +1 -75
- package/lib/canvas-module.js +1 -3
- package/lib/components/Cullable.js +4 -2
- package/lib/components/Geometry.js +3 -1
- package/lib/components/Renderable.js +3 -1
- package/lib/components/Sortable.js +3 -1
- package/lib/components/Transform.js +3 -1
- package/lib/css/LayoutRegistry.js +3 -1
- package/lib/css/StyleValueRegistry.d.ts +8 -0
- package/lib/css/StyleValueRegistry.js +27 -20
- package/lib/css/cssom/CSSColorValue.js +3 -1
- package/lib/css/cssom/CSSGradientValue.js +9 -7
- package/lib/css/cssom/CSSKeywordValue.js +3 -1
- package/lib/css/cssom/CSSMathInvert.js +3 -1
- package/lib/css/cssom/CSSMathMax.js +3 -1
- package/lib/css/cssom/CSSMathMin.js +3 -1
- package/lib/css/cssom/CSSMathNegate.js +3 -1
- package/lib/css/cssom/CSSMathOperator.js +1 -1
- package/lib/css/cssom/CSSMathProduct.js +3 -1
- package/lib/css/cssom/CSSMathSum.js +3 -1
- package/lib/css/cssom/CSSMathValue.js +3 -1
- package/lib/css/cssom/CSSMathVariadic.js +4 -2
- package/lib/css/cssom/CSSNumericValue.js +3 -1
- package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValueType.js +5 -3
- package/lib/css/cssom/CSSRGB.js +4 -2
- package/lib/css/cssom/CSSStyleValue.d.ts +1 -1
- package/lib/css/cssom/CSSStyleValue.js +4 -2
- package/lib/css/cssom/CSSTransformComponent.js +4 -2
- package/lib/css/cssom/CSSTransformValue.js +3 -1
- package/lib/css/cssom/CSSTranslate.js +3 -1
- package/lib/css/cssom/CSSUnitValue.js +4 -2
- package/lib/css/cssom/types.js +1 -1
- package/lib/css/parser/color.js +8 -8
- package/lib/css/parser/dimension.d.ts +1 -1
- package/lib/css/parser/dimension.js +8 -9
- package/lib/css/parser/numeric.js +6 -6
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +5 -5
- package/lib/css/parser/points.js +2 -2
- package/lib/css/parser/transform-origin.js +2 -2
- package/lib/css/parser/transform.js +2 -2
- package/lib/css/properties/CSSPropertyAnchor.js +3 -1
- package/lib/css/properties/CSSPropertyClipPath.js +3 -1
- package/lib/css/properties/CSSPropertyColor.js +3 -1
- package/lib/css/properties/CSSPropertyFilter.js +3 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.js +3 -1
- package/lib/css/properties/CSSPropertyLineDash.js +3 -1
- package/lib/css/properties/CSSPropertyLocalPosition.js +3 -1
- package/lib/css/properties/CSSPropertyOffsetDistance.js +3 -1
- package/lib/css/properties/CSSPropertyOffsetPath.js +3 -1
- package/lib/css/properties/CSSPropertyOpacity.js +3 -1
- package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
- package/lib/css/properties/CSSPropertyPath.js +3 -1
- package/lib/css/properties/CSSPropertyPoints.js +3 -1
- package/lib/css/properties/CSSPropertyShadowBlur.js +3 -1
- package/lib/css/properties/CSSPropertyText.d.ts +1 -1
- package/lib/css/properties/CSSPropertyText.js +4 -2
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +3 -3
- package/lib/css/properties/CSSPropertyTextTransform.js +3 -1
- package/lib/css/properties/CSSPropertyTransform.js +3 -3
- package/lib/css/properties/CSSPropertyTransformOrigin.js +3 -1
- package/lib/css/properties/CSSPropertyVisibility.js +3 -1
- package/lib/css/properties/CSSPropertyZIndex.js +3 -1
- package/lib/display-objects/Circle.js +3 -1
- package/lib/display-objects/CustomElement.js +3 -1
- package/lib/display-objects/DisplayObject.js +13 -12
- package/lib/display-objects/Ellipse.js +3 -1
- package/lib/display-objects/Group.js +3 -1
- package/lib/display-objects/HTML.js +6 -4
- package/lib/display-objects/Image.js +3 -1
- package/lib/display-objects/Line.js +3 -1
- package/lib/display-objects/Path.d.ts +15 -15
- package/lib/display-objects/Path.js +7 -5
- package/lib/display-objects/Polygon.d.ts +8 -1
- package/lib/display-objects/Polygon.js +3 -1
- package/lib/display-objects/Polyline.d.ts +7 -5
- package/lib/display-objects/Polyline.js +3 -1
- package/lib/display-objects/Rect.js +3 -1
- package/lib/display-objects/Text.js +6 -4
- package/lib/dom/Animation.js +4 -2
- package/lib/dom/AnimationEffectTiming.js +3 -1
- package/lib/dom/AnimationEvent.js +3 -1
- package/lib/dom/AnimationTimeline.js +4 -2
- package/lib/dom/CustomElementRegistry.js +3 -1
- package/lib/dom/CustomEvent.js +3 -1
- package/lib/dom/Document.js +5 -3
- package/lib/dom/Element.js +7 -7
- package/lib/dom/EventTarget.js +14 -12
- package/lib/dom/FederatedEvent.js +3 -1
- package/lib/dom/FederatedMouseEvent.js +3 -1
- package/lib/dom/FederatedPointerEvent.js +3 -1
- package/lib/dom/FederatedTouchEvent.d.ts +15 -0
- package/lib/dom/FederatedTouchEvent.js +27 -0
- package/lib/dom/FederatedWheelEvent.js +3 -1
- package/lib/dom/KeyframeEffect.js +4 -2
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.js +3 -1
- package/lib/dom/MutationObserver.js +11 -4
- package/lib/dom/MutationRecord.js +3 -1
- package/lib/dom/Node.js +4 -2
- package/lib/index.js +1 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -1
- package/lib/plugins/CullingPlugin.js +7 -9
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +13 -9
- package/lib/plugins/EventPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.js +175 -157
- package/lib/plugins/FrustumCullingStrategy.js +3 -1
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +17 -15
- package/lib/services/EventService.d.ts +8 -0
- package/lib/services/EventService.js +279 -22
- package/lib/services/OffscreenCanvasCreator.js +3 -1
- package/lib/services/RenderingService.d.ts +17 -16
- package/lib/services/RenderingService.js +22 -19
- package/lib/services/SceneGraphSelector.js +4 -2
- package/lib/services/SceneGraphService.js +8 -6
- package/lib/services/TextService.js +5 -3
- package/lib/services/aabb/CircleUpdater.js +3 -1
- package/lib/services/aabb/EllipseUpdater.js +3 -1
- package/lib/services/aabb/LineUpdater.js +3 -1
- package/lib/services/aabb/PathUpdater.d.ts +3 -3
- package/lib/services/aabb/PathUpdater.js +3 -1
- package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
- package/lib/services/aabb/PolylineUpdater.js +3 -1
- package/lib/services/aabb/RectUpdater.js +6 -4
- package/lib/services/aabb/TextUpdater.js +3 -1
- package/lib/services/aabb/index.js +10 -10
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/shapes/AABB.js +3 -1
- package/lib/shapes/BoundingSphere.js +3 -1
- package/lib/shapes/Frustum.js +4 -2
- package/lib/shapes/Plane.js +3 -1
- package/lib/shapes/Point.js +3 -1
- package/lib/shapes/Ray.js +3 -1
- package/lib/shapes/Rectangle.js +3 -1
- package/lib/types.d.ts +9 -3
- package/lib/types.js +1 -1
- package/lib/utils/animation.js +3 -2
- package/lib/utils/assert.d.ts +6 -0
- package/lib/utils/assert.js +30 -0
- package/lib/utils/bezier-easing.js +1 -1
- package/lib/utils/custom-easing.js +2 -2
- package/lib/utils/event.d.ts +18 -16
- package/lib/utils/hooks.d.ts +280 -0
- package/lib/utils/hooks.js +759 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/math.d.ts +2 -2
- package/lib/utils/math.js +34 -18
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +6 -6
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +11 -0
- package/lib/utils/text.js +7 -5
- package/package.json +5 -6
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
package/es/utils/math.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { quat, vec2, vec4 } from 'gl-matrix';
|
|
2
2
|
import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function clamp(number: number, boundOne: number, boundTwo: number): number;
|
|
4
|
+
export declare function getAngle(angle?: number): number;
|
|
4
5
|
export declare function createVec3(x: number | vec2 | vec3 | vec4, y?: number, z?: number): vec3;
|
|
5
6
|
export declare function deg2rad(deg: number): number;
|
|
6
7
|
export declare function rad2deg(rad: number): number;
|
|
@@ -25,5 +26,4 @@ export declare function getRotationInRadians(mat: mat3): number;
|
|
|
25
26
|
export declare function getEuler(out: vec3, quat: quat | mat4): vec3;
|
|
26
27
|
export declare function fromRotationTranslationScale(rotation: number, x: number, y: number, scaleX: number, scaleY: number): mat3;
|
|
27
28
|
export declare function makePerspective(out: mat4, left: number, right: number, top: number, bottom: number, near: number, far: number): mat4;
|
|
28
|
-
export declare function blend(from: number, to: number, progress: number): number;
|
|
29
29
|
export declare function decompose(mat: mat3): number[];
|
package/es/utils/math.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import { isNumber } from '@antv/util';
|
|
3
2
|
import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
3
|
+
import { isNumber } from './assert';
|
|
4
|
+
export function clamp(number, boundOne, boundTwo) {
|
|
5
|
+
if (!boundTwo) {
|
|
6
|
+
return Math.max(number, boundOne) === boundOne ? number : boundOne;
|
|
7
|
+
} else if (Math.min(number, boundOne) === number) {
|
|
8
|
+
return boundOne;
|
|
9
|
+
} else if (Math.max(number, boundTwo) === number) {
|
|
10
|
+
return boundTwo;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return number;
|
|
14
|
+
}
|
|
4
15
|
export function getAngle(angle) {
|
|
5
16
|
if (angle === undefined) {
|
|
6
17
|
return 0;
|
|
@@ -11,15 +22,23 @@ export function getAngle(angle) {
|
|
|
11
22
|
return angle;
|
|
12
23
|
}
|
|
13
24
|
export function createVec3(x, y, z) {
|
|
25
|
+
if (y === void 0) {
|
|
26
|
+
y = 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (z === void 0) {
|
|
30
|
+
z = 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
14
33
|
if (isNumber(x)) {
|
|
15
34
|
return vec3.fromValues(x, y, z);
|
|
16
35
|
}
|
|
17
36
|
|
|
18
|
-
if (x.length === 3) {
|
|
37
|
+
if (Array.isArray(x) && x.length === 3) {
|
|
19
38
|
return vec3.clone(x);
|
|
20
39
|
}
|
|
21
40
|
|
|
22
|
-
return vec3.fromValues(x[0], x[1], x[2] ||
|
|
41
|
+
return vec3.fromValues(x[0], x[1] || y, x[2] || z);
|
|
23
42
|
}
|
|
24
43
|
export function deg2rad(deg) {
|
|
25
44
|
return deg * (Math.PI / 180);
|
|
@@ -178,9 +197,6 @@ export function makePerspective(out, left, right, top, bottom, near, far) {
|
|
|
178
197
|
out[15] = 0;
|
|
179
198
|
return out;
|
|
180
199
|
}
|
|
181
|
-
export function blend(from, to, progress) {
|
|
182
|
-
return from + (to - from) * progress;
|
|
183
|
-
}
|
|
184
200
|
export function decompose(mat) {
|
|
185
201
|
var row0x = mat[0];
|
|
186
202
|
var row0y = mat[3];
|
package/es/utils/path.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
|
5
5
|
export declare function getPathArea(pathArray: PathCommand[]): number;
|
|
6
6
|
export declare function reverseCurve(pathArray: PathCommand[]): PathCommand[];
|
|
7
7
|
export declare function clonePath(pathArray: PathCommand[]): PathCommand[];
|
|
8
|
-
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["
|
|
8
|
+
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["U" | "u", number, number, number])[];
|
|
9
9
|
/**
|
|
10
10
|
* convert object to path, should account for:
|
|
11
11
|
* * transform & origin
|
package/es/utils/path.js
CHANGED
|
@@ -216,7 +216,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
216
216
|
if (cur[0] === 'M' || cur[0] === 'L') {
|
|
217
217
|
var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
218
218
|
vec3.transformMat4(p, p, localTransform);
|
|
219
|
-
path = ""
|
|
219
|
+
path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
|
|
220
220
|
} else if (cur[0] === 'Z') {
|
|
221
221
|
path = cur[0];
|
|
222
222
|
} else if (cur[0] === 'C') {
|
|
@@ -226,11 +226,11 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
226
226
|
vec3.transformMat4(p1, p1, localTransform);
|
|
227
227
|
vec3.transformMat4(p2, p2, localTransform);
|
|
228
228
|
vec3.transformMat4(p3, p3, localTransform);
|
|
229
|
-
path = ""
|
|
229
|
+
path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
|
|
230
230
|
} else if (cur[0] === 'A') {
|
|
231
231
|
var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
|
|
232
232
|
vec3.transformMat4(c, c, localTransform);
|
|
233
|
-
path = ""
|
|
233
|
+
path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return prev += path;
|
package/es/utils/string.d.ts
CHANGED
package/es/utils/string.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNil } from './assert';
|
|
1
2
|
export function camelCase(str) {
|
|
2
3
|
if (str === void 0) {
|
|
3
4
|
str = '';
|
|
@@ -6,4 +7,11 @@ export function camelCase(str) {
|
|
|
6
7
|
return str.replace(/-([a-z])/g, function (g) {
|
|
7
8
|
return g[1].toUpperCase();
|
|
8
9
|
});
|
|
10
|
+
}
|
|
11
|
+
export function isString(str) {
|
|
12
|
+
if (!isNil(str) && typeof str === 'string') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false;
|
|
9
17
|
}
|
package/es/utils/text.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isNumber
|
|
1
|
+
import { isNumber } from './assert';
|
|
2
|
+
import { isString } from './string';
|
|
2
3
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
3
4
|
export function toFontString(attributes) {
|
|
4
5
|
var fontSize = attributes.fontSize,
|
|
@@ -7,7 +8,7 @@ export function toFontString(attributes) {
|
|
|
7
8
|
fontVariant = attributes.fontVariant,
|
|
8
9
|
fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
9
10
|
|
|
10
|
-
var fontSizeString = isNumber(fontSize) ? fontSize
|
|
11
|
+
var fontSizeString = isNumber(fontSize) ? "".concat(fontSize, "px") : fontSize.toString(); // Clean-up fontFamily property by quoting each font name
|
|
11
12
|
// this will support font names with spaces
|
|
12
13
|
// @ts-ignore
|
|
13
14
|
|
|
@@ -18,11 +19,11 @@ export function toFontString(attributes) {
|
|
|
18
19
|
var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
|
|
19
20
|
|
|
20
21
|
if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
|
|
21
|
-
fontFamily_1 = "\""
|
|
22
|
+
fontFamily_1 = "\"".concat(fontFamily_1, "\"");
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
fontFamilies[i] = fontFamily_1;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
return fontStyle
|
|
28
|
+
return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
|
|
28
29
|
}
|
package/lib/AbstractRenderer.js
CHANGED
|
@@ -7,10 +7,17 @@ exports.AbstractRenderer = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
-
var AbstractRenderer =
|
|
10
|
+
var AbstractRenderer =
|
|
11
|
+
/** @class */
|
|
12
|
+
function () {
|
|
11
13
|
function AbstractRenderer(config) {
|
|
12
14
|
this.plugins = [];
|
|
13
15
|
this.config = (0, _tslib.__assign)({
|
|
16
|
+
/**
|
|
17
|
+
* only dirty object will cause re-render
|
|
18
|
+
*/
|
|
19
|
+
enableDirtyCheck: true,
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* enable auto rendering by default
|
|
16
23
|
*/
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
96
96
|
* get the root displayObject in scenegraph
|
|
97
97
|
* @alias this.document.documentElement
|
|
98
98
|
*/
|
|
99
|
-
getRoot(): import("
|
|
99
|
+
getRoot(): import("./display-objects").Group;
|
|
100
100
|
/**
|
|
101
101
|
* get the camera of canvas
|
|
102
102
|
*/
|
package/lib/Canvas.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.CanvasEvent = exports.Canvas = void 0;
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
@@ -54,7 +54,9 @@ exports.CanvasEvent = CanvasEvent;
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
var Canvas =
|
|
57
|
+
var Canvas =
|
|
58
|
+
/** @class */
|
|
59
|
+
function (_super) {
|
|
58
60
|
(0, _tslib.__extends)(Canvas, _super);
|
|
59
61
|
|
|
60
62
|
function Canvas(config) {
|
|
@@ -313,7 +315,7 @@ var Canvas = function (_super) {
|
|
|
313
315
|
var projectionMode = camera.getProjectionMode();
|
|
314
316
|
camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0);
|
|
315
317
|
|
|
316
|
-
if (projectionMode === _camera.
|
|
318
|
+
if (projectionMode === _camera.CameraProjectionMode.ORTHOGRAPHIC) {
|
|
317
319
|
camera.setOrthographic(width / -2, width / 2, height / 2, height / -2, camera.getNear(), camera.getFar());
|
|
318
320
|
} else {
|
|
319
321
|
camera.setAspect(width / height);
|
package/lib/DisplayObjectPool.js
CHANGED
package/lib/camera/Camera.d.ts
CHANGED
|
@@ -1,31 +1,60 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
import { EventEmitter } from 'eventemitter3';
|
|
2
3
|
import type { vec2 } from 'gl-matrix';
|
|
3
4
|
import { mat4, vec3 } from 'gl-matrix';
|
|
4
|
-
import { Landmark } from './Landmark';
|
|
5
|
+
import type { Landmark } from './Landmark';
|
|
5
6
|
import { Frustum } from '../shapes';
|
|
6
7
|
import type { Canvas } from '../Canvas';
|
|
7
|
-
import {
|
|
8
|
+
import type { TypeEasingFunction } from '../utils/custom-easing';
|
|
8
9
|
export declare const DefaultCamera: Syringe.DefinedToken;
|
|
9
|
-
export declare enum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export declare enum CameraType {
|
|
11
|
+
/**
|
|
12
|
+
* Performs all the rotational operations with the focal point instead of the camera position.
|
|
13
|
+
* This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
|
|
14
|
+
* Camera cannot orbits over the north & south poles.
|
|
15
|
+
* @see http://voxelent.com/tutorial-cameras/
|
|
16
|
+
*
|
|
17
|
+
* In Three.js it's used in OrbitControls.
|
|
18
|
+
* @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
|
|
19
|
+
*/
|
|
20
|
+
ORBITING = 0,
|
|
21
|
+
/**
|
|
22
|
+
* It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
|
|
23
|
+
*
|
|
24
|
+
* In Three.js it's used in OrbitControls.
|
|
25
|
+
* @see https://threejs.org/docs/#examples/en/controls/TrackballControls
|
|
26
|
+
*/
|
|
27
|
+
EXPLORING = 1,
|
|
28
|
+
/**
|
|
29
|
+
* Performs all the rotational operations with the camera position.
|
|
30
|
+
* It's useful in first person shooting games.
|
|
31
|
+
* Camera cannot orbits over the north & south poles.
|
|
32
|
+
*
|
|
33
|
+
* In Three.js it's used in FirstPersonControls.
|
|
34
|
+
* @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
|
|
35
|
+
*/
|
|
36
|
+
TRACKING = 2
|
|
13
37
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
/**
|
|
39
|
+
* CameraType must be TRACKING
|
|
40
|
+
*/
|
|
41
|
+
export declare enum CameraTrackingMode {
|
|
42
|
+
DEFAULT = 0,
|
|
43
|
+
ROTATIONAL = 1,
|
|
44
|
+
TRANSLATIONAL = 2,
|
|
45
|
+
CINEMATIC = 3
|
|
19
46
|
}
|
|
20
|
-
export declare enum
|
|
21
|
-
ORTHOGRAPHIC =
|
|
22
|
-
PERSPECTIVE =
|
|
47
|
+
export declare enum CameraProjectionMode {
|
|
48
|
+
ORTHOGRAPHIC = 0,
|
|
49
|
+
PERSPECTIVE = 1
|
|
23
50
|
}
|
|
24
51
|
export declare const CameraEvent: {
|
|
25
52
|
UPDATED: string;
|
|
26
53
|
};
|
|
27
54
|
/**
|
|
28
55
|
* 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
|
|
56
|
+
* @see https://github.com/d13g0/nucleo.js/blob/master/source/camera/Camera.js
|
|
57
|
+
*
|
|
29
58
|
* 保存相机参数,定义相机动作:
|
|
30
59
|
* 1. dolly 沿 n 轴移动
|
|
31
60
|
* 2. pan 沿 u v 轴移动
|
|
@@ -33,10 +62,6 @@ export declare const CameraEvent: {
|
|
|
33
62
|
* 4. 移动到 Landmark,具有平滑的动画效果,其间禁止其他用户交互
|
|
34
63
|
*/
|
|
35
64
|
export declare class Camera extends EventEmitter {
|
|
36
|
-
static ProjectionMode: {
|
|
37
|
-
ORTHOGRAPHIC: string;
|
|
38
|
-
PERSPECTIVE: string;
|
|
39
|
-
};
|
|
40
65
|
canvas: Canvas;
|
|
41
66
|
/**
|
|
42
67
|
* 相机矩阵
|
|
@@ -46,57 +71,57 @@ export declare class Camera extends EventEmitter {
|
|
|
46
71
|
* u 轴
|
|
47
72
|
* @see http://learnwebgl.brown37.net/07_cameras/camera_introduction.html#a-camera-definition
|
|
48
73
|
*/
|
|
49
|
-
right
|
|
74
|
+
private right;
|
|
50
75
|
/**
|
|
51
76
|
* v 轴 +Y is down
|
|
52
77
|
*/
|
|
53
|
-
up
|
|
78
|
+
private up;
|
|
54
79
|
/**
|
|
55
80
|
* n 轴 +Z is inside
|
|
56
81
|
*/
|
|
57
|
-
forward
|
|
82
|
+
private forward;
|
|
58
83
|
/**
|
|
59
84
|
* 相机位置
|
|
60
85
|
*/
|
|
61
|
-
position
|
|
86
|
+
private position;
|
|
62
87
|
/**
|
|
63
88
|
* 视点位置
|
|
64
89
|
*/
|
|
65
|
-
focalPoint
|
|
90
|
+
private focalPoint;
|
|
66
91
|
/**
|
|
67
|
-
*
|
|
92
|
+
* 视点到相机位置的向量
|
|
68
93
|
* focalPoint - position
|
|
69
94
|
*/
|
|
70
|
-
distanceVector
|
|
95
|
+
private distanceVector;
|
|
71
96
|
/**
|
|
72
97
|
* 相机位置到视点距离
|
|
73
98
|
* length(focalPoint - position)
|
|
74
99
|
*/
|
|
75
|
-
distance
|
|
100
|
+
private distance;
|
|
76
101
|
/**
|
|
77
102
|
* @see https://en.wikipedia.org/wiki/Azimuth
|
|
78
103
|
*/
|
|
79
|
-
azimuth
|
|
80
|
-
elevation
|
|
81
|
-
roll
|
|
82
|
-
relAzimuth
|
|
83
|
-
relElevation
|
|
84
|
-
relRoll
|
|
104
|
+
private azimuth;
|
|
105
|
+
private elevation;
|
|
106
|
+
private roll;
|
|
107
|
+
private relAzimuth;
|
|
108
|
+
private relElevation;
|
|
109
|
+
private relRoll;
|
|
85
110
|
/**
|
|
86
111
|
* 沿 n 轴移动时,保证移动速度从快到慢
|
|
87
112
|
*/
|
|
88
|
-
dollyingStep
|
|
89
|
-
maxDistance
|
|
90
|
-
minDistance
|
|
113
|
+
private dollyingStep;
|
|
114
|
+
private maxDistance;
|
|
115
|
+
private minDistance;
|
|
91
116
|
/**
|
|
92
117
|
* zoom factor of the camera, default is 1
|
|
93
118
|
* eg. https://threejs.org/docs/#api/en/cameras/OrthographicCamera.zoom
|
|
94
119
|
*/
|
|
95
|
-
zoom
|
|
120
|
+
private zoom;
|
|
96
121
|
/**
|
|
97
122
|
* invert the horizontal coordinate system HCS
|
|
98
123
|
*/
|
|
99
|
-
rotateWorld
|
|
124
|
+
private rotateWorld;
|
|
100
125
|
/**
|
|
101
126
|
* 投影矩阵参数
|
|
102
127
|
*/
|
|
@@ -116,6 +141,7 @@ export declare class Camera extends EventEmitter {
|
|
|
116
141
|
private projectionMatrixInverse;
|
|
117
142
|
private jitteredProjectionMatrix;
|
|
118
143
|
private view;
|
|
144
|
+
private enableUpdate;
|
|
119
145
|
private type;
|
|
120
146
|
private trackingMode;
|
|
121
147
|
private projectionMode;
|
|
@@ -132,21 +158,32 @@ export declare class Camera extends EventEmitter {
|
|
|
132
158
|
* ortho matrix for Canvas2D & SVG
|
|
133
159
|
*/
|
|
134
160
|
private orthoMatrix;
|
|
161
|
+
constructor(type?: CameraType, trackingMode?: CameraTrackingMode);
|
|
135
162
|
isOrtho(): boolean;
|
|
136
|
-
|
|
137
|
-
getProjectionMode(): CAMERA_PROJECTION_MODE;
|
|
163
|
+
getProjectionMode(): CameraProjectionMode;
|
|
138
164
|
getPerspective(): mat4;
|
|
139
165
|
getPerspectiveInverse(): mat4;
|
|
140
166
|
getFrustum(): Frustum;
|
|
141
167
|
getPosition(): vec3;
|
|
142
168
|
getFocalPoint(): vec3;
|
|
169
|
+
getDollyingStep(): number;
|
|
143
170
|
getNear(): number;
|
|
144
171
|
getFar(): number;
|
|
145
172
|
getZoom(): number;
|
|
146
173
|
getOrthoMatrix(): mat4;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
174
|
+
getView(): {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
fullWidth: number;
|
|
177
|
+
fullHeight: number;
|
|
178
|
+
offsetX: number;
|
|
179
|
+
offsetY: number;
|
|
180
|
+
width: number;
|
|
181
|
+
height: number;
|
|
182
|
+
};
|
|
183
|
+
setEnableUpdate(enabled: boolean): void;
|
|
184
|
+
setType(type: CameraType, trackingMode?: CameraTrackingMode): this;
|
|
185
|
+
setProjectionMode(projectionMode: CameraProjectionMode): this;
|
|
186
|
+
setTrackingMode(trackingMode: CameraTrackingMode): this;
|
|
150
187
|
/**
|
|
151
188
|
* If flag is true, it reverses the azimuth and elevation angles.
|
|
152
189
|
* Subsequent calls to rotate, setAzimuth, setElevation,
|
|
@@ -159,7 +196,7 @@ export declare class Camera extends EventEmitter {
|
|
|
159
196
|
* By default the camera angles are not reversed.
|
|
160
197
|
* @param {Boolean} flag the boolean flag to reverse the angles.
|
|
161
198
|
*/
|
|
162
|
-
setWorldRotation(flag: boolean):
|
|
199
|
+
setWorldRotation(flag: boolean): this;
|
|
163
200
|
/**
|
|
164
201
|
* 计算 MV 矩阵,为相机矩阵的逆矩阵
|
|
165
202
|
*/
|
|
@@ -184,47 +221,47 @@ export declare class Camera extends EventEmitter {
|
|
|
184
221
|
setPerspective(near: number, far: number, fov: number, aspect: number): this;
|
|
185
222
|
setOrthographic(l: number, r: number, t: number, b: number, near: number, far: number): this;
|
|
186
223
|
/**
|
|
187
|
-
*
|
|
224
|
+
* Move the camera in world coordinates.
|
|
225
|
+
* It will keep looking at the current focal point.
|
|
226
|
+
*
|
|
227
|
+
* support scalars or vectors.
|
|
228
|
+
* @example
|
|
229
|
+
* setPosition(1, 2, 3);
|
|
230
|
+
* setPosition([1, 2, 3]);
|
|
188
231
|
*/
|
|
189
|
-
setPosition(x: number | vec3, y?: number, z?: number): this;
|
|
232
|
+
setPosition(x: number | vec2 | vec3, y?: number, z?: number): this;
|
|
190
233
|
/**
|
|
191
|
-
*
|
|
234
|
+
* Sets the focal point of this camera in world coordinates.
|
|
235
|
+
*
|
|
236
|
+
* support scalars or vectors.
|
|
237
|
+
* @example
|
|
238
|
+
* setFocalPoint(1, 2, 3);
|
|
239
|
+
* setFocalPoint([1, 2, 3]);
|
|
192
240
|
*/
|
|
193
|
-
setFocalPoint(x: number | vec3, y?: number, z?: number): this;
|
|
241
|
+
setFocalPoint(x: number | vec2 | vec3, y?: number, z?: number): this;
|
|
242
|
+
getDistance(): number;
|
|
194
243
|
/**
|
|
195
|
-
*
|
|
244
|
+
* Moves the camera towards/from the focal point.
|
|
196
245
|
*/
|
|
197
246
|
setDistance(d: number): this;
|
|
198
247
|
setMaxDistance(d: number): this;
|
|
199
248
|
setMinDistance(d: number): this;
|
|
200
|
-
/**
|
|
201
|
-
* Changes the initial azimuth of the camera
|
|
202
|
-
*/
|
|
203
|
-
changeAzimuth(az: number): this;
|
|
204
|
-
/**
|
|
205
|
-
* Changes the initial elevation of the camera
|
|
206
|
-
*/
|
|
207
|
-
changeElevation(el: number): this;
|
|
208
|
-
/**
|
|
209
|
-
* Changes the initial roll of the camera
|
|
210
|
-
*/
|
|
211
|
-
changeRoll(rl: number): this;
|
|
212
249
|
/**
|
|
213
250
|
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
214
|
-
*
|
|
251
|
+
* the azimuth in degrees
|
|
215
252
|
*/
|
|
216
253
|
setAzimuth(az: number): this;
|
|
217
254
|
getAzimuth(): number;
|
|
218
255
|
/**
|
|
219
256
|
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
220
|
-
* @param {Number} el the elevation in degrees
|
|
221
257
|
*/
|
|
222
258
|
setElevation(el: number): this;
|
|
259
|
+
getElevation(): number;
|
|
223
260
|
/**
|
|
224
261
|
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
225
|
-
* @param {Number} angle the roll angle
|
|
226
262
|
*/
|
|
227
263
|
setRoll(angle: number): this;
|
|
264
|
+
getRoll(): number;
|
|
228
265
|
/**
|
|
229
266
|
* Changes the azimuth and elevation with respect to the current camera axes
|
|
230
267
|
* @param {Number} azimuth the relative azimuth
|
|
@@ -243,13 +280,14 @@ export declare class Camera extends EventEmitter {
|
|
|
243
280
|
createLandmark(name: string, params?: Partial<{
|
|
244
281
|
position: vec3 | vec2;
|
|
245
282
|
focalPoint: vec3 | vec2;
|
|
246
|
-
zoom
|
|
247
|
-
roll
|
|
283
|
+
zoom: number;
|
|
284
|
+
roll: number;
|
|
248
285
|
}>): Landmark;
|
|
249
|
-
setLandmark(name: string): this;
|
|
250
286
|
gotoLandmark(name: string | Landmark, options?: number | Partial<{
|
|
251
287
|
easing: string;
|
|
288
|
+
easingFunction: TypeEasingFunction;
|
|
252
289
|
duration: number;
|
|
290
|
+
onfinish: () => void;
|
|
253
291
|
}>): void;
|
|
254
292
|
/**
|
|
255
293
|
* 根据相机矩阵重新计算各种相机参数
|
|
@@ -285,4 +323,5 @@ export declare class Camera extends EventEmitter {
|
|
|
285
323
|
private _getDistance;
|
|
286
324
|
private _getOrthoMatrix;
|
|
287
325
|
private triggerUpdate;
|
|
326
|
+
private syncFromLandmark;
|
|
288
327
|
}
|