@antv/g-lite 2.0.11 → 2.0.12-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/Canvas.d.ts +3 -1
- package/dist/css/CSSProperty.d.ts +2 -10
- package/dist/css/StyleValueRegistry.d.ts +0 -23
- package/dist/css/cssom/CSSColorValue.d.ts +1 -0
- package/dist/css/cssom/CSSStyleValue.d.ts +1 -1
- package/dist/css/cssom/index.d.ts +0 -1
- package/dist/css/cssom/types.d.ts +0 -7
- package/dist/css/interfaces.d.ts +0 -6
- package/dist/css/parser/transform-origin.d.ts +0 -2
- package/dist/css/parser/transform.d.ts +3 -2
- package/dist/css/properties/CSSPropertyAngle.d.ts +0 -6
- package/dist/css/properties/CSSPropertyColor.d.ts +0 -4
- package/dist/css/properties/CSSPropertyFilter.d.ts +0 -2
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +0 -6
- package/dist/css/properties/CSSPropertyLengthOrPercentage12.d.ts +0 -1
- package/dist/css/properties/CSSPropertyLengthOrPercentage14.d.ts +0 -1
- package/dist/css/properties/CSSPropertyNumber.d.ts +0 -6
- package/dist/css/properties/CSSPropertyOffsetDistance.d.ts +0 -6
- package/dist/css/properties/CSSPropertyOpacity.d.ts +0 -6
- package/dist/css/properties/CSSPropertyPath.d.ts +0 -1
- package/dist/css/properties/CSSPropertyPoints.d.ts +1 -2
- package/dist/css/properties/CSSPropertyTransform.d.ts +2 -4
- package/dist/css/properties/CSSPropertyTransformOrigin.d.ts +0 -5
- package/dist/css/properties/CSSPropertyZIndex.d.ts +0 -5
- package/dist/display-objects/DisplayObject.d.ts +0 -8
- package/dist/display-objects/Fragment.d.ts +13 -0
- package/dist/display-objects/index.d.ts +1 -0
- package/dist/dom/Element.d.ts +2 -2
- package/dist/dom/Node.d.ts +6 -1
- package/dist/dom/interfaces.d.ts +2 -1
- package/dist/global-runtime.d.ts +0 -12
- package/dist/index.esm.js +1403 -2080
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1403 -2079
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts +2 -4
- package/dist/services/SceneGraphService.d.ts +12 -11
- package/dist/types.d.ts +54 -1
- package/dist/utils/assert.d.ts +0 -9
- package/dist/utils/canvas.d.ts +1 -1
- package/dist/utils/fragment.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/math.d.ts +1 -8
- package/package.json +1 -1
- package/dist/css/cssom/CSSMathOperator.d.ts +0 -11
- package/dist/css/cssom/CSSNumericSumValue.d.ts +0 -7
- package/dist/css/properties/CSSPropertyLocalPosition.d.ts +0 -13
- package/dist/utils/string.d.ts +0 -5
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __read, __extends, __spreadArray, __awaiter, __generator, __values, __rest } from 'tslib';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import {
|
|
4
|
-
import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isArray, isBoolean, isObject, getPointAtLength } from '@antv/util';
|
|
3
|
+
import { vec3, vec4, mat4, mat3, quat as quat$1, vec2 } from 'gl-matrix';
|
|
4
|
+
import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isArray, isBoolean, isFunction, isObject, getPointAtLength } from '@antv/util';
|
|
5
5
|
import * as d3 from 'd3-color';
|
|
6
6
|
import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
|
|
7
7
|
|
|
@@ -588,6 +588,7 @@ var RBush = rbush.exports;
|
|
|
588
588
|
var Shape;
|
|
589
589
|
(function (Shape) {
|
|
590
590
|
Shape["GROUP"] = "g";
|
|
591
|
+
Shape["FRAGMENT"] = "fragment";
|
|
591
592
|
Shape["CIRCLE"] = "circle";
|
|
592
593
|
Shape["ELLIPSE"] = "ellipse";
|
|
593
594
|
Shape["IMAGE"] = "image";
|
|
@@ -670,366 +671,7 @@ var AbstractRenderer = /** @class */ (function () {
|
|
|
670
671
|
return AbstractRenderer;
|
|
671
672
|
}());
|
|
672
673
|
|
|
673
|
-
|
|
674
|
-
a[0] = b[0];
|
|
675
|
-
a[1] = b[1];
|
|
676
|
-
a[2] = b[2];
|
|
677
|
-
return a;
|
|
678
|
-
}
|
|
679
|
-
function subVec3(o, a, b) {
|
|
680
|
-
o[0] = a[0] - b[0];
|
|
681
|
-
o[1] = a[1] - b[1];
|
|
682
|
-
o[2] = a[2] - b[2];
|
|
683
|
-
return o;
|
|
684
|
-
}
|
|
685
|
-
function addVec3(o, a, b) {
|
|
686
|
-
o[0] = a[0] + b[0];
|
|
687
|
-
o[1] = a[1] + b[1];
|
|
688
|
-
o[2] = a[2] + b[2];
|
|
689
|
-
return o;
|
|
690
|
-
}
|
|
691
|
-
function scaleVec3(o, a, b) {
|
|
692
|
-
o[0] = a[0] * b;
|
|
693
|
-
o[1] = a[1] * b;
|
|
694
|
-
o[2] = a[2] * b;
|
|
695
|
-
return o;
|
|
696
|
-
}
|
|
697
|
-
function maxVec3(o, a, b) {
|
|
698
|
-
o[0] = Math.max(a[0], b[0]);
|
|
699
|
-
o[1] = Math.max(a[1], b[1]);
|
|
700
|
-
o[2] = Math.max(a[2], b[2]);
|
|
701
|
-
return o;
|
|
702
|
-
}
|
|
703
|
-
function minVec3(o, a, b) {
|
|
704
|
-
o[0] = Math.min(a[0], b[0]);
|
|
705
|
-
o[1] = Math.min(a[1], b[1]);
|
|
706
|
-
o[2] = Math.min(a[2], b[2]);
|
|
707
|
-
return o;
|
|
708
|
-
}
|
|
709
|
-
function getAngle(angle) {
|
|
710
|
-
if (angle === undefined) {
|
|
711
|
-
return 0;
|
|
712
|
-
}
|
|
713
|
-
else if (angle > 360 || angle < -360) {
|
|
714
|
-
return angle % 360;
|
|
715
|
-
}
|
|
716
|
-
return angle;
|
|
717
|
-
}
|
|
718
|
-
function createVec3(x, y, z) {
|
|
719
|
-
if (y === void 0) { y = 0; }
|
|
720
|
-
if (z === void 0) { z = 0; }
|
|
721
|
-
if (Array.isArray(x) && x.length === 3) {
|
|
722
|
-
return vec3.clone(x);
|
|
723
|
-
}
|
|
724
|
-
if (isNumber(x)) {
|
|
725
|
-
return vec3.fromValues(x, y, z);
|
|
726
|
-
}
|
|
727
|
-
return vec3.fromValues(x[0], x[1] || y, x[2] || z);
|
|
728
|
-
}
|
|
729
|
-
function deg2rad(deg) {
|
|
730
|
-
return deg * (Math.PI / 180);
|
|
731
|
-
}
|
|
732
|
-
function rad2deg(rad) {
|
|
733
|
-
return rad * (180 / Math.PI);
|
|
734
|
-
}
|
|
735
|
-
function grad2deg(grads) {
|
|
736
|
-
grads = grads % 400;
|
|
737
|
-
if (grads < 0) {
|
|
738
|
-
grads += 400;
|
|
739
|
-
}
|
|
740
|
-
return (grads / 400) * 360;
|
|
741
|
-
}
|
|
742
|
-
function deg2turn(deg) {
|
|
743
|
-
return deg / 360;
|
|
744
|
-
}
|
|
745
|
-
function turn2deg(turn) {
|
|
746
|
-
return 360 * turn;
|
|
747
|
-
}
|
|
748
|
-
function getEulerFromQuat(out, quat) {
|
|
749
|
-
var x = quat[0];
|
|
750
|
-
var y = quat[1];
|
|
751
|
-
var z = quat[2];
|
|
752
|
-
var w = quat[3];
|
|
753
|
-
var x2 = x * x;
|
|
754
|
-
var y2 = y * y;
|
|
755
|
-
var z2 = z * z;
|
|
756
|
-
var w2 = w * w;
|
|
757
|
-
var unit = x2 + y2 + z2 + w2;
|
|
758
|
-
var test = x * w - y * z;
|
|
759
|
-
if (test > 0.499995 * unit) {
|
|
760
|
-
// TODO: Use glmatrix.EPSILON
|
|
761
|
-
// singularity at the north pole
|
|
762
|
-
out[0] = Math.PI / 2;
|
|
763
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
764
|
-
out[2] = 0;
|
|
765
|
-
}
|
|
766
|
-
else if (test < -0.499995 * unit) {
|
|
767
|
-
//TODO: Use glmatrix.EPSILON
|
|
768
|
-
// singularity at the south pole
|
|
769
|
-
out[0] = -Math.PI / 2;
|
|
770
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
771
|
-
out[2] = 0;
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
out[0] = Math.asin(2 * (x * z - w * y));
|
|
775
|
-
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
776
|
-
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
777
|
-
}
|
|
778
|
-
// TODO: Return them as degrees and not as radians
|
|
779
|
-
return out;
|
|
780
|
-
}
|
|
781
|
-
function getEulerFromMat4(out, m) {
|
|
782
|
-
var x;
|
|
783
|
-
var z;
|
|
784
|
-
var halfPi = Math.PI * 0.5;
|
|
785
|
-
var _a = __read(mat4.getScaling(vec3.create(), m), 3), sx = _a[0], sy = _a[1], sz = _a[2];
|
|
786
|
-
var y = Math.asin(-m[2] / sx);
|
|
787
|
-
if (y < halfPi) {
|
|
788
|
-
if (y > -halfPi) {
|
|
789
|
-
x = Math.atan2(m[6] / sy, m[10] / sz);
|
|
790
|
-
z = Math.atan2(m[1] / sx, m[0] / sx);
|
|
791
|
-
}
|
|
792
|
-
else {
|
|
793
|
-
// Not a unique solution
|
|
794
|
-
z = 0;
|
|
795
|
-
x = -Math.atan2(m[4] / sy, m[5] / sy);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
else {
|
|
799
|
-
// Not a unique solution
|
|
800
|
-
z = 0;
|
|
801
|
-
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
802
|
-
}
|
|
803
|
-
out[0] = x;
|
|
804
|
-
out[1] = y;
|
|
805
|
-
out[2] = z;
|
|
806
|
-
return out;
|
|
807
|
-
}
|
|
808
|
-
/**
|
|
809
|
-
* @see https://github.com/toji/gl-matrix/issues/329
|
|
810
|
-
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
811
|
-
*/
|
|
812
|
-
function getEuler(out, quat) {
|
|
813
|
-
if (quat.length === 16) {
|
|
814
|
-
return getEulerFromMat4(out, quat);
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
return getEulerFromQuat(out, quat);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
function fromRotationTranslationScale(rotation, x, y, scaleX, scaleY) {
|
|
821
|
-
var cos = Math.cos(rotation);
|
|
822
|
-
var sin = Math.sin(rotation);
|
|
823
|
-
return mat3.fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
824
|
-
}
|
|
825
|
-
function makePerspective(out, left, right, top, bottom, near, far, zero) {
|
|
826
|
-
if (zero === void 0) { zero = false; }
|
|
827
|
-
var x = (2 * near) / (right - left);
|
|
828
|
-
var y = (2 * near) / (top - bottom);
|
|
829
|
-
var a = (right + left) / (right - left);
|
|
830
|
-
var b = (top + bottom) / (top - bottom);
|
|
831
|
-
var c;
|
|
832
|
-
var d;
|
|
833
|
-
if (zero) {
|
|
834
|
-
c = -far / (far - near);
|
|
835
|
-
d = (-far * near) / (far - near);
|
|
836
|
-
}
|
|
837
|
-
else {
|
|
838
|
-
c = -(far + near) / (far - near);
|
|
839
|
-
d = (-2 * far * near) / (far - near);
|
|
840
|
-
}
|
|
841
|
-
out[0] = x;
|
|
842
|
-
out[1] = 0;
|
|
843
|
-
out[2] = 0;
|
|
844
|
-
out[3] = 0;
|
|
845
|
-
out[4] = 0;
|
|
846
|
-
out[5] = y;
|
|
847
|
-
out[6] = 0;
|
|
848
|
-
out[7] = 0;
|
|
849
|
-
out[8] = a;
|
|
850
|
-
out[9] = b;
|
|
851
|
-
out[10] = c;
|
|
852
|
-
out[11] = -1;
|
|
853
|
-
out[12] = 0;
|
|
854
|
-
out[13] = 0;
|
|
855
|
-
out[14] = d;
|
|
856
|
-
out[15] = 0;
|
|
857
|
-
return out;
|
|
858
|
-
}
|
|
859
|
-
function decompose(mat) {
|
|
860
|
-
var row0x = mat[0];
|
|
861
|
-
var row0y = mat[1];
|
|
862
|
-
var row1x = mat[3];
|
|
863
|
-
var row1y = mat[4];
|
|
864
|
-
// decompose 3x3 matrix
|
|
865
|
-
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
866
|
-
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
867
|
-
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y);
|
|
868
|
-
// If determinant is negative, one axis was flipped.
|
|
869
|
-
var determinant = row0x * row1y - row0y * row1x;
|
|
870
|
-
if (determinant < 0) {
|
|
871
|
-
// Flip axis with minimum unit vector dot product.
|
|
872
|
-
if (row0x < row1y) {
|
|
873
|
-
scalingX = -scalingX;
|
|
874
|
-
}
|
|
875
|
-
else {
|
|
876
|
-
scalingY = -scalingY;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
// Renormalize matrix to remove scale.
|
|
880
|
-
if (scalingX) {
|
|
881
|
-
row0x *= 1 / scalingX;
|
|
882
|
-
row0y *= 1 / scalingX;
|
|
883
|
-
}
|
|
884
|
-
if (scalingY) {
|
|
885
|
-
row1x *= 1 / scalingY;
|
|
886
|
-
row1y *= 1 / scalingY;
|
|
887
|
-
}
|
|
888
|
-
// Compute rotation and renormalize matrix.
|
|
889
|
-
var rotation = Math.atan2(row0y, row0x);
|
|
890
|
-
var angle = rad2deg(rotation);
|
|
891
|
-
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
892
|
-
}
|
|
893
|
-
var tmp = mat4.create();
|
|
894
|
-
var perspectiveMatrix = mat4.create();
|
|
895
|
-
var tmpVec4 = vec4.create();
|
|
896
|
-
var row = [vec3.create(), vec3.create(), vec3.create()];
|
|
897
|
-
var pdum3 = vec3.create();
|
|
898
|
-
/*
|
|
899
|
-
Input: matrix ; a 4x4 matrix
|
|
900
|
-
Output: translation ; a 3 component vector
|
|
901
|
-
scale ; a 3 component vector
|
|
902
|
-
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
903
|
-
perspective ; a 4 component vector
|
|
904
|
-
quaternion ; a 4 component vector
|
|
905
|
-
Returns false if the matrix cannot be decomposed, true if it can
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
References:
|
|
909
|
-
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
910
|
-
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
911
|
-
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
912
|
-
*/
|
|
913
|
-
function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
914
|
-
//normalize, if not possible then bail out early
|
|
915
|
-
if (!normalize(tmp, matrix))
|
|
916
|
-
return false;
|
|
917
|
-
// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
918
|
-
// an easy way to test for singularity of the upper 3x3 component.
|
|
919
|
-
mat4.copy(perspectiveMatrix, tmp);
|
|
920
|
-
perspectiveMatrix[3] = 0;
|
|
921
|
-
perspectiveMatrix[7] = 0;
|
|
922
|
-
perspectiveMatrix[11] = 0;
|
|
923
|
-
perspectiveMatrix[15] = 1;
|
|
924
|
-
// If the perspectiveMatrix is not invertible, we are also unable to
|
|
925
|
-
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
926
|
-
if (Math.abs(mat4.determinant(perspectiveMatrix)) < 1e-8)
|
|
927
|
-
return false;
|
|
928
|
-
var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11], a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
|
|
929
|
-
// First, isolate perspective.
|
|
930
|
-
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
931
|
-
tmpVec4[0] = a03;
|
|
932
|
-
tmpVec4[1] = a13;
|
|
933
|
-
tmpVec4[2] = a23;
|
|
934
|
-
tmpVec4[3] = a33;
|
|
935
|
-
// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
936
|
-
// rightHandSide by the inverse.
|
|
937
|
-
// resuing the perspectiveMatrix here since it's no longer needed
|
|
938
|
-
var ret = mat4.invert(perspectiveMatrix, perspectiveMatrix);
|
|
939
|
-
if (!ret)
|
|
940
|
-
return false;
|
|
941
|
-
mat4.transpose(perspectiveMatrix, perspectiveMatrix);
|
|
942
|
-
//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
943
|
-
vec4.transformMat4(perspective, tmpVec4, perspectiveMatrix);
|
|
944
|
-
}
|
|
945
|
-
else {
|
|
946
|
-
//no perspective
|
|
947
|
-
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
948
|
-
perspective[3] = 1;
|
|
949
|
-
}
|
|
950
|
-
// Next take care of translation
|
|
951
|
-
translation[0] = a30;
|
|
952
|
-
translation[1] = a31;
|
|
953
|
-
translation[2] = a32;
|
|
954
|
-
// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
955
|
-
mat3from4(row, tmp);
|
|
956
|
-
// Compute X scale factor and normalize first row.
|
|
957
|
-
scale[0] = vec3.length(row[0]);
|
|
958
|
-
vec3.normalize(row[0], row[0]);
|
|
959
|
-
// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
960
|
-
skew[0] = vec3.dot(row[0], row[1]);
|
|
961
|
-
combine(row[1], row[1], row[0], 1.0, -skew[0]);
|
|
962
|
-
// Now, compute Y scale and normalize 2nd row.
|
|
963
|
-
scale[1] = vec3.length(row[1]);
|
|
964
|
-
vec3.normalize(row[1], row[1]);
|
|
965
|
-
skew[0] /= scale[1];
|
|
966
|
-
// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
967
|
-
skew[1] = vec3.dot(row[0], row[2]);
|
|
968
|
-
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
969
|
-
skew[2] = vec3.dot(row[1], row[2]);
|
|
970
|
-
combine(row[2], row[2], row[1], 1.0, -skew[2]);
|
|
971
|
-
// Next, get Z scale and normalize 3rd row.
|
|
972
|
-
scale[2] = vec3.length(row[2]);
|
|
973
|
-
vec3.normalize(row[2], row[2]);
|
|
974
|
-
skew[1] /= scale[2];
|
|
975
|
-
skew[2] /= scale[2];
|
|
976
|
-
// At this point, the matrix (in rows) is orthonormal.
|
|
977
|
-
// Check for a coordinate system flip. If the determinant
|
|
978
|
-
// is -1, then negate the matrix and the scaling factors.
|
|
979
|
-
vec3.cross(pdum3, row[1], row[2]);
|
|
980
|
-
if (vec3.dot(row[0], pdum3) < 0) {
|
|
981
|
-
for (var i = 0; i < 3; i++) {
|
|
982
|
-
scale[i] *= -1;
|
|
983
|
-
row[i][0] *= -1;
|
|
984
|
-
row[i][1] *= -1;
|
|
985
|
-
row[i][2] *= -1;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
// Now, get the rotations out
|
|
989
|
-
quaternion[0] =
|
|
990
|
-
0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
991
|
-
quaternion[1] =
|
|
992
|
-
0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
993
|
-
quaternion[2] =
|
|
994
|
-
0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
995
|
-
quaternion[3] =
|
|
996
|
-
0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
997
|
-
if (row[2][1] > row[1][2])
|
|
998
|
-
quaternion[0] = -quaternion[0];
|
|
999
|
-
if (row[0][2] > row[2][0])
|
|
1000
|
-
quaternion[1] = -quaternion[1];
|
|
1001
|
-
if (row[1][0] > row[0][1])
|
|
1002
|
-
quaternion[2] = -quaternion[2];
|
|
1003
|
-
return true;
|
|
1004
|
-
}
|
|
1005
|
-
function normalize(out, mat) {
|
|
1006
|
-
var m44 = mat[15];
|
|
1007
|
-
// Cannot normalize.
|
|
1008
|
-
if (m44 === 0)
|
|
1009
|
-
return false;
|
|
1010
|
-
var scale = 1 / m44;
|
|
1011
|
-
for (var i = 0; i < 16; i++)
|
|
1012
|
-
out[i] = mat[i] * scale;
|
|
1013
|
-
return true;
|
|
1014
|
-
}
|
|
1015
|
-
//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
1016
|
-
function mat3from4(out, mat4x4) {
|
|
1017
|
-
out[0][0] = mat4x4[0];
|
|
1018
|
-
out[0][1] = mat4x4[1];
|
|
1019
|
-
out[0][2] = mat4x4[2];
|
|
1020
|
-
out[1][0] = mat4x4[4];
|
|
1021
|
-
out[1][1] = mat4x4[5];
|
|
1022
|
-
out[1][2] = mat4x4[6];
|
|
1023
|
-
out[2][0] = mat4x4[8];
|
|
1024
|
-
out[2][1] = mat4x4[9];
|
|
1025
|
-
out[2][2] = mat4x4[10];
|
|
1026
|
-
}
|
|
1027
|
-
function combine(out, a, b, scale1, scale2) {
|
|
1028
|
-
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
1029
|
-
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
1030
|
-
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
674
|
+
var addVec3 = vec3.add, copyVec3 = vec3.copy, maxVec3 = vec3.max, minVec3 = vec3.min, scaleVec3 = vec3.scale, subVec3 = vec3.sub;
|
|
1033
675
|
/**
|
|
1034
676
|
* Axis-Aligned Bounding Box
|
|
1035
677
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
@@ -1048,27 +690,13 @@ var AABB = /** @class */ (function () {
|
|
|
1048
690
|
aabb.halfExtents[1] === 0 &&
|
|
1049
691
|
aabb.halfExtents[2] === 0));
|
|
1050
692
|
};
|
|
1051
|
-
// center: vec3 = vec3.create();
|
|
1052
|
-
// halfExtents: vec3 = vec3.create();
|
|
1053
|
-
// min: vec3 = vec3.create();
|
|
1054
|
-
// max: vec3 = vec3.create();
|
|
1055
693
|
AABB.prototype.update = function (center, halfExtents) {
|
|
1056
694
|
copyVec3(this.center, center);
|
|
1057
695
|
copyVec3(this.halfExtents, halfExtents);
|
|
1058
696
|
subVec3(this.min, this.center, this.halfExtents);
|
|
1059
697
|
addVec3(this.max, this.center, this.halfExtents);
|
|
1060
|
-
// vec3.copy(this.center, center);
|
|
1061
|
-
// vec3.copy(this.halfExtents, halfExtents);
|
|
1062
|
-
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
1063
|
-
// vec3.add(this.max, this.center, this.halfExtents);
|
|
1064
698
|
};
|
|
1065
699
|
AABB.prototype.setMinMax = function (min, max) {
|
|
1066
|
-
// vec3.add(this.center, max, min);
|
|
1067
|
-
// vec3.scale(this.center, this.center, 0.5);
|
|
1068
|
-
// vec3.sub(this.halfExtents, max, min);
|
|
1069
|
-
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
1070
|
-
// vec3.copy(this.min, min);
|
|
1071
|
-
// vec3.copy(this.max, max);
|
|
1072
700
|
addVec3(this.center, max, min);
|
|
1073
701
|
scaleVec3(this.center, this.center, 0.5);
|
|
1074
702
|
subVec3(this.halfExtents, max, min);
|
|
@@ -1212,25 +840,11 @@ var AABB = /** @class */ (function () {
|
|
|
1212
840
|
return null;
|
|
1213
841
|
}
|
|
1214
842
|
var intersection = new AABB();
|
|
1215
|
-
// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
1216
|
-
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
1217
843
|
var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
|
|
1218
844
|
var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
|
|
1219
845
|
intersection.setMinMax(min, max);
|
|
1220
846
|
return intersection;
|
|
1221
|
-
};
|
|
1222
|
-
// containsPoint(point: vec3) {
|
|
1223
|
-
// const min = this.getMin();
|
|
1224
|
-
// const max = this.getMax();
|
|
1225
|
-
// return !(
|
|
1226
|
-
// point[0] < min[0] ||
|
|
1227
|
-
// point[0] > max[0] ||
|
|
1228
|
-
// point[1] < min[1] ||
|
|
1229
|
-
// point[1] > max[1] ||
|
|
1230
|
-
// point[2] < min[2] ||
|
|
1231
|
-
// point[2] > max[2]
|
|
1232
|
-
// );
|
|
1233
|
-
// }
|
|
847
|
+
};
|
|
1234
848
|
/**
|
|
1235
849
|
* get n-vertex
|
|
1236
850
|
* @param plane plane of CullingVolume
|
|
@@ -1403,67 +1017,405 @@ var Point = /** @class */ (function () {
|
|
|
1403
1017
|
this.x = x;
|
|
1404
1018
|
this.y = y;
|
|
1405
1019
|
}
|
|
1406
|
-
Point.prototype.clone = function () {
|
|
1407
|
-
return new Point(this.x, this.y);
|
|
1408
|
-
};
|
|
1409
|
-
Point.prototype.copyFrom = function (p) {
|
|
1410
|
-
this.x = p.x;
|
|
1411
|
-
this.y = p.y;
|
|
1412
|
-
};
|
|
1413
|
-
return Point;
|
|
1414
|
-
}());
|
|
1415
|
-
|
|
1416
|
-
var Rectangle = /** @class */ (function () {
|
|
1417
|
-
function Rectangle(x, y, width, height) {
|
|
1418
|
-
this.x = x;
|
|
1419
|
-
this.y = y;
|
|
1420
|
-
this.width = width;
|
|
1421
|
-
this.height = height;
|
|
1422
|
-
this.left = x;
|
|
1423
|
-
this.right = x + width;
|
|
1424
|
-
this.top = y;
|
|
1425
|
-
this.bottom = y + height;
|
|
1020
|
+
Point.prototype.clone = function () {
|
|
1021
|
+
return new Point(this.x, this.y);
|
|
1022
|
+
};
|
|
1023
|
+
Point.prototype.copyFrom = function (p) {
|
|
1024
|
+
this.x = p.x;
|
|
1025
|
+
this.y = p.y;
|
|
1026
|
+
};
|
|
1027
|
+
return Point;
|
|
1028
|
+
}());
|
|
1029
|
+
|
|
1030
|
+
var Rectangle = /** @class */ (function () {
|
|
1031
|
+
function Rectangle(x, y, width, height) {
|
|
1032
|
+
this.x = x;
|
|
1033
|
+
this.y = y;
|
|
1034
|
+
this.width = width;
|
|
1035
|
+
this.height = height;
|
|
1036
|
+
this.left = x;
|
|
1037
|
+
this.right = x + width;
|
|
1038
|
+
this.top = y;
|
|
1039
|
+
this.bottom = y + height;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect/fromRect_static
|
|
1043
|
+
*/
|
|
1044
|
+
Rectangle.fromRect = function (rect) {
|
|
1045
|
+
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
|
|
1046
|
+
};
|
|
1047
|
+
/**
|
|
1048
|
+
* will return a new rect instance
|
|
1049
|
+
*/
|
|
1050
|
+
Rectangle.applyTransform = function (rect, matrix) {
|
|
1051
|
+
var topLeft = vec4.fromValues(rect.x, rect.y, 0, 1);
|
|
1052
|
+
var topRight = vec4.fromValues(rect.x + rect.width, rect.y, 0, 1);
|
|
1053
|
+
var bottomLeft = vec4.fromValues(rect.x, rect.y + rect.height, 0, 1);
|
|
1054
|
+
var bottomRight = vec4.fromValues(rect.x + rect.width, rect.y + rect.height, 0, 1);
|
|
1055
|
+
var transformedTopLeft = vec4.create();
|
|
1056
|
+
var transformedTopRight = vec4.create();
|
|
1057
|
+
var transformedBottomLeft = vec4.create();
|
|
1058
|
+
var transformedBottomRight = vec4.create();
|
|
1059
|
+
vec4.transformMat4(transformedTopLeft, topLeft, matrix);
|
|
1060
|
+
vec4.transformMat4(transformedTopRight, topRight, matrix);
|
|
1061
|
+
vec4.transformMat4(transformedBottomLeft, bottomLeft, matrix);
|
|
1062
|
+
vec4.transformMat4(transformedBottomRight, bottomRight, matrix);
|
|
1063
|
+
var minX = Math.min(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1064
|
+
var minY = Math.min(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1065
|
+
var maxX = Math.max(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1066
|
+
var maxY = Math.max(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1067
|
+
return Rectangle.fromRect({
|
|
1068
|
+
x: minX,
|
|
1069
|
+
y: minY,
|
|
1070
|
+
width: maxX - minX,
|
|
1071
|
+
height: maxY - minY,
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
Rectangle.prototype.toJSON = function () { };
|
|
1075
|
+
return Rectangle;
|
|
1076
|
+
}());
|
|
1077
|
+
|
|
1078
|
+
var ERROR_MSG_METHOD_NOT_IMPLEMENTED = 'Method not implemented.';
|
|
1079
|
+
var ERROR_MSG_USE_DOCUMENT_ELEMENT = 'Use document.documentElement instead.';
|
|
1080
|
+
var ERROR_MSG_APPEND_DESTROYED_ELEMENT = 'Cannot append a destroyed element.';
|
|
1081
|
+
|
|
1082
|
+
function getAngle(angle) {
|
|
1083
|
+
if (angle === undefined) {
|
|
1084
|
+
return 0;
|
|
1085
|
+
}
|
|
1086
|
+
else if (angle > 360 || angle < -360) {
|
|
1087
|
+
return angle % 360;
|
|
1088
|
+
}
|
|
1089
|
+
return angle;
|
|
1090
|
+
}
|
|
1091
|
+
var $vec3$2 = vec3.create();
|
|
1092
|
+
function createVec3(x, y, z, clone) {
|
|
1093
|
+
if (y === void 0) { y = 0; }
|
|
1094
|
+
if (z === void 0) { z = 0; }
|
|
1095
|
+
if (clone === void 0) { clone = true; }
|
|
1096
|
+
if (Array.isArray(x) && x.length === 3) {
|
|
1097
|
+
return clone ? vec3.clone(x) : vec3.copy($vec3$2, x);
|
|
1098
|
+
}
|
|
1099
|
+
if (isNumber(x)) {
|
|
1100
|
+
return clone ? vec3.fromValues(x, y, z) : vec3.set($vec3$2, x, y, z);
|
|
1101
|
+
}
|
|
1102
|
+
return clone
|
|
1103
|
+
? vec3.fromValues(x[0], x[1] || y, x[2] || z)
|
|
1104
|
+
: vec3.set($vec3$2, x[0], x[1] || y, x[2] || z);
|
|
1105
|
+
}
|
|
1106
|
+
var DEG_RAD = Math.PI / 180;
|
|
1107
|
+
function deg2rad(deg) {
|
|
1108
|
+
return deg * DEG_RAD;
|
|
1109
|
+
}
|
|
1110
|
+
var RAD_DEG = 180 / Math.PI;
|
|
1111
|
+
function rad2deg(rad) {
|
|
1112
|
+
return rad * RAD_DEG;
|
|
1113
|
+
}
|
|
1114
|
+
var GRAD_DEG = 0.9; // 360 / 400;
|
|
1115
|
+
function grad2deg(grads) {
|
|
1116
|
+
grads = grads % 400;
|
|
1117
|
+
if (grads < 0) {
|
|
1118
|
+
grads += 400;
|
|
1119
|
+
}
|
|
1120
|
+
return grads * GRAD_DEG;
|
|
1121
|
+
}
|
|
1122
|
+
function deg2turn(deg) {
|
|
1123
|
+
return deg / 360;
|
|
1124
|
+
}
|
|
1125
|
+
function turn2deg(turn) {
|
|
1126
|
+
return 360 * turn;
|
|
1127
|
+
}
|
|
1128
|
+
var HALF_PI = Math.PI / 2;
|
|
1129
|
+
function getEulerFromQuat(out, quat) {
|
|
1130
|
+
var x = quat[0];
|
|
1131
|
+
var y = quat[1];
|
|
1132
|
+
var z = quat[2];
|
|
1133
|
+
var w = quat[3];
|
|
1134
|
+
var x2 = x * x;
|
|
1135
|
+
var y2 = y * y;
|
|
1136
|
+
var z2 = z * z;
|
|
1137
|
+
var w2 = w * w;
|
|
1138
|
+
var unit = x2 + y2 + z2 + w2;
|
|
1139
|
+
var test = x * w - y * z;
|
|
1140
|
+
if (test > 0.499995 * unit) {
|
|
1141
|
+
// TODO: Use glmatrix.EPSILON
|
|
1142
|
+
// singularity at the north pole
|
|
1143
|
+
out[0] = HALF_PI;
|
|
1144
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
1145
|
+
out[2] = 0;
|
|
1146
|
+
}
|
|
1147
|
+
else if (test < -0.499995 * unit) {
|
|
1148
|
+
//TODO: Use glmatrix.EPSILON
|
|
1149
|
+
// singularity at the south pole
|
|
1150
|
+
out[0] = -HALF_PI;
|
|
1151
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
1152
|
+
out[2] = 0;
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
out[0] = Math.asin(2 * (x * z - w * y));
|
|
1156
|
+
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
1157
|
+
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
1158
|
+
}
|
|
1159
|
+
// TODO: Return them as degrees and not as radians
|
|
1160
|
+
return out;
|
|
1161
|
+
}
|
|
1162
|
+
function getEulerFromMat4(out, m) {
|
|
1163
|
+
var x;
|
|
1164
|
+
var z;
|
|
1165
|
+
var _a = __read(mat4.getScaling(vec3.create(), m), 3), sx = _a[0], sy = _a[1], sz = _a[2];
|
|
1166
|
+
var y = Math.asin(-m[2] / sx);
|
|
1167
|
+
if (y < HALF_PI) {
|
|
1168
|
+
if (y > -HALF_PI) {
|
|
1169
|
+
x = Math.atan2(m[6] / sy, m[10] / sz);
|
|
1170
|
+
z = Math.atan2(m[1] / sx, m[0] / sx);
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
// Not a unique solution
|
|
1174
|
+
z = 0;
|
|
1175
|
+
x = -Math.atan2(m[4] / sy, m[5] / sy);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
// Not a unique solution
|
|
1180
|
+
z = 0;
|
|
1181
|
+
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
1182
|
+
}
|
|
1183
|
+
out[0] = x;
|
|
1184
|
+
out[1] = y;
|
|
1185
|
+
out[2] = z;
|
|
1186
|
+
return out;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* @see https://github.com/toji/gl-matrix/issues/329
|
|
1190
|
+
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
1191
|
+
*/
|
|
1192
|
+
function getEuler(out, quat) {
|
|
1193
|
+
if (quat.length === 16) {
|
|
1194
|
+
return getEulerFromMat4(out, quat);
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
return getEulerFromQuat(out, quat);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
function fromRotationTranslationScale(rotation, x, y, scaleX, scaleY) {
|
|
1201
|
+
var cos = Math.cos(rotation);
|
|
1202
|
+
var sin = Math.sin(rotation);
|
|
1203
|
+
return mat3.fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
1204
|
+
}
|
|
1205
|
+
function makePerspective(out, left, right, top, bottom, near, far, zero) {
|
|
1206
|
+
if (zero === void 0) { zero = false; }
|
|
1207
|
+
var twoNear = 2 * near;
|
|
1208
|
+
var rightMinusLeft = right - left;
|
|
1209
|
+
var topMinusBottom = top - bottom;
|
|
1210
|
+
var x = twoNear / rightMinusLeft;
|
|
1211
|
+
var y = twoNear / topMinusBottom;
|
|
1212
|
+
var a = (right + left) / rightMinusLeft;
|
|
1213
|
+
var b = (top + bottom) / topMinusBottom;
|
|
1214
|
+
var c;
|
|
1215
|
+
var d;
|
|
1216
|
+
var farMinusNear = far - near;
|
|
1217
|
+
var farMulNear = far * near;
|
|
1218
|
+
if (zero) {
|
|
1219
|
+
c = -far / farMinusNear;
|
|
1220
|
+
d = -farMulNear / farMinusNear;
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
c = -(far + near) / farMinusNear;
|
|
1224
|
+
d = (-2 * farMulNear) / farMinusNear;
|
|
1225
|
+
}
|
|
1226
|
+
out[0] = x;
|
|
1227
|
+
out[1] = 0;
|
|
1228
|
+
out[2] = 0;
|
|
1229
|
+
out[3] = 0;
|
|
1230
|
+
out[4] = 0;
|
|
1231
|
+
out[5] = y;
|
|
1232
|
+
out[6] = 0;
|
|
1233
|
+
out[7] = 0;
|
|
1234
|
+
out[8] = a;
|
|
1235
|
+
out[9] = b;
|
|
1236
|
+
out[10] = c;
|
|
1237
|
+
out[11] = -1;
|
|
1238
|
+
out[12] = 0;
|
|
1239
|
+
out[13] = 0;
|
|
1240
|
+
out[14] = d;
|
|
1241
|
+
out[15] = 0;
|
|
1242
|
+
return out;
|
|
1243
|
+
}
|
|
1244
|
+
function decompose(mat) {
|
|
1245
|
+
var row0x = mat[0];
|
|
1246
|
+
var row0y = mat[1];
|
|
1247
|
+
var row1x = mat[3];
|
|
1248
|
+
var row1y = mat[4];
|
|
1249
|
+
// decompose 3x3 matrix
|
|
1250
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
1251
|
+
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
1252
|
+
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y);
|
|
1253
|
+
// If determinant is negative, one axis was flipped.
|
|
1254
|
+
var determinant = row0x * row1y - row0y * row1x;
|
|
1255
|
+
if (determinant < 0) {
|
|
1256
|
+
// Flip axis with minimum unit vector dot product.
|
|
1257
|
+
if (row0x < row1y) {
|
|
1258
|
+
scalingX = -scalingX;
|
|
1259
|
+
}
|
|
1260
|
+
else {
|
|
1261
|
+
scalingY = -scalingY;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
// Renormalize matrix to remove scale.
|
|
1265
|
+
if (scalingX) {
|
|
1266
|
+
var invScalingX = 1 / scalingX;
|
|
1267
|
+
row0x *= invScalingX;
|
|
1268
|
+
row0y *= invScalingX;
|
|
1269
|
+
}
|
|
1270
|
+
if (scalingY) {
|
|
1271
|
+
var invScalingY = 1 / scalingY;
|
|
1272
|
+
row1x *= invScalingY;
|
|
1273
|
+
row1y *= invScalingY;
|
|
1274
|
+
}
|
|
1275
|
+
// Compute rotation and renormalize matrix.
|
|
1276
|
+
var rotation = Math.atan2(row0y, row0x);
|
|
1277
|
+
var angle = rad2deg(rotation);
|
|
1278
|
+
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
1279
|
+
}
|
|
1280
|
+
var tmp = mat4.create();
|
|
1281
|
+
var perspectiveMatrix = mat4.create();
|
|
1282
|
+
var tmpVec4 = vec4.create();
|
|
1283
|
+
var row = [vec3.create(), vec3.create(), vec3.create()];
|
|
1284
|
+
var pdum3 = vec3.create();
|
|
1285
|
+
/*
|
|
1286
|
+
Input: matrix ; a 4x4 matrix
|
|
1287
|
+
Output: translation ; a 3 component vector
|
|
1288
|
+
scale ; a 3 component vector
|
|
1289
|
+
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
1290
|
+
perspective ; a 4 component vector
|
|
1291
|
+
quaternion ; a 4 component vector
|
|
1292
|
+
Returns false if the matrix cannot be decomposed, true if it can
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
References:
|
|
1296
|
+
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
1297
|
+
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
1298
|
+
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
1299
|
+
*/
|
|
1300
|
+
function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
1301
|
+
//normalize, if not possible then bail out early
|
|
1302
|
+
if (!normalize(tmp, matrix))
|
|
1303
|
+
return false;
|
|
1304
|
+
// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
1305
|
+
// an easy way to test for singularity of the upper 3x3 component.
|
|
1306
|
+
mat4.copy(perspectiveMatrix, tmp);
|
|
1307
|
+
perspectiveMatrix[3] = 0;
|
|
1308
|
+
perspectiveMatrix[7] = 0;
|
|
1309
|
+
perspectiveMatrix[11] = 0;
|
|
1310
|
+
perspectiveMatrix[15] = 1;
|
|
1311
|
+
// If the perspectiveMatrix is not invertible, we are also unable to
|
|
1312
|
+
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
1313
|
+
if (Math.abs(mat4.determinant(perspectiveMatrix)) < 1e-8)
|
|
1314
|
+
return false;
|
|
1315
|
+
var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11], a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
|
|
1316
|
+
// First, isolate perspective.
|
|
1317
|
+
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
1318
|
+
tmpVec4[0] = a03;
|
|
1319
|
+
tmpVec4[1] = a13;
|
|
1320
|
+
tmpVec4[2] = a23;
|
|
1321
|
+
tmpVec4[3] = a33;
|
|
1322
|
+
// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
1323
|
+
// rightHandSide by the inverse.
|
|
1324
|
+
// resuing the perspectiveMatrix here since it's no longer needed
|
|
1325
|
+
var ret = mat4.invert(perspectiveMatrix, perspectiveMatrix);
|
|
1326
|
+
if (!ret)
|
|
1327
|
+
return false;
|
|
1328
|
+
mat4.transpose(perspectiveMatrix, perspectiveMatrix);
|
|
1329
|
+
//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
1330
|
+
vec4.transformMat4(perspective, tmpVec4, perspectiveMatrix);
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
//no perspective
|
|
1334
|
+
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
1335
|
+
perspective[3] = 1;
|
|
1426
1336
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1337
|
+
// Next take care of translation
|
|
1338
|
+
translation[0] = a30;
|
|
1339
|
+
translation[1] = a31;
|
|
1340
|
+
translation[2] = a32;
|
|
1341
|
+
// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
1342
|
+
mat3from4(row, tmp);
|
|
1343
|
+
// Compute X scale factor and normalize first row.
|
|
1344
|
+
scale[0] = vec3.length(row[0]);
|
|
1345
|
+
vec3.normalize(row[0], row[0]);
|
|
1346
|
+
// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
1347
|
+
skew[0] = vec3.dot(row[0], row[1]);
|
|
1348
|
+
combine(row[1], row[1], row[0], 1.0, -skew[0]);
|
|
1349
|
+
// Now, compute Y scale and normalize 2nd row.
|
|
1350
|
+
scale[1] = vec3.length(row[1]);
|
|
1351
|
+
vec3.normalize(row[1], row[1]);
|
|
1352
|
+
skew[0] /= scale[1];
|
|
1353
|
+
// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
1354
|
+
skew[1] = vec3.dot(row[0], row[2]);
|
|
1355
|
+
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
1356
|
+
skew[2] = vec3.dot(row[1], row[2]);
|
|
1357
|
+
combine(row[2], row[2], row[1], 1.0, -skew[2]);
|
|
1358
|
+
// Next, get Z scale and normalize 3rd row.
|
|
1359
|
+
scale[2] = vec3.length(row[2]);
|
|
1360
|
+
vec3.normalize(row[2], row[2]);
|
|
1361
|
+
skew[1] /= scale[2];
|
|
1362
|
+
skew[2] /= scale[2];
|
|
1363
|
+
// At this point, the matrix (in rows) is orthonormal.
|
|
1364
|
+
// Check for a coordinate system flip. If the determinant
|
|
1365
|
+
// is -1, then negate the matrix and the scaling factors.
|
|
1366
|
+
vec3.cross(pdum3, row[1], row[2]);
|
|
1367
|
+
if (vec3.dot(row[0], pdum3) < 0) {
|
|
1368
|
+
for (var i = 0; i < 3; i++) {
|
|
1369
|
+
scale[i] *= -1;
|
|
1370
|
+
row[i][0] *= -1;
|
|
1371
|
+
row[i][1] *= -1;
|
|
1372
|
+
row[i][2] *= -1;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
// Now, get the rotations out
|
|
1376
|
+
quaternion[0] =
|
|
1377
|
+
0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
1378
|
+
quaternion[1] =
|
|
1379
|
+
0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
1380
|
+
quaternion[2] =
|
|
1381
|
+
0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
1382
|
+
quaternion[3] =
|
|
1383
|
+
0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
1384
|
+
if (row[2][1] > row[1][2])
|
|
1385
|
+
quaternion[0] = -quaternion[0];
|
|
1386
|
+
if (row[0][2] > row[2][0])
|
|
1387
|
+
quaternion[1] = -quaternion[1];
|
|
1388
|
+
if (row[1][0] > row[0][1])
|
|
1389
|
+
quaternion[2] = -quaternion[2];
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
function normalize(out, mat) {
|
|
1393
|
+
var m44 = mat[15];
|
|
1394
|
+
// Cannot normalize.
|
|
1395
|
+
if (m44 === 0)
|
|
1396
|
+
return false;
|
|
1397
|
+
var scale = 1 / m44;
|
|
1398
|
+
for (var i = 0; i < 16; i++)
|
|
1399
|
+
out[i] = mat[i] * scale;
|
|
1400
|
+
return true;
|
|
1401
|
+
}
|
|
1402
|
+
//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
1403
|
+
function mat3from4(out, mat4x4) {
|
|
1404
|
+
out[0][0] = mat4x4[0];
|
|
1405
|
+
out[0][1] = mat4x4[1];
|
|
1406
|
+
out[0][2] = mat4x4[2];
|
|
1407
|
+
out[1][0] = mat4x4[4];
|
|
1408
|
+
out[1][1] = mat4x4[5];
|
|
1409
|
+
out[1][2] = mat4x4[6];
|
|
1410
|
+
out[2][0] = mat4x4[8];
|
|
1411
|
+
out[2][1] = mat4x4[9];
|
|
1412
|
+
out[2][2] = mat4x4[10];
|
|
1413
|
+
}
|
|
1414
|
+
function combine(out, a, b, scale1, scale2) {
|
|
1415
|
+
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
1416
|
+
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
1417
|
+
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
1418
|
+
}
|
|
1467
1419
|
|
|
1468
1420
|
/**
|
|
1469
1421
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
@@ -2215,6 +2167,99 @@ var Camera = /** @class */ (function () {
|
|
|
2215
2167
|
return Camera;
|
|
2216
2168
|
}());
|
|
2217
2169
|
|
|
2170
|
+
/**
|
|
2171
|
+
* @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
|
|
2172
|
+
*/
|
|
2173
|
+
var Strategy;
|
|
2174
|
+
(function (Strategy) {
|
|
2175
|
+
Strategy[Strategy["Standard"] = 0] = "Standard";
|
|
2176
|
+
})(Strategy || (Strategy = {}));
|
|
2177
|
+
|
|
2178
|
+
var SortReason;
|
|
2179
|
+
(function (SortReason) {
|
|
2180
|
+
SortReason[SortReason["ADDED"] = 0] = "ADDED";
|
|
2181
|
+
SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
|
|
2182
|
+
SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
|
|
2183
|
+
})(SortReason || (SortReason = {}));
|
|
2184
|
+
|
|
2185
|
+
var EMPTY_PARSED_PATH = {
|
|
2186
|
+
absolutePath: [],
|
|
2187
|
+
hasArc: false,
|
|
2188
|
+
segments: [],
|
|
2189
|
+
polygons: [],
|
|
2190
|
+
polylines: [],
|
|
2191
|
+
curve: null,
|
|
2192
|
+
totalLength: 0,
|
|
2193
|
+
rect: new Rectangle(0, 0, 0, 0),
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
/**
|
|
2197
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
2198
|
+
*/
|
|
2199
|
+
var PropertySyntax;
|
|
2200
|
+
(function (PropertySyntax) {
|
|
2201
|
+
/**
|
|
2202
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
2203
|
+
*/
|
|
2204
|
+
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
2205
|
+
/**
|
|
2206
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
2207
|
+
*/
|
|
2208
|
+
PropertySyntax["COLOR"] = "<color>";
|
|
2209
|
+
/**
|
|
2210
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
2211
|
+
*/
|
|
2212
|
+
PropertySyntax["PAINT"] = "<paint>";
|
|
2213
|
+
/**
|
|
2214
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
2215
|
+
*/
|
|
2216
|
+
PropertySyntax["NUMBER"] = "<number>";
|
|
2217
|
+
/**
|
|
2218
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
|
|
2219
|
+
*/
|
|
2220
|
+
PropertySyntax["ANGLE"] = "<angle>";
|
|
2221
|
+
/**
|
|
2222
|
+
* <number> with range 0..1
|
|
2223
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
2224
|
+
*/
|
|
2225
|
+
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
2226
|
+
/**
|
|
2227
|
+
* <number> with range 0..Infinity
|
|
2228
|
+
*/
|
|
2229
|
+
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
2230
|
+
/**
|
|
2231
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
2232
|
+
*/
|
|
2233
|
+
PropertySyntax["LENGTH"] = "<length>";
|
|
2234
|
+
/**
|
|
2235
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
2236
|
+
*/
|
|
2237
|
+
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
2238
|
+
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
2239
|
+
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
2240
|
+
/**
|
|
2241
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
2242
|
+
*/
|
|
2243
|
+
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
2244
|
+
/**
|
|
2245
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
2246
|
+
*/
|
|
2247
|
+
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
2248
|
+
PropertySyntax["PATH"] = "<path>";
|
|
2249
|
+
/**
|
|
2250
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
2251
|
+
*/
|
|
2252
|
+
PropertySyntax["FILTER"] = "<filter>";
|
|
2253
|
+
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
2254
|
+
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
2255
|
+
PropertySyntax["DEFINED_PATH"] = "<defined-path>";
|
|
2256
|
+
PropertySyntax["MARKER"] = "<marker>";
|
|
2257
|
+
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
2258
|
+
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
2259
|
+
PropertySyntax["TEXT"] = "<text>";
|
|
2260
|
+
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
2261
|
+
})(PropertySyntax || (PropertySyntax = {}));
|
|
2262
|
+
|
|
2218
2263
|
function memoize(func, resolver) {
|
|
2219
2264
|
if (typeof func !== 'function' ||
|
|
2220
2265
|
(resolver != null && typeof resolver !== 'function')) {
|
|
@@ -2331,14 +2376,6 @@ var UnitCategory;
|
|
|
2331
2376
|
// kUResolution,
|
|
2332
2377
|
UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
|
|
2333
2378
|
})(UnitCategory || (UnitCategory = {}));
|
|
2334
|
-
var ValueRange;
|
|
2335
|
-
(function (ValueRange) {
|
|
2336
|
-
ValueRange[ValueRange["kAll"] = 0] = "kAll";
|
|
2337
|
-
ValueRange[ValueRange["kNonNegative"] = 1] = "kNonNegative";
|
|
2338
|
-
ValueRange[ValueRange["kInteger"] = 2] = "kInteger";
|
|
2339
|
-
ValueRange[ValueRange["kNonNegativeInteger"] = 3] = "kNonNegativeInteger";
|
|
2340
|
-
ValueRange[ValueRange["kPositiveInteger"] = 4] = "kPositiveInteger";
|
|
2341
|
-
})(ValueRange || (ValueRange = {}));
|
|
2342
2379
|
var Nested;
|
|
2343
2380
|
(function (Nested) {
|
|
2344
2381
|
Nested[Nested["kYes"] = 0] = "kYes";
|
|
@@ -2857,13 +2894,6 @@ var CSSColorValue = /** @class */ (function (_super) {
|
|
|
2857
2894
|
CSSColorValue.prototype.getType = function () {
|
|
2858
2895
|
return CSSStyleValueType.kColorType;
|
|
2859
2896
|
};
|
|
2860
|
-
// buildCSSText(n: Nested, p: ParenLess, result: string): string {
|
|
2861
|
-
// let text = '';
|
|
2862
|
-
// if (this.colorSpace === 'rgb') {
|
|
2863
|
-
// text = `rgba(${this.channels.join(',')},${this.alpha})`;
|
|
2864
|
-
// }
|
|
2865
|
-
// return (result += text);
|
|
2866
|
-
// }
|
|
2867
2897
|
/**
|
|
2868
2898
|
* @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
|
|
2869
2899
|
*/
|
|
@@ -2924,82 +2954,6 @@ var CSSKeywordValue = /** @class */ (function (_super) {
|
|
|
2924
2954
|
return CSSKeywordValue;
|
|
2925
2955
|
}(CSSStyleValue));
|
|
2926
2956
|
|
|
2927
|
-
var camelCase = memoize(function (str) {
|
|
2928
|
-
if (str === void 0) { str = ''; }
|
|
2929
|
-
return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
2930
|
-
});
|
|
2931
|
-
var kebabize = function (str) {
|
|
2932
|
-
return str
|
|
2933
|
-
.split('')
|
|
2934
|
-
.map(function (letter, idx) {
|
|
2935
|
-
return letter.toUpperCase() === letter
|
|
2936
|
-
? "".concat(idx !== 0 ? '-' : '').concat(letter.toLowerCase())
|
|
2937
|
-
: letter;
|
|
2938
|
-
})
|
|
2939
|
-
.join('');
|
|
2940
|
-
};
|
|
2941
|
-
|
|
2942
|
-
function DCHECK(bool) {
|
|
2943
|
-
if (!bool) {
|
|
2944
|
-
throw new Error();
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
function isFunction(func) {
|
|
2948
|
-
return typeof func === 'function';
|
|
2949
|
-
}
|
|
2950
|
-
function isSymbol(value) {
|
|
2951
|
-
// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
|
|
2952
|
-
return typeof value === 'symbol';
|
|
2953
|
-
}
|
|
2954
|
-
var definedProps = function (obj) {
|
|
2955
|
-
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
2956
|
-
var _b = __read(_a, 2), v = _b[1];
|
|
2957
|
-
return v !== undefined;
|
|
2958
|
-
}));
|
|
2959
|
-
};
|
|
2960
|
-
var FORMAT_ATTR_MAP = {
|
|
2961
|
-
d: {
|
|
2962
|
-
alias: 'path',
|
|
2963
|
-
},
|
|
2964
|
-
strokeDasharray: {
|
|
2965
|
-
alias: 'lineDash',
|
|
2966
|
-
},
|
|
2967
|
-
strokeWidth: {
|
|
2968
|
-
alias: 'lineWidth',
|
|
2969
|
-
},
|
|
2970
|
-
textAnchor: {
|
|
2971
|
-
alias: 'textAlign',
|
|
2972
|
-
},
|
|
2973
|
-
src: {
|
|
2974
|
-
alias: 'img',
|
|
2975
|
-
},
|
|
2976
|
-
};
|
|
2977
|
-
var formatAttributeName = memoize(function (name) {
|
|
2978
|
-
var attributeName = camelCase(name);
|
|
2979
|
-
var map = FORMAT_ATTR_MAP[attributeName];
|
|
2980
|
-
attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
|
|
2981
|
-
return attributeName;
|
|
2982
|
-
});
|
|
2983
|
-
|
|
2984
|
-
// type CSSNumericBaseType =
|
|
2985
|
-
// | 'length'
|
|
2986
|
-
// | 'angle'
|
|
2987
|
-
// | 'time'
|
|
2988
|
-
// | 'frequency'
|
|
2989
|
-
// | 'resolution'
|
|
2990
|
-
// | 'flex'
|
|
2991
|
-
// | 'percent';
|
|
2992
|
-
// https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
|
|
2993
|
-
// interface CSSNumericType {
|
|
2994
|
-
// length: number;
|
|
2995
|
-
// angle: number;
|
|
2996
|
-
// time: number;
|
|
2997
|
-
// frequency: number;
|
|
2998
|
-
// resolution: number;
|
|
2999
|
-
// flex: number;
|
|
3000
|
-
// percent: number;
|
|
3001
|
-
// percentHint: CSSNumericBaseType;
|
|
3002
|
-
// }
|
|
3003
2957
|
var formatInfinityOrNaN = function (number, suffix) {
|
|
3004
2958
|
if (suffix === void 0) { suffix = ''; }
|
|
3005
2959
|
var result = '';
|
|
@@ -3010,7 +2964,6 @@ var formatInfinityOrNaN = function (number, suffix) {
|
|
|
3010
2964
|
result = '-infinity';
|
|
3011
2965
|
}
|
|
3012
2966
|
else {
|
|
3013
|
-
DCHECK(Number.isNaN(number));
|
|
3014
2967
|
result = 'NaN';
|
|
3015
2968
|
}
|
|
3016
2969
|
return (result += suffix);
|
|
@@ -3106,25 +3059,25 @@ var CSSUnitValue = /** @class */ (function (_super) {
|
|
|
3106
3059
|
case UnitType.kSeconds:
|
|
3107
3060
|
// case UnitType.kHertz:
|
|
3108
3061
|
// case UnitType.kKilohertz:
|
|
3109
|
-
case UnitType.kTurns:
|
|
3110
|
-
{
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
}
|
|
3120
|
-
else {
|
|
3121
|
-
text = value + (unit_1 || '');
|
|
3122
|
-
}
|
|
3062
|
+
case UnitType.kTurns: {
|
|
3063
|
+
// case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
3064
|
+
var kMinInteger = -999999;
|
|
3065
|
+
var kMaxInteger = 999999;
|
|
3066
|
+
var value = this.value;
|
|
3067
|
+
var unit = unitTypeToString(this.unit);
|
|
3068
|
+
if (value < kMinInteger || value > kMaxInteger) {
|
|
3069
|
+
var unit_1 = unitTypeToString(this.unit);
|
|
3070
|
+
if (!Number.isFinite(value) || Number.isNaN(value)) {
|
|
3071
|
+
text = formatInfinityOrNaN(value, unit_1);
|
|
3123
3072
|
}
|
|
3124
3073
|
else {
|
|
3125
|
-
text =
|
|
3074
|
+
text = value + (unit_1 || '');
|
|
3126
3075
|
}
|
|
3127
3076
|
}
|
|
3077
|
+
else {
|
|
3078
|
+
text = "".concat(value).concat(unit);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3128
3081
|
}
|
|
3129
3082
|
result += text;
|
|
3130
3083
|
return result;
|
|
@@ -3208,99 +3161,6 @@ var getOrCreateUnitValue = function (value, unitOrName) {
|
|
|
3208
3161
|
};
|
|
3209
3162
|
new CSSUnitValue(50, '%');
|
|
3210
3163
|
|
|
3211
|
-
/**
|
|
3212
|
-
* @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
|
|
3213
|
-
*/
|
|
3214
|
-
var Strategy;
|
|
3215
|
-
(function (Strategy) {
|
|
3216
|
-
Strategy[Strategy["Standard"] = 0] = "Standard";
|
|
3217
|
-
})(Strategy || (Strategy = {}));
|
|
3218
|
-
|
|
3219
|
-
var SortReason;
|
|
3220
|
-
(function (SortReason) {
|
|
3221
|
-
SortReason[SortReason["ADDED"] = 0] = "ADDED";
|
|
3222
|
-
SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
|
|
3223
|
-
SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
|
|
3224
|
-
})(SortReason || (SortReason = {}));
|
|
3225
|
-
|
|
3226
|
-
var EMPTY_PARSED_PATH = {
|
|
3227
|
-
absolutePath: [],
|
|
3228
|
-
hasArc: false,
|
|
3229
|
-
segments: [],
|
|
3230
|
-
polygons: [],
|
|
3231
|
-
polylines: [],
|
|
3232
|
-
curve: null,
|
|
3233
|
-
totalLength: 0,
|
|
3234
|
-
rect: new Rectangle(0, 0, 0, 0),
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
|
-
/**
|
|
3238
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
3239
|
-
*/
|
|
3240
|
-
var PropertySyntax;
|
|
3241
|
-
(function (PropertySyntax) {
|
|
3242
|
-
/**
|
|
3243
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
3244
|
-
*/
|
|
3245
|
-
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
3246
|
-
/**
|
|
3247
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
3248
|
-
*/
|
|
3249
|
-
PropertySyntax["COLOR"] = "<color>";
|
|
3250
|
-
/**
|
|
3251
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
3252
|
-
*/
|
|
3253
|
-
PropertySyntax["PAINT"] = "<paint>";
|
|
3254
|
-
/**
|
|
3255
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
3256
|
-
*/
|
|
3257
|
-
PropertySyntax["NUMBER"] = "<number>";
|
|
3258
|
-
/**
|
|
3259
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
|
|
3260
|
-
*/
|
|
3261
|
-
PropertySyntax["ANGLE"] = "<angle>";
|
|
3262
|
-
/**
|
|
3263
|
-
* <number> with range 0..1
|
|
3264
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
3265
|
-
*/
|
|
3266
|
-
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
3267
|
-
/**
|
|
3268
|
-
* <number> with range 0..Infinity
|
|
3269
|
-
*/
|
|
3270
|
-
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
3271
|
-
/**
|
|
3272
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
3273
|
-
*/
|
|
3274
|
-
PropertySyntax["LENGTH"] = "<length>";
|
|
3275
|
-
/**
|
|
3276
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
3277
|
-
*/
|
|
3278
|
-
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
3279
|
-
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
3280
|
-
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
3281
|
-
/**
|
|
3282
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
3283
|
-
*/
|
|
3284
|
-
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
3285
|
-
/**
|
|
3286
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
3287
|
-
*/
|
|
3288
|
-
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
3289
|
-
PropertySyntax["PATH"] = "<path>";
|
|
3290
|
-
/**
|
|
3291
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
3292
|
-
*/
|
|
3293
|
-
PropertySyntax["FILTER"] = "<filter>";
|
|
3294
|
-
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
3295
|
-
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
3296
|
-
PropertySyntax["DEFINED_PATH"] = "<defined-path>";
|
|
3297
|
-
PropertySyntax["MARKER"] = "<marker>";
|
|
3298
|
-
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
3299
|
-
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
3300
|
-
PropertySyntax["TEXT"] = "<text>";
|
|
3301
|
-
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
3302
|
-
})(PropertySyntax || (PropertySyntax = {}));
|
|
3303
|
-
|
|
3304
3164
|
/**
|
|
3305
3165
|
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
3306
3166
|
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
@@ -4124,16 +3984,6 @@ function parseDimensionArrayFormat(string, size) {
|
|
|
4124
3984
|
}
|
|
4125
3985
|
}
|
|
4126
3986
|
}
|
|
4127
|
-
function parseDimensionArray(string) {
|
|
4128
|
-
if (isString(string)) {
|
|
4129
|
-
// "1px 2px 3px"
|
|
4130
|
-
return string.split(' ').map(function (segment) { return parseLengthOrPercentage(segment); });
|
|
4131
|
-
}
|
|
4132
|
-
else {
|
|
4133
|
-
// [1, '2px', 3]
|
|
4134
|
-
return string.map(function (segment) { return parseLengthOrPercentage(segment.toString()); });
|
|
4135
|
-
}
|
|
4136
|
-
}
|
|
4137
3987
|
// export function mergeDimensionList(
|
|
4138
3988
|
// left: CSSUnitValue[],
|
|
4139
3989
|
// right: CSSUnitValue[],
|
|
@@ -5162,6 +5012,7 @@ function mergePoints(left, right) {
|
|
|
5162
5012
|
}
|
|
5163
5013
|
|
|
5164
5014
|
var _ = null;
|
|
5015
|
+
var TRANSFORM_REGEXP = /\s*(\w+)\(([^)]*)\)/g;
|
|
5165
5016
|
function cast(pattern) {
|
|
5166
5017
|
return function (contents) {
|
|
5167
5018
|
var i = 0;
|
|
@@ -5180,48 +5031,75 @@ var transformFunctions = {
|
|
|
5180
5031
|
matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
|
|
5181
5032
|
matrix3d: ['NNNNNNNNNNNNNNNN', id],
|
|
5182
5033
|
rotate: ['A'],
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5034
|
+
rotateX: ['A'],
|
|
5035
|
+
rotateY: ['A'],
|
|
5036
|
+
rotateZ: ['A'],
|
|
5186
5037
|
rotate3d: ['NNNA'],
|
|
5187
5038
|
perspective: ['L'],
|
|
5188
5039
|
scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
|
|
5189
|
-
|
|
5040
|
+
scaleX: [
|
|
5190
5041
|
'N',
|
|
5191
5042
|
cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]),
|
|
5192
5043
|
cast([_, new CSSUnitValue(1)]),
|
|
5193
5044
|
],
|
|
5194
|
-
|
|
5045
|
+
scaleY: [
|
|
5195
5046
|
'N',
|
|
5196
5047
|
cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]),
|
|
5197
5048
|
cast([new CSSUnitValue(1), _]),
|
|
5198
5049
|
],
|
|
5199
|
-
|
|
5050
|
+
scaleZ: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
|
|
5200
5051
|
scale3d: ['NNN', id],
|
|
5201
5052
|
skew: ['Aa', null, id],
|
|
5202
|
-
|
|
5203
|
-
|
|
5053
|
+
skewX: ['A', null, cast([_, Odeg])],
|
|
5054
|
+
skewY: ['A', null, cast([Odeg, _])],
|
|
5204
5055
|
translate: ['Tt', cast([_, _, Opx]), id],
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5056
|
+
translateX: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
|
|
5057
|
+
translateY: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
|
|
5058
|
+
translateZ: ['L', cast([Opx, Opx, _])],
|
|
5208
5059
|
translate3d: ['TTL', id],
|
|
5209
5060
|
};
|
|
5061
|
+
function parseArrayTransform(transform) {
|
|
5062
|
+
var result = [];
|
|
5063
|
+
var length = transform.length;
|
|
5064
|
+
for (var i = 0; i < length; i++) {
|
|
5065
|
+
var item = transform[i];
|
|
5066
|
+
var name_1 = item[0];
|
|
5067
|
+
var args = item.slice(1);
|
|
5068
|
+
// infer default value
|
|
5069
|
+
if (name_1 === 'translate' || name_1 === 'skew') {
|
|
5070
|
+
if (args.length === 1)
|
|
5071
|
+
args.push(0);
|
|
5072
|
+
}
|
|
5073
|
+
else if (name_1 === 'scale') {
|
|
5074
|
+
if (args.length === 1)
|
|
5075
|
+
args.push(args[0]);
|
|
5076
|
+
}
|
|
5077
|
+
var functionData = transformFunctions[name_1];
|
|
5078
|
+
if (!functionData)
|
|
5079
|
+
return [];
|
|
5080
|
+
var parsedArgs = args.map(function (value) { return getOrCreateUnitValue(value); });
|
|
5081
|
+
result.push({ t: name_1, d: parsedArgs });
|
|
5082
|
+
}
|
|
5083
|
+
return result;
|
|
5084
|
+
}
|
|
5210
5085
|
/**
|
|
5211
5086
|
* none
|
|
5212
5087
|
* scale(1) scale(1, 2)
|
|
5213
5088
|
* scaleX(1)
|
|
5214
5089
|
*/
|
|
5215
|
-
function parseTransform(
|
|
5216
|
-
|
|
5217
|
-
|
|
5090
|
+
function parseTransform(transform) {
|
|
5091
|
+
if (Array.isArray(transform)) {
|
|
5092
|
+
return parseArrayTransform(transform);
|
|
5093
|
+
}
|
|
5094
|
+
transform = (transform || 'none').trim();
|
|
5095
|
+
if (transform === 'none') {
|
|
5218
5096
|
return [];
|
|
5219
5097
|
}
|
|
5220
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5221
5098
|
var result = [];
|
|
5222
5099
|
var match;
|
|
5223
5100
|
var prevLastIndex = 0;
|
|
5224
|
-
|
|
5101
|
+
TRANSFORM_REGEXP.lastIndex = 0;
|
|
5102
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5225
5103
|
if (match.index !== prevLastIndex) {
|
|
5226
5104
|
return [];
|
|
5227
5105
|
}
|
|
@@ -5268,22 +5146,25 @@ function parseTransform(string) {
|
|
|
5268
5146
|
parsedArgs.push(parsedArg);
|
|
5269
5147
|
}
|
|
5270
5148
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5271
|
-
if (
|
|
5149
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5272
5150
|
return result;
|
|
5273
5151
|
}
|
|
5274
5152
|
}
|
|
5275
5153
|
return [];
|
|
5276
5154
|
}
|
|
5277
|
-
function parseTransformUnmemoize(
|
|
5278
|
-
|
|
5279
|
-
|
|
5155
|
+
function parseTransformUnmemoize(transform) {
|
|
5156
|
+
if (Array.isArray(transform)) {
|
|
5157
|
+
return parseArrayTransform(transform);
|
|
5158
|
+
}
|
|
5159
|
+
transform = (transform || 'none').trim();
|
|
5160
|
+
if (transform === 'none') {
|
|
5280
5161
|
return [];
|
|
5281
5162
|
}
|
|
5282
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5283
5163
|
var result = [];
|
|
5284
5164
|
var match;
|
|
5285
5165
|
var prevLastIndex = 0;
|
|
5286
|
-
|
|
5166
|
+
TRANSFORM_REGEXP.lastIndex = 0;
|
|
5167
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5287
5168
|
if (match.index !== prevLastIndex) {
|
|
5288
5169
|
return [];
|
|
5289
5170
|
}
|
|
@@ -5330,7 +5211,7 @@ function parseTransformUnmemoize(string) {
|
|
|
5330
5211
|
parsedArgs.push(parsedArg);
|
|
5331
5212
|
}
|
|
5332
5213
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5333
|
-
if (
|
|
5214
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5334
5215
|
return result;
|
|
5335
5216
|
}
|
|
5336
5217
|
}
|
|
@@ -5342,7 +5223,7 @@ function convertItemToMatrix(item) {
|
|
|
5342
5223
|
var z;
|
|
5343
5224
|
var angle;
|
|
5344
5225
|
switch (item.t) {
|
|
5345
|
-
case '
|
|
5226
|
+
case 'rotateX':
|
|
5346
5227
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5347
5228
|
return [
|
|
5348
5229
|
1,
|
|
@@ -5362,7 +5243,7 @@ function convertItemToMatrix(item) {
|
|
|
5362
5243
|
0,
|
|
5363
5244
|
1,
|
|
5364
5245
|
];
|
|
5365
|
-
case '
|
|
5246
|
+
case 'rotateY':
|
|
5366
5247
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5367
5248
|
return [
|
|
5368
5249
|
Math.cos(angle),
|
|
@@ -5383,7 +5264,7 @@ function convertItemToMatrix(item) {
|
|
|
5383
5264
|
1,
|
|
5384
5265
|
];
|
|
5385
5266
|
case 'rotate':
|
|
5386
|
-
case '
|
|
5267
|
+
case 'rotateZ':
|
|
5387
5268
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5388
5269
|
return [
|
|
5389
5270
|
Math.cos(angle),
|
|
@@ -5460,11 +5341,11 @@ function convertItemToMatrix(item) {
|
|
|
5460
5341
|
0,
|
|
5461
5342
|
1,
|
|
5462
5343
|
];
|
|
5463
|
-
case '
|
|
5344
|
+
case 'scaleX':
|
|
5464
5345
|
return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5465
|
-
case '
|
|
5346
|
+
case 'scaleY':
|
|
5466
5347
|
return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5467
|
-
case '
|
|
5348
|
+
case 'scaleZ':
|
|
5468
5349
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
|
|
5469
5350
|
case 'scale3d':
|
|
5470
5351
|
return [
|
|
@@ -5506,10 +5387,10 @@ function convertItemToMatrix(item) {
|
|
|
5506
5387
|
0,
|
|
5507
5388
|
1,
|
|
5508
5389
|
];
|
|
5509
|
-
case '
|
|
5390
|
+
case 'skewX':
|
|
5510
5391
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5511
5392
|
return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5512
|
-
case '
|
|
5393
|
+
case 'skewY':
|
|
5513
5394
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5514
5395
|
return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5515
5396
|
case 'translate':
|
|
@@ -5517,13 +5398,13 @@ function convertItemToMatrix(item) {
|
|
|
5517
5398
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5518
5399
|
y = convertPercentUnit(item.d[1], 0, null) || 0;
|
|
5519
5400
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
|
|
5520
|
-
case '
|
|
5401
|
+
case 'translateX':
|
|
5521
5402
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5522
5403
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
|
|
5523
|
-
case '
|
|
5404
|
+
case 'translateY':
|
|
5524
5405
|
y = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5525
5406
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
|
|
5526
|
-
case '
|
|
5407
|
+
case 'translateZ':
|
|
5527
5408
|
z = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5528
5409
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
|
|
5529
5410
|
case 'translate3d':
|
|
@@ -5764,13 +5645,13 @@ function quat(fromQ, toQ, f) {
|
|
|
5764
5645
|
}
|
|
5765
5646
|
return quat;
|
|
5766
5647
|
}
|
|
5767
|
-
//
|
|
5648
|
+
// scaleX/Y/Z -> scale
|
|
5768
5649
|
function typeTo2D(type) {
|
|
5769
|
-
return type.replace(/[
|
|
5650
|
+
return type.replace(/[XY]/, '');
|
|
5770
5651
|
}
|
|
5771
|
-
//
|
|
5652
|
+
// scaleX/Y/Z -> scale3d
|
|
5772
5653
|
function typeTo3D(type) {
|
|
5773
|
-
return type.replace(/(
|
|
5654
|
+
return type.replace(/(X|Y|Z|3d)?$/, '3d');
|
|
5774
5655
|
}
|
|
5775
5656
|
var isMatrixOrPerspective = function (lt, rt) {
|
|
5776
5657
|
return ((lt === 'perspective' && rt === 'perspective') ||
|
|
@@ -5951,39 +5832,6 @@ var parseTransformOrigin = memoize(function (value) {
|
|
|
5951
5832
|
];
|
|
5952
5833
|
}
|
|
5953
5834
|
});
|
|
5954
|
-
var parseTransformOriginUnmemoize = function (value) {
|
|
5955
|
-
if (isString(value)) {
|
|
5956
|
-
if (value === 'text-anchor') {
|
|
5957
|
-
return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
|
|
5958
|
-
}
|
|
5959
|
-
var values = value.split(' ');
|
|
5960
|
-
if (values.length === 1) {
|
|
5961
|
-
if (values[0] === 'top' || values[0] === 'bottom') {
|
|
5962
|
-
// 'top' -> 'center top'
|
|
5963
|
-
values[1] = values[0];
|
|
5964
|
-
values[0] = 'center';
|
|
5965
|
-
}
|
|
5966
|
-
else {
|
|
5967
|
-
// '50px' -> '50px center'
|
|
5968
|
-
values[1] = 'center';
|
|
5969
|
-
}
|
|
5970
|
-
}
|
|
5971
|
-
if (values.length !== 2) {
|
|
5972
|
-
return null;
|
|
5973
|
-
}
|
|
5974
|
-
// eg. center bottom
|
|
5975
|
-
return [
|
|
5976
|
-
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
|
|
5977
|
-
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
|
|
5978
|
-
];
|
|
5979
|
-
}
|
|
5980
|
-
else {
|
|
5981
|
-
return [
|
|
5982
|
-
getOrCreateUnitValue(value[0] || 0, 'px'),
|
|
5983
|
-
getOrCreateUnitValue(value[1] || 0, 'px'),
|
|
5984
|
-
];
|
|
5985
|
-
}
|
|
5986
|
-
};
|
|
5987
5835
|
function convertKeyword2Percent(keyword) {
|
|
5988
5836
|
if (keyword === 'center') {
|
|
5989
5837
|
return '50%';
|
|
@@ -6578,23 +6426,7 @@ var BUILT_IN_PROPERTIES = [
|
|
|
6578
6426
|
];
|
|
6579
6427
|
var GEOMETRY_ATTRIBUTE_NAMES = BUILT_IN_PROPERTIES.filter(function (n) { return !!n.l; }).map(function (n) { return n.n; });
|
|
6580
6428
|
var propertyMetadataCache = {};
|
|
6581
|
-
var unresolvedProperties = new WeakMap();
|
|
6582
|
-
// const uniqueAttributeSet = new Set<string>();
|
|
6583
|
-
// const tmpVec3a = vec3.create();
|
|
6584
|
-
// const tmpVec3b = vec3.create();
|
|
6585
|
-
// const tmpVec3c = vec3.create();
|
|
6586
|
-
var isPropertyResolved = function (object, name) {
|
|
6587
|
-
var properties = unresolvedProperties.get(object);
|
|
6588
|
-
if (!properties || properties.length === 0) {
|
|
6589
|
-
return true;
|
|
6590
|
-
}
|
|
6591
|
-
return properties.includes(name);
|
|
6592
|
-
};
|
|
6593
6429
|
var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
6594
|
-
/**
|
|
6595
|
-
* need recalc later
|
|
6596
|
-
*/
|
|
6597
|
-
// dirty = false;
|
|
6598
6430
|
function DefaultStyleValueRegistry(runtime) {
|
|
6599
6431
|
var _this = this;
|
|
6600
6432
|
this.runtime = runtime;
|
|
@@ -6607,9 +6439,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6607
6439
|
propertyMetadataCache[name] = metadata;
|
|
6608
6440
|
});
|
|
6609
6441
|
};
|
|
6610
|
-
DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
|
|
6611
|
-
delete propertyMetadataCache[name];
|
|
6612
|
-
};
|
|
6613
6442
|
DefaultStyleValueRegistry.prototype.getPropertySyntax = function (syntax) {
|
|
6614
6443
|
return this.runtime.CSSPropertySyntaxFactory[syntax];
|
|
6615
6444
|
};
|
|
@@ -6623,7 +6452,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6623
6452
|
* * post process
|
|
6624
6453
|
*/
|
|
6625
6454
|
DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
|
|
6626
|
-
var _this = this;
|
|
6627
6455
|
if (options === void 0) { options = {
|
|
6628
6456
|
skipUpdateAttribute: false,
|
|
6629
6457
|
skipParse: false,
|
|
@@ -6631,366 +6459,117 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6631
6459
|
usedAttributes: [],
|
|
6632
6460
|
memoize: true,
|
|
6633
6461
|
}; }
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
if (attributes.filter) {
|
|
6660
|
-
object.parsedStyle.filter = parseFilter(attributes.filter);
|
|
6661
|
-
}
|
|
6662
|
-
// Rect
|
|
6663
|
-
// @ts-ignore
|
|
6664
|
-
if (!isNil(attributes.radius)) {
|
|
6665
|
-
// @ts-ignore
|
|
6666
|
-
object.parsedStyle.radius = parseDimensionArrayFormat(
|
|
6667
|
-
// @ts-ignore
|
|
6668
|
-
attributes.radius, 4);
|
|
6669
|
-
}
|
|
6670
|
-
// Polyline
|
|
6671
|
-
if (!isNil(attributes.lineDash)) {
|
|
6672
|
-
object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
|
|
6673
|
-
}
|
|
6674
|
-
// @ts-ignore
|
|
6675
|
-
if (attributes.points) {
|
|
6676
|
-
// @ts-ignore
|
|
6677
|
-
object.parsedStyle.points = parsePoints(attributes.points);
|
|
6678
|
-
}
|
|
6679
|
-
// Path
|
|
6680
|
-
// @ts-ignore
|
|
6681
|
-
if (attributes.d === '') {
|
|
6682
|
-
object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
|
|
6683
|
-
}
|
|
6462
|
+
Object.assign(object.attributes, attributes);
|
|
6463
|
+
// clipPath
|
|
6464
|
+
var oldClipPath = object.parsedStyle.clipPath;
|
|
6465
|
+
var oldOffsetPath = object.parsedStyle.offsetPath;
|
|
6466
|
+
Object.assign(object.parsedStyle, attributes);
|
|
6467
|
+
var needUpdateGeometry = !!options.forceUpdateGeometry;
|
|
6468
|
+
if (!needUpdateGeometry &&
|
|
6469
|
+
GEOMETRY_ATTRIBUTE_NAMES.some(function (name) { return name in attributes; })) {
|
|
6470
|
+
needUpdateGeometry = true;
|
|
6471
|
+
}
|
|
6472
|
+
if (attributes.fill) {
|
|
6473
|
+
object.parsedStyle.fill = parseColor(attributes.fill);
|
|
6474
|
+
}
|
|
6475
|
+
if (attributes.stroke) {
|
|
6476
|
+
object.parsedStyle.stroke = parseColor(attributes.stroke);
|
|
6477
|
+
}
|
|
6478
|
+
if (attributes.shadowColor) {
|
|
6479
|
+
object.parsedStyle.shadowColor = parseColor(attributes.shadowColor);
|
|
6480
|
+
}
|
|
6481
|
+
if (attributes.filter) {
|
|
6482
|
+
object.parsedStyle.filter = parseFilter(attributes.filter);
|
|
6483
|
+
}
|
|
6484
|
+
// Rect
|
|
6485
|
+
// @ts-ignore
|
|
6486
|
+
if (!isNil(attributes.radius)) {
|
|
6684
6487
|
// @ts-ignore
|
|
6685
|
-
|
|
6686
|
-
object.parsedStyle.d = parsePath(
|
|
6687
|
-
// @ts-ignore
|
|
6688
|
-
attributes.d);
|
|
6689
|
-
}
|
|
6690
|
-
// Text
|
|
6691
|
-
if (attributes.textTransform) {
|
|
6692
|
-
this.runtime.CSSPropertySyntaxFactory['<text-transform>'].calculator(null, null, { value: attributes.textTransform }, object, null);
|
|
6693
|
-
}
|
|
6694
|
-
if (!isUndefined(attributes.clipPath)) {
|
|
6695
|
-
this.runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
|
|
6696
|
-
}
|
|
6697
|
-
if (attributes.offsetPath) {
|
|
6698
|
-
this.runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
|
|
6699
|
-
}
|
|
6700
|
-
if (attributes.transform) {
|
|
6701
|
-
object.parsedStyle.transform = parseTransform(attributes.transform);
|
|
6702
|
-
}
|
|
6703
|
-
if (attributes.transformOrigin) {
|
|
6704
|
-
object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
|
|
6705
|
-
}
|
|
6706
|
-
// Marker
|
|
6488
|
+
object.parsedStyle.radius = parseDimensionArrayFormat(
|
|
6707
6489
|
// @ts-ignore
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6490
|
+
attributes.radius, 4);
|
|
6491
|
+
}
|
|
6492
|
+
// Polyline
|
|
6493
|
+
if (!isNil(attributes.lineDash)) {
|
|
6494
|
+
object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
|
|
6495
|
+
}
|
|
6496
|
+
// @ts-ignore
|
|
6497
|
+
if (attributes.points) {
|
|
6715
6498
|
// @ts-ignore
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6499
|
+
object.parsedStyle.points = parsePoints(attributes.points);
|
|
6500
|
+
}
|
|
6501
|
+
// Path
|
|
6502
|
+
// @ts-ignore
|
|
6503
|
+
if (attributes.d === '') {
|
|
6504
|
+
object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
|
|
6505
|
+
}
|
|
6506
|
+
// @ts-ignore
|
|
6507
|
+
if (attributes.d) {
|
|
6508
|
+
object.parsedStyle.d = parsePath(
|
|
6723
6509
|
// @ts-ignore
|
|
6724
|
-
|
|
6725
|
-
object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory['<marker>'].calculator('',
|
|
6726
|
-
// @ts-ignore
|
|
6727
|
-
attributes.markerMid,
|
|
6728
|
-
// @ts-ignore
|
|
6729
|
-
attributes.markerMid, null, null);
|
|
6730
|
-
}
|
|
6731
|
-
if (!isNil(attributes.zIndex)) {
|
|
6732
|
-
this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames);
|
|
6733
|
-
}
|
|
6734
|
-
if (!isNil(attributes.offsetDistance)) {
|
|
6735
|
-
this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, attributeNames);
|
|
6736
|
-
}
|
|
6737
|
-
if (attributes.transform) {
|
|
6738
|
-
this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames);
|
|
6739
|
-
}
|
|
6740
|
-
if (attributes.transformOrigin) {
|
|
6741
|
-
this.runtime.CSSPropertySyntaxFactory['<transform-origin>'].postProcessor(object, attributeNames);
|
|
6742
|
-
}
|
|
6743
|
-
if (needUpdateGeometry) {
|
|
6744
|
-
object.geometry.dirty = true;
|
|
6745
|
-
object.renderable.boundsDirty = true;
|
|
6746
|
-
object.renderable.renderBoundsDirty = true;
|
|
6747
|
-
if (!options.forceUpdateGeometry) {
|
|
6748
|
-
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6749
|
-
}
|
|
6750
|
-
}
|
|
6510
|
+
attributes.d);
|
|
6751
6511
|
}
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
var attributeNames_1 = Object.keys(attributes);
|
|
6756
|
-
attributeNames_1.forEach(function (attributeName) {
|
|
6757
|
-
var _a;
|
|
6758
|
-
if (!skipUpdateAttribute_1) {
|
|
6759
|
-
object.attributes[attributeName] = attributes[attributeName];
|
|
6760
|
-
}
|
|
6761
|
-
if (!needUpdateGeometry_1 && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
|
|
6762
|
-
needUpdateGeometry_1 = true;
|
|
6763
|
-
}
|
|
6764
|
-
});
|
|
6765
|
-
if (!skipParse) {
|
|
6766
|
-
attributeNames_1.forEach(function (name) {
|
|
6767
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize_1);
|
|
6768
|
-
});
|
|
6769
|
-
}
|
|
6770
|
-
// let hasUnresolvedProperties = false;
|
|
6771
|
-
// parse according to priority
|
|
6772
|
-
// path 50
|
|
6773
|
-
// points 50
|
|
6774
|
-
// text 50
|
|
6775
|
-
// textTransform 51
|
|
6776
|
-
// transform 100
|
|
6777
|
-
// transformOrigin 100
|
|
6778
|
-
if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
|
|
6779
|
-
// uniqueAttributeSet.clear();
|
|
6780
|
-
attributeNames_1 = Array.from(new Set(attributeNames_1.concat(usedAttributes)));
|
|
6781
|
-
}
|
|
6782
|
-
// [
|
|
6783
|
-
// 'path',
|
|
6784
|
-
// 'points',
|
|
6785
|
-
// 'text',
|
|
6786
|
-
// 'textTransform',
|
|
6787
|
-
// 'transform',
|
|
6788
|
-
// 'transformOrigin',
|
|
6789
|
-
// ].forEach((name) => {
|
|
6790
|
-
// const index = attributeNames.indexOf(name);
|
|
6791
|
-
// if (index > -1) {
|
|
6792
|
-
// attributeNames.splice(index, 1);
|
|
6793
|
-
// attributeNames.push(name);
|
|
6794
|
-
// }
|
|
6795
|
-
// });
|
|
6796
|
-
attributeNames_1.forEach(function (name) {
|
|
6797
|
-
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
6798
|
-
if (name in object.computedStyle) {
|
|
6799
|
-
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize_1);
|
|
6800
|
-
}
|
|
6801
|
-
});
|
|
6802
|
-
// if (hasUnresolvedProperties) {
|
|
6803
|
-
// this.dirty = true;
|
|
6804
|
-
// return;
|
|
6805
|
-
// }
|
|
6806
|
-
// update geometry
|
|
6807
|
-
if (needUpdateGeometry_1) {
|
|
6808
|
-
object.geometry.dirty = true;
|
|
6809
|
-
object.renderable.boundsDirty = true;
|
|
6810
|
-
object.renderable.renderBoundsDirty = true;
|
|
6811
|
-
if (!options.forceUpdateGeometry) {
|
|
6812
|
-
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6813
|
-
}
|
|
6814
|
-
}
|
|
6815
|
-
attributeNames_1.forEach(function (name) {
|
|
6816
|
-
if (name in object.parsedStyle) {
|
|
6817
|
-
_this.postProcessProperty(name, object, attributeNames_1);
|
|
6818
|
-
}
|
|
6819
|
-
});
|
|
6820
|
-
if (this.runtime.enableCSSParsing && object.children.length) {
|
|
6821
|
-
attributeNames_1.forEach(function (name) {
|
|
6822
|
-
if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
|
|
6823
|
-
// update children's inheritable
|
|
6824
|
-
object.children.forEach(function (child) {
|
|
6825
|
-
child.internalSetAttribute(name, null, {
|
|
6826
|
-
skipUpdateAttribute: true,
|
|
6827
|
-
skipParse: true,
|
|
6828
|
-
});
|
|
6829
|
-
});
|
|
6830
|
-
}
|
|
6831
|
-
});
|
|
6832
|
-
}
|
|
6512
|
+
// Text
|
|
6513
|
+
if (attributes.textTransform) {
|
|
6514
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TEXT_TRANSFORM].calculator(null, null, { value: attributes.textTransform }, object, null);
|
|
6833
6515
|
}
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6516
|
+
if (!isUndefined(attributes.clipPath)) {
|
|
6517
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
|
|
6518
|
+
}
|
|
6519
|
+
if (attributes.offsetPath) {
|
|
6520
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.DEFINED_PATH].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
|
|
6521
|
+
}
|
|
6522
|
+
if (attributes.transform) {
|
|
6523
|
+
object.parsedStyle.transform = parseTransform(attributes.transform);
|
|
6524
|
+
}
|
|
6525
|
+
if (attributes.transformOrigin) {
|
|
6526
|
+
object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
|
|
6527
|
+
}
|
|
6528
|
+
// Marker
|
|
6529
|
+
// @ts-ignore
|
|
6530
|
+
if (attributes.markerStart) {
|
|
6531
|
+
object.parsedStyle.markerStart = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
|
|
6532
|
+
// @ts-ignore
|
|
6533
|
+
attributes.markerStart,
|
|
6534
|
+
// @ts-ignore
|
|
6535
|
+
attributes.markerStart, null, null);
|
|
6843
6536
|
}
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6537
|
+
// @ts-ignore
|
|
6538
|
+
if (attributes.markerEnd) {
|
|
6539
|
+
object.parsedStyle.markerEnd = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator(null,
|
|
6540
|
+
// @ts-ignore
|
|
6541
|
+
attributes.markerEnd,
|
|
6542
|
+
// @ts-ignore
|
|
6543
|
+
attributes.markerEnd, null, null);
|
|
6847
6544
|
}
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
computed = getOrCreateKeyword(value);
|
|
6856
|
-
}
|
|
6857
|
-
else if (handler) {
|
|
6858
|
-
if (!memoized && handler.parserUnmemoize) {
|
|
6859
|
-
computed = handler.parserUnmemoize(value, object);
|
|
6860
|
-
}
|
|
6861
|
-
else if (handler.parser) {
|
|
6862
|
-
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
|
|
6863
|
-
computed = handler.parser(value, object);
|
|
6864
|
-
}
|
|
6865
|
-
}
|
|
6866
|
-
}
|
|
6545
|
+
// @ts-ignore
|
|
6546
|
+
if (attributes.markerMid) {
|
|
6547
|
+
object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory[PropertySyntax.MARKER].calculator('',
|
|
6548
|
+
// @ts-ignore
|
|
6549
|
+
attributes.markerMid,
|
|
6550
|
+
// @ts-ignore
|
|
6551
|
+
attributes.markerMid, null, null);
|
|
6867
6552
|
}
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
/**
|
|
6871
|
-
* computed value -> used value
|
|
6872
|
-
*/
|
|
6873
|
-
DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object, memoized) {
|
|
6874
|
-
var metadata = propertyMetadataCache[name];
|
|
6875
|
-
var isDocumentElement = object.id === 'g-root';
|
|
6876
|
-
// let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
|
|
6877
|
-
var used = computed;
|
|
6878
|
-
if (metadata) {
|
|
6879
|
-
var syntax = metadata.syntax, inherited = metadata.inh, defaultValue = metadata.d;
|
|
6880
|
-
if (computed instanceof CSSKeywordValue) {
|
|
6881
|
-
var value = computed.value;
|
|
6882
|
-
/**
|
|
6883
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
|
|
6884
|
-
*/
|
|
6885
|
-
if (value === 'unset') {
|
|
6886
|
-
if (inherited && !isDocumentElement) {
|
|
6887
|
-
value = 'inherit';
|
|
6888
|
-
}
|
|
6889
|
-
else {
|
|
6890
|
-
value = 'initial';
|
|
6891
|
-
}
|
|
6892
|
-
}
|
|
6893
|
-
if (value === 'initial') {
|
|
6894
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
6895
|
-
if (!isNil(defaultValue)) {
|
|
6896
|
-
computed = this.parseProperty(name, isFunction(defaultValue)
|
|
6897
|
-
? defaultValue(object.nodeName)
|
|
6898
|
-
: defaultValue, object, memoized);
|
|
6899
|
-
}
|
|
6900
|
-
}
|
|
6901
|
-
else if (value === 'inherit') {
|
|
6902
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
6903
|
-
// behave like `inherit`
|
|
6904
|
-
var resolved = this.tryToResolveProperty(object, name, {
|
|
6905
|
-
inherited: true,
|
|
6906
|
-
});
|
|
6907
|
-
if (!isNil(resolved)) {
|
|
6908
|
-
// object.parsedStyle[name] = resolved;
|
|
6909
|
-
// return false;
|
|
6910
|
-
return resolved;
|
|
6911
|
-
}
|
|
6912
|
-
else {
|
|
6913
|
-
this.addUnresolveProperty(object, name);
|
|
6914
|
-
return;
|
|
6915
|
-
}
|
|
6916
|
-
}
|
|
6917
|
-
}
|
|
6918
|
-
var handler = syntax && this.getPropertySyntax(syntax);
|
|
6919
|
-
if (handler && handler.calculator) {
|
|
6920
|
-
// convert computed value to used value
|
|
6921
|
-
var oldParsedValue = object.parsedStyle[name];
|
|
6922
|
-
used = handler.calculator(name, oldParsedValue, computed, object, this.runtime);
|
|
6923
|
-
}
|
|
6924
|
-
else if (computed instanceof CSSKeywordValue) {
|
|
6925
|
-
used = computed.value;
|
|
6926
|
-
}
|
|
6927
|
-
else {
|
|
6928
|
-
used = computed;
|
|
6929
|
-
}
|
|
6553
|
+
if (!isNil(attributes.zIndex)) {
|
|
6554
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.Z_INDEX].postProcessor(object);
|
|
6930
6555
|
}
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
return used;
|
|
6934
|
-
};
|
|
6935
|
-
DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object, attributes) {
|
|
6936
|
-
var metadata = propertyMetadataCache[name];
|
|
6937
|
-
if (metadata && metadata.syntax) {
|
|
6938
|
-
var handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
|
|
6939
|
-
var propertyHandler = handler;
|
|
6940
|
-
if (propertyHandler && propertyHandler.postProcessor) {
|
|
6941
|
-
propertyHandler.postProcessor(object, attributes);
|
|
6942
|
-
}
|
|
6556
|
+
if (!isNil(attributes.offsetDistance)) {
|
|
6557
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.OFFSET_DISTANCE].postProcessor(object);
|
|
6943
6558
|
}
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
* resolve later
|
|
6947
|
-
*/
|
|
6948
|
-
DefaultStyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
|
|
6949
|
-
var properties = unresolvedProperties.get(object);
|
|
6950
|
-
if (!properties) {
|
|
6951
|
-
unresolvedProperties.set(object, []);
|
|
6952
|
-
properties = unresolvedProperties.get(object);
|
|
6559
|
+
if (attributes.transform) {
|
|
6560
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM].postProcessor(object);
|
|
6953
6561
|
}
|
|
6954
|
-
if (
|
|
6955
|
-
|
|
6562
|
+
if (attributes.transformOrigin) {
|
|
6563
|
+
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
|
|
6956
6564
|
}
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
isPropertyResolved(object.parentElement, name)) {
|
|
6964
|
-
// const computedValue = object.parentElement.computedStyle[name];
|
|
6965
|
-
var usedValue = object.parentElement.parsedStyle[name];
|
|
6966
|
-
if (
|
|
6967
|
-
// usedValue instanceof CSSKeywordValue &&
|
|
6968
|
-
usedValue === 'unset' ||
|
|
6969
|
-
usedValue === 'initial' ||
|
|
6970
|
-
usedValue === 'inherit') {
|
|
6971
|
-
return;
|
|
6972
|
-
}
|
|
6973
|
-
// else if (
|
|
6974
|
-
// usedValue instanceof CSSUnitValue &&
|
|
6975
|
-
// CSSUnitValue.isRelativeUnit(usedValue.unit)
|
|
6976
|
-
// ) {
|
|
6977
|
-
// return false;
|
|
6978
|
-
// }
|
|
6979
|
-
return usedValue;
|
|
6565
|
+
if (needUpdateGeometry) {
|
|
6566
|
+
object.geometry.dirty = true;
|
|
6567
|
+
object.renderable.boundsDirty = true;
|
|
6568
|
+
object.renderable.renderBoundsDirty = true;
|
|
6569
|
+
if (!options.forceUpdateGeometry) {
|
|
6570
|
+
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6980
6571
|
}
|
|
6981
6572
|
}
|
|
6982
|
-
return;
|
|
6983
|
-
};
|
|
6984
|
-
DefaultStyleValueRegistry.prototype.recalc = function (object) {
|
|
6985
|
-
var properties = unresolvedProperties.get(object);
|
|
6986
|
-
if (properties && properties.length) {
|
|
6987
|
-
var attributes_1 = {};
|
|
6988
|
-
properties.forEach(function (property) {
|
|
6989
|
-
attributes_1[property] = object.attributes[property];
|
|
6990
|
-
});
|
|
6991
|
-
this.processProperties(object, attributes_1);
|
|
6992
|
-
unresolvedProperties.delete(object);
|
|
6993
|
-
}
|
|
6994
6573
|
};
|
|
6995
6574
|
/**
|
|
6996
6575
|
* update geometry when relative props changed,
|
|
@@ -7015,12 +6594,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7015
6594
|
Math.abs(hheight),
|
|
7016
6595
|
hdepth,
|
|
7017
6596
|
];
|
|
7018
|
-
// const halfExtents = vec3.set(
|
|
7019
|
-
// tmpVec3a,
|
|
7020
|
-
// Math.abs(width) / 2,
|
|
7021
|
-
// Math.abs(height) / 2,
|
|
7022
|
-
// depth / 2,
|
|
7023
|
-
// );
|
|
7024
6597
|
// anchor is center by default, don't account for lineWidth here
|
|
7025
6598
|
var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
|
|
7026
6599
|
// lineCap,
|
|
@@ -7040,26 +6613,13 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7040
6613
|
nodeName === Shape.PATH
|
|
7041
6614
|
? Math.SQRT2
|
|
7042
6615
|
: 0.5;
|
|
7043
|
-
// if (lineCap?.value === 'square') {
|
|
7044
|
-
// expansion = Math.SQRT1_2;
|
|
7045
|
-
// }
|
|
7046
|
-
// if (lineJoin?.value === 'miter' && expansion < Math.SQRT2 * miterLimit) {
|
|
7047
|
-
// expansion = Math.SQRT1_2 * miterLimit;
|
|
7048
|
-
// }
|
|
7049
6616
|
// append border only if stroke existed
|
|
7050
6617
|
var hasStroke = stroke && !stroke.isNone;
|
|
7051
6618
|
if (hasStroke) {
|
|
7052
6619
|
var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) *
|
|
7053
6620
|
expansion;
|
|
7054
|
-
// halfExtents[0] += halfLineWidth[0];
|
|
7055
|
-
// halfExtents[1] += halfLineWidth[1];
|
|
7056
6621
|
halfExtents[0] += halfLineWidth;
|
|
7057
6622
|
halfExtents[1] += halfLineWidth;
|
|
7058
|
-
// vec3.add(
|
|
7059
|
-
// halfExtents,
|
|
7060
|
-
// halfExtents,
|
|
7061
|
-
// vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
|
|
7062
|
-
// );
|
|
7063
6623
|
}
|
|
7064
6624
|
geometry_1.renderBounds.update(center, halfExtents);
|
|
7065
6625
|
// account for shadow, only support constant value now
|
|
@@ -7084,7 +6644,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7084
6644
|
var name = _a.name, params = _a.params;
|
|
7085
6645
|
if (name === 'blur') {
|
|
7086
6646
|
var blurRadius = params[0].value;
|
|
7087
|
-
geometry_1.renderBounds.update(geometry_1.renderBounds.center,
|
|
6647
|
+
geometry_1.renderBounds.update(geometry_1.renderBounds.center, vec3.add(geometry_1.renderBounds.halfExtents, geometry_1.renderBounds.halfExtents, [blurRadius, blurRadius, 0]));
|
|
7088
6648
|
}
|
|
7089
6649
|
else if (name === 'drop-shadow') {
|
|
7090
6650
|
var shadowOffsetX = params[0].value;
|
|
@@ -7146,21 +6706,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7146
6706
|
}
|
|
7147
6707
|
}
|
|
7148
6708
|
};
|
|
7149
|
-
DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
|
|
7150
|
-
var metadata = propertyMetadataCache[name];
|
|
7151
|
-
if (!metadata) {
|
|
7152
|
-
return false;
|
|
7153
|
-
}
|
|
7154
|
-
return metadata.inh;
|
|
7155
|
-
};
|
|
7156
6709
|
return DefaultStyleValueRegistry;
|
|
7157
6710
|
}());
|
|
7158
6711
|
|
|
7159
6712
|
var CSSPropertyAngle = /** @class */ (function () {
|
|
7160
6713
|
function CSSPropertyAngle() {
|
|
7161
|
-
this.parser = parseAngle;
|
|
7162
|
-
this.parserUnmemoize = parseAngleUnmemoize;
|
|
7163
|
-
this.parserWithCSSDisabled = null;
|
|
7164
6714
|
this.mixer = mergeNumbers;
|
|
7165
6715
|
}
|
|
7166
6716
|
CSSPropertyAngle.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -7197,7 +6747,6 @@ var CSSPropertyClipPath = /** @class */ (function () {
|
|
|
7197
6747
|
var CSSPropertyColor = /** @class */ (function () {
|
|
7198
6748
|
function CSSPropertyColor() {
|
|
7199
6749
|
this.parser = parseColor;
|
|
7200
|
-
this.parserWithCSSDisabled = parseColor;
|
|
7201
6750
|
this.mixer = mergeColors;
|
|
7202
6751
|
}
|
|
7203
6752
|
CSSPropertyColor.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -7212,7 +6761,6 @@ var CSSPropertyColor = /** @class */ (function () {
|
|
|
7212
6761
|
|
|
7213
6762
|
var CSSPropertyFilter = /** @class */ (function () {
|
|
7214
6763
|
function CSSPropertyFilter() {
|
|
7215
|
-
this.parser = parseFilter;
|
|
7216
6764
|
}
|
|
7217
6765
|
CSSPropertyFilter.prototype.calculator = function (name, oldParsed, parsed) {
|
|
7218
6766
|
// unset or none
|
|
@@ -7233,9 +6781,6 @@ function getFontSize(object) {
|
|
|
7233
6781
|
*/
|
|
7234
6782
|
var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
7235
6783
|
function CSSPropertyLengthOrPercentage() {
|
|
7236
|
-
this.parser = parseLengthOrPercentage;
|
|
7237
|
-
this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
|
|
7238
|
-
this.parserWithCSSDisabled = null;
|
|
7239
6784
|
this.mixer = mergeNumbers;
|
|
7240
6785
|
}
|
|
7241
6786
|
/**
|
|
@@ -7250,7 +6795,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7250
6795
|
return computed;
|
|
7251
6796
|
}
|
|
7252
6797
|
if (CSSUnitValue.isRelativeUnit(computed.unit)) {
|
|
7253
|
-
var registry = runtime.styleValueRegistry;
|
|
7254
6798
|
if (computed.unit === UnitType.kPercentage) {
|
|
7255
6799
|
// TODO: merge dimensions
|
|
7256
6800
|
return 0;
|
|
@@ -7262,12 +6806,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7262
6806
|
fontSize *= computed.value;
|
|
7263
6807
|
return fontSize;
|
|
7264
6808
|
}
|
|
7265
|
-
else {
|
|
7266
|
-
registry.addUnresolveProperty(object, name);
|
|
7267
|
-
}
|
|
7268
|
-
}
|
|
7269
|
-
else {
|
|
7270
|
-
registry.addUnresolveProperty(object, name);
|
|
7271
6809
|
}
|
|
7272
6810
|
return 0;
|
|
7273
6811
|
}
|
|
@@ -7278,12 +6816,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7278
6816
|
fontSize *= computed.value;
|
|
7279
6817
|
return fontSize;
|
|
7280
6818
|
}
|
|
7281
|
-
else {
|
|
7282
|
-
registry.addUnresolveProperty(object, name);
|
|
7283
|
-
}
|
|
7284
|
-
}
|
|
7285
|
-
else {
|
|
7286
|
-
registry.addUnresolveProperty(object, name);
|
|
7287
6819
|
}
|
|
7288
6820
|
return 0;
|
|
7289
6821
|
}
|
|
@@ -7310,17 +6842,6 @@ var CSSPropertyLengthOrPercentage12 = /** @class */ (function () {
|
|
|
7310
6842
|
function CSSPropertyLengthOrPercentage12() {
|
|
7311
6843
|
this.mixer = mergeNumberLists;
|
|
7312
6844
|
}
|
|
7313
|
-
CSSPropertyLengthOrPercentage12.prototype.parser = function (radius) {
|
|
7314
|
-
var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
|
|
7315
|
-
var formatted;
|
|
7316
|
-
if (parsed.length === 1) {
|
|
7317
|
-
formatted = [parsed[0], parsed[0]];
|
|
7318
|
-
}
|
|
7319
|
-
else {
|
|
7320
|
-
formatted = [parsed[0], parsed[1]];
|
|
7321
|
-
}
|
|
7322
|
-
return formatted;
|
|
7323
|
-
};
|
|
7324
6845
|
CSSPropertyLengthOrPercentage12.prototype.calculator = function (name, oldParsed, computed) {
|
|
7325
6846
|
return computed.map(function (c) { return c.value; });
|
|
7326
6847
|
};
|
|
@@ -7339,24 +6860,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
|
|
|
7339
6860
|
function CSSPropertyLengthOrPercentage14() {
|
|
7340
6861
|
this.mixer = mergeNumberLists;
|
|
7341
6862
|
}
|
|
7342
|
-
CSSPropertyLengthOrPercentage14.prototype.parser = function (radius) {
|
|
7343
|
-
var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
|
|
7344
|
-
var formatted;
|
|
7345
|
-
// format to Tuple<CSSUnitValue>
|
|
7346
|
-
if (parsed.length === 1) {
|
|
7347
|
-
formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
|
|
7348
|
-
}
|
|
7349
|
-
else if (parsed.length === 2) {
|
|
7350
|
-
formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
|
|
7351
|
-
}
|
|
7352
|
-
else if (parsed.length === 3) {
|
|
7353
|
-
formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
|
|
7354
|
-
}
|
|
7355
|
-
else {
|
|
7356
|
-
formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
7357
|
-
}
|
|
7358
|
-
return formatted;
|
|
7359
|
-
};
|
|
7360
6863
|
CSSPropertyLengthOrPercentage14.prototype.calculator = function (name, oldParsed, computed) {
|
|
7361
6864
|
return computed.map(function (c) { return c.value; });
|
|
7362
6865
|
};
|
|
@@ -7384,9 +6887,6 @@ var CSSPropertyMarker = /** @class */ (function () {
|
|
|
7384
6887
|
var CSSPropertyNumber = /** @class */ (function () {
|
|
7385
6888
|
function CSSPropertyNumber() {
|
|
7386
6889
|
this.mixer = mergeNumbers;
|
|
7387
|
-
this.parser = parseNumber;
|
|
7388
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7389
|
-
this.parserWithCSSDisabled = null;
|
|
7390
6890
|
}
|
|
7391
6891
|
CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
|
|
7392
6892
|
return computed.value;
|
|
@@ -7396,9 +6896,6 @@ var CSSPropertyNumber = /** @class */ (function () {
|
|
|
7396
6896
|
|
|
7397
6897
|
var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
7398
6898
|
function CSSPropertyOffsetDistance() {
|
|
7399
|
-
this.parser = parseNumber;
|
|
7400
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7401
|
-
this.parserWithCSSDisabled = null;
|
|
7402
6899
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7403
6900
|
}
|
|
7404
6901
|
CSSPropertyOffsetDistance.prototype.calculator = function (name, oldParsed, computed) {
|
|
@@ -7428,9 +6925,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
|
7428
6925
|
*/
|
|
7429
6926
|
var CSSPropertyOpacity = /** @class */ (function () {
|
|
7430
6927
|
function CSSPropertyOpacity() {
|
|
7431
|
-
this.parser = parseNumber;
|
|
7432
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7433
|
-
this.parserWithCSSDisabled = null;
|
|
7434
6928
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7435
6929
|
}
|
|
7436
6930
|
CSSPropertyOpacity.prototype.calculator = function (name, oldParsed, computed) {
|
|
@@ -7445,7 +6939,6 @@ var CSSPropertyPath = /** @class */ (function () {
|
|
|
7445
6939
|
* path2Curve
|
|
7446
6940
|
*/
|
|
7447
6941
|
this.parser = parsePath;
|
|
7448
|
-
this.parserWithCSSDisabled = parsePath;
|
|
7449
6942
|
this.mixer = mergePaths;
|
|
7450
6943
|
}
|
|
7451
6944
|
CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
|
|
@@ -7469,7 +6962,6 @@ var CSSPropertyPath = /** @class */ (function () {
|
|
|
7469
6962
|
|
|
7470
6963
|
var CSSPropertyPoints = /** @class */ (function () {
|
|
7471
6964
|
function CSSPropertyPoints() {
|
|
7472
|
-
this.parser = parsePoints;
|
|
7473
6965
|
this.mixer = mergePoints;
|
|
7474
6966
|
}
|
|
7475
6967
|
return CSSPropertyPoints;
|
|
@@ -7533,20 +7025,26 @@ var CSSPropertyTextTransform = /** @class */ (function () {
|
|
|
7533
7025
|
return CSSPropertyTextTransform;
|
|
7534
7026
|
}());
|
|
7535
7027
|
|
|
7536
|
-
var
|
|
7537
|
-
|
|
7028
|
+
var definedProps = function (obj) {
|
|
7029
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
7030
|
+
var _b = __read(_a, 2), v = _b[1];
|
|
7031
|
+
return v !== undefined;
|
|
7032
|
+
}));
|
|
7033
|
+
};
|
|
7034
|
+
|
|
7035
|
+
var CANVAS_Map = new WeakMap();
|
|
7538
7036
|
/**
|
|
7539
7037
|
* destroy existed canvas with the same id
|
|
7540
7038
|
*/
|
|
7541
|
-
function cleanExistedCanvas(container, canvas) {
|
|
7039
|
+
function cleanExistedCanvas(container, canvas, cleanUp) {
|
|
7542
7040
|
if (container) {
|
|
7543
|
-
var
|
|
7544
|
-
? container
|
|
7545
|
-
: container
|
|
7546
|
-
if (
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7041
|
+
var $dom = typeof container === 'string'
|
|
7042
|
+
? document.getElementById(container)
|
|
7043
|
+
: container;
|
|
7044
|
+
if (CANVAS_Map.has($dom))
|
|
7045
|
+
CANVAS_Map.get($dom).destroy(cleanUp);
|
|
7046
|
+
else
|
|
7047
|
+
CANVAS_Map.set($dom, canvas);
|
|
7550
7048
|
}
|
|
7551
7049
|
}
|
|
7552
7050
|
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
@@ -7631,6 +7129,12 @@ var TOUCH_TO_POINTER = {
|
|
|
7631
7129
|
};
|
|
7632
7130
|
var clock = typeof performance === 'object' && performance.now ? performance : Date;
|
|
7633
7131
|
|
|
7132
|
+
function isInFragment(node) {
|
|
7133
|
+
if (node.nodeName === Shape.FRAGMENT)
|
|
7134
|
+
return true;
|
|
7135
|
+
return node.getRootNode().nodeName === Shape.FRAGMENT;
|
|
7136
|
+
}
|
|
7137
|
+
|
|
7634
7138
|
function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
|
|
7635
7139
|
// account for pointerEvents
|
|
7636
7140
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
@@ -7889,114 +7393,100 @@ function createSkewMatrix(skewMatrix, skewX, skewY) {
|
|
|
7889
7393
|
skewMatrix[1] = Math.tan(skewY); // Skew X axis in Y direction
|
|
7890
7394
|
return skewMatrix;
|
|
7891
7395
|
}
|
|
7892
|
-
var
|
|
7893
|
-
var
|
|
7894
|
-
var
|
|
7396
|
+
var $mat4_1 = mat4.create();
|
|
7397
|
+
var $mat4_2 = mat4.create();
|
|
7398
|
+
var parser = {
|
|
7399
|
+
scale: function (d) {
|
|
7400
|
+
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, 1]);
|
|
7401
|
+
},
|
|
7402
|
+
scaleX: function (d) {
|
|
7403
|
+
mat4.fromScaling($mat4_1, [d[0].value, 1, 1]);
|
|
7404
|
+
},
|
|
7405
|
+
scaleY: function (d) {
|
|
7406
|
+
mat4.fromScaling($mat4_1, [1, d[0].value, 1]);
|
|
7407
|
+
},
|
|
7408
|
+
scaleZ: function (d) {
|
|
7409
|
+
mat4.fromScaling($mat4_1, [1, 1, d[0].value]);
|
|
7410
|
+
},
|
|
7411
|
+
scale3d: function (d) {
|
|
7412
|
+
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, d[2].value]);
|
|
7413
|
+
},
|
|
7414
|
+
translate: function (d) {
|
|
7415
|
+
mat4.fromTranslation($mat4_1, [d[0].value, d[1].value, 0]);
|
|
7416
|
+
},
|
|
7417
|
+
translateX: function (d) {
|
|
7418
|
+
mat4.fromTranslation($mat4_1, [d[0].value, 0, 0]);
|
|
7419
|
+
},
|
|
7420
|
+
translateY: function (d) {
|
|
7421
|
+
mat4.fromTranslation($mat4_1, [0, d[0].value, 0]);
|
|
7422
|
+
},
|
|
7423
|
+
translateZ: function (d) {
|
|
7424
|
+
mat4.fromTranslation($mat4_1, [0, 0, d[0].value]);
|
|
7425
|
+
},
|
|
7426
|
+
translate3d: function (d) {
|
|
7427
|
+
mat4.fromTranslation($mat4_1, [d[0].value, d[1].value, d[2].value]);
|
|
7428
|
+
},
|
|
7429
|
+
rotate: function (d) {
|
|
7430
|
+
mat4.fromZRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7431
|
+
},
|
|
7432
|
+
rotateX: function (d) {
|
|
7433
|
+
mat4.fromXRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7434
|
+
},
|
|
7435
|
+
rotateY: function (d) {
|
|
7436
|
+
mat4.fromYRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7437
|
+
},
|
|
7438
|
+
rotateZ: function (d) {
|
|
7439
|
+
mat4.fromZRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7440
|
+
},
|
|
7441
|
+
rotate3d: function (d) {
|
|
7442
|
+
mat4.fromRotation($mat4_1, deg2rad(convertAngleUnit(d[3])), [
|
|
7443
|
+
d[0].value,
|
|
7444
|
+
d[1].value,
|
|
7445
|
+
d[2].value,
|
|
7446
|
+
]);
|
|
7447
|
+
},
|
|
7448
|
+
skew: function (d) {
|
|
7449
|
+
createSkewMatrix($mat4_1, deg2rad(d[0].value), deg2rad(d[1].value));
|
|
7450
|
+
},
|
|
7451
|
+
skewX: function (d) {
|
|
7452
|
+
createSkewMatrix($mat4_1, deg2rad(d[0].value), 0);
|
|
7453
|
+
},
|
|
7454
|
+
skewY: function (d) {
|
|
7455
|
+
createSkewMatrix($mat4_1, 0, deg2rad(d[0].value));
|
|
7456
|
+
},
|
|
7457
|
+
matrix: function (d) {
|
|
7458
|
+
// prettier-ignore
|
|
7459
|
+
mat4.set($mat4_1, d[0].value, d[1].value, 0, 0, d[2].value, d[3].value, 0, 0, 0, 0, 1, 0, d[4].value, d[5].value, 0, 1);
|
|
7460
|
+
},
|
|
7461
|
+
matrix3d: function (d) {
|
|
7462
|
+
// @ts-ignore
|
|
7463
|
+
mat4.set.apply(mat4, __spreadArray([$mat4_1], __read(d.map(function (s) { return s.value; })), false));
|
|
7464
|
+
},
|
|
7465
|
+
};
|
|
7466
|
+
var optimizer = {
|
|
7467
|
+
translate: function (object, d) {
|
|
7468
|
+
object.setLocalPosition([d[0].value, d[1].value]);
|
|
7469
|
+
},
|
|
7470
|
+
translate3d: function (object, d) {
|
|
7471
|
+
object.setLocalPosition([d[0].value, d[1].value, d[2].value]);
|
|
7472
|
+
},
|
|
7473
|
+
};
|
|
7895
7474
|
function parsedTransformToMat4(transform, object) {
|
|
7896
7475
|
if (transform.length) {
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7909
|
-
mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
|
|
7910
|
-
}
|
|
7911
|
-
else if (t === 'scaley') {
|
|
7912
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7913
|
-
mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
|
|
7914
|
-
}
|
|
7915
|
-
else if (t === 'scalez') {
|
|
7916
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7917
|
-
mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
|
|
7918
|
-
}
|
|
7919
|
-
else if (t === 'scale3d') {
|
|
7920
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
|
|
7921
|
-
1, 1, 1,
|
|
7922
|
-
];
|
|
7923
|
-
mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], newScale[2]]);
|
|
7924
|
-
}
|
|
7925
|
-
else if (t === 'translate') {
|
|
7926
|
-
var newTranslation = d || [Opx, Opx];
|
|
7927
|
-
mat4.fromTranslation(tmpMat2, [
|
|
7928
|
-
newTranslation[0].value,
|
|
7929
|
-
newTranslation[1].value,
|
|
7930
|
-
0,
|
|
7931
|
-
]);
|
|
7932
|
-
}
|
|
7933
|
-
else if (t === 'translatex') {
|
|
7934
|
-
var newTranslation = d || [Opx];
|
|
7935
|
-
mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
|
|
7936
|
-
}
|
|
7937
|
-
else if (t === 'translatey') {
|
|
7938
|
-
var newTranslation = d || [Opx];
|
|
7939
|
-
mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
|
|
7940
|
-
}
|
|
7941
|
-
else if (t === 'translatez') {
|
|
7942
|
-
var newTranslation = d || [Opx];
|
|
7943
|
-
mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
|
|
7944
|
-
}
|
|
7945
|
-
else if (t === 'translate3d') {
|
|
7946
|
-
var newTranslation = d || [Opx, Opx, Opx];
|
|
7947
|
-
mat4.fromTranslation(tmpMat2, [
|
|
7948
|
-
newTranslation[0].value,
|
|
7949
|
-
newTranslation[1].value,
|
|
7950
|
-
newTranslation[2].value,
|
|
7951
|
-
]);
|
|
7952
|
-
}
|
|
7953
|
-
else if (t === 'rotate') {
|
|
7954
|
-
var newAngles = d || [Odeg];
|
|
7955
|
-
mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7956
|
-
}
|
|
7957
|
-
else if (t === 'rotatex') {
|
|
7958
|
-
var newAngles = d || [Odeg];
|
|
7959
|
-
mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7960
|
-
}
|
|
7961
|
-
else if (t === 'rotatey') {
|
|
7962
|
-
var newAngles = d || [Odeg];
|
|
7963
|
-
mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7964
|
-
}
|
|
7965
|
-
else if (t === 'rotatez') {
|
|
7966
|
-
var newAngles = d || [Odeg];
|
|
7967
|
-
mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7968
|
-
}
|
|
7969
|
-
else if (t === 'rotate3d') {
|
|
7970
|
-
var newAngles = d || [Opx, Opx, Opx, Odeg];
|
|
7971
|
-
mat4.fromRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[3])), [
|
|
7972
|
-
newAngles[0].value,
|
|
7973
|
-
newAngles[1].value,
|
|
7974
|
-
newAngles[2].value,
|
|
7975
|
-
]);
|
|
7976
|
-
}
|
|
7977
|
-
else if (t === 'skew') {
|
|
7978
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
|
|
7979
|
-
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
|
|
7980
|
-
}
|
|
7981
|
-
else if (t === 'skewx') {
|
|
7982
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
7983
|
-
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
|
|
7984
|
-
}
|
|
7985
|
-
else if (t === 'skewy') {
|
|
7986
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
7987
|
-
createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
|
|
7988
|
-
}
|
|
7989
|
-
else if (t === 'matrix') {
|
|
7990
|
-
var _a = __read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
|
|
7991
|
-
mat4.set(tmpMat2, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1);
|
|
7992
|
-
}
|
|
7993
|
-
else if (t === 'matrix3d') {
|
|
7994
|
-
// @ts-ignore
|
|
7995
|
-
mat4.set.apply(mat4, __spreadArray([tmpMat2], __read(d.map(function (s) { return s.value; })), false));
|
|
7476
|
+
if (transform.length === 1 && optimizer[transform[0].t]) {
|
|
7477
|
+
optimizer[transform[0].t](object, transform[0].d);
|
|
7478
|
+
return;
|
|
7479
|
+
}
|
|
7480
|
+
var m = mat4.identity($mat4_2);
|
|
7481
|
+
for (var i = 0; i < transform.length; i++) {
|
|
7482
|
+
var _a = transform[i], t = _a.t, d = _a.d;
|
|
7483
|
+
var p = parser[t];
|
|
7484
|
+
if (p) {
|
|
7485
|
+
p(d);
|
|
7486
|
+
mat4.mul(m, m, $mat4_1);
|
|
7996
7487
|
}
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
object.setLocalTransform(m_1);
|
|
7488
|
+
}
|
|
7489
|
+
object.setLocalTransform(m);
|
|
8000
7490
|
}
|
|
8001
7491
|
else {
|
|
8002
7492
|
object.resetLocalTransform();
|
|
@@ -8036,9 +7526,7 @@ function parsedTransformToMat4(transform, object) {
|
|
|
8036
7526
|
*/
|
|
8037
7527
|
var CSSPropertyTransform = /** @class */ (function () {
|
|
8038
7528
|
function CSSPropertyTransform() {
|
|
8039
|
-
this.parser =
|
|
8040
|
-
this.parserUnmemoize = parseTransformUnmemoize;
|
|
8041
|
-
this.parserWithCSSDisabled = parseTransformUnmemoize;
|
|
7529
|
+
this.parser = parseTransformUnmemoize;
|
|
8042
7530
|
this.mixer = mergeTransforms;
|
|
8043
7531
|
}
|
|
8044
7532
|
CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -8049,8 +7537,7 @@ var CSSPropertyTransform = /** @class */ (function () {
|
|
|
8049
7537
|
return parsed;
|
|
8050
7538
|
};
|
|
8051
7539
|
CSSPropertyTransform.prototype.postProcessor = function (object) {
|
|
8052
|
-
|
|
8053
|
-
parsedTransformToMat4(transform, object);
|
|
7540
|
+
parsedTransformToMat4(object.parsedStyle.transform, object);
|
|
8054
7541
|
};
|
|
8055
7542
|
return CSSPropertyTransform;
|
|
8056
7543
|
}());
|
|
@@ -8062,8 +7549,6 @@ var CSSPropertyTransform = /** @class */ (function () {
|
|
|
8062
7549
|
*/
|
|
8063
7550
|
var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
8064
7551
|
function CSSPropertyTransformOrigin() {
|
|
8065
|
-
this.parser = parseTransformOrigin;
|
|
8066
|
-
this.parserUnmemoize = parseTransformOriginUnmemoize;
|
|
8067
7552
|
}
|
|
8068
7553
|
CSSPropertyTransformOrigin.prototype.postProcessor = function (object) {
|
|
8069
7554
|
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
@@ -8081,8 +7566,6 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
|
8081
7566
|
|
|
8082
7567
|
var CSSPropertyZIndex = /** @class */ (function () {
|
|
8083
7568
|
function CSSPropertyZIndex() {
|
|
8084
|
-
this.parser = parseNumber;
|
|
8085
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
8086
7569
|
}
|
|
8087
7570
|
CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
|
|
8088
7571
|
return computed.value;
|
|
@@ -8241,17 +7724,8 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8241
7724
|
this.globalRuntime = globalRuntime;
|
|
8242
7725
|
}
|
|
8243
7726
|
TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
|
|
8244
|
-
var text = parsedStyle.text
|
|
8245
|
-
return
|
|
8246
|
-
? text &&
|
|
8247
|
-
fontSize &&
|
|
8248
|
-
fontStyle &&
|
|
8249
|
-
fontWeight &&
|
|
8250
|
-
fontVariant &&
|
|
8251
|
-
textAlign &&
|
|
8252
|
-
textBaseline &&
|
|
8253
|
-
!isNil(lineWidth)
|
|
8254
|
-
: text;
|
|
7727
|
+
var text = parsedStyle.text;
|
|
7728
|
+
return text;
|
|
8255
7729
|
};
|
|
8256
7730
|
TextUpdater.prototype.update = function (parsedStyle, object) {
|
|
8257
7731
|
var _a, _b;
|
|
@@ -8282,7 +7756,7 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8282
7756
|
var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
|
|
8283
7757
|
var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
|
|
8284
7758
|
parsedStyle.metrics = metrics;
|
|
8285
|
-
var width = metrics.width, height = metrics.height
|
|
7759
|
+
var width = metrics.width, height = metrics.height;
|
|
8286
7760
|
var hwidth = width / 2;
|
|
8287
7761
|
var hheight = height / 2;
|
|
8288
7762
|
// default 'left'
|
|
@@ -8295,18 +7769,12 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8295
7769
|
}
|
|
8296
7770
|
var lineYOffset = y - hheight;
|
|
8297
7771
|
if (textBaseline === 'middle') {
|
|
8298
|
-
// eslint-disable-next-line prefer-destructuring
|
|
8299
7772
|
lineYOffset += hheight;
|
|
8300
7773
|
}
|
|
8301
7774
|
else if (textBaseline === 'top' || textBaseline === 'hanging') {
|
|
8302
7775
|
lineYOffset += hheight * 2;
|
|
8303
7776
|
}
|
|
8304
|
-
else if (textBaseline === 'alphabetic')
|
|
8305
|
-
// prevent calling getImageData for ascent metrics
|
|
8306
|
-
lineYOffset += this.globalRuntime.enableCSSParsing
|
|
8307
|
-
? lineHeight - fontProperties.ascent
|
|
8308
|
-
: 0;
|
|
8309
|
-
}
|
|
7777
|
+
else if (textBaseline === 'alphabetic') ;
|
|
8310
7778
|
else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
|
|
8311
7779
|
lineYOffset += 0;
|
|
8312
7780
|
}
|
|
@@ -8762,7 +8230,7 @@ var CustomEvent = /** @class */ (function (_super) {
|
|
|
8762
8230
|
return CustomEvent;
|
|
8763
8231
|
}(FederatedEvent));
|
|
8764
8232
|
|
|
8765
|
-
var
|
|
8233
|
+
var CANVAS_CACHE = new WeakMap();
|
|
8766
8234
|
/**
|
|
8767
8235
|
* Objects that can receive events and may have listeners for them.
|
|
8768
8236
|
* eg. Element, Canvas, DisplayObject
|
|
@@ -8788,43 +8256,21 @@ var EventTarget = /** @class */ (function () {
|
|
|
8788
8256
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
|
|
8789
8257
|
*/
|
|
8790
8258
|
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
8791
|
-
var
|
|
8792
|
-
var
|
|
8793
|
-
var
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
if (
|
|
8799
|
-
|
|
8800
|
-
type = eventType;
|
|
8801
|
-
delegatedName = name_1;
|
|
8802
|
-
useDelegatedName = true;
|
|
8803
|
-
}
|
|
8804
|
-
type = capture ? "".concat(type, "capture") : type;
|
|
8259
|
+
var _a, _b;
|
|
8260
|
+
var capture = false;
|
|
8261
|
+
var once = false;
|
|
8262
|
+
if (isBoolean(options))
|
|
8263
|
+
capture = options;
|
|
8264
|
+
else if (options)
|
|
8265
|
+
(_a = options.capture, capture = _a === void 0 ? false : _a, _b = options.once, once = _b === void 0 ? false : _b);
|
|
8266
|
+
if (capture)
|
|
8267
|
+
type += 'capture';
|
|
8805
8268
|
listener = isFunction(listener) ? listener : listener.handleEvent;
|
|
8806
|
-
|
|
8807
|
-
if (
|
|
8808
|
-
var originListener_1 = listener;
|
|
8809
|
-
listener = function () {
|
|
8810
|
-
var _a;
|
|
8811
|
-
var args = [];
|
|
8812
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8813
|
-
args[_i] = arguments[_i];
|
|
8814
|
-
}
|
|
8815
|
-
if (((_a = args[0].target) === null || _a === void 0 ? void 0 : _a.name) !== delegatedName) {
|
|
8816
|
-
return;
|
|
8817
|
-
}
|
|
8818
|
-
// @ts-ignore
|
|
8819
|
-
originListener_1.apply(void 0, __spreadArray([], __read(args), false));
|
|
8820
|
-
};
|
|
8821
|
-
}
|
|
8822
|
-
if (once) {
|
|
8269
|
+
var context = isFunction(listener) ? undefined : listener;
|
|
8270
|
+
if (once)
|
|
8823
8271
|
this.emitter.once(type, listener, context);
|
|
8824
|
-
|
|
8825
|
-
else {
|
|
8272
|
+
else
|
|
8826
8273
|
this.emitter.on(type, listener, context);
|
|
8827
|
-
}
|
|
8828
8274
|
return this;
|
|
8829
8275
|
};
|
|
8830
8276
|
/**
|
|
@@ -8842,13 +8288,17 @@ var EventTarget = /** @class */ (function () {
|
|
|
8842
8288
|
return this;
|
|
8843
8289
|
};
|
|
8844
8290
|
EventTarget.prototype.removeAllEventListeners = function () {
|
|
8845
|
-
|
|
8291
|
+
var _a;
|
|
8292
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
|
|
8846
8293
|
};
|
|
8847
8294
|
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8295
|
+
if (!this.emitter)
|
|
8296
|
+
return this;
|
|
8297
|
+
var capture = isBoolean(options) ? options : options === null || options === void 0 ? void 0 : options.capture;
|
|
8298
|
+
if (capture)
|
|
8299
|
+
type += 'capture';
|
|
8851
8300
|
listener = isFunction(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
|
|
8301
|
+
var context = isFunction(listener) ? undefined : listener;
|
|
8852
8302
|
this.emitter.off(type, listener, context);
|
|
8853
8303
|
return this;
|
|
8854
8304
|
};
|
|
@@ -8864,36 +8314,34 @@ var EventTarget = /** @class */ (function () {
|
|
|
8864
8314
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
|
|
8865
8315
|
*/
|
|
8866
8316
|
EventTarget.prototype.dispatchEvent = function (e, skipPropagate) {
|
|
8867
|
-
var _a
|
|
8317
|
+
var _a;
|
|
8868
8318
|
if (skipPropagate === void 0) { skipPropagate = false; }
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
}
|
|
8882
|
-
else {
|
|
8883
|
-
canvas = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
8319
|
+
var canvas = CANVAS_CACHE.get(this);
|
|
8320
|
+
if (!canvas) {
|
|
8321
|
+
// @ts-expect-error document may be defined in inherited class
|
|
8322
|
+
if (this.document)
|
|
8323
|
+
canvas = this;
|
|
8324
|
+
// @ts-expect-error defaultView may be defined in inherited class
|
|
8325
|
+
else if (this.defaultView)
|
|
8326
|
+
canvas = this.defaultView;
|
|
8327
|
+
else
|
|
8328
|
+
canvas = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
8329
|
+
if (canvas)
|
|
8330
|
+
CANVAS_CACHE.set(this, canvas);
|
|
8884
8331
|
}
|
|
8885
|
-
// assign event manager
|
|
8886
8332
|
if (canvas) {
|
|
8887
|
-
e.manager = canvas.getEventService()
|
|
8888
|
-
if (!e.manager)
|
|
8333
|
+
e.manager = canvas.getEventService();
|
|
8334
|
+
if (!e.manager)
|
|
8889
8335
|
return false;
|
|
8890
|
-
}
|
|
8891
8336
|
e.defaultPrevented = false;
|
|
8892
|
-
e.path
|
|
8893
|
-
|
|
8337
|
+
if (e.path)
|
|
8338
|
+
e.path.length = 0;
|
|
8339
|
+
// @ts-ignore
|
|
8340
|
+
else
|
|
8341
|
+
e.page = [];
|
|
8342
|
+
if (!skipPropagate)
|
|
8894
8343
|
e.target = this;
|
|
8895
|
-
|
|
8896
|
-
(_b = e.manager) === null || _b === void 0 ? void 0 : _b.dispatchEvent(e, e.type, skipPropagate);
|
|
8344
|
+
e.manager.dispatchEvent(e, e.type, skipPropagate);
|
|
8897
8345
|
}
|
|
8898
8346
|
return !e.defaultPrevented;
|
|
8899
8347
|
};
|
|
@@ -9191,12 +8639,19 @@ var Node = /** @class */ (function (_super) {
|
|
|
9191
8639
|
}
|
|
9192
8640
|
return temp;
|
|
9193
8641
|
};
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
8642
|
+
/**
|
|
8643
|
+
* iterate current node and its descendants
|
|
8644
|
+
* @param callback - callback to execute for each node, return false to break
|
|
8645
|
+
* @param assigned - whether to iterate assigned nodes
|
|
8646
|
+
*/
|
|
8647
|
+
Node.prototype.forEach = function (callback) {
|
|
8648
|
+
var result = callback(this);
|
|
8649
|
+
if (result !== false) {
|
|
8650
|
+
var nodes = this.childNodes;
|
|
8651
|
+
var length_1 = nodes.length;
|
|
8652
|
+
for (var i = 0; i < length_1; i++) {
|
|
8653
|
+
nodes[i].forEach(callback);
|
|
8654
|
+
}
|
|
9200
8655
|
}
|
|
9201
8656
|
};
|
|
9202
8657
|
/**
|
|
@@ -10196,10 +9651,6 @@ var RenderingService = /** @class */ (function () {
|
|
|
10196
9651
|
RenderingService.prototype.renderDisplayObject = function (displayObject, canvasConfig, renderingContext) {
|
|
10197
9652
|
var _this = this;
|
|
10198
9653
|
var _a = canvasConfig.renderer.getConfig(), enableDirtyCheck = _a.enableDirtyCheck, enableCulling = _a.enableCulling;
|
|
10199
|
-
// recalc style values
|
|
10200
|
-
if (this.globalRuntime.enableCSSParsing) {
|
|
10201
|
-
this.globalRuntime.styleValueRegistry.recalc(displayObject);
|
|
10202
|
-
}
|
|
10203
9654
|
// TODO: relayout
|
|
10204
9655
|
// dirtycheck first
|
|
10205
9656
|
var renderable = displayObject.renderable;
|
|
@@ -10406,26 +9857,6 @@ var DefaultSceneGraphSelector = /** @class */ (function () {
|
|
|
10406
9857
|
return DefaultSceneGraphSelector;
|
|
10407
9858
|
}());
|
|
10408
9859
|
|
|
10409
|
-
var MutationEvent = /** @class */ (function (_super) {
|
|
10410
|
-
__extends(MutationEvent, _super);
|
|
10411
|
-
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
10412
|
-
var _this = _super.call(this, null) || this;
|
|
10413
|
-
_this.relatedNode = relatedNode;
|
|
10414
|
-
_this.prevValue = prevValue;
|
|
10415
|
-
_this.newValue = newValue;
|
|
10416
|
-
_this.attrName = attrName;
|
|
10417
|
-
_this.attrChange = attrChange;
|
|
10418
|
-
_this.prevParsedValue = prevParsedValue;
|
|
10419
|
-
_this.newParsedValue = newParsedValue;
|
|
10420
|
-
_this.type = typeArg;
|
|
10421
|
-
return _this;
|
|
10422
|
-
}
|
|
10423
|
-
MutationEvent.ADDITION = 2;
|
|
10424
|
-
MutationEvent.MODIFICATION = 1;
|
|
10425
|
-
MutationEvent.REMOVAL = 3;
|
|
10426
|
-
return MutationEvent;
|
|
10427
|
-
}(FederatedEvent));
|
|
10428
|
-
|
|
10429
9860
|
/**
|
|
10430
9861
|
* built-in events for element
|
|
10431
9862
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
|
|
@@ -10463,6 +9894,26 @@ var ElementEvent;
|
|
|
10463
9894
|
ElementEvent["CULLED"] = "culled";
|
|
10464
9895
|
})(ElementEvent || (ElementEvent = {}));
|
|
10465
9896
|
|
|
9897
|
+
var MutationEvent = /** @class */ (function (_super) {
|
|
9898
|
+
__extends(MutationEvent, _super);
|
|
9899
|
+
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
9900
|
+
var _this = _super.call(this, null) || this;
|
|
9901
|
+
_this.relatedNode = relatedNode;
|
|
9902
|
+
_this.prevValue = prevValue;
|
|
9903
|
+
_this.newValue = newValue;
|
|
9904
|
+
_this.attrName = attrName;
|
|
9905
|
+
_this.attrChange = attrChange;
|
|
9906
|
+
_this.prevParsedValue = prevParsedValue;
|
|
9907
|
+
_this.newParsedValue = newParsedValue;
|
|
9908
|
+
_this.type = typeArg;
|
|
9909
|
+
return _this;
|
|
9910
|
+
}
|
|
9911
|
+
MutationEvent.ADDITION = 2;
|
|
9912
|
+
MutationEvent.MODIFICATION = 1;
|
|
9913
|
+
MutationEvent.REMOVAL = 3;
|
|
9914
|
+
return MutationEvent;
|
|
9915
|
+
}(FederatedEvent));
|
|
9916
|
+
|
|
10466
9917
|
function markRenderableDirty(e) {
|
|
10467
9918
|
var renderable = e.renderable;
|
|
10468
9919
|
if (renderable) {
|
|
@@ -10471,6 +9922,33 @@ function markRenderableDirty(e) {
|
|
|
10471
9922
|
}
|
|
10472
9923
|
}
|
|
10473
9924
|
var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0, '', '');
|
|
9925
|
+
// Object pooling
|
|
9926
|
+
/** do not modify this objects */
|
|
9927
|
+
var $vec2Zero = vec2.create();
|
|
9928
|
+
/** do not modify this objects */
|
|
9929
|
+
var $vec3Zero = vec3.create();
|
|
9930
|
+
/** do not modify this objects */
|
|
9931
|
+
var $vec3One = vec3.fromValues(1, 1, 1);
|
|
9932
|
+
/** do not modify this objects */
|
|
9933
|
+
var $mat4Identity = mat4.create();
|
|
9934
|
+
/** shared objects */
|
|
9935
|
+
var $vec2 = vec2.create();
|
|
9936
|
+
/** shared objects */
|
|
9937
|
+
var $vec3$1 = vec3.create();
|
|
9938
|
+
/** shared objects */
|
|
9939
|
+
var $mat4 = mat4.create();
|
|
9940
|
+
/** shared objects */
|
|
9941
|
+
var $quat$1 = quat$1.create();
|
|
9942
|
+
var $setLocalTransform_1 = vec3.create();
|
|
9943
|
+
var $setLocalTransform_2 = quat$1.create();
|
|
9944
|
+
var $setLocalTransform_3 = vec3.create();
|
|
9945
|
+
var $setLocalPosition = vec3.create();
|
|
9946
|
+
var $setPosition_1 = vec3.create();
|
|
9947
|
+
var $setPosition_ParentInvertMatrix = mat4.create();
|
|
9948
|
+
var $setEulerAngles_InvParentRot = quat$1.create();
|
|
9949
|
+
var $rotateLocal = quat$1.create();
|
|
9950
|
+
var $rotate_ParentInvertRotation = quat$1.create();
|
|
9951
|
+
var $triggerPendingEvents_detail = { affectChildren: true };
|
|
10474
9952
|
/**
|
|
10475
9953
|
* update transform in scene graph
|
|
10476
9954
|
*
|
|
@@ -10478,253 +9956,11 @@ var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0
|
|
|
10478
9956
|
*/
|
|
10479
9957
|
var DefaultSceneGraphService = /** @class */ (function () {
|
|
10480
9958
|
function DefaultSceneGraphService(runtime) {
|
|
10481
|
-
var _this = this;
|
|
10482
9959
|
this.runtime = runtime;
|
|
10483
|
-
|
|
9960
|
+
// target -> affectChildren
|
|
9961
|
+
this.pendingEvents = new Map();
|
|
10484
9962
|
this.boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
|
|
10485
|
-
/**
|
|
10486
|
-
* rotate in world space
|
|
10487
|
-
*/
|
|
10488
|
-
this.rotate = (function () {
|
|
10489
|
-
var parentInvertRotation = quat$1.create();
|
|
10490
|
-
return function (element, degrees, y, z, dirtify) {
|
|
10491
|
-
if (y === void 0) { y = 0; }
|
|
10492
|
-
if (z === void 0) { z = 0; }
|
|
10493
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10494
|
-
if (typeof degrees === 'number') {
|
|
10495
|
-
degrees = vec3.fromValues(degrees, y, z);
|
|
10496
|
-
}
|
|
10497
|
-
var transform = element.transformable;
|
|
10498
|
-
if (element.parentNode === null ||
|
|
10499
|
-
!element.parentNode.transformable) {
|
|
10500
|
-
_this.rotateLocal(element, degrees);
|
|
10501
|
-
}
|
|
10502
|
-
else {
|
|
10503
|
-
var rotation = quat$1.create();
|
|
10504
|
-
quat$1.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10505
|
-
var rot = _this.getRotation(element);
|
|
10506
|
-
var parentRot = _this.getRotation(element.parentNode);
|
|
10507
|
-
quat$1.copy(parentInvertRotation, parentRot);
|
|
10508
|
-
quat$1.invert(parentInvertRotation, parentInvertRotation);
|
|
10509
|
-
quat$1.multiply(rotation, parentInvertRotation, rotation);
|
|
10510
|
-
quat$1.multiply(transform.localRotation, rotation, rot);
|
|
10511
|
-
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10512
|
-
if (dirtify) {
|
|
10513
|
-
_this.dirtifyLocal(element, transform);
|
|
10514
|
-
}
|
|
10515
|
-
}
|
|
10516
|
-
};
|
|
10517
|
-
})();
|
|
10518
|
-
/**
|
|
10519
|
-
* rotate in local space
|
|
10520
|
-
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
10521
|
-
*/
|
|
10522
|
-
this.rotateLocal = (function () {
|
|
10523
|
-
var rotation = quat$1.create();
|
|
10524
|
-
return function (element, degrees, y, z, dirtify) {
|
|
10525
|
-
if (y === void 0) { y = 0; }
|
|
10526
|
-
if (z === void 0) { z = 0; }
|
|
10527
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10528
|
-
if (typeof degrees === 'number') {
|
|
10529
|
-
degrees = vec3.fromValues(degrees, y, z);
|
|
10530
|
-
}
|
|
10531
|
-
var transform = element.transformable;
|
|
10532
|
-
quat$1.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10533
|
-
quat$1.mul(transform.localRotation, transform.localRotation, rotation);
|
|
10534
|
-
if (dirtify) {
|
|
10535
|
-
_this.dirtifyLocal(element, transform);
|
|
10536
|
-
}
|
|
10537
|
-
};
|
|
10538
|
-
})();
|
|
10539
|
-
/**
|
|
10540
|
-
* set euler angles(degrees) in world space
|
|
10541
|
-
*/
|
|
10542
|
-
this.setEulerAngles = (function () {
|
|
10543
|
-
var invParentRot = quat$1.create();
|
|
10544
|
-
return function (element, degrees, y, z, dirtify) {
|
|
10545
|
-
if (y === void 0) { y = 0; }
|
|
10546
|
-
if (z === void 0) { z = 0; }
|
|
10547
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10548
|
-
if (typeof degrees === 'number') {
|
|
10549
|
-
degrees = vec3.fromValues(degrees, y, z);
|
|
10550
|
-
}
|
|
10551
|
-
var transform = element.transformable;
|
|
10552
|
-
if (element.parentNode === null ||
|
|
10553
|
-
!element.parentNode.transformable) {
|
|
10554
|
-
_this.setLocalEulerAngles(element, degrees);
|
|
10555
|
-
}
|
|
10556
|
-
else {
|
|
10557
|
-
quat$1.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
10558
|
-
var parentRotation = _this.getRotation(element.parentNode);
|
|
10559
|
-
quat$1.copy(invParentRot, quat$1.invert(quat$1.create(), parentRotation));
|
|
10560
|
-
quat$1.mul(transform.localRotation, transform.localRotation, invParentRot);
|
|
10561
|
-
if (dirtify) {
|
|
10562
|
-
_this.dirtifyLocal(element, transform);
|
|
10563
|
-
}
|
|
10564
|
-
}
|
|
10565
|
-
};
|
|
10566
|
-
})();
|
|
10567
|
-
/**
|
|
10568
|
-
* translate in local space
|
|
10569
|
-
*
|
|
10570
|
-
* @example
|
|
10571
|
-
* ```
|
|
10572
|
-
* translateLocal(x, y, z)
|
|
10573
|
-
* translateLocal(vec3(x, y, z))
|
|
10574
|
-
* ```
|
|
10575
|
-
*/
|
|
10576
|
-
this.translateLocal = (function () {
|
|
10577
|
-
return function (element, translation, y, z, dirtify) {
|
|
10578
|
-
if (y === void 0) { y = 0; }
|
|
10579
|
-
if (z === void 0) { z = 0; }
|
|
10580
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10581
|
-
if (typeof translation === 'number') {
|
|
10582
|
-
translation = vec3.fromValues(translation, y, z);
|
|
10583
|
-
}
|
|
10584
|
-
var transform = element.transformable;
|
|
10585
|
-
if (vec3.equals(translation, vec3.create())) {
|
|
10586
|
-
return;
|
|
10587
|
-
}
|
|
10588
|
-
vec3.transformQuat(translation, translation, transform.localRotation);
|
|
10589
|
-
vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
10590
|
-
if (dirtify) {
|
|
10591
|
-
_this.dirtifyLocal(element, transform);
|
|
10592
|
-
}
|
|
10593
|
-
};
|
|
10594
|
-
})();
|
|
10595
|
-
/**
|
|
10596
|
-
* move to position in world space
|
|
10597
|
-
*
|
|
10598
|
-
* 对应 g 原版的 move/moveTo
|
|
10599
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
10600
|
-
*/
|
|
10601
|
-
this.setPosition = (function () {
|
|
10602
|
-
var parentInvertMatrix = mat4.create();
|
|
10603
|
-
var tmpPosition = vec3.create();
|
|
10604
|
-
return function (element, position, dirtify) {
|
|
10605
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10606
|
-
var transform = element.transformable;
|
|
10607
|
-
tmpPosition[0] = position[0];
|
|
10608
|
-
tmpPosition[1] = position[1];
|
|
10609
|
-
tmpPosition[2] = position[2] || 0;
|
|
10610
|
-
if (vec3.equals(_this.getPosition(element), tmpPosition)) {
|
|
10611
|
-
return;
|
|
10612
|
-
}
|
|
10613
|
-
vec3.copy(transform.position, tmpPosition);
|
|
10614
|
-
if (element.parentNode === null ||
|
|
10615
|
-
!element.parentNode.transformable) {
|
|
10616
|
-
vec3.copy(transform.localPosition, tmpPosition);
|
|
10617
|
-
}
|
|
10618
|
-
else {
|
|
10619
|
-
var parentTransform = element.parentNode.transformable;
|
|
10620
|
-
mat4.copy(parentInvertMatrix, parentTransform.worldTransform);
|
|
10621
|
-
mat4.invert(parentInvertMatrix, parentInvertMatrix);
|
|
10622
|
-
vec3.transformMat4(transform.localPosition, tmpPosition, parentInvertMatrix);
|
|
10623
|
-
}
|
|
10624
|
-
if (dirtify) {
|
|
10625
|
-
_this.dirtifyLocal(element, transform);
|
|
10626
|
-
}
|
|
10627
|
-
};
|
|
10628
|
-
})();
|
|
10629
|
-
/**
|
|
10630
|
-
* move to position in local space
|
|
10631
|
-
*/
|
|
10632
|
-
this.setLocalPosition = (function () {
|
|
10633
|
-
var tmpPosition = vec3.create();
|
|
10634
|
-
return function (element, position, dirtify) {
|
|
10635
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10636
|
-
var transform = element.transformable;
|
|
10637
|
-
tmpPosition[0] = position[0];
|
|
10638
|
-
tmpPosition[1] = position[1];
|
|
10639
|
-
tmpPosition[2] = position[2] || 0;
|
|
10640
|
-
if (vec3.equals(transform.localPosition, tmpPosition)) {
|
|
10641
|
-
return;
|
|
10642
|
-
}
|
|
10643
|
-
vec3.copy(transform.localPosition, tmpPosition);
|
|
10644
|
-
if (dirtify) {
|
|
10645
|
-
_this.dirtifyLocal(element, transform);
|
|
10646
|
-
}
|
|
10647
|
-
};
|
|
10648
|
-
})();
|
|
10649
|
-
/**
|
|
10650
|
-
* translate in world space
|
|
10651
|
-
*
|
|
10652
|
-
* @example
|
|
10653
|
-
* ```
|
|
10654
|
-
* translate(x, y, z)
|
|
10655
|
-
* translate(vec3(x, y, z))
|
|
10656
|
-
* ```
|
|
10657
|
-
*
|
|
10658
|
-
* 对应 g 原版的 translate 2D
|
|
10659
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
10660
|
-
*/
|
|
10661
|
-
this.translate = (function () {
|
|
10662
|
-
var zeroVec3 = vec3.create();
|
|
10663
|
-
var tmpVec3 = vec3.create();
|
|
10664
|
-
var tr = vec3.create();
|
|
10665
|
-
return function (element, translation, y, z, dirtify) {
|
|
10666
|
-
if (y === void 0) { y = 0; }
|
|
10667
|
-
if (z === void 0) { z = 0; }
|
|
10668
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10669
|
-
if (typeof translation === 'number') {
|
|
10670
|
-
translation = vec3.set(tmpVec3, translation, y, z);
|
|
10671
|
-
}
|
|
10672
|
-
if (vec3.equals(translation, zeroVec3)) {
|
|
10673
|
-
return;
|
|
10674
|
-
}
|
|
10675
|
-
vec3.add(tr, _this.getPosition(element), translation);
|
|
10676
|
-
_this.setPosition(element, tr, dirtify);
|
|
10677
|
-
};
|
|
10678
|
-
})();
|
|
10679
|
-
this.setRotation = function () {
|
|
10680
|
-
var parentInvertRotation = quat$1.create();
|
|
10681
|
-
return function (element, rotation, y, z, w, dirtify) {
|
|
10682
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10683
|
-
var transform = element.transformable;
|
|
10684
|
-
if (typeof rotation === 'number') {
|
|
10685
|
-
rotation = quat$1.fromValues(rotation, y, z, w);
|
|
10686
|
-
}
|
|
10687
|
-
if (element.parentNode === null ||
|
|
10688
|
-
!element.parentNode.transformable) {
|
|
10689
|
-
_this.setLocalRotation(element, rotation);
|
|
10690
|
-
}
|
|
10691
|
-
else {
|
|
10692
|
-
var parentRot = _this.getRotation(element.parentNode);
|
|
10693
|
-
quat$1.copy(parentInvertRotation, parentRot);
|
|
10694
|
-
quat$1.invert(parentInvertRotation, parentInvertRotation);
|
|
10695
|
-
quat$1.multiply(transform.localRotation, parentInvertRotation, rotation);
|
|
10696
|
-
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10697
|
-
if (dirtify) {
|
|
10698
|
-
_this.dirtifyLocal(element, transform);
|
|
10699
|
-
}
|
|
10700
|
-
}
|
|
10701
|
-
};
|
|
10702
|
-
};
|
|
10703
9963
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10704
|
-
this.calcLocalTransform = (function () {
|
|
10705
|
-
var tmpMat = mat4.create();
|
|
10706
|
-
var tmpPosition = vec3.create();
|
|
10707
|
-
var tmpQuat = quat$1.fromValues(0, 0, 0, 1);
|
|
10708
|
-
return function (transform) {
|
|
10709
|
-
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
10710
|
-
if (hasSkew) {
|
|
10711
|
-
mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, vec3.fromValues(1, 1, 1), transform.origin);
|
|
10712
|
-
// apply skew2D
|
|
10713
|
-
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
10714
|
-
var tmpMat4 = mat4.identity(tmpMat);
|
|
10715
|
-
tmpMat4[4] = Math.tan(transform.localSkew[0]);
|
|
10716
|
-
tmpMat4[1] = Math.tan(transform.localSkew[1]);
|
|
10717
|
-
mat4.multiply(transform.localTransform, transform.localTransform, tmpMat4);
|
|
10718
|
-
}
|
|
10719
|
-
var scaling = mat4.fromRotationTranslationScaleOrigin(tmpMat, tmpQuat, tmpPosition, transform.localScale, transform.origin);
|
|
10720
|
-
mat4.multiply(transform.localTransform, transform.localTransform, scaling);
|
|
10721
|
-
}
|
|
10722
|
-
else {
|
|
10723
|
-
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
10724
|
-
mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
|
|
10725
|
-
}
|
|
10726
|
-
};
|
|
10727
|
-
})();
|
|
10728
9964
|
}
|
|
10729
9965
|
DefaultSceneGraphService.prototype.matches = function (query, root) {
|
|
10730
9966
|
return this.runtime.sceneGraphSelector.is(query, root);
|
|
@@ -10743,12 +9979,23 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10743
9979
|
detached = child.parentNode !== parent;
|
|
10744
9980
|
this.detach(child);
|
|
10745
9981
|
}
|
|
9982
|
+
var isChildFragment = child.nodeName === Shape.FRAGMENT;
|
|
9983
|
+
var isAttachToFragment = isInFragment(parent);
|
|
10746
9984
|
child.parentNode = parent;
|
|
10747
|
-
|
|
10748
|
-
child.
|
|
9985
|
+
var nodes = isChildFragment
|
|
9986
|
+
? child.childNodes
|
|
9987
|
+
: [child];
|
|
9988
|
+
if (isNumber(index)) {
|
|
9989
|
+
nodes.forEach(function (node) {
|
|
9990
|
+
parent.childNodes.splice(index, 0, node);
|
|
9991
|
+
node.parentNode = parent;
|
|
9992
|
+
});
|
|
10749
9993
|
}
|
|
10750
9994
|
else {
|
|
10751
|
-
|
|
9995
|
+
nodes.forEach(function (node) {
|
|
9996
|
+
parent.childNodes.push(node);
|
|
9997
|
+
node.parentNode = parent;
|
|
9998
|
+
});
|
|
10752
9999
|
}
|
|
10753
10000
|
// parent needs re-sort
|
|
10754
10001
|
var sortable = parent.sortable;
|
|
@@ -10762,13 +10009,15 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10762
10009
|
sortable.dirty = true;
|
|
10763
10010
|
sortable.dirtyReason = SortReason.ADDED;
|
|
10764
10011
|
}
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
if (
|
|
10768
|
-
this.
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10012
|
+
if (isAttachToFragment)
|
|
10013
|
+
return;
|
|
10014
|
+
if (isChildFragment)
|
|
10015
|
+
this.dirtifyFragment(child);
|
|
10016
|
+
else {
|
|
10017
|
+
var transform = child.transformable;
|
|
10018
|
+
if (transform) {
|
|
10019
|
+
this.dirtifyWorld(child, transform);
|
|
10020
|
+
}
|
|
10772
10021
|
}
|
|
10773
10022
|
if (detached) {
|
|
10774
10023
|
child.dispatchEvent(reparentEvent);
|
|
@@ -10836,6 +10085,70 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10836
10085
|
originVec[2] = origin[2] || 0;
|
|
10837
10086
|
this.dirtifyLocal(element, transform);
|
|
10838
10087
|
};
|
|
10088
|
+
/**
|
|
10089
|
+
* rotate in world space
|
|
10090
|
+
*/
|
|
10091
|
+
DefaultSceneGraphService.prototype.rotate = function (element, degrees, y, z) {
|
|
10092
|
+
if (y === void 0) { y = 0; }
|
|
10093
|
+
if (z === void 0) { z = 0; }
|
|
10094
|
+
if (typeof degrees === 'number') {
|
|
10095
|
+
degrees = vec3.fromValues(degrees, y, z);
|
|
10096
|
+
}
|
|
10097
|
+
var transform = element.transformable;
|
|
10098
|
+
if (element.parentNode === null ||
|
|
10099
|
+
!element.parentNode.transformable) {
|
|
10100
|
+
this.rotateLocal(element, degrees);
|
|
10101
|
+
}
|
|
10102
|
+
else {
|
|
10103
|
+
var rotation = $quat$1;
|
|
10104
|
+
quat$1.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10105
|
+
var rot = this.getRotation(element);
|
|
10106
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
10107
|
+
quat$1.copy($rotate_ParentInvertRotation, parentRot);
|
|
10108
|
+
quat$1.invert($rotate_ParentInvertRotation, $rotate_ParentInvertRotation);
|
|
10109
|
+
quat$1.multiply(rotation, $rotate_ParentInvertRotation, rotation);
|
|
10110
|
+
quat$1.multiply(transform.localRotation, rotation, rot);
|
|
10111
|
+
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10112
|
+
this.dirtifyLocal(element, transform);
|
|
10113
|
+
}
|
|
10114
|
+
};
|
|
10115
|
+
/**
|
|
10116
|
+
* rotate in local space
|
|
10117
|
+
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
10118
|
+
*/
|
|
10119
|
+
DefaultSceneGraphService.prototype.rotateLocal = function (element, degrees, y, z) {
|
|
10120
|
+
if (y === void 0) { y = 0; }
|
|
10121
|
+
if (z === void 0) { z = 0; }
|
|
10122
|
+
if (typeof degrees === 'number') {
|
|
10123
|
+
degrees = vec3.fromValues(degrees, y, z);
|
|
10124
|
+
}
|
|
10125
|
+
var transform = element.transformable;
|
|
10126
|
+
quat$1.fromEuler($rotateLocal, degrees[0], degrees[1], degrees[2]);
|
|
10127
|
+
quat$1.mul(transform.localRotation, transform.localRotation, $rotateLocal);
|
|
10128
|
+
this.dirtifyLocal(element, transform);
|
|
10129
|
+
};
|
|
10130
|
+
/**
|
|
10131
|
+
* set euler angles(degrees) in world space
|
|
10132
|
+
*/
|
|
10133
|
+
DefaultSceneGraphService.prototype.setEulerAngles = function (element, degrees, y, z) {
|
|
10134
|
+
if (y === void 0) { y = 0; }
|
|
10135
|
+
if (z === void 0) { z = 0; }
|
|
10136
|
+
if (typeof degrees === 'number') {
|
|
10137
|
+
degrees = vec3.fromValues(degrees, y, z);
|
|
10138
|
+
}
|
|
10139
|
+
var transform = element.transformable;
|
|
10140
|
+
if (element.parentNode === null ||
|
|
10141
|
+
!element.parentNode.transformable) {
|
|
10142
|
+
this.setLocalEulerAngles(element, degrees);
|
|
10143
|
+
}
|
|
10144
|
+
else {
|
|
10145
|
+
quat$1.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
10146
|
+
var parentRotation = this.getRotation(element.parentNode);
|
|
10147
|
+
quat$1.copy($setEulerAngles_InvParentRot, quat$1.invert($quat$1, parentRotation));
|
|
10148
|
+
quat$1.mul(transform.localRotation, transform.localRotation, $setEulerAngles_InvParentRot);
|
|
10149
|
+
this.dirtifyLocal(element, transform);
|
|
10150
|
+
}
|
|
10151
|
+
};
|
|
10839
10152
|
/**
|
|
10840
10153
|
* set euler angles(degrees) in local space
|
|
10841
10154
|
*/
|
|
@@ -10853,32 +10166,140 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10853
10166
|
}
|
|
10854
10167
|
};
|
|
10855
10168
|
/**
|
|
10856
|
-
*
|
|
10169
|
+
* translate in local space
|
|
10170
|
+
*
|
|
10171
|
+
* @example
|
|
10172
|
+
* ```
|
|
10173
|
+
* translateLocal(x, y, z)
|
|
10174
|
+
* translateLocal(vec3(x, y, z))
|
|
10175
|
+
* ```
|
|
10176
|
+
*/
|
|
10177
|
+
DefaultSceneGraphService.prototype.translateLocal = function (element, translation, y, z) {
|
|
10178
|
+
if (y === void 0) { y = 0; }
|
|
10179
|
+
if (z === void 0) { z = 0; }
|
|
10180
|
+
if (typeof translation === 'number') {
|
|
10181
|
+
translation = vec3.fromValues(translation, y, z);
|
|
10182
|
+
}
|
|
10183
|
+
var transform = element.transformable;
|
|
10184
|
+
if (vec3.equals(translation, $vec3Zero))
|
|
10185
|
+
return;
|
|
10186
|
+
vec3.transformQuat(translation, translation, transform.localRotation);
|
|
10187
|
+
vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
10188
|
+
this.dirtifyLocal(element, transform);
|
|
10189
|
+
};
|
|
10190
|
+
/**
|
|
10191
|
+
* move to position in world space
|
|
10192
|
+
*
|
|
10193
|
+
* 对应 g 原版的 move/moveTo
|
|
10194
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
10195
|
+
*/
|
|
10196
|
+
DefaultSceneGraphService.prototype.setPosition = function (element, position) {
|
|
10197
|
+
var _a;
|
|
10198
|
+
var transform = element.transformable;
|
|
10199
|
+
$setPosition_1[0] = position[0];
|
|
10200
|
+
$setPosition_1[1] = position[1];
|
|
10201
|
+
$setPosition_1[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
|
|
10202
|
+
if (vec3.equals(this.getPosition(element), $setPosition_1)) {
|
|
10203
|
+
return;
|
|
10204
|
+
}
|
|
10205
|
+
vec3.copy(transform.position, $setPosition_1);
|
|
10206
|
+
if (element.parentNode === null ||
|
|
10207
|
+
!element.parentNode.transformable) {
|
|
10208
|
+
vec3.copy(transform.localPosition, $setPosition_1);
|
|
10209
|
+
}
|
|
10210
|
+
else {
|
|
10211
|
+
var parentTransform = element.parentNode.transformable;
|
|
10212
|
+
mat4.copy($setPosition_ParentInvertMatrix, parentTransform.worldTransform);
|
|
10213
|
+
mat4.invert($setPosition_ParentInvertMatrix, $setPosition_ParentInvertMatrix);
|
|
10214
|
+
vec3.transformMat4(transform.localPosition, $setPosition_1, $setPosition_ParentInvertMatrix);
|
|
10215
|
+
}
|
|
10216
|
+
this.dirtifyLocal(element, transform);
|
|
10217
|
+
};
|
|
10218
|
+
/**
|
|
10219
|
+
* move to position in local space
|
|
10857
10220
|
*/
|
|
10858
|
-
DefaultSceneGraphService.prototype.
|
|
10221
|
+
DefaultSceneGraphService.prototype.setLocalPosition = function (element, position, dirtify) {
|
|
10222
|
+
var _a;
|
|
10859
10223
|
if (dirtify === void 0) { dirtify = true; }
|
|
10860
10224
|
var transform = element.transformable;
|
|
10861
|
-
|
|
10225
|
+
$setLocalPosition[0] = position[0];
|
|
10226
|
+
$setLocalPosition[1] = position[1];
|
|
10227
|
+
$setLocalPosition[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
|
|
10228
|
+
if (vec3.equals(transform.localPosition, $setLocalPosition)) {
|
|
10229
|
+
return;
|
|
10230
|
+
}
|
|
10231
|
+
vec3.copy(transform.localPosition, $setLocalPosition);
|
|
10862
10232
|
if (dirtify) {
|
|
10863
10233
|
this.dirtifyLocal(element, transform);
|
|
10864
10234
|
}
|
|
10865
10235
|
};
|
|
10236
|
+
/**
|
|
10237
|
+
* scale in local space
|
|
10238
|
+
*/
|
|
10239
|
+
DefaultSceneGraphService.prototype.scaleLocal = function (element, scaling) {
|
|
10240
|
+
var _a;
|
|
10241
|
+
var transform = element.transformable;
|
|
10242
|
+
vec3.multiply(transform.localScale, transform.localScale, vec3.set($vec3$1, scaling[0], scaling[1], (_a = scaling[2]) !== null && _a !== void 0 ? _a : 1));
|
|
10243
|
+
this.dirtifyLocal(element, transform);
|
|
10244
|
+
};
|
|
10866
10245
|
DefaultSceneGraphService.prototype.setLocalScale = function (element, scaling, dirtify) {
|
|
10246
|
+
var _a;
|
|
10867
10247
|
if (dirtify === void 0) { dirtify = true; }
|
|
10868
10248
|
var transform = element.transformable;
|
|
10869
|
-
|
|
10870
|
-
if (vec3.equals(
|
|
10249
|
+
vec3.set($vec3$1, scaling[0], scaling[1], (_a = scaling[2]) !== null && _a !== void 0 ? _a : transform.localScale[2]);
|
|
10250
|
+
if (vec3.equals($vec3$1, transform.localScale)) {
|
|
10871
10251
|
return;
|
|
10872
10252
|
}
|
|
10873
|
-
vec3.copy(transform.localScale,
|
|
10253
|
+
vec3.copy(transform.localScale, $vec3$1);
|
|
10874
10254
|
if (dirtify) {
|
|
10875
10255
|
this.dirtifyLocal(element, transform);
|
|
10876
10256
|
}
|
|
10877
10257
|
};
|
|
10258
|
+
/**
|
|
10259
|
+
* translate in world space
|
|
10260
|
+
*
|
|
10261
|
+
* @example
|
|
10262
|
+
* ```
|
|
10263
|
+
* translate(x, y, z)
|
|
10264
|
+
* translate(vec3(x, y, z))
|
|
10265
|
+
* ```
|
|
10266
|
+
*
|
|
10267
|
+
* 对应 g 原版的 translate 2D
|
|
10268
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
10269
|
+
*/
|
|
10270
|
+
DefaultSceneGraphService.prototype.translate = function (element, translation, y, z) {
|
|
10271
|
+
if (y === void 0) { y = 0; }
|
|
10272
|
+
if (z === void 0) { z = 0; }
|
|
10273
|
+
if (typeof translation === 'number') {
|
|
10274
|
+
translation = vec3.set($vec3$1, translation, y, z);
|
|
10275
|
+
}
|
|
10276
|
+
if (vec3.equals(translation, $vec3Zero))
|
|
10277
|
+
return;
|
|
10278
|
+
vec3.add($vec3$1, this.getPosition(element), translation);
|
|
10279
|
+
this.setPosition(element, $vec3$1);
|
|
10280
|
+
};
|
|
10281
|
+
DefaultSceneGraphService.prototype.setRotation = function (element, rotation, y, z, w) {
|
|
10282
|
+
var transform = element.transformable;
|
|
10283
|
+
if (typeof rotation === 'number') {
|
|
10284
|
+
rotation = quat$1.fromValues(rotation, y, z, w);
|
|
10285
|
+
}
|
|
10286
|
+
if (element.parentNode === null ||
|
|
10287
|
+
!element.parentNode.transformable) {
|
|
10288
|
+
this.setLocalRotation(element, rotation);
|
|
10289
|
+
}
|
|
10290
|
+
else {
|
|
10291
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
10292
|
+
quat$1.copy($quat$1, parentRot);
|
|
10293
|
+
quat$1.invert($quat$1, $quat$1);
|
|
10294
|
+
quat$1.multiply(transform.localRotation, $quat$1, rotation);
|
|
10295
|
+
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10296
|
+
this.dirtifyLocal(element, transform);
|
|
10297
|
+
}
|
|
10298
|
+
};
|
|
10878
10299
|
DefaultSceneGraphService.prototype.setLocalRotation = function (element, rotation, y, z, w, dirtify) {
|
|
10879
10300
|
if (dirtify === void 0) { dirtify = true; }
|
|
10880
10301
|
if (typeof rotation === 'number') {
|
|
10881
|
-
rotation = quat$1.
|
|
10302
|
+
rotation = quat$1.set($quat$1, rotation, y, z, w);
|
|
10882
10303
|
}
|
|
10883
10304
|
var transform = element.transformable;
|
|
10884
10305
|
quat$1.copy(transform.localRotation, rotation);
|
|
@@ -10886,15 +10307,20 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10886
10307
|
this.dirtifyLocal(element, transform);
|
|
10887
10308
|
}
|
|
10888
10309
|
};
|
|
10889
|
-
DefaultSceneGraphService.prototype.setLocalSkew = function (element, skew, y) {
|
|
10310
|
+
DefaultSceneGraphService.prototype.setLocalSkew = function (element, skew, y, dirtify) {
|
|
10311
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10890
10312
|
if (typeof skew === 'number') {
|
|
10891
|
-
skew = vec2.
|
|
10313
|
+
skew = vec2.set($vec2, skew, y);
|
|
10892
10314
|
}
|
|
10893
10315
|
var transform = element.transformable;
|
|
10894
10316
|
vec2.copy(transform.localSkew, skew);
|
|
10895
|
-
|
|
10317
|
+
if (dirtify) {
|
|
10318
|
+
this.dirtifyLocal(element, transform);
|
|
10319
|
+
}
|
|
10896
10320
|
};
|
|
10897
10321
|
DefaultSceneGraphService.prototype.dirtifyLocal = function (element, transform) {
|
|
10322
|
+
if (isInFragment(element))
|
|
10323
|
+
return;
|
|
10898
10324
|
if (!transform.localDirtyFlag) {
|
|
10899
10325
|
transform.localDirtyFlag = true;
|
|
10900
10326
|
if (!transform.dirtyFlag) {
|
|
@@ -10909,11 +10335,43 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10909
10335
|
this.dirtifyWorldInternal(element, transform);
|
|
10910
10336
|
this.dirtifyToRoot(element, true);
|
|
10911
10337
|
};
|
|
10338
|
+
DefaultSceneGraphService.prototype.dirtifyFragment = function (element) {
|
|
10339
|
+
var transform = element.transformable;
|
|
10340
|
+
if (transform) {
|
|
10341
|
+
transform.frozen = false;
|
|
10342
|
+
transform.dirtyFlag = true;
|
|
10343
|
+
transform.localDirtyFlag = true;
|
|
10344
|
+
}
|
|
10345
|
+
var renderable = element.renderable;
|
|
10346
|
+
if (renderable) {
|
|
10347
|
+
renderable.renderBoundsDirty = true;
|
|
10348
|
+
renderable.boundsDirty = true;
|
|
10349
|
+
renderable.dirty = true;
|
|
10350
|
+
}
|
|
10351
|
+
var length = element.childNodes.length;
|
|
10352
|
+
for (var i = 0; i < length; i++) {
|
|
10353
|
+
this.dirtifyFragment(element.childNodes[i]);
|
|
10354
|
+
}
|
|
10355
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
10356
|
+
this.pendingEvents.set(element, false);
|
|
10357
|
+
}
|
|
10358
|
+
};
|
|
10912
10359
|
DefaultSceneGraphService.prototype.triggerPendingEvents = function () {
|
|
10913
10360
|
var _this = this;
|
|
10914
|
-
var
|
|
10361
|
+
var triggered = new Set();
|
|
10362
|
+
var skipped = new Set();
|
|
10363
|
+
this.pendingEvents.forEach(function (_, element) {
|
|
10364
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
10365
|
+
element.forEach(function (e) {
|
|
10366
|
+
if (e !== element)
|
|
10367
|
+
skipped.add(e);
|
|
10368
|
+
});
|
|
10369
|
+
}
|
|
10370
|
+
});
|
|
10915
10371
|
var trigger = function (element, detail) {
|
|
10916
|
-
if (element.isConnected &&
|
|
10372
|
+
if (element.isConnected &&
|
|
10373
|
+
!triggered.has(element) &&
|
|
10374
|
+
!skipped.has(element)) {
|
|
10917
10375
|
_this.boundsChangedEvent.detail = detail;
|
|
10918
10376
|
_this.boundsChangedEvent.target = element;
|
|
10919
10377
|
if (element.isMutationObserved) {
|
|
@@ -10922,25 +10380,25 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10922
10380
|
else {
|
|
10923
10381
|
element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
|
|
10924
10382
|
}
|
|
10925
|
-
|
|
10383
|
+
triggered.add(element);
|
|
10926
10384
|
}
|
|
10927
10385
|
};
|
|
10928
|
-
this.pendingEvents.forEach(function (
|
|
10929
|
-
|
|
10930
|
-
if (
|
|
10386
|
+
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
10387
|
+
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
10388
|
+
if (affectChildren) {
|
|
10931
10389
|
element.forEach(function (e) {
|
|
10932
|
-
trigger(e,
|
|
10390
|
+
trigger(e, $triggerPendingEvents_detail);
|
|
10933
10391
|
});
|
|
10934
10392
|
}
|
|
10935
|
-
else
|
|
10936
|
-
trigger(element,
|
|
10937
|
-
}
|
|
10393
|
+
else
|
|
10394
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
10938
10395
|
});
|
|
10396
|
+
triggered.clear();
|
|
10397
|
+
skipped.clear();
|
|
10939
10398
|
this.clearPendingEvents();
|
|
10940
|
-
set.clear();
|
|
10941
10399
|
};
|
|
10942
10400
|
DefaultSceneGraphService.prototype.clearPendingEvents = function () {
|
|
10943
|
-
this.pendingEvents
|
|
10401
|
+
this.pendingEvents.clear();
|
|
10944
10402
|
};
|
|
10945
10403
|
DefaultSceneGraphService.prototype.dirtifyToRoot = function (element, affectChildren) {
|
|
10946
10404
|
if (affectChildren === void 0) { affectChildren = false; }
|
|
@@ -10958,10 +10416,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10958
10416
|
markRenderableDirty(e);
|
|
10959
10417
|
});
|
|
10960
10418
|
}
|
|
10961
|
-
// inform dependencies
|
|
10962
10419
|
this.informDependentDisplayObjects(element);
|
|
10963
|
-
|
|
10964
|
-
this.pendingEvents.push([element, { affectChildren: affectChildren }]);
|
|
10420
|
+
this.pendingEvents.set(element, affectChildren);
|
|
10965
10421
|
};
|
|
10966
10422
|
DefaultSceneGraphService.prototype.updateDisplayObjectDependency = function (name, oldPath, newPath, object) {
|
|
10967
10423
|
// clear ref to old clip path
|
|
@@ -11036,6 +10492,45 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11036
10492
|
DefaultSceneGraphService.prototype.getLocalSkew = function (element) {
|
|
11037
10493
|
return element.transformable.localSkew;
|
|
11038
10494
|
};
|
|
10495
|
+
DefaultSceneGraphService.prototype.calcLocalTransform = function (transform) {
|
|
10496
|
+
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
10497
|
+
if (hasSkew) {
|
|
10498
|
+
mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, vec3.fromValues(1, 1, 1), transform.origin);
|
|
10499
|
+
// apply skew2D
|
|
10500
|
+
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
10501
|
+
mat4.identity($mat4);
|
|
10502
|
+
$mat4[4] = Math.tan(transform.localSkew[0]);
|
|
10503
|
+
$mat4[1] = Math.tan(transform.localSkew[1]);
|
|
10504
|
+
mat4.multiply(transform.localTransform, transform.localTransform, $mat4);
|
|
10505
|
+
}
|
|
10506
|
+
var scaling = mat4.fromRotationTranslationScaleOrigin($mat4, quat$1.set($quat$1, 0, 0, 0, 1), vec3.set($vec3$1, 1, 1, 1), transform.localScale, transform.origin);
|
|
10507
|
+
mat4.multiply(transform.localTransform, transform.localTransform, scaling);
|
|
10508
|
+
}
|
|
10509
|
+
else {
|
|
10510
|
+
var localTransform = transform.localTransform, localPosition = transform.localPosition, localRotation = transform.localRotation, localScale = transform.localScale, origin_1 = transform.origin;
|
|
10511
|
+
var hasPosition = localPosition[0] !== 0 ||
|
|
10512
|
+
localPosition[1] !== 0 ||
|
|
10513
|
+
localPosition[2] !== 0;
|
|
10514
|
+
var hasRotation = localRotation[3] !== 1 ||
|
|
10515
|
+
localRotation[0] !== 0 ||
|
|
10516
|
+
localRotation[1] !== 0 ||
|
|
10517
|
+
localRotation[2] !== 0;
|
|
10518
|
+
var hasScale = localScale[0] !== 1 || localScale[1] !== 1 || localScale[2] !== 1;
|
|
10519
|
+
var hasOrigin = origin_1[0] !== 0 || origin_1[1] !== 0 || origin_1[2] !== 0;
|
|
10520
|
+
if (!hasRotation && !hasScale && !hasOrigin) {
|
|
10521
|
+
if (hasPosition) {
|
|
10522
|
+
mat4.fromTranslation(localTransform, localPosition);
|
|
10523
|
+
}
|
|
10524
|
+
else {
|
|
10525
|
+
mat4.identity(localTransform);
|
|
10526
|
+
}
|
|
10527
|
+
}
|
|
10528
|
+
else {
|
|
10529
|
+
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
10530
|
+
mat4.fromRotationTranslationScaleOrigin(localTransform, localRotation, localPosition, localScale, origin_1);
|
|
10531
|
+
}
|
|
10532
|
+
}
|
|
10533
|
+
};
|
|
11039
10534
|
DefaultSceneGraphService.prototype.getLocalTransform = function (element) {
|
|
11040
10535
|
var transform = element.transformable;
|
|
11041
10536
|
if (transform.localDirtyFlag) {
|
|
@@ -11045,19 +10540,20 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11045
10540
|
return transform.localTransform;
|
|
11046
10541
|
};
|
|
11047
10542
|
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
11048
|
-
var t = mat4.getTranslation(
|
|
11049
|
-
var r = mat4.getRotation(
|
|
11050
|
-
var s = mat4.getScaling(
|
|
10543
|
+
var t = mat4.getTranslation($setLocalTransform_1, transform);
|
|
10544
|
+
var r = mat4.getRotation($setLocalTransform_2, transform);
|
|
10545
|
+
var s = mat4.getScaling($setLocalTransform_3, transform);
|
|
11051
10546
|
this.setLocalScale(element, s, false);
|
|
11052
10547
|
this.setLocalPosition(element, t, false);
|
|
11053
10548
|
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11054
10549
|
this.dirtifyLocal(element, element.transformable);
|
|
11055
10550
|
};
|
|
11056
10551
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
11057
|
-
this.setLocalScale(element,
|
|
11058
|
-
this.setLocalPosition(element,
|
|
11059
|
-
this.setLocalEulerAngles(element,
|
|
11060
|
-
this.setLocalSkew(element,
|
|
10552
|
+
this.setLocalScale(element, $vec3One, false);
|
|
10553
|
+
this.setLocalPosition(element, $vec3Zero, false);
|
|
10554
|
+
this.setLocalEulerAngles(element, $vec3Zero, undefined, undefined, false);
|
|
10555
|
+
this.setLocalSkew(element, $vec2Zero, undefined, false);
|
|
10556
|
+
this.dirtifyLocal(element, element.transformable);
|
|
11061
10557
|
};
|
|
11062
10558
|
DefaultSceneGraphService.prototype.getTransformedGeometryBounds = function (element, render, existedAABB) {
|
|
11063
10559
|
if (render === void 0) { render = false; }
|
|
@@ -11149,9 +10645,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11149
10645
|
*/
|
|
11150
10646
|
DefaultSceneGraphService.prototype.getLocalBounds = function (element) {
|
|
11151
10647
|
if (element.parentNode) {
|
|
11152
|
-
var parentInvert =
|
|
10648
|
+
var parentInvert = $mat4Identity;
|
|
11153
10649
|
if (element.parentNode.transformable) {
|
|
11154
|
-
parentInvert = mat4.invert(mat4
|
|
10650
|
+
parentInvert = mat4.invert($mat4, this.getWorldTransform(element.parentNode));
|
|
11155
10651
|
}
|
|
11156
10652
|
var bounds = this.getBounds(element);
|
|
11157
10653
|
if (!AABB.isEmpty(bounds)) {
|
|
@@ -11404,19 +10900,12 @@ var TextService = /** @class */ (function () {
|
|
|
11404
10900
|
// dropShadowDistance = 0,
|
|
11405
10901
|
leading = _g === void 0 ? 0 : _g;
|
|
11406
10902
|
var font = toFontString(parsedStyle);
|
|
11407
|
-
// if (runtime.enableCSSParsing) {
|
|
11408
10903
|
var fontProperties = this.measureFont(font, offscreenCanvas);
|
|
11409
10904
|
// fallback in case UA disallow canvas data extraction
|
|
11410
|
-
// (toDataURI, getImageData functions)
|
|
11411
10905
|
if (fontProperties.fontSize === 0) {
|
|
11412
10906
|
fontProperties.fontSize = fontSize;
|
|
11413
10907
|
fontProperties.ascent = fontSize;
|
|
11414
10908
|
}
|
|
11415
|
-
// } else {
|
|
11416
|
-
// fontProperties = {
|
|
11417
|
-
// fontSize,
|
|
11418
|
-
// };
|
|
11419
|
-
// }
|
|
11420
10909
|
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
|
|
11421
10910
|
context.font = font;
|
|
11422
10911
|
// no overflowing by default
|
|
@@ -11738,10 +11227,7 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
|
|
|
11738
11227
|
runtime.styleValueRegistry = new DefaultStyleValueRegistry(runtime);
|
|
11739
11228
|
runtime.layoutRegistry = null;
|
|
11740
11229
|
runtime.globalThis = getGlobalThis();
|
|
11741
|
-
runtime.enableCSSParsing = false;
|
|
11742
|
-
runtime.enableDataset = false;
|
|
11743
11230
|
runtime.enableStyleSyntax = true;
|
|
11744
|
-
runtime.enableAttributeDashCased = false;
|
|
11745
11231
|
runtime.enableSizeAttenuation = false;
|
|
11746
11232
|
|
|
11747
11233
|
var entityCounter = 0;
|
|
@@ -11830,34 +11316,7 @@ var Element = /** @class */ (function (_super) {
|
|
|
11830
11316
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
11831
11317
|
*/
|
|
11832
11318
|
_this.style = {};
|
|
11833
|
-
_this.computedStyle =
|
|
11834
|
-
? {
|
|
11835
|
-
opacity: unsetKeywordValue,
|
|
11836
|
-
fillOpacity: unsetKeywordValue,
|
|
11837
|
-
strokeOpacity: unsetKeywordValue,
|
|
11838
|
-
fill: unsetKeywordValue,
|
|
11839
|
-
stroke: unsetKeywordValue,
|
|
11840
|
-
transform: unsetKeywordValue,
|
|
11841
|
-
transformOrigin: unsetKeywordValue,
|
|
11842
|
-
visibility: unsetKeywordValue,
|
|
11843
|
-
pointerEvents: unsetKeywordValue,
|
|
11844
|
-
lineWidth: unsetKeywordValue,
|
|
11845
|
-
lineCap: unsetKeywordValue,
|
|
11846
|
-
lineJoin: unsetKeywordValue,
|
|
11847
|
-
increasedLineWidthForHitTesting: unsetKeywordValue,
|
|
11848
|
-
fontSize: unsetKeywordValue,
|
|
11849
|
-
fontFamily: unsetKeywordValue,
|
|
11850
|
-
fontStyle: unsetKeywordValue,
|
|
11851
|
-
fontWeight: unsetKeywordValue,
|
|
11852
|
-
fontVariant: unsetKeywordValue,
|
|
11853
|
-
textAlign: unsetKeywordValue,
|
|
11854
|
-
textBaseline: unsetKeywordValue,
|
|
11855
|
-
textTransform: unsetKeywordValue,
|
|
11856
|
-
zIndex: unsetKeywordValue,
|
|
11857
|
-
filter: unsetKeywordValue,
|
|
11858
|
-
shadowType: unsetKeywordValue,
|
|
11859
|
-
}
|
|
11860
|
-
: null;
|
|
11319
|
+
_this.computedStyle = {};
|
|
11861
11320
|
/**
|
|
11862
11321
|
* Renderers will use these used values.
|
|
11863
11322
|
*/
|
|
@@ -11986,7 +11445,12 @@ var Element = /** @class */ (function (_super) {
|
|
|
11986
11445
|
}
|
|
11987
11446
|
runtime.sceneGraphService.attach(child, this, index);
|
|
11988
11447
|
if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
|
|
11989
|
-
this.
|
|
11448
|
+
if (!isInFragment(this) && child.nodeName === Shape.FRAGMENT) {
|
|
11449
|
+
this.ownerDocument.defaultView.mountFragment(child);
|
|
11450
|
+
}
|
|
11451
|
+
else {
|
|
11452
|
+
this.ownerDocument.defaultView.mountChildren(child);
|
|
11453
|
+
}
|
|
11990
11454
|
}
|
|
11991
11455
|
// @ts-ignore
|
|
11992
11456
|
if (this.isMutationObserved) {
|
|
@@ -12100,9 +11564,9 @@ var Element = /** @class */ (function (_super) {
|
|
|
12100
11564
|
this.forEach(function (object) {
|
|
12101
11565
|
if (object !== _this && filter(object)) {
|
|
12102
11566
|
target = object;
|
|
12103
|
-
return
|
|
11567
|
+
return false;
|
|
12104
11568
|
}
|
|
12105
|
-
return
|
|
11569
|
+
return true;
|
|
12106
11570
|
});
|
|
12107
11571
|
return target;
|
|
12108
11572
|
};
|
|
@@ -12260,17 +11724,13 @@ var Element = /** @class */ (function (_super) {
|
|
|
12260
11724
|
*/
|
|
12261
11725
|
Element.prototype.getAttribute = function (name) {
|
|
12262
11726
|
// @see https://github.com/antvis/G/issues/1267
|
|
12263
|
-
if (
|
|
12264
|
-
return
|
|
11727
|
+
if (typeof name === 'symbol') {
|
|
11728
|
+
return undefined;
|
|
12265
11729
|
}
|
|
12266
11730
|
var value = this.attributes[name];
|
|
12267
11731
|
if (value === undefined) {
|
|
12268
|
-
if (runtime.enableAttributeDashCased) {
|
|
12269
|
-
var attributeName = formatAttributeName(name);
|
|
12270
|
-
value = this.attributes[attributeName];
|
|
12271
|
-
}
|
|
12272
11732
|
// if the given attribute does not exist, the value returned will either be null or ""
|
|
12273
|
-
return
|
|
11733
|
+
return value;
|
|
12274
11734
|
}
|
|
12275
11735
|
else {
|
|
12276
11736
|
return value;
|
|
@@ -12342,78 +11802,8 @@ var Proxy = runtime.globalThis.Proxy
|
|
|
12342
11802
|
? runtime.globalThis.Proxy
|
|
12343
11803
|
: function () { };
|
|
12344
11804
|
var mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
|
|
12345
|
-
var
|
|
12346
|
-
|
|
12347
|
-
fillOpacity: '',
|
|
12348
|
-
strokeOpacity: '',
|
|
12349
|
-
fill: '',
|
|
12350
|
-
stroke: '',
|
|
12351
|
-
transform: '',
|
|
12352
|
-
transformOrigin: '',
|
|
12353
|
-
visibility: '',
|
|
12354
|
-
pointerEvents: '',
|
|
12355
|
-
lineWidth: '',
|
|
12356
|
-
lineCap: '',
|
|
12357
|
-
lineJoin: '',
|
|
12358
|
-
increasedLineWidthForHitTesting: '',
|
|
12359
|
-
fontSize: '',
|
|
12360
|
-
fontFamily: '',
|
|
12361
|
-
fontStyle: '',
|
|
12362
|
-
fontWeight: '',
|
|
12363
|
-
fontVariant: '',
|
|
12364
|
-
textAlign: '',
|
|
12365
|
-
textBaseline: '',
|
|
12366
|
-
textTransform: '',
|
|
12367
|
-
zIndex: '',
|
|
12368
|
-
filter: '',
|
|
12369
|
-
shadowType: '',
|
|
12370
|
-
};
|
|
12371
|
-
var DEFAULT_PARSED_STYLE_PROPS = {
|
|
12372
|
-
fill: noneColor,
|
|
12373
|
-
stroke: noneColor,
|
|
12374
|
-
transform: [],
|
|
12375
|
-
zIndex: 0,
|
|
12376
|
-
filter: [],
|
|
12377
|
-
shadowType: 'outer',
|
|
12378
|
-
miterLimit: 10,
|
|
12379
|
-
};
|
|
12380
|
-
// const DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = {
|
|
12381
|
-
// ...DEFAULT_PARSED_STYLE_PROPS,
|
|
12382
|
-
// opacity: 1,
|
|
12383
|
-
// fillOpacity: 1,
|
|
12384
|
-
// strokeOpacity: 1,
|
|
12385
|
-
// visibility: 'visible',
|
|
12386
|
-
// pointerEvents: 'auto',
|
|
12387
|
-
// lineWidth: 1,
|
|
12388
|
-
// lineCap: 'butt',
|
|
12389
|
-
// lineJoin: 'miter',
|
|
12390
|
-
// increasedLineWidthForHitTesting: 0,
|
|
12391
|
-
// fillRule: 'nonzero',
|
|
12392
|
-
// // TODO: transformOrigin
|
|
12393
|
-
// };
|
|
12394
|
-
var INHERITABLE_BASE_STYLE_PROPS = [
|
|
12395
|
-
'opacity',
|
|
12396
|
-
'fillOpacity',
|
|
12397
|
-
'strokeOpacity',
|
|
12398
|
-
'transformOrigin',
|
|
12399
|
-
'visibility',
|
|
12400
|
-
'pointerEvents',
|
|
12401
|
-
'lineWidth',
|
|
12402
|
-
'lineCap',
|
|
12403
|
-
'lineJoin',
|
|
12404
|
-
'increasedLineWidthForHitTesting',
|
|
12405
|
-
];
|
|
12406
|
-
var INHERITABLE_STYLE_PROPS = __spreadArray(__spreadArray([], __read(INHERITABLE_BASE_STYLE_PROPS), false), [
|
|
12407
|
-
'fontSize',
|
|
12408
|
-
'fontFamily',
|
|
12409
|
-
'fontStyle',
|
|
12410
|
-
'fontWeight',
|
|
12411
|
-
'fontVariant',
|
|
12412
|
-
'textAlign',
|
|
12413
|
-
'textBaseline',
|
|
12414
|
-
'textTransform',
|
|
12415
|
-
], false);
|
|
12416
|
-
var DATASET_PREFIX = 'data-';
|
|
11805
|
+
var $vec3 = vec3.create();
|
|
11806
|
+
var $quat = quat$1.create();
|
|
12417
11807
|
/**
|
|
12418
11808
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
12419
11809
|
*
|
|
@@ -12446,38 +11836,17 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12446
11836
|
// eg. group.get('name')
|
|
12447
11837
|
_this.config = config;
|
|
12448
11838
|
// init scene graph node
|
|
12449
|
-
_this.id =
|
|
12450
|
-
_this.name =
|
|
12451
|
-
if (
|
|
12452
|
-
_this.className =
|
|
12453
|
-
}
|
|
12454
|
-
_this.nodeName = _this.config.type || Shape.GROUP;
|
|
12455
|
-
if (runtime.enableCSSParsing) {
|
|
12456
|
-
Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
|
|
12457
|
-
Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
|
|
11839
|
+
_this.id = config.id || '';
|
|
11840
|
+
_this.name = config.name || '';
|
|
11841
|
+
if (config.className || config.class) {
|
|
11842
|
+
_this.className = config.className || config.class;
|
|
12458
11843
|
}
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
_this.config.initialParsedStyle);
|
|
11844
|
+
_this.nodeName = config.type || Shape.GROUP;
|
|
11845
|
+
if (config.initialParsedStyle) {
|
|
11846
|
+
Object.assign(_this.parsedStyle, config.initialParsedStyle);
|
|
12463
11847
|
}
|
|
12464
11848
|
// start to process attributes
|
|
12465
|
-
_this.initAttributes(
|
|
12466
|
-
if (runtime.enableDataset) {
|
|
12467
|
-
_this.dataset = new Proxy({}, {
|
|
12468
|
-
get: function (target, name) {
|
|
12469
|
-
var formattedName = "".concat(DATASET_PREFIX).concat(kebabize(name));
|
|
12470
|
-
if (target[formattedName] !== undefined) {
|
|
12471
|
-
return target[formattedName];
|
|
12472
|
-
}
|
|
12473
|
-
return _this.getAttribute(formattedName);
|
|
12474
|
-
},
|
|
12475
|
-
set: function (_, prop, value) {
|
|
12476
|
-
_this.setAttribute("".concat(DATASET_PREFIX).concat(kebabize(prop)), value);
|
|
12477
|
-
return true;
|
|
12478
|
-
},
|
|
12479
|
-
});
|
|
12480
|
-
}
|
|
11849
|
+
_this.initAttributes(config.style);
|
|
12481
11850
|
if (runtime.enableStyleSyntax) {
|
|
12482
11851
|
_this.style = new Proxy(
|
|
12483
11852
|
// @ts-ignore
|
|
@@ -12517,13 +11886,6 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12517
11886
|
this.getAnimations().forEach(function (animation) {
|
|
12518
11887
|
animation.cancel();
|
|
12519
11888
|
});
|
|
12520
|
-
// FIXME
|
|
12521
|
-
// this.renderable = null;
|
|
12522
|
-
// this.cullable = null;
|
|
12523
|
-
// this.transformable = null;
|
|
12524
|
-
// this.rBushNode = null;
|
|
12525
|
-
// this.geometry = null;
|
|
12526
|
-
// this.sortable = null;
|
|
12527
11889
|
};
|
|
12528
11890
|
DisplayObject.prototype.cloneNode = function (deep, customCloneFunc) {
|
|
12529
11891
|
var clonedStyle = __assign({}, this.attributes);
|
|
@@ -12566,39 +11928,16 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12566
11928
|
};
|
|
12567
11929
|
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
12568
11930
|
if (attributes === void 0) { attributes = {}; }
|
|
12569
|
-
var renderable = this.renderable;
|
|
12570
11931
|
var options = {
|
|
12571
11932
|
forceUpdateGeometry: true,
|
|
12572
|
-
// usedAttributes:
|
|
12573
|
-
// // only Group / Text should account for text relative props
|
|
12574
|
-
// this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
|
|
12575
|
-
// ? INHERITABLE_STYLE_PROPS
|
|
12576
|
-
// : INHERITABLE_BASE_STYLE_PROPS,
|
|
12577
11933
|
};
|
|
12578
|
-
|
|
12579
|
-
// @ts-ignore
|
|
12580
|
-
options.usedAttributes = INHERITABLE_STYLE_PROPS;
|
|
12581
|
-
}
|
|
12582
|
-
// account for FCP, process properties as less as possible
|
|
12583
|
-
var formattedAttributes = attributes;
|
|
12584
|
-
if (runtime.enableAttributeDashCased) {
|
|
12585
|
-
// @ts-ignore
|
|
12586
|
-
formattedAttributes = {};
|
|
12587
|
-
for (var name_1 in attributes) {
|
|
12588
|
-
var attributeName = formatAttributeName(name_1);
|
|
12589
|
-
formattedAttributes[attributeName] = attributes[name_1];
|
|
12590
|
-
}
|
|
12591
|
-
}
|
|
12592
|
-
runtime.styleValueRegistry.processProperties(this, formattedAttributes, options);
|
|
11934
|
+
runtime.styleValueRegistry.processProperties(this, attributes, options);
|
|
12593
11935
|
// redraw at next frame
|
|
12594
|
-
renderable.dirty = true;
|
|
11936
|
+
this.renderable.dirty = true;
|
|
12595
11937
|
};
|
|
12596
11938
|
DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
|
|
12597
11939
|
if (force === void 0) { force = false; }
|
|
12598
11940
|
if (memoize === void 0) { memoize = true; }
|
|
12599
|
-
if (runtime.enableAttributeDashCased) {
|
|
12600
|
-
name = formatAttributeName(name);
|
|
12601
|
-
}
|
|
12602
11941
|
// ignore undefined value
|
|
12603
11942
|
if (isUndefined(value)) {
|
|
12604
11943
|
return;
|
|
@@ -12660,7 +11999,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12660
11999
|
DisplayObject.prototype.setOrigin = function (position, y, z) {
|
|
12661
12000
|
if (y === void 0) { y = 0; }
|
|
12662
12001
|
if (z === void 0) { z = 0; }
|
|
12663
|
-
runtime.sceneGraphService.setOrigin(this, createVec3(position, y, z));
|
|
12002
|
+
runtime.sceneGraphService.setOrigin(this, createVec3(position, y, z, false));
|
|
12664
12003
|
return this;
|
|
12665
12004
|
};
|
|
12666
12005
|
DisplayObject.prototype.getOrigin = function () {
|
|
@@ -12672,7 +12011,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12672
12011
|
DisplayObject.prototype.setPosition = function (position, y, z) {
|
|
12673
12012
|
if (y === void 0) { y = 0; }
|
|
12674
12013
|
if (z === void 0) { z = 0; }
|
|
12675
|
-
runtime.sceneGraphService.setPosition(this, createVec3(position, y, z));
|
|
12014
|
+
runtime.sceneGraphService.setPosition(this, createVec3(position, y, z, false));
|
|
12676
12015
|
return this;
|
|
12677
12016
|
};
|
|
12678
12017
|
/**
|
|
@@ -12681,7 +12020,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12681
12020
|
DisplayObject.prototype.setLocalPosition = function (position, y, z) {
|
|
12682
12021
|
if (y === void 0) { y = 0; }
|
|
12683
12022
|
if (z === void 0) { z = 0; }
|
|
12684
|
-
runtime.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
|
|
12023
|
+
runtime.sceneGraphService.setLocalPosition(this, createVec3(position, y, z, false));
|
|
12685
12024
|
return this;
|
|
12686
12025
|
};
|
|
12687
12026
|
/**
|
|
@@ -12690,7 +12029,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12690
12029
|
DisplayObject.prototype.translate = function (position, y, z) {
|
|
12691
12030
|
if (y === void 0) { y = 0; }
|
|
12692
12031
|
if (z === void 0) { z = 0; }
|
|
12693
|
-
runtime.sceneGraphService.translate(this, createVec3(position, y, z));
|
|
12032
|
+
runtime.sceneGraphService.translate(this, createVec3(position, y, z, false));
|
|
12694
12033
|
return this;
|
|
12695
12034
|
};
|
|
12696
12035
|
/**
|
|
@@ -12699,7 +12038,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12699
12038
|
DisplayObject.prototype.translateLocal = function (position, y, z) {
|
|
12700
12039
|
if (y === void 0) { y = 0; }
|
|
12701
12040
|
if (z === void 0) { z = 0; }
|
|
12702
|
-
runtime.sceneGraphService.translateLocal(this, createVec3(position, y, z));
|
|
12041
|
+
runtime.sceneGraphService.translateLocal(this, createVec3(position, y, z, false));
|
|
12703
12042
|
return this;
|
|
12704
12043
|
};
|
|
12705
12044
|
DisplayObject.prototype.getPosition = function () {
|
|
@@ -12723,7 +12062,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12723
12062
|
if (typeof scaling === 'number') {
|
|
12724
12063
|
y = y || scaling;
|
|
12725
12064
|
z = z || scaling;
|
|
12726
|
-
scaling = createVec3(scaling, y, z);
|
|
12065
|
+
scaling = createVec3(scaling, y, z, false);
|
|
12727
12066
|
}
|
|
12728
12067
|
runtime.sceneGraphService.scaleLocal(this, scaling);
|
|
12729
12068
|
return this;
|
|
@@ -12735,7 +12074,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12735
12074
|
if (typeof scaling === 'number') {
|
|
12736
12075
|
y = y || scaling;
|
|
12737
12076
|
z = z || scaling;
|
|
12738
|
-
scaling = createVec3(scaling, y, z);
|
|
12077
|
+
scaling = createVec3(scaling, y, z, false);
|
|
12739
12078
|
}
|
|
12740
12079
|
runtime.sceneGraphService.setLocalScale(this, scaling);
|
|
12741
12080
|
return this;
|
|
@@ -12756,14 +12095,14 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12756
12095
|
* only return degrees of Z axis in world space
|
|
12757
12096
|
*/
|
|
12758
12097
|
DisplayObject.prototype.getEulerAngles = function () {
|
|
12759
|
-
var _a = __read(getEuler(vec3
|
|
12098
|
+
var _a = __read(getEuler($vec3, runtime.sceneGraphService.getWorldTransform(this)), 3), ez = _a[2];
|
|
12760
12099
|
return rad2deg(ez);
|
|
12761
12100
|
};
|
|
12762
12101
|
/**
|
|
12763
12102
|
* only return degrees of Z axis in local space
|
|
12764
12103
|
*/
|
|
12765
12104
|
DisplayObject.prototype.getLocalEulerAngles = function () {
|
|
12766
|
-
var _a = __read(getEuler(vec3
|
|
12105
|
+
var _a = __read(getEuler($vec3, runtime.sceneGraphService.getLocalRotation(this)), 3), ez = _a[2];
|
|
12767
12106
|
return rad2deg(ez);
|
|
12768
12107
|
};
|
|
12769
12108
|
/**
|
|
@@ -12859,10 +12198,8 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12859
12198
|
* shortcut for Used value of `visibility`
|
|
12860
12199
|
*/
|
|
12861
12200
|
DisplayObject.prototype.isVisible = function () {
|
|
12862
|
-
var _a
|
|
12863
|
-
return
|
|
12864
|
-
? ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible'
|
|
12865
|
-
: ((_b = this.parsedStyle) === null || _b === void 0 ? void 0 : _b.visibility) !== 'hidden';
|
|
12201
|
+
var _a;
|
|
12202
|
+
return ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) !== 'hidden';
|
|
12866
12203
|
};
|
|
12867
12204
|
Object.defineProperty(DisplayObject.prototype, "interactive", {
|
|
12868
12205
|
get: function () {
|
|
@@ -12943,10 +12280,10 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12943
12280
|
*/
|
|
12944
12281
|
DisplayObject.prototype.getMatrix = function (transformMat4) {
|
|
12945
12282
|
var transform = transformMat4 || this.getWorldTransform();
|
|
12946
|
-
var _a = __read(mat4.getTranslation(vec3
|
|
12947
|
-
var _b = __read(mat4.getScaling(vec3
|
|
12948
|
-
var rotation = mat4.getRotation(quat
|
|
12949
|
-
var _c = __read(getEuler(vec3
|
|
12283
|
+
var _a = __read(mat4.getTranslation($vec3, transform), 2), tx = _a[0], ty = _a[1];
|
|
12284
|
+
var _b = __read(mat4.getScaling($vec3, transform), 2), sx = _b[0], sy = _b[1];
|
|
12285
|
+
var rotation = mat4.getRotation($quat, transform);
|
|
12286
|
+
var _c = __read(getEuler($vec3, rotation), 3), eux = _c[0], euz = _c[2];
|
|
12950
12287
|
// gimbal lock at 90 degrees
|
|
12951
12288
|
return fromRotationTranslationScale(eux || euz, tx, ty, sx, sy);
|
|
12952
12289
|
};
|
|
@@ -12982,28 +12319,18 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12982
12319
|
* @deprecated
|
|
12983
12320
|
*/
|
|
12984
12321
|
DisplayObject.prototype.show = function () {
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
}
|
|
12988
|
-
else {
|
|
12989
|
-
this.forEach(function (object) {
|
|
12990
|
-
object.style.visibility = 'visible';
|
|
12991
|
-
});
|
|
12992
|
-
}
|
|
12322
|
+
this.forEach(function (object) {
|
|
12323
|
+
object.style.visibility = 'visible';
|
|
12324
|
+
});
|
|
12993
12325
|
};
|
|
12994
12326
|
/**
|
|
12995
12327
|
* Use `visibility: hidden` instead.
|
|
12996
12328
|
* @deprecated
|
|
12997
12329
|
*/
|
|
12998
12330
|
DisplayObject.prototype.hide = function () {
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
}
|
|
13002
|
-
else {
|
|
13003
|
-
this.forEach(function (object) {
|
|
13004
|
-
object.style.visibility = 'hidden';
|
|
13005
|
-
});
|
|
13006
|
-
}
|
|
12331
|
+
this.forEach(function (object) {
|
|
12332
|
+
object.style.visibility = 'hidden';
|
|
12333
|
+
});
|
|
13007
12334
|
};
|
|
13008
12335
|
/**
|
|
13009
12336
|
* Use `childElementCount` instead.
|
|
@@ -13118,8 +12445,7 @@ var CustomElement = /** @class */ (function (_super) {
|
|
|
13118
12445
|
if (_a === void 0) { _a = {}; }
|
|
13119
12446
|
var _this = this;
|
|
13120
12447
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13121
|
-
_this = _super.call(this, __assign({ style:
|
|
13122
|
-
? __assign({}, style) : __assign({}, style) }, rest)) || this;
|
|
12448
|
+
_this = _super.call(this, __assign({ style: style }, rest)) || this;
|
|
13123
12449
|
// static get observedAttributes(): string[] {
|
|
13124
12450
|
// return [];
|
|
13125
12451
|
// }
|
|
@@ -13138,6 +12464,23 @@ var Ellipse = /** @class */ (function (_super) {
|
|
|
13138
12464
|
return Ellipse;
|
|
13139
12465
|
}(DisplayObject));
|
|
13140
12466
|
|
|
12467
|
+
/**
|
|
12468
|
+
* 节点片段,用于包裹多个节点并批量操作
|
|
12469
|
+
*
|
|
12470
|
+
* 向 Fragment 或者根节点为 Fragment 的节点添加子节点时,不会触发渲染和事件。
|
|
12471
|
+
*
|
|
12472
|
+
* 当 Fragment 被挂载到 Canvas 中的节点时,其子节点会一次性被渲染,并触发合并事件。
|
|
12473
|
+
*
|
|
12474
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
|
12475
|
+
*/
|
|
12476
|
+
var Fragment = /** @class */ (function (_super) {
|
|
12477
|
+
__extends(Fragment, _super);
|
|
12478
|
+
function Fragment() {
|
|
12479
|
+
return _super.call(this, { type: Shape.FRAGMENT }) || this;
|
|
12480
|
+
}
|
|
12481
|
+
return Fragment;
|
|
12482
|
+
}(DisplayObject));
|
|
12483
|
+
|
|
13141
12484
|
/**
|
|
13142
12485
|
* its attributes are inherited by its children.
|
|
13143
12486
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
|
|
@@ -13167,8 +12510,7 @@ var HTML = /** @class */ (function (_super) {
|
|
|
13167
12510
|
if (_a === void 0) { _a = {}; }
|
|
13168
12511
|
var _this = this;
|
|
13169
12512
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13170
|
-
_this = _super.call(this, __assign({ type: Shape.HTML, style:
|
|
13171
|
-
? __assign({ x: '', y: '', width: 'auto', height: 'auto', innerHTML: '' }, style) : __assign({}, style) }, rest)) || this;
|
|
12513
|
+
_this = _super.call(this, __assign({ type: Shape.HTML, style: style }, rest)) || this;
|
|
13172
12514
|
_this.cullable.enable = false;
|
|
13173
12515
|
return _this;
|
|
13174
12516
|
}
|
|
@@ -13360,13 +12702,10 @@ var Path = /** @class */ (function (_super) {
|
|
|
13360
12702
|
if (_a === void 0) { _a = {}; }
|
|
13361
12703
|
var _this = this;
|
|
13362
12704
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13363
|
-
_this = _super.call(this, __assign({ type: Shape.PATH, style:
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
miterLimit: 4,
|
|
13368
|
-
d: __assign({}, EMPTY_PARSED_PATH),
|
|
13369
|
-
} }, rest)) || this;
|
|
12705
|
+
_this = _super.call(this, __assign({ type: Shape.PATH, style: style, initialParsedStyle: {
|
|
12706
|
+
miterLimit: 4,
|
|
12707
|
+
d: __assign({}, EMPTY_PARSED_PATH),
|
|
12708
|
+
} }, rest)) || this;
|
|
13370
12709
|
_this.markerStartAngle = 0;
|
|
13371
12710
|
_this.markerEndAngle = 0;
|
|
13372
12711
|
/**
|
|
@@ -13561,18 +12900,15 @@ var Polygon = /** @class */ (function (_super) {
|
|
|
13561
12900
|
if (_a === void 0) { _a = {}; }
|
|
13562
12901
|
var _this = this;
|
|
13563
12902
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13564
|
-
_this = _super.call(this, __assign({ type: Shape.POLYGON, style:
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
miterLimit: 4,
|
|
13574
|
-
isClosed: true,
|
|
13575
|
-
} }, rest)) || this;
|
|
12903
|
+
_this = _super.call(this, __assign({ type: Shape.POLYGON, style: style, initialParsedStyle: {
|
|
12904
|
+
points: {
|
|
12905
|
+
points: [],
|
|
12906
|
+
totalLength: 0,
|
|
12907
|
+
segments: [],
|
|
12908
|
+
},
|
|
12909
|
+
miterLimit: 4,
|
|
12910
|
+
isClosed: true,
|
|
12911
|
+
} }, rest)) || this;
|
|
13576
12912
|
_this.markerStartAngle = 0;
|
|
13577
12913
|
_this.markerEndAngle = 0;
|
|
13578
12914
|
/**
|
|
@@ -13707,18 +13043,15 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13707
13043
|
function Polyline(_a) {
|
|
13708
13044
|
if (_a === void 0) { _a = {}; }
|
|
13709
13045
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13710
|
-
return _super.call(this, __assign({ type: Shape.POLYLINE, style:
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
miterLimit: 4,
|
|
13720
|
-
isClosed: false,
|
|
13721
|
-
} }, rest)) || this;
|
|
13046
|
+
return _super.call(this, __assign({ type: Shape.POLYLINE, style: style, initialParsedStyle: {
|
|
13047
|
+
points: {
|
|
13048
|
+
points: [],
|
|
13049
|
+
totalLength: 0,
|
|
13050
|
+
segments: [],
|
|
13051
|
+
},
|
|
13052
|
+
miterLimit: 4,
|
|
13053
|
+
isClosed: false,
|
|
13054
|
+
} }, rest)) || this;
|
|
13722
13055
|
}
|
|
13723
13056
|
Polyline.prototype.getTotalLength = function () {
|
|
13724
13057
|
return getOrCalculatePolylineTotalLength(this);
|
|
@@ -13802,16 +13135,8 @@ var Text = /** @class */ (function (_super) {
|
|
|
13802
13135
|
function Text(_a) {
|
|
13803
13136
|
if (_a === void 0) { _a = {}; }
|
|
13804
13137
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13805
|
-
return _super.call(this, __assign({ type: Shape.TEXT, style:
|
|
13806
|
-
|
|
13807
|
-
// whiteSpace: 'pre',
|
|
13808
|
-
wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style) }, rest)) || this;
|
|
13809
|
-
}
|
|
13810
|
-
// lengthAdjust: SVGAnimatedEnumeration;
|
|
13811
|
-
// textLength: SVGAnimatedLength;
|
|
13812
|
-
// getCharNumAtPosition(point?: DOMPointInit): number {
|
|
13813
|
-
// throw new Error('Method not implemented.');
|
|
13814
|
-
// }
|
|
13138
|
+
return _super.call(this, __assign({ type: Shape.TEXT, style: __assign({ fill: 'black' }, style) }, rest)) || this;
|
|
13139
|
+
}
|
|
13815
13140
|
/**
|
|
13816
13141
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
|
|
13817
13142
|
*/
|
|
@@ -13820,27 +13145,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
13820
13145
|
this.getGeometryBounds();
|
|
13821
13146
|
return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
|
|
13822
13147
|
};
|
|
13823
|
-
// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
13824
|
-
// throw new Error('Method not implemented.');
|
|
13825
|
-
// }
|
|
13826
|
-
// getExtentOfChar(charnum: number): DOMRect {
|
|
13827
|
-
// throw new Error('Method not implemented.');
|
|
13828
|
-
// }
|
|
13829
|
-
// getNumberOfChars(): number {
|
|
13830
|
-
// throw new Error('Method not implemented.');
|
|
13831
|
-
// }
|
|
13832
|
-
// getRotationOfChar(charnum: number): number {
|
|
13833
|
-
// throw new Error('Method not implemented.');
|
|
13834
|
-
// }
|
|
13835
|
-
// getStartPositionOfChar(charnum: number): DOMPoint {
|
|
13836
|
-
// throw new Error('Method not implemented.');
|
|
13837
|
-
// }
|
|
13838
|
-
// getSubStringLength(charnum: number, nchars: number): number {
|
|
13839
|
-
// throw new Error('Method not implemented.');
|
|
13840
|
-
// }
|
|
13841
|
-
// selectSubString(charnum: number, nchars: number): void {
|
|
13842
|
-
// throw new Error('Method not implemented.');
|
|
13843
|
-
// }
|
|
13844
13148
|
Text.prototype.getLineBoundingRects = function () {
|
|
13845
13149
|
var _a;
|
|
13846
13150
|
this.getGeometryBounds();
|
|
@@ -14795,10 +14099,7 @@ var FrustumCullingStrategy = /** @class */ (function () {
|
|
|
14795
14099
|
|
|
14796
14100
|
var PrepareRendererPlugin = /** @class */ (function () {
|
|
14797
14101
|
function PrepareRendererPlugin() {
|
|
14798
|
-
|
|
14799
|
-
* sync to RBush later
|
|
14800
|
-
*/
|
|
14801
|
-
this.toSync = new Set();
|
|
14102
|
+
this.syncTasks = new Map();
|
|
14802
14103
|
this.isFirstTimeRendering = true;
|
|
14803
14104
|
this.syncing = false;
|
|
14804
14105
|
this.isFirstTimeRenderingFinished = false;
|
|
@@ -14815,21 +14116,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14815
14116
|
renderingService.dirtify();
|
|
14816
14117
|
};
|
|
14817
14118
|
var handleBoundsChanged = function (e) {
|
|
14818
|
-
|
|
14819
|
-
var object = e.target;
|
|
14820
|
-
if (affectChildren) {
|
|
14821
|
-
object.forEach(function (node) {
|
|
14822
|
-
_this.toSync.add(node);
|
|
14823
|
-
});
|
|
14824
|
-
}
|
|
14825
|
-
var p = object;
|
|
14826
|
-
while (p) {
|
|
14827
|
-
if (p.renderable) {
|
|
14828
|
-
_this.toSync.add(p);
|
|
14829
|
-
}
|
|
14830
|
-
p = p.parentElement;
|
|
14831
|
-
}
|
|
14832
|
-
// this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
|
|
14119
|
+
_this.syncTasks.set(e.target, e.detail.affectChildren);
|
|
14833
14120
|
renderingService.dirtify();
|
|
14834
14121
|
};
|
|
14835
14122
|
var handleMounted = function (e) {
|
|
@@ -14837,12 +14124,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14837
14124
|
if (runtime.enableSizeAttenuation) {
|
|
14838
14125
|
runtime.styleValueRegistry.updateSizeAttenuation(object, canvas.getCamera().getZoom());
|
|
14839
14126
|
}
|
|
14840
|
-
if (runtime.enableCSSParsing) {
|
|
14841
|
-
// recalc style values
|
|
14842
|
-
runtime.styleValueRegistry.recalc(object);
|
|
14843
|
-
}
|
|
14844
|
-
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
14845
|
-
renderingService.dirtify();
|
|
14846
14127
|
};
|
|
14847
14128
|
var handleUnmounted = function (e) {
|
|
14848
14129
|
var object = e.target;
|
|
@@ -14850,7 +14131,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14850
14131
|
if (rBushNode.aabb) {
|
|
14851
14132
|
_this.rBush.remove(rBushNode.aabb);
|
|
14852
14133
|
}
|
|
14853
|
-
_this.
|
|
14134
|
+
_this.syncTasks.delete(object);
|
|
14854
14135
|
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
14855
14136
|
renderingService.dirtify();
|
|
14856
14137
|
};
|
|
@@ -14865,7 +14146,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14865
14146
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
14866
14147
|
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
14867
14148
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14868
|
-
_this.
|
|
14149
|
+
_this.syncTasks.clear();
|
|
14869
14150
|
});
|
|
14870
14151
|
var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
|
|
14871
14152
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
@@ -14882,60 +14163,78 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14882
14163
|
}
|
|
14883
14164
|
});
|
|
14884
14165
|
};
|
|
14166
|
+
PrepareRendererPlugin.prototype.syncNode = function (node, force) {
|
|
14167
|
+
if (force === void 0) { force = false; }
|
|
14168
|
+
if (!node.isConnected)
|
|
14169
|
+
return;
|
|
14170
|
+
var rBushNode = node.rBushNode;
|
|
14171
|
+
// clear dirty node
|
|
14172
|
+
if (rBushNode.aabb)
|
|
14173
|
+
this.rBush.remove(rBushNode.aabb);
|
|
14174
|
+
var renderBounds = node.getRenderBounds();
|
|
14175
|
+
if (renderBounds) {
|
|
14176
|
+
var renderable = node.renderable;
|
|
14177
|
+
if (force) {
|
|
14178
|
+
if (!renderable.dirtyRenderBounds) {
|
|
14179
|
+
renderable.dirtyRenderBounds = new AABB();
|
|
14180
|
+
}
|
|
14181
|
+
// save last dirty aabb
|
|
14182
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14183
|
+
}
|
|
14184
|
+
var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14185
|
+
var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14186
|
+
if (!rBushNode.aabb) {
|
|
14187
|
+
rBushNode.aabb = {};
|
|
14188
|
+
}
|
|
14189
|
+
rBushNode.aabb.displayObject = node;
|
|
14190
|
+
rBushNode.aabb.minX = minX;
|
|
14191
|
+
rBushNode.aabb.minY = minY;
|
|
14192
|
+
rBushNode.aabb.maxX = maxX;
|
|
14193
|
+
rBushNode.aabb.maxY = maxY;
|
|
14194
|
+
}
|
|
14195
|
+
if (rBushNode.aabb) {
|
|
14196
|
+
// TODO: NaN occurs when width/height of Rect is 0
|
|
14197
|
+
if (!isNaN(rBushNode.aabb.maxX) &&
|
|
14198
|
+
!isNaN(rBushNode.aabb.maxX) &&
|
|
14199
|
+
!isNaN(rBushNode.aabb.minX) &&
|
|
14200
|
+
!isNaN(rBushNode.aabb.minY)) {
|
|
14201
|
+
return rBushNode.aabb;
|
|
14202
|
+
}
|
|
14203
|
+
}
|
|
14204
|
+
};
|
|
14885
14205
|
PrepareRendererPlugin.prototype.syncRTree = function (force) {
|
|
14886
14206
|
var _this = this;
|
|
14887
14207
|
if (force === void 0) { force = false; }
|
|
14888
|
-
if (!force && (this.syncing || this.
|
|
14208
|
+
if (!force && (this.syncing || this.syncTasks.size === 0)) {
|
|
14889
14209
|
return;
|
|
14890
14210
|
}
|
|
14891
14211
|
this.syncing = true;
|
|
14892
14212
|
// bounds changed, need re-inserting its children
|
|
14893
14213
|
var bulk = [];
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
.
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
_this.rBush.remove(rBushNode.aabb);
|
|
14902
|
-
}
|
|
14903
|
-
var renderBounds = node.getRenderBounds();
|
|
14904
|
-
if (renderBounds) {
|
|
14905
|
-
var renderable = node.renderable;
|
|
14906
|
-
if (force) {
|
|
14907
|
-
if (!renderable.dirtyRenderBounds) {
|
|
14908
|
-
renderable.dirtyRenderBounds = new AABB();
|
|
14909
|
-
}
|
|
14910
|
-
// save last dirty aabb
|
|
14911
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14214
|
+
var synced = new Set();
|
|
14215
|
+
var sync = function (node) {
|
|
14216
|
+
if (!synced.has(node) && node.renderable) {
|
|
14217
|
+
var aabb = _this.syncNode(node, force);
|
|
14218
|
+
if (aabb) {
|
|
14219
|
+
bulk.push(aabb);
|
|
14220
|
+
synced.add(node);
|
|
14912
14221
|
}
|
|
14913
|
-
var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14914
|
-
var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14915
|
-
if (!rBushNode.aabb) {
|
|
14916
|
-
rBushNode.aabb = {};
|
|
14917
|
-
}
|
|
14918
|
-
rBushNode.aabb.displayObject = node;
|
|
14919
|
-
rBushNode.aabb.minX = minX;
|
|
14920
|
-
rBushNode.aabb.minY = minY;
|
|
14921
|
-
rBushNode.aabb.maxX = maxX;
|
|
14922
|
-
rBushNode.aabb.maxY = maxY;
|
|
14923
14222
|
}
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14223
|
+
};
|
|
14224
|
+
this.syncTasks.forEach(function (affectChildren, node) {
|
|
14225
|
+
if (affectChildren) {
|
|
14226
|
+
node.forEach(sync);
|
|
14227
|
+
}
|
|
14228
|
+
var parent = node;
|
|
14229
|
+
while (parent) {
|
|
14230
|
+
sync(parent);
|
|
14231
|
+
parent = parent.parentElement;
|
|
14932
14232
|
}
|
|
14933
14233
|
});
|
|
14934
14234
|
// use bulk inserting, which is ~2-3 times faster
|
|
14935
14235
|
// @see https://github.com/mourner/rbush#bulk-inserting-data
|
|
14936
14236
|
this.rBush.load(bulk);
|
|
14937
14237
|
bulk.length = 0;
|
|
14938
|
-
this.toSync.clear();
|
|
14939
14238
|
this.syncing = false;
|
|
14940
14239
|
};
|
|
14941
14240
|
PrepareRendererPlugin.tag = 'Prepare';
|
|
@@ -14985,15 +14284,16 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
14985
14284
|
*/
|
|
14986
14285
|
_this.Element = DisplayObject;
|
|
14987
14286
|
_this.inited = false;
|
|
14287
|
+
_this.destroyed = false;
|
|
14988
14288
|
_this.context = {};
|
|
14989
14289
|
// create document
|
|
14990
14290
|
_this.document = new Document();
|
|
14991
14291
|
_this.document.defaultView = _this;
|
|
14992
14292
|
// create registry of custom elements
|
|
14993
14293
|
_this.customElements = new CustomElementRegistry();
|
|
14994
|
-
var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent, dblClickSpeed = config.dblClickSpeed;
|
|
14294
|
+
var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, _a = config.cleanUpOnDestroy, cleanUpOnDestroy = _a === void 0 ? true : _a, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent, dblClickSpeed = config.dblClickSpeed;
|
|
14995
14295
|
if (!supportsMutipleCanvasesInOneContainer) {
|
|
14996
|
-
cleanExistedCanvas(container, _this);
|
|
14296
|
+
cleanExistedCanvas(container, _this, cleanUpOnDestroy);
|
|
14997
14297
|
}
|
|
14998
14298
|
var canvasWidth = width;
|
|
14999
14299
|
var canvasHeight = height;
|
|
@@ -15054,6 +14354,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15054
14354
|
document: document,
|
|
15055
14355
|
supportsCSSTransform: supportsCSSTransform,
|
|
15056
14356
|
useNativeClickEvent: useNativeClickEvent,
|
|
14357
|
+
cleanUpOnDestroy: cleanUpOnDestroy,
|
|
15057
14358
|
alwaysTriggerPointerEventOnCanvas: alwaysTriggerPointerEventOnCanvas,
|
|
15058
14359
|
});
|
|
15059
14360
|
_this.initDefaultCamera(canvasWidth, canvasHeight, renderer.clipSpaceNearZ);
|
|
@@ -15164,7 +14465,8 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15164
14465
|
*/
|
|
15165
14466
|
Canvas.prototype.destroy = function (cleanUp, skipTriggerEvent) {
|
|
15166
14467
|
if (cleanUp === void 0) { cleanUp = true; }
|
|
15167
|
-
if (skipTriggerEvent ===
|
|
14468
|
+
if (skipTriggerEvent === undefined)
|
|
14469
|
+
skipTriggerEvent = this.getConfig().fastCleanExistingCanvas;
|
|
15168
14470
|
if (!skipTriggerEvent) {
|
|
15169
14471
|
this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
|
|
15170
14472
|
}
|
|
@@ -15193,6 +14495,17 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15193
14495
|
if (!skipTriggerEvent) {
|
|
15194
14496
|
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY));
|
|
15195
14497
|
}
|
|
14498
|
+
var clearEventRetain = function (event) {
|
|
14499
|
+
event.currentTarget = null;
|
|
14500
|
+
event.manager = null;
|
|
14501
|
+
event.target = null;
|
|
14502
|
+
};
|
|
14503
|
+
clearEventRetain(mountedEvent);
|
|
14504
|
+
clearEventRetain(unmountedEvent);
|
|
14505
|
+
clearEventRetain(beforeRenderEvent);
|
|
14506
|
+
clearEventRetain(rerenderEvent);
|
|
14507
|
+
clearEventRetain(afterRenderEvent);
|
|
14508
|
+
this.destroyed = true;
|
|
15196
14509
|
};
|
|
15197
14510
|
/**
|
|
15198
14511
|
* compatible with G 3.0
|
|
@@ -15264,6 +14577,8 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15264
14577
|
Canvas.prototype.run = function () {
|
|
15265
14578
|
var _this = this;
|
|
15266
14579
|
var tick = function (time, frame) {
|
|
14580
|
+
if (_this.destroyed)
|
|
14581
|
+
return _this.cancelAnimationFrame(_this.frameId);
|
|
15267
14582
|
_this.render(frame);
|
|
15268
14583
|
_this.frameId = _this.requestAnimationFrame(tick);
|
|
15269
14584
|
};
|
|
@@ -15380,12 +14695,14 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15380
14695
|
_this.unmountChildren(child);
|
|
15381
14696
|
});
|
|
15382
14697
|
if (this.inited) {
|
|
15383
|
-
if (
|
|
15384
|
-
parent.
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
14698
|
+
if (!this.getConfig().cleanUpOnDestroy) {
|
|
14699
|
+
if (parent.isMutationObserved) {
|
|
14700
|
+
parent.dispatchEvent(unmountedEvent);
|
|
14701
|
+
}
|
|
14702
|
+
else {
|
|
14703
|
+
unmountedEvent.target = parent;
|
|
14704
|
+
this.dispatchEvent(unmountedEvent, true);
|
|
14705
|
+
}
|
|
15389
14706
|
}
|
|
15390
14707
|
// skip document.documentElement
|
|
15391
14708
|
if (parent !== this.document.documentElement) {
|
|
@@ -15400,35 +14717,41 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15400
14717
|
}
|
|
15401
14718
|
}
|
|
15402
14719
|
};
|
|
15403
|
-
Canvas.prototype.mountChildren = function (
|
|
14720
|
+
Canvas.prototype.mountChildren = function (child, skipTriggerEvent) {
|
|
15404
14721
|
var _this = this;
|
|
14722
|
+
if (skipTriggerEvent === void 0) { skipTriggerEvent = isInFragment(child); }
|
|
15405
14723
|
if (this.inited) {
|
|
15406
|
-
if (!
|
|
15407
|
-
|
|
15408
|
-
|
|
15409
|
-
if (
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
14724
|
+
if (!child.isConnected) {
|
|
14725
|
+
child.ownerDocument = this.document;
|
|
14726
|
+
child.isConnected = true;
|
|
14727
|
+
if (!skipTriggerEvent) {
|
|
14728
|
+
if (child.isMutationObserved) {
|
|
14729
|
+
child.dispatchEvent(mountedEvent);
|
|
14730
|
+
}
|
|
14731
|
+
else {
|
|
14732
|
+
mountedEvent.target = child;
|
|
14733
|
+
this.dispatchEvent(mountedEvent, true);
|
|
14734
|
+
}
|
|
15415
14735
|
}
|
|
15416
14736
|
}
|
|
15417
14737
|
}
|
|
15418
14738
|
else {
|
|
15419
|
-
console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ',
|
|
14739
|
+
console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', child.nodeName);
|
|
15420
14740
|
}
|
|
15421
14741
|
// recursively mount children
|
|
15422
|
-
|
|
15423
|
-
_this.mountChildren(
|
|
14742
|
+
child.childNodes.forEach(function (c) {
|
|
14743
|
+
_this.mountChildren(c, skipTriggerEvent);
|
|
15424
14744
|
});
|
|
15425
14745
|
// trigger after mounted
|
|
15426
|
-
if (
|
|
15427
|
-
if (
|
|
15428
|
-
|
|
14746
|
+
if (child.isCustomElement) {
|
|
14747
|
+
if (child.connectedCallback) {
|
|
14748
|
+
child.connectedCallback();
|
|
15429
14749
|
}
|
|
15430
14750
|
}
|
|
15431
14751
|
};
|
|
14752
|
+
Canvas.prototype.mountFragment = function (child) {
|
|
14753
|
+
this.mountChildren(child, false);
|
|
14754
|
+
};
|
|
15432
14755
|
Canvas.prototype.client2Viewport = function (client) {
|
|
15433
14756
|
return this.getEventService().client2Viewport(client);
|
|
15434
14757
|
};
|
|
@@ -15458,5 +14781,5 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15458
14781
|
return Canvas;
|
|
15459
14782
|
}(EventTarget));
|
|
15460
14783
|
|
|
15461
|
-
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
|
|
14784
|
+
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Fragment, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
|
|
15462
14785
|
//# sourceMappingURL=index.esm.js.map
|