@antv/g-lite 2.0.11 → 2.1.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 +2 -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 +1512 -2192
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1495 -2174
- 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/services/interfaces.d.ts +6 -5
- 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.js
CHANGED
|
@@ -609,6 +609,7 @@ var RBush = rbush.exports;
|
|
|
609
609
|
exports.Shape = void 0;
|
|
610
610
|
(function (Shape) {
|
|
611
611
|
Shape["GROUP"] = "g";
|
|
612
|
+
Shape["FRAGMENT"] = "fragment";
|
|
612
613
|
Shape["CIRCLE"] = "circle";
|
|
613
614
|
Shape["ELLIPSE"] = "ellipse";
|
|
614
615
|
Shape["IMAGE"] = "image";
|
|
@@ -691,366 +692,7 @@ var AbstractRenderer = /** @class */ (function () {
|
|
|
691
692
|
return AbstractRenderer;
|
|
692
693
|
}());
|
|
693
694
|
|
|
694
|
-
|
|
695
|
-
a[0] = b[0];
|
|
696
|
-
a[1] = b[1];
|
|
697
|
-
a[2] = b[2];
|
|
698
|
-
return a;
|
|
699
|
-
}
|
|
700
|
-
function subVec3(o, a, b) {
|
|
701
|
-
o[0] = a[0] - b[0];
|
|
702
|
-
o[1] = a[1] - b[1];
|
|
703
|
-
o[2] = a[2] - b[2];
|
|
704
|
-
return o;
|
|
705
|
-
}
|
|
706
|
-
function addVec3(o, a, b) {
|
|
707
|
-
o[0] = a[0] + b[0];
|
|
708
|
-
o[1] = a[1] + b[1];
|
|
709
|
-
o[2] = a[2] + b[2];
|
|
710
|
-
return o;
|
|
711
|
-
}
|
|
712
|
-
function scaleVec3(o, a, b) {
|
|
713
|
-
o[0] = a[0] * b;
|
|
714
|
-
o[1] = a[1] * b;
|
|
715
|
-
o[2] = a[2] * b;
|
|
716
|
-
return o;
|
|
717
|
-
}
|
|
718
|
-
function maxVec3(o, a, b) {
|
|
719
|
-
o[0] = Math.max(a[0], b[0]);
|
|
720
|
-
o[1] = Math.max(a[1], b[1]);
|
|
721
|
-
o[2] = Math.max(a[2], b[2]);
|
|
722
|
-
return o;
|
|
723
|
-
}
|
|
724
|
-
function minVec3(o, a, b) {
|
|
725
|
-
o[0] = Math.min(a[0], b[0]);
|
|
726
|
-
o[1] = Math.min(a[1], b[1]);
|
|
727
|
-
o[2] = Math.min(a[2], b[2]);
|
|
728
|
-
return o;
|
|
729
|
-
}
|
|
730
|
-
function getAngle(angle) {
|
|
731
|
-
if (angle === undefined) {
|
|
732
|
-
return 0;
|
|
733
|
-
}
|
|
734
|
-
else if (angle > 360 || angle < -360) {
|
|
735
|
-
return angle % 360;
|
|
736
|
-
}
|
|
737
|
-
return angle;
|
|
738
|
-
}
|
|
739
|
-
function createVec3(x, y, z) {
|
|
740
|
-
if (y === void 0) { y = 0; }
|
|
741
|
-
if (z === void 0) { z = 0; }
|
|
742
|
-
if (Array.isArray(x) && x.length === 3) {
|
|
743
|
-
return glMatrix.vec3.clone(x);
|
|
744
|
-
}
|
|
745
|
-
if (util.isNumber(x)) {
|
|
746
|
-
return glMatrix.vec3.fromValues(x, y, z);
|
|
747
|
-
}
|
|
748
|
-
return glMatrix.vec3.fromValues(x[0], x[1] || y, x[2] || z);
|
|
749
|
-
}
|
|
750
|
-
function deg2rad(deg) {
|
|
751
|
-
return deg * (Math.PI / 180);
|
|
752
|
-
}
|
|
753
|
-
function rad2deg(rad) {
|
|
754
|
-
return rad * (180 / Math.PI);
|
|
755
|
-
}
|
|
756
|
-
function grad2deg(grads) {
|
|
757
|
-
grads = grads % 400;
|
|
758
|
-
if (grads < 0) {
|
|
759
|
-
grads += 400;
|
|
760
|
-
}
|
|
761
|
-
return (grads / 400) * 360;
|
|
762
|
-
}
|
|
763
|
-
function deg2turn(deg) {
|
|
764
|
-
return deg / 360;
|
|
765
|
-
}
|
|
766
|
-
function turn2deg(turn) {
|
|
767
|
-
return 360 * turn;
|
|
768
|
-
}
|
|
769
|
-
function getEulerFromQuat(out, quat) {
|
|
770
|
-
var x = quat[0];
|
|
771
|
-
var y = quat[1];
|
|
772
|
-
var z = quat[2];
|
|
773
|
-
var w = quat[3];
|
|
774
|
-
var x2 = x * x;
|
|
775
|
-
var y2 = y * y;
|
|
776
|
-
var z2 = z * z;
|
|
777
|
-
var w2 = w * w;
|
|
778
|
-
var unit = x2 + y2 + z2 + w2;
|
|
779
|
-
var test = x * w - y * z;
|
|
780
|
-
if (test > 0.499995 * unit) {
|
|
781
|
-
// TODO: Use glmatrix.EPSILON
|
|
782
|
-
// singularity at the north pole
|
|
783
|
-
out[0] = Math.PI / 2;
|
|
784
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
785
|
-
out[2] = 0;
|
|
786
|
-
}
|
|
787
|
-
else if (test < -0.499995 * unit) {
|
|
788
|
-
//TODO: Use glmatrix.EPSILON
|
|
789
|
-
// singularity at the south pole
|
|
790
|
-
out[0] = -Math.PI / 2;
|
|
791
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
792
|
-
out[2] = 0;
|
|
793
|
-
}
|
|
794
|
-
else {
|
|
795
|
-
out[0] = Math.asin(2 * (x * z - w * y));
|
|
796
|
-
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
797
|
-
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
798
|
-
}
|
|
799
|
-
// TODO: Return them as degrees and not as radians
|
|
800
|
-
return out;
|
|
801
|
-
}
|
|
802
|
-
function getEulerFromMat4(out, m) {
|
|
803
|
-
var x;
|
|
804
|
-
var z;
|
|
805
|
-
var halfPi = Math.PI * 0.5;
|
|
806
|
-
var _a = tslib.__read(glMatrix.mat4.getScaling(glMatrix.vec3.create(), m), 3), sx = _a[0], sy = _a[1], sz = _a[2];
|
|
807
|
-
var y = Math.asin(-m[2] / sx);
|
|
808
|
-
if (y < halfPi) {
|
|
809
|
-
if (y > -halfPi) {
|
|
810
|
-
x = Math.atan2(m[6] / sy, m[10] / sz);
|
|
811
|
-
z = Math.atan2(m[1] / sx, m[0] / sx);
|
|
812
|
-
}
|
|
813
|
-
else {
|
|
814
|
-
// Not a unique solution
|
|
815
|
-
z = 0;
|
|
816
|
-
x = -Math.atan2(m[4] / sy, m[5] / sy);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
// Not a unique solution
|
|
821
|
-
z = 0;
|
|
822
|
-
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
823
|
-
}
|
|
824
|
-
out[0] = x;
|
|
825
|
-
out[1] = y;
|
|
826
|
-
out[2] = z;
|
|
827
|
-
return out;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* @see https://github.com/toji/gl-matrix/issues/329
|
|
831
|
-
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
832
|
-
*/
|
|
833
|
-
function getEuler(out, quat) {
|
|
834
|
-
if (quat.length === 16) {
|
|
835
|
-
return getEulerFromMat4(out, quat);
|
|
836
|
-
}
|
|
837
|
-
else {
|
|
838
|
-
return getEulerFromQuat(out, quat);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
function fromRotationTranslationScale(rotation, x, y, scaleX, scaleY) {
|
|
842
|
-
var cos = Math.cos(rotation);
|
|
843
|
-
var sin = Math.sin(rotation);
|
|
844
|
-
return glMatrix.mat3.fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
845
|
-
}
|
|
846
|
-
function makePerspective(out, left, right, top, bottom, near, far, zero) {
|
|
847
|
-
if (zero === void 0) { zero = false; }
|
|
848
|
-
var x = (2 * near) / (right - left);
|
|
849
|
-
var y = (2 * near) / (top - bottom);
|
|
850
|
-
var a = (right + left) / (right - left);
|
|
851
|
-
var b = (top + bottom) / (top - bottom);
|
|
852
|
-
var c;
|
|
853
|
-
var d;
|
|
854
|
-
if (zero) {
|
|
855
|
-
c = -far / (far - near);
|
|
856
|
-
d = (-far * near) / (far - near);
|
|
857
|
-
}
|
|
858
|
-
else {
|
|
859
|
-
c = -(far + near) / (far - near);
|
|
860
|
-
d = (-2 * far * near) / (far - near);
|
|
861
|
-
}
|
|
862
|
-
out[0] = x;
|
|
863
|
-
out[1] = 0;
|
|
864
|
-
out[2] = 0;
|
|
865
|
-
out[3] = 0;
|
|
866
|
-
out[4] = 0;
|
|
867
|
-
out[5] = y;
|
|
868
|
-
out[6] = 0;
|
|
869
|
-
out[7] = 0;
|
|
870
|
-
out[8] = a;
|
|
871
|
-
out[9] = b;
|
|
872
|
-
out[10] = c;
|
|
873
|
-
out[11] = -1;
|
|
874
|
-
out[12] = 0;
|
|
875
|
-
out[13] = 0;
|
|
876
|
-
out[14] = d;
|
|
877
|
-
out[15] = 0;
|
|
878
|
-
return out;
|
|
879
|
-
}
|
|
880
|
-
function decompose(mat) {
|
|
881
|
-
var row0x = mat[0];
|
|
882
|
-
var row0y = mat[1];
|
|
883
|
-
var row1x = mat[3];
|
|
884
|
-
var row1y = mat[4];
|
|
885
|
-
// decompose 3x3 matrix
|
|
886
|
-
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
887
|
-
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
888
|
-
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y);
|
|
889
|
-
// If determinant is negative, one axis was flipped.
|
|
890
|
-
var determinant = row0x * row1y - row0y * row1x;
|
|
891
|
-
if (determinant < 0) {
|
|
892
|
-
// Flip axis with minimum unit vector dot product.
|
|
893
|
-
if (row0x < row1y) {
|
|
894
|
-
scalingX = -scalingX;
|
|
895
|
-
}
|
|
896
|
-
else {
|
|
897
|
-
scalingY = -scalingY;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
// Renormalize matrix to remove scale.
|
|
901
|
-
if (scalingX) {
|
|
902
|
-
row0x *= 1 / scalingX;
|
|
903
|
-
row0y *= 1 / scalingX;
|
|
904
|
-
}
|
|
905
|
-
if (scalingY) {
|
|
906
|
-
row1x *= 1 / scalingY;
|
|
907
|
-
row1y *= 1 / scalingY;
|
|
908
|
-
}
|
|
909
|
-
// Compute rotation and renormalize matrix.
|
|
910
|
-
var rotation = Math.atan2(row0y, row0x);
|
|
911
|
-
var angle = rad2deg(rotation);
|
|
912
|
-
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
913
|
-
}
|
|
914
|
-
var tmp = glMatrix.mat4.create();
|
|
915
|
-
var perspectiveMatrix = glMatrix.mat4.create();
|
|
916
|
-
var tmpVec4 = glMatrix.vec4.create();
|
|
917
|
-
var row = [glMatrix.vec3.create(), glMatrix.vec3.create(), glMatrix.vec3.create()];
|
|
918
|
-
var pdum3 = glMatrix.vec3.create();
|
|
919
|
-
/*
|
|
920
|
-
Input: matrix ; a 4x4 matrix
|
|
921
|
-
Output: translation ; a 3 component vector
|
|
922
|
-
scale ; a 3 component vector
|
|
923
|
-
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
924
|
-
perspective ; a 4 component vector
|
|
925
|
-
quaternion ; a 4 component vector
|
|
926
|
-
Returns false if the matrix cannot be decomposed, true if it can
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
References:
|
|
930
|
-
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
931
|
-
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
932
|
-
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
933
|
-
*/
|
|
934
|
-
function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
935
|
-
//normalize, if not possible then bail out early
|
|
936
|
-
if (!normalize(tmp, matrix))
|
|
937
|
-
return false;
|
|
938
|
-
// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
939
|
-
// an easy way to test for singularity of the upper 3x3 component.
|
|
940
|
-
glMatrix.mat4.copy(perspectiveMatrix, tmp);
|
|
941
|
-
perspectiveMatrix[3] = 0;
|
|
942
|
-
perspectiveMatrix[7] = 0;
|
|
943
|
-
perspectiveMatrix[11] = 0;
|
|
944
|
-
perspectiveMatrix[15] = 1;
|
|
945
|
-
// If the perspectiveMatrix is not invertible, we are also unable to
|
|
946
|
-
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
947
|
-
if (Math.abs(glMatrix.mat4.determinant(perspectiveMatrix)) < 1e-8)
|
|
948
|
-
return false;
|
|
949
|
-
var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11], a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
|
|
950
|
-
// First, isolate perspective.
|
|
951
|
-
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
952
|
-
tmpVec4[0] = a03;
|
|
953
|
-
tmpVec4[1] = a13;
|
|
954
|
-
tmpVec4[2] = a23;
|
|
955
|
-
tmpVec4[3] = a33;
|
|
956
|
-
// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
957
|
-
// rightHandSide by the inverse.
|
|
958
|
-
// resuing the perspectiveMatrix here since it's no longer needed
|
|
959
|
-
var ret = glMatrix.mat4.invert(perspectiveMatrix, perspectiveMatrix);
|
|
960
|
-
if (!ret)
|
|
961
|
-
return false;
|
|
962
|
-
glMatrix.mat4.transpose(perspectiveMatrix, perspectiveMatrix);
|
|
963
|
-
//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
964
|
-
glMatrix.vec4.transformMat4(perspective, tmpVec4, perspectiveMatrix);
|
|
965
|
-
}
|
|
966
|
-
else {
|
|
967
|
-
//no perspective
|
|
968
|
-
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
969
|
-
perspective[3] = 1;
|
|
970
|
-
}
|
|
971
|
-
// Next take care of translation
|
|
972
|
-
translation[0] = a30;
|
|
973
|
-
translation[1] = a31;
|
|
974
|
-
translation[2] = a32;
|
|
975
|
-
// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
976
|
-
mat3from4(row, tmp);
|
|
977
|
-
// Compute X scale factor and normalize first row.
|
|
978
|
-
scale[0] = glMatrix.vec3.length(row[0]);
|
|
979
|
-
glMatrix.vec3.normalize(row[0], row[0]);
|
|
980
|
-
// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
981
|
-
skew[0] = glMatrix.vec3.dot(row[0], row[1]);
|
|
982
|
-
combine(row[1], row[1], row[0], 1.0, -skew[0]);
|
|
983
|
-
// Now, compute Y scale and normalize 2nd row.
|
|
984
|
-
scale[1] = glMatrix.vec3.length(row[1]);
|
|
985
|
-
glMatrix.vec3.normalize(row[1], row[1]);
|
|
986
|
-
skew[0] /= scale[1];
|
|
987
|
-
// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
988
|
-
skew[1] = glMatrix.vec3.dot(row[0], row[2]);
|
|
989
|
-
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
990
|
-
skew[2] = glMatrix.vec3.dot(row[1], row[2]);
|
|
991
|
-
combine(row[2], row[2], row[1], 1.0, -skew[2]);
|
|
992
|
-
// Next, get Z scale and normalize 3rd row.
|
|
993
|
-
scale[2] = glMatrix.vec3.length(row[2]);
|
|
994
|
-
glMatrix.vec3.normalize(row[2], row[2]);
|
|
995
|
-
skew[1] /= scale[2];
|
|
996
|
-
skew[2] /= scale[2];
|
|
997
|
-
// At this point, the matrix (in rows) is orthonormal.
|
|
998
|
-
// Check for a coordinate system flip. If the determinant
|
|
999
|
-
// is -1, then negate the matrix and the scaling factors.
|
|
1000
|
-
glMatrix.vec3.cross(pdum3, row[1], row[2]);
|
|
1001
|
-
if (glMatrix.vec3.dot(row[0], pdum3) < 0) {
|
|
1002
|
-
for (var i = 0; i < 3; i++) {
|
|
1003
|
-
scale[i] *= -1;
|
|
1004
|
-
row[i][0] *= -1;
|
|
1005
|
-
row[i][1] *= -1;
|
|
1006
|
-
row[i][2] *= -1;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
// Now, get the rotations out
|
|
1010
|
-
quaternion[0] =
|
|
1011
|
-
0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
1012
|
-
quaternion[1] =
|
|
1013
|
-
0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
1014
|
-
quaternion[2] =
|
|
1015
|
-
0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
1016
|
-
quaternion[3] =
|
|
1017
|
-
0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
1018
|
-
if (row[2][1] > row[1][2])
|
|
1019
|
-
quaternion[0] = -quaternion[0];
|
|
1020
|
-
if (row[0][2] > row[2][0])
|
|
1021
|
-
quaternion[1] = -quaternion[1];
|
|
1022
|
-
if (row[1][0] > row[0][1])
|
|
1023
|
-
quaternion[2] = -quaternion[2];
|
|
1024
|
-
return true;
|
|
1025
|
-
}
|
|
1026
|
-
function normalize(out, mat) {
|
|
1027
|
-
var m44 = mat[15];
|
|
1028
|
-
// Cannot normalize.
|
|
1029
|
-
if (m44 === 0)
|
|
1030
|
-
return false;
|
|
1031
|
-
var scale = 1 / m44;
|
|
1032
|
-
for (var i = 0; i < 16; i++)
|
|
1033
|
-
out[i] = mat[i] * scale;
|
|
1034
|
-
return true;
|
|
1035
|
-
}
|
|
1036
|
-
//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
1037
|
-
function mat3from4(out, mat4x4) {
|
|
1038
|
-
out[0][0] = mat4x4[0];
|
|
1039
|
-
out[0][1] = mat4x4[1];
|
|
1040
|
-
out[0][2] = mat4x4[2];
|
|
1041
|
-
out[1][0] = mat4x4[4];
|
|
1042
|
-
out[1][1] = mat4x4[5];
|
|
1043
|
-
out[1][2] = mat4x4[6];
|
|
1044
|
-
out[2][0] = mat4x4[8];
|
|
1045
|
-
out[2][1] = mat4x4[9];
|
|
1046
|
-
out[2][2] = mat4x4[10];
|
|
1047
|
-
}
|
|
1048
|
-
function combine(out, a, b, scale1, scale2) {
|
|
1049
|
-
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
1050
|
-
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
1051
|
-
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
695
|
+
var addVec3 = glMatrix.vec3.add, copyVec3 = glMatrix.vec3.copy, maxVec3 = glMatrix.vec3.max, minVec3 = glMatrix.vec3.min, scaleVec3 = glMatrix.vec3.scale, subVec3 = glMatrix.vec3.sub;
|
|
1054
696
|
/**
|
|
1055
697
|
* Axis-Aligned Bounding Box
|
|
1056
698
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
@@ -1069,27 +711,13 @@ var AABB = /** @class */ (function () {
|
|
|
1069
711
|
aabb.halfExtents[1] === 0 &&
|
|
1070
712
|
aabb.halfExtents[2] === 0));
|
|
1071
713
|
};
|
|
1072
|
-
// center: vec3 = vec3.create();
|
|
1073
|
-
// halfExtents: vec3 = vec3.create();
|
|
1074
|
-
// min: vec3 = vec3.create();
|
|
1075
|
-
// max: vec3 = vec3.create();
|
|
1076
714
|
AABB.prototype.update = function (center, halfExtents) {
|
|
1077
715
|
copyVec3(this.center, center);
|
|
1078
716
|
copyVec3(this.halfExtents, halfExtents);
|
|
1079
717
|
subVec3(this.min, this.center, this.halfExtents);
|
|
1080
718
|
addVec3(this.max, this.center, this.halfExtents);
|
|
1081
|
-
// vec3.copy(this.center, center);
|
|
1082
|
-
// vec3.copy(this.halfExtents, halfExtents);
|
|
1083
|
-
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
1084
|
-
// vec3.add(this.max, this.center, this.halfExtents);
|
|
1085
719
|
};
|
|
1086
720
|
AABB.prototype.setMinMax = function (min, max) {
|
|
1087
|
-
// vec3.add(this.center, max, min);
|
|
1088
|
-
// vec3.scale(this.center, this.center, 0.5);
|
|
1089
|
-
// vec3.sub(this.halfExtents, max, min);
|
|
1090
|
-
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
1091
|
-
// vec3.copy(this.min, min);
|
|
1092
|
-
// vec3.copy(this.max, max);
|
|
1093
721
|
addVec3(this.center, max, min);
|
|
1094
722
|
scaleVec3(this.center, this.center, 0.5);
|
|
1095
723
|
subVec3(this.halfExtents, max, min);
|
|
@@ -1233,25 +861,11 @@ var AABB = /** @class */ (function () {
|
|
|
1233
861
|
return null;
|
|
1234
862
|
}
|
|
1235
863
|
var intersection = new AABB();
|
|
1236
|
-
// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
1237
|
-
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
1238
864
|
var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
|
|
1239
865
|
var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
|
|
1240
866
|
intersection.setMinMax(min, max);
|
|
1241
867
|
return intersection;
|
|
1242
868
|
};
|
|
1243
|
-
// containsPoint(point: vec3) {
|
|
1244
|
-
// const min = this.getMin();
|
|
1245
|
-
// const max = this.getMax();
|
|
1246
|
-
// return !(
|
|
1247
|
-
// point[0] < min[0] ||
|
|
1248
|
-
// point[0] > max[0] ||
|
|
1249
|
-
// point[1] < min[1] ||
|
|
1250
|
-
// point[1] > max[1] ||
|
|
1251
|
-
// point[2] < min[2] ||
|
|
1252
|
-
// point[2] > max[2]
|
|
1253
|
-
// );
|
|
1254
|
-
// }
|
|
1255
869
|
/**
|
|
1256
870
|
* get n-vertex
|
|
1257
871
|
* @param plane plane of CullingVolume
|
|
@@ -1324,167 +938,505 @@ var AABB = /** @class */ (function () {
|
|
|
1324
938
|
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
1325
939
|
}
|
|
1326
940
|
else {
|
|
1327
|
-
return [this.min[0], this.min[1], this.min[2]];
|
|
1328
|
-
// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
941
|
+
return [this.min[0], this.min[1], this.min[2]];
|
|
942
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
return AABB;
|
|
946
|
+
}());
|
|
947
|
+
|
|
948
|
+
var Plane = /** @class */ (function () {
|
|
949
|
+
function Plane(distance, normal) {
|
|
950
|
+
this.distance = distance || 0;
|
|
951
|
+
this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
|
|
952
|
+
this.updatePNVertexFlag();
|
|
953
|
+
}
|
|
954
|
+
Plane.prototype.updatePNVertexFlag = function () {
|
|
955
|
+
this.pnVertexFlag =
|
|
956
|
+
(Number(this.normal[0] >= 0) << 8) +
|
|
957
|
+
(Number(this.normal[1] >= 0) << 4) +
|
|
958
|
+
Number(this.normal[2] >= 0);
|
|
959
|
+
};
|
|
960
|
+
Plane.prototype.distanceToPoint = function (point) {
|
|
961
|
+
return glMatrix.vec3.dot(point, this.normal) - this.distance;
|
|
962
|
+
};
|
|
963
|
+
Plane.prototype.normalize = function () {
|
|
964
|
+
var invLen = 1 / glMatrix.vec3.len(this.normal);
|
|
965
|
+
glMatrix.vec3.scale(this.normal, this.normal, invLen);
|
|
966
|
+
this.distance *= invLen;
|
|
967
|
+
};
|
|
968
|
+
Plane.prototype.intersectsLine = function (start, end, point) {
|
|
969
|
+
var d0 = this.distanceToPoint(start);
|
|
970
|
+
var d1 = this.distanceToPoint(end);
|
|
971
|
+
var t = d0 / (d0 - d1);
|
|
972
|
+
var intersects = t >= 0 && t <= 1;
|
|
973
|
+
if (intersects && point) {
|
|
974
|
+
glMatrix.vec3.lerp(point, start, end, t);
|
|
975
|
+
}
|
|
976
|
+
return intersects;
|
|
977
|
+
};
|
|
978
|
+
return Plane;
|
|
979
|
+
}());
|
|
980
|
+
|
|
981
|
+
exports.Mask = void 0;
|
|
982
|
+
(function (Mask) {
|
|
983
|
+
Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
|
|
984
|
+
Mask[Mask["INSIDE"] = 0] = "INSIDE";
|
|
985
|
+
Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
|
|
986
|
+
})(exports.Mask || (exports.Mask = {}));
|
|
987
|
+
var Frustum = /** @class */ (function () {
|
|
988
|
+
function Frustum(planes) {
|
|
989
|
+
this.planes = [];
|
|
990
|
+
if (planes) {
|
|
991
|
+
this.planes = planes;
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
for (var i = 0; i < 6; i++) {
|
|
995
|
+
this.planes.push(new Plane());
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* extract 6 planes from projectionMatrix
|
|
1001
|
+
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
1002
|
+
*/
|
|
1003
|
+
Frustum.prototype.extractFromVPMatrix = function (projectionMatrix) {
|
|
1004
|
+
// @ts-ignore
|
|
1005
|
+
var _a = tslib.__read(projectionMatrix, 16), m0 = _a[0], m1 = _a[1], m2 = _a[2], m3 = _a[3], m4 = _a[4], m5 = _a[5], m6 = _a[6], m7 = _a[7], m8 = _a[8], m9 = _a[9], m10 = _a[10], m11 = _a[11], m12 = _a[12], m13 = _a[13], m14 = _a[14], m15 = _a[15];
|
|
1006
|
+
// right
|
|
1007
|
+
glMatrix.vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
|
|
1008
|
+
this.planes[0].distance = m15 - m12;
|
|
1009
|
+
// left
|
|
1010
|
+
glMatrix.vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
|
|
1011
|
+
this.planes[1].distance = m15 + m12;
|
|
1012
|
+
// bottom
|
|
1013
|
+
glMatrix.vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
|
|
1014
|
+
this.planes[2].distance = m15 + m13;
|
|
1015
|
+
// top
|
|
1016
|
+
glMatrix.vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
|
|
1017
|
+
this.planes[3].distance = m15 - m13;
|
|
1018
|
+
// far
|
|
1019
|
+
glMatrix.vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
|
|
1020
|
+
this.planes[4].distance = m15 - m14;
|
|
1021
|
+
// near
|
|
1022
|
+
glMatrix.vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
|
|
1023
|
+
this.planes[5].distance = m15 + m14;
|
|
1024
|
+
this.planes.forEach(function (plane) {
|
|
1025
|
+
plane.normalize();
|
|
1026
|
+
plane.updatePNVertexFlag();
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
return Frustum;
|
|
1030
|
+
}());
|
|
1031
|
+
|
|
1032
|
+
var Point = /** @class */ (function () {
|
|
1033
|
+
function Point(x, y) {
|
|
1034
|
+
if (x === void 0) { x = 0; }
|
|
1035
|
+
if (y === void 0) { y = 0; }
|
|
1036
|
+
this.x = 0;
|
|
1037
|
+
this.y = 0;
|
|
1038
|
+
this.x = x;
|
|
1039
|
+
this.y = y;
|
|
1040
|
+
}
|
|
1041
|
+
Point.prototype.clone = function () {
|
|
1042
|
+
return new Point(this.x, this.y);
|
|
1043
|
+
};
|
|
1044
|
+
Point.prototype.copyFrom = function (p) {
|
|
1045
|
+
this.x = p.x;
|
|
1046
|
+
this.y = p.y;
|
|
1047
|
+
};
|
|
1048
|
+
return Point;
|
|
1049
|
+
}());
|
|
1050
|
+
|
|
1051
|
+
var Rectangle = /** @class */ (function () {
|
|
1052
|
+
function Rectangle(x, y, width, height) {
|
|
1053
|
+
this.x = x;
|
|
1054
|
+
this.y = y;
|
|
1055
|
+
this.width = width;
|
|
1056
|
+
this.height = height;
|
|
1057
|
+
this.left = x;
|
|
1058
|
+
this.right = x + width;
|
|
1059
|
+
this.top = y;
|
|
1060
|
+
this.bottom = y + height;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect/fromRect_static
|
|
1064
|
+
*/
|
|
1065
|
+
Rectangle.fromRect = function (rect) {
|
|
1066
|
+
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
|
|
1067
|
+
};
|
|
1068
|
+
/**
|
|
1069
|
+
* will return a new rect instance
|
|
1070
|
+
*/
|
|
1071
|
+
Rectangle.applyTransform = function (rect, matrix) {
|
|
1072
|
+
var topLeft = glMatrix.vec4.fromValues(rect.x, rect.y, 0, 1);
|
|
1073
|
+
var topRight = glMatrix.vec4.fromValues(rect.x + rect.width, rect.y, 0, 1);
|
|
1074
|
+
var bottomLeft = glMatrix.vec4.fromValues(rect.x, rect.y + rect.height, 0, 1);
|
|
1075
|
+
var bottomRight = glMatrix.vec4.fromValues(rect.x + rect.width, rect.y + rect.height, 0, 1);
|
|
1076
|
+
var transformedTopLeft = glMatrix.vec4.create();
|
|
1077
|
+
var transformedTopRight = glMatrix.vec4.create();
|
|
1078
|
+
var transformedBottomLeft = glMatrix.vec4.create();
|
|
1079
|
+
var transformedBottomRight = glMatrix.vec4.create();
|
|
1080
|
+
glMatrix.vec4.transformMat4(transformedTopLeft, topLeft, matrix);
|
|
1081
|
+
glMatrix.vec4.transformMat4(transformedTopRight, topRight, matrix);
|
|
1082
|
+
glMatrix.vec4.transformMat4(transformedBottomLeft, bottomLeft, matrix);
|
|
1083
|
+
glMatrix.vec4.transformMat4(transformedBottomRight, bottomRight, matrix);
|
|
1084
|
+
var minX = Math.min(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1085
|
+
var minY = Math.min(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1086
|
+
var maxX = Math.max(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1087
|
+
var maxY = Math.max(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1088
|
+
return Rectangle.fromRect({
|
|
1089
|
+
x: minX,
|
|
1090
|
+
y: minY,
|
|
1091
|
+
width: maxX - minX,
|
|
1092
|
+
height: maxY - minY,
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
Rectangle.prototype.toJSON = function () { };
|
|
1096
|
+
return Rectangle;
|
|
1097
|
+
}());
|
|
1098
|
+
|
|
1099
|
+
var ERROR_MSG_METHOD_NOT_IMPLEMENTED = 'Method not implemented.';
|
|
1100
|
+
var ERROR_MSG_USE_DOCUMENT_ELEMENT = 'Use document.documentElement instead.';
|
|
1101
|
+
var ERROR_MSG_APPEND_DESTROYED_ELEMENT = 'Cannot append a destroyed element.';
|
|
1102
|
+
|
|
1103
|
+
function getAngle(angle) {
|
|
1104
|
+
if (angle === undefined) {
|
|
1105
|
+
return 0;
|
|
1106
|
+
}
|
|
1107
|
+
else if (angle > 360 || angle < -360) {
|
|
1108
|
+
return angle % 360;
|
|
1109
|
+
}
|
|
1110
|
+
return angle;
|
|
1111
|
+
}
|
|
1112
|
+
var $vec3$2 = glMatrix.vec3.create();
|
|
1113
|
+
function createVec3(x, y, z, clone) {
|
|
1114
|
+
if (y === void 0) { y = 0; }
|
|
1115
|
+
if (z === void 0) { z = 0; }
|
|
1116
|
+
if (clone === void 0) { clone = true; }
|
|
1117
|
+
if (Array.isArray(x) && x.length === 3) {
|
|
1118
|
+
return clone ? glMatrix.vec3.clone(x) : glMatrix.vec3.copy($vec3$2, x);
|
|
1119
|
+
}
|
|
1120
|
+
if (util.isNumber(x)) {
|
|
1121
|
+
return clone ? glMatrix.vec3.fromValues(x, y, z) : glMatrix.vec3.set($vec3$2, x, y, z);
|
|
1122
|
+
}
|
|
1123
|
+
return clone
|
|
1124
|
+
? glMatrix.vec3.fromValues(x[0], x[1] || y, x[2] || z)
|
|
1125
|
+
: glMatrix.vec3.set($vec3$2, x[0], x[1] || y, x[2] || z);
|
|
1126
|
+
}
|
|
1127
|
+
var DEG_RAD = Math.PI / 180;
|
|
1128
|
+
function deg2rad(deg) {
|
|
1129
|
+
return deg * DEG_RAD;
|
|
1130
|
+
}
|
|
1131
|
+
var RAD_DEG = 180 / Math.PI;
|
|
1132
|
+
function rad2deg(rad) {
|
|
1133
|
+
return rad * RAD_DEG;
|
|
1134
|
+
}
|
|
1135
|
+
var GRAD_DEG = 0.9; // 360 / 400;
|
|
1136
|
+
function grad2deg(grads) {
|
|
1137
|
+
grads = grads % 400;
|
|
1138
|
+
if (grads < 0) {
|
|
1139
|
+
grads += 400;
|
|
1140
|
+
}
|
|
1141
|
+
return grads * GRAD_DEG;
|
|
1142
|
+
}
|
|
1143
|
+
function deg2turn(deg) {
|
|
1144
|
+
return deg / 360;
|
|
1145
|
+
}
|
|
1146
|
+
function turn2deg(turn) {
|
|
1147
|
+
return 360 * turn;
|
|
1148
|
+
}
|
|
1149
|
+
var HALF_PI = Math.PI / 2;
|
|
1150
|
+
function getEulerFromQuat(out, quat) {
|
|
1151
|
+
var x = quat[0];
|
|
1152
|
+
var y = quat[1];
|
|
1153
|
+
var z = quat[2];
|
|
1154
|
+
var w = quat[3];
|
|
1155
|
+
var x2 = x * x;
|
|
1156
|
+
var y2 = y * y;
|
|
1157
|
+
var z2 = z * z;
|
|
1158
|
+
var w2 = w * w;
|
|
1159
|
+
var unit = x2 + y2 + z2 + w2;
|
|
1160
|
+
var test = x * w - y * z;
|
|
1161
|
+
if (test > 0.499995 * unit) {
|
|
1162
|
+
// TODO: Use glmatrix.EPSILON
|
|
1163
|
+
// singularity at the north pole
|
|
1164
|
+
out[0] = HALF_PI;
|
|
1165
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
1166
|
+
out[2] = 0;
|
|
1167
|
+
}
|
|
1168
|
+
else if (test < -0.499995 * unit) {
|
|
1169
|
+
//TODO: Use glmatrix.EPSILON
|
|
1170
|
+
// singularity at the south pole
|
|
1171
|
+
out[0] = -HALF_PI;
|
|
1172
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
1173
|
+
out[2] = 0;
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
out[0] = Math.asin(2 * (x * z - w * y));
|
|
1177
|
+
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
1178
|
+
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
1179
|
+
}
|
|
1180
|
+
// TODO: Return them as degrees and not as radians
|
|
1181
|
+
return out;
|
|
1182
|
+
}
|
|
1183
|
+
function getEulerFromMat4(out, m) {
|
|
1184
|
+
var x;
|
|
1185
|
+
var z;
|
|
1186
|
+
var _a = tslib.__read(glMatrix.mat4.getScaling(glMatrix.vec3.create(), m), 3), sx = _a[0], sy = _a[1], sz = _a[2];
|
|
1187
|
+
var y = Math.asin(-m[2] / sx);
|
|
1188
|
+
if (y < HALF_PI) {
|
|
1189
|
+
if (y > -HALF_PI) {
|
|
1190
|
+
x = Math.atan2(m[6] / sy, m[10] / sz);
|
|
1191
|
+
z = Math.atan2(m[1] / sx, m[0] / sx);
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
// Not a unique solution
|
|
1195
|
+
z = 0;
|
|
1196
|
+
x = -Math.atan2(m[4] / sy, m[5] / sy);
|
|
1329
1197
|
}
|
|
1330
|
-
};
|
|
1331
|
-
return AABB;
|
|
1332
|
-
}());
|
|
1333
|
-
|
|
1334
|
-
var Plane = /** @class */ (function () {
|
|
1335
|
-
function Plane(distance, normal) {
|
|
1336
|
-
this.distance = distance || 0;
|
|
1337
|
-
this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
|
|
1338
|
-
this.updatePNVertexFlag();
|
|
1339
1198
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
(
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
var
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1199
|
+
else {
|
|
1200
|
+
// Not a unique solution
|
|
1201
|
+
z = 0;
|
|
1202
|
+
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
1203
|
+
}
|
|
1204
|
+
out[0] = x;
|
|
1205
|
+
out[1] = y;
|
|
1206
|
+
out[2] = z;
|
|
1207
|
+
return out;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* @see https://github.com/toji/gl-matrix/issues/329
|
|
1211
|
+
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
1212
|
+
*/
|
|
1213
|
+
function getEuler(out, quat) {
|
|
1214
|
+
if (quat.length === 16) {
|
|
1215
|
+
return getEulerFromMat4(out, quat);
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
return getEulerFromQuat(out, quat);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function fromRotationTranslationScale(rotation, x, y, scaleX, scaleY) {
|
|
1222
|
+
var cos = Math.cos(rotation);
|
|
1223
|
+
var sin = Math.sin(rotation);
|
|
1224
|
+
return glMatrix.mat3.fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
1225
|
+
}
|
|
1226
|
+
function makePerspective(out, left, right, top, bottom, near, far, zero) {
|
|
1227
|
+
if (zero === void 0) { zero = false; }
|
|
1228
|
+
var twoNear = 2 * near;
|
|
1229
|
+
var rightMinusLeft = right - left;
|
|
1230
|
+
var topMinusBottom = top - bottom;
|
|
1231
|
+
var x = twoNear / rightMinusLeft;
|
|
1232
|
+
var y = twoNear / topMinusBottom;
|
|
1233
|
+
var a = (right + left) / rightMinusLeft;
|
|
1234
|
+
var b = (top + bottom) / topMinusBottom;
|
|
1235
|
+
var c;
|
|
1236
|
+
var d;
|
|
1237
|
+
var farMinusNear = far - near;
|
|
1238
|
+
var farMulNear = far * near;
|
|
1239
|
+
if (zero) {
|
|
1240
|
+
c = -far / farMinusNear;
|
|
1241
|
+
d = -farMulNear / farMinusNear;
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
c = -(far + near) / farMinusNear;
|
|
1245
|
+
d = (-2 * farMulNear) / farMinusNear;
|
|
1246
|
+
}
|
|
1247
|
+
out[0] = x;
|
|
1248
|
+
out[1] = 0;
|
|
1249
|
+
out[2] = 0;
|
|
1250
|
+
out[3] = 0;
|
|
1251
|
+
out[4] = 0;
|
|
1252
|
+
out[5] = y;
|
|
1253
|
+
out[6] = 0;
|
|
1254
|
+
out[7] = 0;
|
|
1255
|
+
out[8] = a;
|
|
1256
|
+
out[9] = b;
|
|
1257
|
+
out[10] = c;
|
|
1258
|
+
out[11] = -1;
|
|
1259
|
+
out[12] = 0;
|
|
1260
|
+
out[13] = 0;
|
|
1261
|
+
out[14] = d;
|
|
1262
|
+
out[15] = 0;
|
|
1263
|
+
return out;
|
|
1264
|
+
}
|
|
1265
|
+
function decompose(mat) {
|
|
1266
|
+
var row0x = mat[0];
|
|
1267
|
+
var row0y = mat[1];
|
|
1268
|
+
var row1x = mat[3];
|
|
1269
|
+
var row1y = mat[4];
|
|
1270
|
+
// decompose 3x3 matrix
|
|
1271
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
1272
|
+
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
1273
|
+
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y);
|
|
1274
|
+
// If determinant is negative, one axis was flipped.
|
|
1275
|
+
var determinant = row0x * row1y - row0y * row1x;
|
|
1276
|
+
if (determinant < 0) {
|
|
1277
|
+
// Flip axis with minimum unit vector dot product.
|
|
1278
|
+
if (row0x < row1y) {
|
|
1279
|
+
scalingX = -scalingX;
|
|
1378
1280
|
}
|
|
1379
1281
|
else {
|
|
1380
|
-
|
|
1381
|
-
this.planes.push(new Plane());
|
|
1382
|
-
}
|
|
1282
|
+
scalingY = -scalingY;
|
|
1383
1283
|
}
|
|
1384
1284
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
};
|
|
1415
|
-
return Frustum;
|
|
1416
|
-
}());
|
|
1285
|
+
// Renormalize matrix to remove scale.
|
|
1286
|
+
if (scalingX) {
|
|
1287
|
+
var invScalingX = 1 / scalingX;
|
|
1288
|
+
row0x *= invScalingX;
|
|
1289
|
+
row0y *= invScalingX;
|
|
1290
|
+
}
|
|
1291
|
+
if (scalingY) {
|
|
1292
|
+
var invScalingY = 1 / scalingY;
|
|
1293
|
+
row1x *= invScalingY;
|
|
1294
|
+
row1y *= invScalingY;
|
|
1295
|
+
}
|
|
1296
|
+
// Compute rotation and renormalize matrix.
|
|
1297
|
+
var rotation = Math.atan2(row0y, row0x);
|
|
1298
|
+
var angle = rad2deg(rotation);
|
|
1299
|
+
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
1300
|
+
}
|
|
1301
|
+
var tmp = glMatrix.mat4.create();
|
|
1302
|
+
var perspectiveMatrix = glMatrix.mat4.create();
|
|
1303
|
+
var tmpVec4 = glMatrix.vec4.create();
|
|
1304
|
+
var row = [glMatrix.vec3.create(), glMatrix.vec3.create(), glMatrix.vec3.create()];
|
|
1305
|
+
var pdum3 = glMatrix.vec3.create();
|
|
1306
|
+
/*
|
|
1307
|
+
Input: matrix ; a 4x4 matrix
|
|
1308
|
+
Output: translation ; a 3 component vector
|
|
1309
|
+
scale ; a 3 component vector
|
|
1310
|
+
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
1311
|
+
perspective ; a 4 component vector
|
|
1312
|
+
quaternion ; a 4 component vector
|
|
1313
|
+
Returns false if the matrix cannot be decomposed, true if it can
|
|
1417
1314
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1315
|
+
|
|
1316
|
+
References:
|
|
1317
|
+
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
1318
|
+
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
1319
|
+
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
1320
|
+
*/
|
|
1321
|
+
function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
1322
|
+
//normalize, if not possible then bail out early
|
|
1323
|
+
if (!normalize(tmp, matrix))
|
|
1324
|
+
return false;
|
|
1325
|
+
// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
1326
|
+
// an easy way to test for singularity of the upper 3x3 component.
|
|
1327
|
+
glMatrix.mat4.copy(perspectiveMatrix, tmp);
|
|
1328
|
+
perspectiveMatrix[3] = 0;
|
|
1329
|
+
perspectiveMatrix[7] = 0;
|
|
1330
|
+
perspectiveMatrix[11] = 0;
|
|
1331
|
+
perspectiveMatrix[15] = 1;
|
|
1332
|
+
// If the perspectiveMatrix is not invertible, we are also unable to
|
|
1333
|
+
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
1334
|
+
if (Math.abs(glMatrix.mat4.determinant(perspectiveMatrix)) < 1e-8)
|
|
1335
|
+
return false;
|
|
1336
|
+
var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11], a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
|
|
1337
|
+
// First, isolate perspective.
|
|
1338
|
+
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
1339
|
+
tmpVec4[0] = a03;
|
|
1340
|
+
tmpVec4[1] = a13;
|
|
1341
|
+
tmpVec4[2] = a23;
|
|
1342
|
+
tmpVec4[3] = a33;
|
|
1343
|
+
// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
1344
|
+
// rightHandSide by the inverse.
|
|
1345
|
+
// resuing the perspectiveMatrix here since it's no longer needed
|
|
1346
|
+
var ret = glMatrix.mat4.invert(perspectiveMatrix, perspectiveMatrix);
|
|
1347
|
+
if (!ret)
|
|
1348
|
+
return false;
|
|
1349
|
+
glMatrix.mat4.transpose(perspectiveMatrix, perspectiveMatrix);
|
|
1350
|
+
//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
1351
|
+
glMatrix.vec4.transformMat4(perspective, tmpVec4, perspectiveMatrix);
|
|
1426
1352
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
this.x = p.x;
|
|
1432
|
-
this.y = p.y;
|
|
1433
|
-
};
|
|
1434
|
-
return Point;
|
|
1435
|
-
}());
|
|
1436
|
-
|
|
1437
|
-
var Rectangle = /** @class */ (function () {
|
|
1438
|
-
function Rectangle(x, y, width, height) {
|
|
1439
|
-
this.x = x;
|
|
1440
|
-
this.y = y;
|
|
1441
|
-
this.width = width;
|
|
1442
|
-
this.height = height;
|
|
1443
|
-
this.left = x;
|
|
1444
|
-
this.right = x + width;
|
|
1445
|
-
this.top = y;
|
|
1446
|
-
this.bottom = y + height;
|
|
1353
|
+
else {
|
|
1354
|
+
//no perspective
|
|
1355
|
+
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
1356
|
+
perspective[3] = 1;
|
|
1447
1357
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1358
|
+
// Next take care of translation
|
|
1359
|
+
translation[0] = a30;
|
|
1360
|
+
translation[1] = a31;
|
|
1361
|
+
translation[2] = a32;
|
|
1362
|
+
// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
1363
|
+
mat3from4(row, tmp);
|
|
1364
|
+
// Compute X scale factor and normalize first row.
|
|
1365
|
+
scale[0] = glMatrix.vec3.length(row[0]);
|
|
1366
|
+
glMatrix.vec3.normalize(row[0], row[0]);
|
|
1367
|
+
// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
1368
|
+
skew[0] = glMatrix.vec3.dot(row[0], row[1]);
|
|
1369
|
+
combine(row[1], row[1], row[0], 1.0, -skew[0]);
|
|
1370
|
+
// Now, compute Y scale and normalize 2nd row.
|
|
1371
|
+
scale[1] = glMatrix.vec3.length(row[1]);
|
|
1372
|
+
glMatrix.vec3.normalize(row[1], row[1]);
|
|
1373
|
+
skew[0] /= scale[1];
|
|
1374
|
+
// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
1375
|
+
skew[1] = glMatrix.vec3.dot(row[0], row[2]);
|
|
1376
|
+
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
1377
|
+
skew[2] = glMatrix.vec3.dot(row[1], row[2]);
|
|
1378
|
+
combine(row[2], row[2], row[1], 1.0, -skew[2]);
|
|
1379
|
+
// Next, get Z scale and normalize 3rd row.
|
|
1380
|
+
scale[2] = glMatrix.vec3.length(row[2]);
|
|
1381
|
+
glMatrix.vec3.normalize(row[2], row[2]);
|
|
1382
|
+
skew[1] /= scale[2];
|
|
1383
|
+
skew[2] /= scale[2];
|
|
1384
|
+
// At this point, the matrix (in rows) is orthonormal.
|
|
1385
|
+
// Check for a coordinate system flip. If the determinant
|
|
1386
|
+
// is -1, then negate the matrix and the scaling factors.
|
|
1387
|
+
glMatrix.vec3.cross(pdum3, row[1], row[2]);
|
|
1388
|
+
if (glMatrix.vec3.dot(row[0], pdum3) < 0) {
|
|
1389
|
+
for (var i = 0; i < 3; i++) {
|
|
1390
|
+
scale[i] *= -1;
|
|
1391
|
+
row[i][0] *= -1;
|
|
1392
|
+
row[i][1] *= -1;
|
|
1393
|
+
row[i][2] *= -1;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
// Now, get the rotations out
|
|
1397
|
+
quaternion[0] =
|
|
1398
|
+
0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
1399
|
+
quaternion[1] =
|
|
1400
|
+
0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
1401
|
+
quaternion[2] =
|
|
1402
|
+
0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
1403
|
+
quaternion[3] =
|
|
1404
|
+
0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
1405
|
+
if (row[2][1] > row[1][2])
|
|
1406
|
+
quaternion[0] = -quaternion[0];
|
|
1407
|
+
if (row[0][2] > row[2][0])
|
|
1408
|
+
quaternion[1] = -quaternion[1];
|
|
1409
|
+
if (row[1][0] > row[0][1])
|
|
1410
|
+
quaternion[2] = -quaternion[2];
|
|
1411
|
+
return true;
|
|
1412
|
+
}
|
|
1413
|
+
function normalize(out, mat) {
|
|
1414
|
+
var m44 = mat[15];
|
|
1415
|
+
// Cannot normalize.
|
|
1416
|
+
if (m44 === 0)
|
|
1417
|
+
return false;
|
|
1418
|
+
var scale = 1 / m44;
|
|
1419
|
+
for (var i = 0; i < 16; i++)
|
|
1420
|
+
out[i] = mat[i] * scale;
|
|
1421
|
+
return true;
|
|
1422
|
+
}
|
|
1423
|
+
//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
1424
|
+
function mat3from4(out, mat4x4) {
|
|
1425
|
+
out[0][0] = mat4x4[0];
|
|
1426
|
+
out[0][1] = mat4x4[1];
|
|
1427
|
+
out[0][2] = mat4x4[2];
|
|
1428
|
+
out[1][0] = mat4x4[4];
|
|
1429
|
+
out[1][1] = mat4x4[5];
|
|
1430
|
+
out[1][2] = mat4x4[6];
|
|
1431
|
+
out[2][0] = mat4x4[8];
|
|
1432
|
+
out[2][1] = mat4x4[9];
|
|
1433
|
+
out[2][2] = mat4x4[10];
|
|
1434
|
+
}
|
|
1435
|
+
function combine(out, a, b, scale1, scale2) {
|
|
1436
|
+
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
1437
|
+
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
1438
|
+
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
1439
|
+
}
|
|
1488
1440
|
|
|
1489
1441
|
/**
|
|
1490
1442
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
@@ -2236,6 +2188,99 @@ var Camera = /** @class */ (function () {
|
|
|
2236
2188
|
return Camera;
|
|
2237
2189
|
}());
|
|
2238
2190
|
|
|
2191
|
+
/**
|
|
2192
|
+
* @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
|
|
2193
|
+
*/
|
|
2194
|
+
exports.Strategy = void 0;
|
|
2195
|
+
(function (Strategy) {
|
|
2196
|
+
Strategy[Strategy["Standard"] = 0] = "Standard";
|
|
2197
|
+
})(exports.Strategy || (exports.Strategy = {}));
|
|
2198
|
+
|
|
2199
|
+
exports.SortReason = void 0;
|
|
2200
|
+
(function (SortReason) {
|
|
2201
|
+
SortReason[SortReason["ADDED"] = 0] = "ADDED";
|
|
2202
|
+
SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
|
|
2203
|
+
SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
|
|
2204
|
+
})(exports.SortReason || (exports.SortReason = {}));
|
|
2205
|
+
|
|
2206
|
+
var EMPTY_PARSED_PATH = {
|
|
2207
|
+
absolutePath: [],
|
|
2208
|
+
hasArc: false,
|
|
2209
|
+
segments: [],
|
|
2210
|
+
polygons: [],
|
|
2211
|
+
polylines: [],
|
|
2212
|
+
curve: null,
|
|
2213
|
+
totalLength: 0,
|
|
2214
|
+
rect: new Rectangle(0, 0, 0, 0),
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
2219
|
+
*/
|
|
2220
|
+
exports.PropertySyntax = void 0;
|
|
2221
|
+
(function (PropertySyntax) {
|
|
2222
|
+
/**
|
|
2223
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
2224
|
+
*/
|
|
2225
|
+
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
2226
|
+
/**
|
|
2227
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
2228
|
+
*/
|
|
2229
|
+
PropertySyntax["COLOR"] = "<color>";
|
|
2230
|
+
/**
|
|
2231
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
2232
|
+
*/
|
|
2233
|
+
PropertySyntax["PAINT"] = "<paint>";
|
|
2234
|
+
/**
|
|
2235
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
2236
|
+
*/
|
|
2237
|
+
PropertySyntax["NUMBER"] = "<number>";
|
|
2238
|
+
/**
|
|
2239
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
|
|
2240
|
+
*/
|
|
2241
|
+
PropertySyntax["ANGLE"] = "<angle>";
|
|
2242
|
+
/**
|
|
2243
|
+
* <number> with range 0..1
|
|
2244
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
2245
|
+
*/
|
|
2246
|
+
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
2247
|
+
/**
|
|
2248
|
+
* <number> with range 0..Infinity
|
|
2249
|
+
*/
|
|
2250
|
+
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
2251
|
+
/**
|
|
2252
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
2253
|
+
*/
|
|
2254
|
+
PropertySyntax["LENGTH"] = "<length>";
|
|
2255
|
+
/**
|
|
2256
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
2257
|
+
*/
|
|
2258
|
+
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
2259
|
+
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
2260
|
+
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
2261
|
+
/**
|
|
2262
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
2263
|
+
*/
|
|
2264
|
+
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
2265
|
+
/**
|
|
2266
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
2267
|
+
*/
|
|
2268
|
+
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
2269
|
+
PropertySyntax["PATH"] = "<path>";
|
|
2270
|
+
/**
|
|
2271
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
2272
|
+
*/
|
|
2273
|
+
PropertySyntax["FILTER"] = "<filter>";
|
|
2274
|
+
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
2275
|
+
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
2276
|
+
PropertySyntax["DEFINED_PATH"] = "<defined-path>";
|
|
2277
|
+
PropertySyntax["MARKER"] = "<marker>";
|
|
2278
|
+
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
2279
|
+
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
2280
|
+
PropertySyntax["TEXT"] = "<text>";
|
|
2281
|
+
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
2282
|
+
})(exports.PropertySyntax || (exports.PropertySyntax = {}));
|
|
2283
|
+
|
|
2239
2284
|
function memoize(func, resolver) {
|
|
2240
2285
|
if (typeof func !== 'function' ||
|
|
2241
2286
|
(resolver != null && typeof resolver !== 'function')) {
|
|
@@ -2352,14 +2397,6 @@ var UnitCategory;
|
|
|
2352
2397
|
// kUResolution,
|
|
2353
2398
|
UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
|
|
2354
2399
|
})(UnitCategory || (UnitCategory = {}));
|
|
2355
|
-
var ValueRange;
|
|
2356
|
-
(function (ValueRange) {
|
|
2357
|
-
ValueRange[ValueRange["kAll"] = 0] = "kAll";
|
|
2358
|
-
ValueRange[ValueRange["kNonNegative"] = 1] = "kNonNegative";
|
|
2359
|
-
ValueRange[ValueRange["kInteger"] = 2] = "kInteger";
|
|
2360
|
-
ValueRange[ValueRange["kNonNegativeInteger"] = 3] = "kNonNegativeInteger";
|
|
2361
|
-
ValueRange[ValueRange["kPositiveInteger"] = 4] = "kPositiveInteger";
|
|
2362
|
-
})(ValueRange || (ValueRange = {}));
|
|
2363
2400
|
var Nested;
|
|
2364
2401
|
(function (Nested) {
|
|
2365
2402
|
Nested[Nested["kYes"] = 0] = "kYes";
|
|
@@ -2878,13 +2915,6 @@ var CSSColorValue = /** @class */ (function (_super) {
|
|
|
2878
2915
|
CSSColorValue.prototype.getType = function () {
|
|
2879
2916
|
return CSSStyleValueType.kColorType;
|
|
2880
2917
|
};
|
|
2881
|
-
// buildCSSText(n: Nested, p: ParenLess, result: string): string {
|
|
2882
|
-
// let text = '';
|
|
2883
|
-
// if (this.colorSpace === 'rgb') {
|
|
2884
|
-
// text = `rgba(${this.channels.join(',')},${this.alpha})`;
|
|
2885
|
-
// }
|
|
2886
|
-
// return (result += text);
|
|
2887
|
-
// }
|
|
2888
2918
|
/**
|
|
2889
2919
|
* @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to
|
|
2890
2920
|
*/
|
|
@@ -2945,82 +2975,6 @@ var CSSKeywordValue = /** @class */ (function (_super) {
|
|
|
2945
2975
|
return CSSKeywordValue;
|
|
2946
2976
|
}(CSSStyleValue));
|
|
2947
2977
|
|
|
2948
|
-
var camelCase = memoize(function (str) {
|
|
2949
|
-
if (str === void 0) { str = ''; }
|
|
2950
|
-
return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
2951
|
-
});
|
|
2952
|
-
var kebabize = function (str) {
|
|
2953
|
-
return str
|
|
2954
|
-
.split('')
|
|
2955
|
-
.map(function (letter, idx) {
|
|
2956
|
-
return letter.toUpperCase() === letter
|
|
2957
|
-
? "".concat(idx !== 0 ? '-' : '').concat(letter.toLowerCase())
|
|
2958
|
-
: letter;
|
|
2959
|
-
})
|
|
2960
|
-
.join('');
|
|
2961
|
-
};
|
|
2962
|
-
|
|
2963
|
-
function DCHECK(bool) {
|
|
2964
|
-
if (!bool) {
|
|
2965
|
-
throw new Error();
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
function isFunction(func) {
|
|
2969
|
-
return typeof func === 'function';
|
|
2970
|
-
}
|
|
2971
|
-
function isSymbol(value) {
|
|
2972
|
-
// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
|
|
2973
|
-
return typeof value === 'symbol';
|
|
2974
|
-
}
|
|
2975
|
-
var definedProps = function (obj) {
|
|
2976
|
-
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
2977
|
-
var _b = tslib.__read(_a, 2), v = _b[1];
|
|
2978
|
-
return v !== undefined;
|
|
2979
|
-
}));
|
|
2980
|
-
};
|
|
2981
|
-
var FORMAT_ATTR_MAP = {
|
|
2982
|
-
d: {
|
|
2983
|
-
alias: 'path',
|
|
2984
|
-
},
|
|
2985
|
-
strokeDasharray: {
|
|
2986
|
-
alias: 'lineDash',
|
|
2987
|
-
},
|
|
2988
|
-
strokeWidth: {
|
|
2989
|
-
alias: 'lineWidth',
|
|
2990
|
-
},
|
|
2991
|
-
textAnchor: {
|
|
2992
|
-
alias: 'textAlign',
|
|
2993
|
-
},
|
|
2994
|
-
src: {
|
|
2995
|
-
alias: 'img',
|
|
2996
|
-
},
|
|
2997
|
-
};
|
|
2998
|
-
var formatAttributeName = memoize(function (name) {
|
|
2999
|
-
var attributeName = camelCase(name);
|
|
3000
|
-
var map = FORMAT_ATTR_MAP[attributeName];
|
|
3001
|
-
attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
|
|
3002
|
-
return attributeName;
|
|
3003
|
-
});
|
|
3004
|
-
|
|
3005
|
-
// type CSSNumericBaseType =
|
|
3006
|
-
// | 'length'
|
|
3007
|
-
// | 'angle'
|
|
3008
|
-
// | 'time'
|
|
3009
|
-
// | 'frequency'
|
|
3010
|
-
// | 'resolution'
|
|
3011
|
-
// | 'flex'
|
|
3012
|
-
// | 'percent';
|
|
3013
|
-
// https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
|
|
3014
|
-
// interface CSSNumericType {
|
|
3015
|
-
// length: number;
|
|
3016
|
-
// angle: number;
|
|
3017
|
-
// time: number;
|
|
3018
|
-
// frequency: number;
|
|
3019
|
-
// resolution: number;
|
|
3020
|
-
// flex: number;
|
|
3021
|
-
// percent: number;
|
|
3022
|
-
// percentHint: CSSNumericBaseType;
|
|
3023
|
-
// }
|
|
3024
2978
|
var formatInfinityOrNaN = function (number, suffix) {
|
|
3025
2979
|
if (suffix === void 0) { suffix = ''; }
|
|
3026
2980
|
var result = '';
|
|
@@ -3031,7 +2985,6 @@ var formatInfinityOrNaN = function (number, suffix) {
|
|
|
3031
2985
|
result = '-infinity';
|
|
3032
2986
|
}
|
|
3033
2987
|
else {
|
|
3034
|
-
DCHECK(Number.isNaN(number));
|
|
3035
2988
|
result = 'NaN';
|
|
3036
2989
|
}
|
|
3037
2990
|
return (result += suffix);
|
|
@@ -3127,25 +3080,25 @@ var CSSUnitValue = /** @class */ (function (_super) {
|
|
|
3127
3080
|
case exports.UnitType.kSeconds:
|
|
3128
3081
|
// case UnitType.kHertz:
|
|
3129
3082
|
// case UnitType.kKilohertz:
|
|
3130
|
-
case exports.UnitType.kTurns:
|
|
3131
|
-
{
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
}
|
|
3141
|
-
else {
|
|
3142
|
-
text = value + (unit_1 || '');
|
|
3143
|
-
}
|
|
3083
|
+
case exports.UnitType.kTurns: {
|
|
3084
|
+
// 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:
|
|
3085
|
+
var kMinInteger = -999999;
|
|
3086
|
+
var kMaxInteger = 999999;
|
|
3087
|
+
var value = this.value;
|
|
3088
|
+
var unit = unitTypeToString(this.unit);
|
|
3089
|
+
if (value < kMinInteger || value > kMaxInteger) {
|
|
3090
|
+
var unit_1 = unitTypeToString(this.unit);
|
|
3091
|
+
if (!Number.isFinite(value) || Number.isNaN(value)) {
|
|
3092
|
+
text = formatInfinityOrNaN(value, unit_1);
|
|
3144
3093
|
}
|
|
3145
3094
|
else {
|
|
3146
|
-
text =
|
|
3095
|
+
text = value + (unit_1 || '');
|
|
3147
3096
|
}
|
|
3148
3097
|
}
|
|
3098
|
+
else {
|
|
3099
|
+
text = "".concat(value).concat(unit);
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3149
3102
|
}
|
|
3150
3103
|
result += text;
|
|
3151
3104
|
return result;
|
|
@@ -3229,99 +3182,6 @@ var getOrCreateUnitValue = function (value, unitOrName) {
|
|
|
3229
3182
|
};
|
|
3230
3183
|
new CSSUnitValue(50, '%');
|
|
3231
3184
|
|
|
3232
|
-
/**
|
|
3233
|
-
* @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
|
|
3234
|
-
*/
|
|
3235
|
-
exports.Strategy = void 0;
|
|
3236
|
-
(function (Strategy) {
|
|
3237
|
-
Strategy[Strategy["Standard"] = 0] = "Standard";
|
|
3238
|
-
})(exports.Strategy || (exports.Strategy = {}));
|
|
3239
|
-
|
|
3240
|
-
exports.SortReason = void 0;
|
|
3241
|
-
(function (SortReason) {
|
|
3242
|
-
SortReason[SortReason["ADDED"] = 0] = "ADDED";
|
|
3243
|
-
SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
|
|
3244
|
-
SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
|
|
3245
|
-
})(exports.SortReason || (exports.SortReason = {}));
|
|
3246
|
-
|
|
3247
|
-
var EMPTY_PARSED_PATH = {
|
|
3248
|
-
absolutePath: [],
|
|
3249
|
-
hasArc: false,
|
|
3250
|
-
segments: [],
|
|
3251
|
-
polygons: [],
|
|
3252
|
-
polylines: [],
|
|
3253
|
-
curve: null,
|
|
3254
|
-
totalLength: 0,
|
|
3255
|
-
rect: new Rectangle(0, 0, 0, 0),
|
|
3256
|
-
};
|
|
3257
|
-
|
|
3258
|
-
/**
|
|
3259
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
|
|
3260
|
-
*/
|
|
3261
|
-
exports.PropertySyntax = void 0;
|
|
3262
|
-
(function (PropertySyntax) {
|
|
3263
|
-
/**
|
|
3264
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
3265
|
-
*/
|
|
3266
|
-
PropertySyntax["COORDINATE"] = "<coordinate>";
|
|
3267
|
-
/**
|
|
3268
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
|
|
3269
|
-
*/
|
|
3270
|
-
PropertySyntax["COLOR"] = "<color>";
|
|
3271
|
-
/**
|
|
3272
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
|
|
3273
|
-
*/
|
|
3274
|
-
PropertySyntax["PAINT"] = "<paint>";
|
|
3275
|
-
/**
|
|
3276
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
|
|
3277
|
-
*/
|
|
3278
|
-
PropertySyntax["NUMBER"] = "<number>";
|
|
3279
|
-
/**
|
|
3280
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
|
|
3281
|
-
*/
|
|
3282
|
-
PropertySyntax["ANGLE"] = "<angle>";
|
|
3283
|
-
/**
|
|
3284
|
-
* <number> with range 0..1
|
|
3285
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
|
|
3286
|
-
*/
|
|
3287
|
-
PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
|
|
3288
|
-
/**
|
|
3289
|
-
* <number> with range 0..Infinity
|
|
3290
|
-
*/
|
|
3291
|
-
PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
|
|
3292
|
-
/**
|
|
3293
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
|
|
3294
|
-
*/
|
|
3295
|
-
PropertySyntax["LENGTH"] = "<length>";
|
|
3296
|
-
/**
|
|
3297
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
|
|
3298
|
-
*/
|
|
3299
|
-
PropertySyntax["PERCENTAGE"] = "<percentage>";
|
|
3300
|
-
PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
|
|
3301
|
-
PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
|
|
3302
|
-
/**
|
|
3303
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
|
|
3304
|
-
*/
|
|
3305
|
-
PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
|
|
3306
|
-
/**
|
|
3307
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
3308
|
-
*/
|
|
3309
|
-
PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
|
|
3310
|
-
PropertySyntax["PATH"] = "<path>";
|
|
3311
|
-
/**
|
|
3312
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
3313
|
-
*/
|
|
3314
|
-
PropertySyntax["FILTER"] = "<filter>";
|
|
3315
|
-
PropertySyntax["Z_INDEX"] = "<z-index>";
|
|
3316
|
-
PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
|
|
3317
|
-
PropertySyntax["DEFINED_PATH"] = "<defined-path>";
|
|
3318
|
-
PropertySyntax["MARKER"] = "<marker>";
|
|
3319
|
-
PropertySyntax["TRANSFORM"] = "<transform>";
|
|
3320
|
-
PropertySyntax["TRANSFORM_ORIGIN"] = "<transform-origin>";
|
|
3321
|
-
PropertySyntax["TEXT"] = "<text>";
|
|
3322
|
-
PropertySyntax["TEXT_TRANSFORM"] = "<text-transform>";
|
|
3323
|
-
})(exports.PropertySyntax || (exports.PropertySyntax = {}));
|
|
3324
|
-
|
|
3325
3185
|
/**
|
|
3326
3186
|
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
3327
3187
|
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
@@ -4145,16 +4005,6 @@ function parseDimensionArrayFormat(string, size) {
|
|
|
4145
4005
|
}
|
|
4146
4006
|
}
|
|
4147
4007
|
}
|
|
4148
|
-
function parseDimensionArray(string) {
|
|
4149
|
-
if (util.isString(string)) {
|
|
4150
|
-
// "1px 2px 3px"
|
|
4151
|
-
return string.split(' ').map(function (segment) { return parseLengthOrPercentage(segment); });
|
|
4152
|
-
}
|
|
4153
|
-
else {
|
|
4154
|
-
// [1, '2px', 3]
|
|
4155
|
-
return string.map(function (segment) { return parseLengthOrPercentage(segment.toString()); });
|
|
4156
|
-
}
|
|
4157
|
-
}
|
|
4158
4008
|
// export function mergeDimensionList(
|
|
4159
4009
|
// left: CSSUnitValue[],
|
|
4160
4010
|
// right: CSSUnitValue[],
|
|
@@ -5183,6 +5033,7 @@ function mergePoints(left, right) {
|
|
|
5183
5033
|
}
|
|
5184
5034
|
|
|
5185
5035
|
var _ = null;
|
|
5036
|
+
var TRANSFORM_REGEXP = /\s*(\w+)\(([^)]*)\)/g;
|
|
5186
5037
|
function cast(pattern) {
|
|
5187
5038
|
return function (contents) {
|
|
5188
5039
|
var i = 0;
|
|
@@ -5201,48 +5052,75 @@ var transformFunctions = {
|
|
|
5201
5052
|
matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
|
|
5202
5053
|
matrix3d: ['NNNNNNNNNNNNNNNN', id],
|
|
5203
5054
|
rotate: ['A'],
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5055
|
+
rotateX: ['A'],
|
|
5056
|
+
rotateY: ['A'],
|
|
5057
|
+
rotateZ: ['A'],
|
|
5207
5058
|
rotate3d: ['NNNA'],
|
|
5208
5059
|
perspective: ['L'],
|
|
5209
5060
|
scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
|
|
5210
|
-
|
|
5061
|
+
scaleX: [
|
|
5211
5062
|
'N',
|
|
5212
5063
|
cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]),
|
|
5213
5064
|
cast([_, new CSSUnitValue(1)]),
|
|
5214
5065
|
],
|
|
5215
|
-
|
|
5066
|
+
scaleY: [
|
|
5216
5067
|
'N',
|
|
5217
5068
|
cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]),
|
|
5218
5069
|
cast([new CSSUnitValue(1), _]),
|
|
5219
5070
|
],
|
|
5220
|
-
|
|
5071
|
+
scaleZ: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
|
|
5221
5072
|
scale3d: ['NNN', id],
|
|
5222
5073
|
skew: ['Aa', null, id],
|
|
5223
|
-
|
|
5224
|
-
|
|
5074
|
+
skewX: ['A', null, cast([_, Odeg])],
|
|
5075
|
+
skewY: ['A', null, cast([Odeg, _])],
|
|
5225
5076
|
translate: ['Tt', cast([_, _, Opx]), id],
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5077
|
+
translateX: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
|
|
5078
|
+
translateY: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
|
|
5079
|
+
translateZ: ['L', cast([Opx, Opx, _])],
|
|
5229
5080
|
translate3d: ['TTL', id],
|
|
5230
5081
|
};
|
|
5082
|
+
function parseArrayTransform(transform) {
|
|
5083
|
+
var result = [];
|
|
5084
|
+
var length = transform.length;
|
|
5085
|
+
for (var i = 0; i < length; i++) {
|
|
5086
|
+
var item = transform[i];
|
|
5087
|
+
var name_1 = item[0];
|
|
5088
|
+
var args = item.slice(1);
|
|
5089
|
+
// infer default value
|
|
5090
|
+
if (name_1 === 'translate' || name_1 === 'skew') {
|
|
5091
|
+
if (args.length === 1)
|
|
5092
|
+
args.push(0);
|
|
5093
|
+
}
|
|
5094
|
+
else if (name_1 === 'scale') {
|
|
5095
|
+
if (args.length === 1)
|
|
5096
|
+
args.push(args[0]);
|
|
5097
|
+
}
|
|
5098
|
+
var functionData = transformFunctions[name_1];
|
|
5099
|
+
if (!functionData)
|
|
5100
|
+
return [];
|
|
5101
|
+
var parsedArgs = args.map(function (value) { return getOrCreateUnitValue(value); });
|
|
5102
|
+
result.push({ t: name_1, d: parsedArgs });
|
|
5103
|
+
}
|
|
5104
|
+
return result;
|
|
5105
|
+
}
|
|
5231
5106
|
/**
|
|
5232
5107
|
* none
|
|
5233
5108
|
* scale(1) scale(1, 2)
|
|
5234
5109
|
* scaleX(1)
|
|
5235
5110
|
*/
|
|
5236
|
-
function parseTransform(
|
|
5237
|
-
|
|
5238
|
-
|
|
5111
|
+
function parseTransform(transform) {
|
|
5112
|
+
if (Array.isArray(transform)) {
|
|
5113
|
+
return parseArrayTransform(transform);
|
|
5114
|
+
}
|
|
5115
|
+
transform = (transform || 'none').trim();
|
|
5116
|
+
if (transform === 'none') {
|
|
5239
5117
|
return [];
|
|
5240
5118
|
}
|
|
5241
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5242
5119
|
var result = [];
|
|
5243
5120
|
var match;
|
|
5244
5121
|
var prevLastIndex = 0;
|
|
5245
|
-
|
|
5122
|
+
TRANSFORM_REGEXP.lastIndex = 0;
|
|
5123
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5246
5124
|
if (match.index !== prevLastIndex) {
|
|
5247
5125
|
return [];
|
|
5248
5126
|
}
|
|
@@ -5289,22 +5167,25 @@ function parseTransform(string) {
|
|
|
5289
5167
|
parsedArgs.push(parsedArg);
|
|
5290
5168
|
}
|
|
5291
5169
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5292
|
-
if (
|
|
5170
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5293
5171
|
return result;
|
|
5294
5172
|
}
|
|
5295
5173
|
}
|
|
5296
5174
|
return [];
|
|
5297
5175
|
}
|
|
5298
|
-
function parseTransformUnmemoize(
|
|
5299
|
-
|
|
5300
|
-
|
|
5176
|
+
function parseTransformUnmemoize(transform) {
|
|
5177
|
+
if (Array.isArray(transform)) {
|
|
5178
|
+
return parseArrayTransform(transform);
|
|
5179
|
+
}
|
|
5180
|
+
transform = (transform || 'none').trim();
|
|
5181
|
+
if (transform === 'none') {
|
|
5301
5182
|
return [];
|
|
5302
5183
|
}
|
|
5303
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5304
5184
|
var result = [];
|
|
5305
5185
|
var match;
|
|
5306
5186
|
var prevLastIndex = 0;
|
|
5307
|
-
|
|
5187
|
+
TRANSFORM_REGEXP.lastIndex = 0;
|
|
5188
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5308
5189
|
if (match.index !== prevLastIndex) {
|
|
5309
5190
|
return [];
|
|
5310
5191
|
}
|
|
@@ -5351,7 +5232,7 @@ function parseTransformUnmemoize(string) {
|
|
|
5351
5232
|
parsedArgs.push(parsedArg);
|
|
5352
5233
|
}
|
|
5353
5234
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5354
|
-
if (
|
|
5235
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5355
5236
|
return result;
|
|
5356
5237
|
}
|
|
5357
5238
|
}
|
|
@@ -5363,7 +5244,7 @@ function convertItemToMatrix(item) {
|
|
|
5363
5244
|
var z;
|
|
5364
5245
|
var angle;
|
|
5365
5246
|
switch (item.t) {
|
|
5366
|
-
case '
|
|
5247
|
+
case 'rotateX':
|
|
5367
5248
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5368
5249
|
return [
|
|
5369
5250
|
1,
|
|
@@ -5383,7 +5264,7 @@ function convertItemToMatrix(item) {
|
|
|
5383
5264
|
0,
|
|
5384
5265
|
1,
|
|
5385
5266
|
];
|
|
5386
|
-
case '
|
|
5267
|
+
case 'rotateY':
|
|
5387
5268
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5388
5269
|
return [
|
|
5389
5270
|
Math.cos(angle),
|
|
@@ -5404,7 +5285,7 @@ function convertItemToMatrix(item) {
|
|
|
5404
5285
|
1,
|
|
5405
5286
|
];
|
|
5406
5287
|
case 'rotate':
|
|
5407
|
-
case '
|
|
5288
|
+
case 'rotateZ':
|
|
5408
5289
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5409
5290
|
return [
|
|
5410
5291
|
Math.cos(angle),
|
|
@@ -5481,11 +5362,11 @@ function convertItemToMatrix(item) {
|
|
|
5481
5362
|
0,
|
|
5482
5363
|
1,
|
|
5483
5364
|
];
|
|
5484
|
-
case '
|
|
5365
|
+
case 'scaleX':
|
|
5485
5366
|
return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5486
|
-
case '
|
|
5367
|
+
case 'scaleY':
|
|
5487
5368
|
return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5488
|
-
case '
|
|
5369
|
+
case 'scaleZ':
|
|
5489
5370
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
|
|
5490
5371
|
case 'scale3d':
|
|
5491
5372
|
return [
|
|
@@ -5527,10 +5408,10 @@ function convertItemToMatrix(item) {
|
|
|
5527
5408
|
0,
|
|
5528
5409
|
1,
|
|
5529
5410
|
];
|
|
5530
|
-
case '
|
|
5411
|
+
case 'skewX':
|
|
5531
5412
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5532
5413
|
return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5533
|
-
case '
|
|
5414
|
+
case 'skewY':
|
|
5534
5415
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5535
5416
|
return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5536
5417
|
case 'translate':
|
|
@@ -5538,13 +5419,13 @@ function convertItemToMatrix(item) {
|
|
|
5538
5419
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5539
5420
|
y = convertPercentUnit(item.d[1], 0, null) || 0;
|
|
5540
5421
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
|
|
5541
|
-
case '
|
|
5422
|
+
case 'translateX':
|
|
5542
5423
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5543
5424
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
|
|
5544
|
-
case '
|
|
5425
|
+
case 'translateY':
|
|
5545
5426
|
y = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5546
5427
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
|
|
5547
|
-
case '
|
|
5428
|
+
case 'translateZ':
|
|
5548
5429
|
z = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5549
5430
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
|
|
5550
5431
|
case 'translate3d':
|
|
@@ -5785,13 +5666,13 @@ function quat(fromQ, toQ, f) {
|
|
|
5785
5666
|
}
|
|
5786
5667
|
return quat;
|
|
5787
5668
|
}
|
|
5788
|
-
//
|
|
5669
|
+
// scaleX/Y/Z -> scale
|
|
5789
5670
|
function typeTo2D(type) {
|
|
5790
|
-
return type.replace(/[
|
|
5671
|
+
return type.replace(/[XY]/, '');
|
|
5791
5672
|
}
|
|
5792
|
-
//
|
|
5673
|
+
// scaleX/Y/Z -> scale3d
|
|
5793
5674
|
function typeTo3D(type) {
|
|
5794
|
-
return type.replace(/(
|
|
5675
|
+
return type.replace(/(X|Y|Z|3d)?$/, '3d');
|
|
5795
5676
|
}
|
|
5796
5677
|
var isMatrixOrPerspective = function (lt, rt) {
|
|
5797
5678
|
return ((lt === 'perspective' && rt === 'perspective') ||
|
|
@@ -5972,39 +5853,6 @@ var parseTransformOrigin = memoize(function (value) {
|
|
|
5972
5853
|
];
|
|
5973
5854
|
}
|
|
5974
5855
|
});
|
|
5975
|
-
var parseTransformOriginUnmemoize = function (value) {
|
|
5976
|
-
if (util.isString(value)) {
|
|
5977
|
-
if (value === 'text-anchor') {
|
|
5978
|
-
return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
|
|
5979
|
-
}
|
|
5980
|
-
var values = value.split(' ');
|
|
5981
|
-
if (values.length === 1) {
|
|
5982
|
-
if (values[0] === 'top' || values[0] === 'bottom') {
|
|
5983
|
-
// 'top' -> 'center top'
|
|
5984
|
-
values[1] = values[0];
|
|
5985
|
-
values[0] = 'center';
|
|
5986
|
-
}
|
|
5987
|
-
else {
|
|
5988
|
-
// '50px' -> '50px center'
|
|
5989
|
-
values[1] = 'center';
|
|
5990
|
-
}
|
|
5991
|
-
}
|
|
5992
|
-
if (values.length !== 2) {
|
|
5993
|
-
return null;
|
|
5994
|
-
}
|
|
5995
|
-
// eg. center bottom
|
|
5996
|
-
return [
|
|
5997
|
-
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
|
|
5998
|
-
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
|
|
5999
|
-
];
|
|
6000
|
-
}
|
|
6001
|
-
else {
|
|
6002
|
-
return [
|
|
6003
|
-
getOrCreateUnitValue(value[0] || 0, 'px'),
|
|
6004
|
-
getOrCreateUnitValue(value[1] || 0, 'px'),
|
|
6005
|
-
];
|
|
6006
|
-
}
|
|
6007
|
-
};
|
|
6008
5856
|
function convertKeyword2Percent(keyword) {
|
|
6009
5857
|
if (keyword === 'center') {
|
|
6010
5858
|
return '50%';
|
|
@@ -6599,23 +6447,7 @@ var BUILT_IN_PROPERTIES = [
|
|
|
6599
6447
|
];
|
|
6600
6448
|
var GEOMETRY_ATTRIBUTE_NAMES = BUILT_IN_PROPERTIES.filter(function (n) { return !!n.l; }).map(function (n) { return n.n; });
|
|
6601
6449
|
var propertyMetadataCache = {};
|
|
6602
|
-
var unresolvedProperties = new WeakMap();
|
|
6603
|
-
// const uniqueAttributeSet = new Set<string>();
|
|
6604
|
-
// const tmpVec3a = vec3.create();
|
|
6605
|
-
// const tmpVec3b = vec3.create();
|
|
6606
|
-
// const tmpVec3c = vec3.create();
|
|
6607
|
-
var isPropertyResolved = function (object, name) {
|
|
6608
|
-
var properties = unresolvedProperties.get(object);
|
|
6609
|
-
if (!properties || properties.length === 0) {
|
|
6610
|
-
return true;
|
|
6611
|
-
}
|
|
6612
|
-
return properties.includes(name);
|
|
6613
|
-
};
|
|
6614
6450
|
var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
6615
|
-
/**
|
|
6616
|
-
* need recalc later
|
|
6617
|
-
*/
|
|
6618
|
-
// dirty = false;
|
|
6619
6451
|
function DefaultStyleValueRegistry(runtime) {
|
|
6620
6452
|
var _this = this;
|
|
6621
6453
|
this.runtime = runtime;
|
|
@@ -6628,9 +6460,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6628
6460
|
propertyMetadataCache[name] = metadata;
|
|
6629
6461
|
});
|
|
6630
6462
|
};
|
|
6631
|
-
DefaultStyleValueRegistry.prototype.unregisterMetadata = function (name) {
|
|
6632
|
-
delete propertyMetadataCache[name];
|
|
6633
|
-
};
|
|
6634
6463
|
DefaultStyleValueRegistry.prototype.getPropertySyntax = function (syntax) {
|
|
6635
6464
|
return this.runtime.CSSPropertySyntaxFactory[syntax];
|
|
6636
6465
|
};
|
|
@@ -6644,7 +6473,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6644
6473
|
* * post process
|
|
6645
6474
|
*/
|
|
6646
6475
|
DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
|
|
6647
|
-
var _this = this;
|
|
6648
6476
|
if (options === void 0) { options = {
|
|
6649
6477
|
skipUpdateAttribute: false,
|
|
6650
6478
|
skipParse: false,
|
|
@@ -6652,365 +6480,116 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6652
6480
|
usedAttributes: [],
|
|
6653
6481
|
memoize: true,
|
|
6654
6482
|
}; }
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
if (attributes.filter) {
|
|
6681
|
-
object.parsedStyle.filter = parseFilter(attributes.filter);
|
|
6682
|
-
}
|
|
6683
|
-
// Rect
|
|
6684
|
-
// @ts-ignore
|
|
6685
|
-
if (!util.isNil(attributes.radius)) {
|
|
6686
|
-
// @ts-ignore
|
|
6687
|
-
object.parsedStyle.radius = parseDimensionArrayFormat(
|
|
6688
|
-
// @ts-ignore
|
|
6689
|
-
attributes.radius, 4);
|
|
6690
|
-
}
|
|
6691
|
-
// Polyline
|
|
6692
|
-
if (!util.isNil(attributes.lineDash)) {
|
|
6693
|
-
object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
|
|
6694
|
-
}
|
|
6695
|
-
// @ts-ignore
|
|
6696
|
-
if (attributes.points) {
|
|
6697
|
-
// @ts-ignore
|
|
6698
|
-
object.parsedStyle.points = parsePoints(attributes.points);
|
|
6699
|
-
}
|
|
6700
|
-
// Path
|
|
6701
|
-
// @ts-ignore
|
|
6702
|
-
if (attributes.d === '') {
|
|
6703
|
-
object.parsedStyle.d = tslib.__assign({}, EMPTY_PARSED_PATH);
|
|
6704
|
-
}
|
|
6483
|
+
Object.assign(object.attributes, attributes);
|
|
6484
|
+
// clipPath
|
|
6485
|
+
var oldClipPath = object.parsedStyle.clipPath;
|
|
6486
|
+
var oldOffsetPath = object.parsedStyle.offsetPath;
|
|
6487
|
+
Object.assign(object.parsedStyle, attributes);
|
|
6488
|
+
var needUpdateGeometry = !!options.forceUpdateGeometry;
|
|
6489
|
+
if (!needUpdateGeometry &&
|
|
6490
|
+
GEOMETRY_ATTRIBUTE_NAMES.some(function (name) { return name in attributes; })) {
|
|
6491
|
+
needUpdateGeometry = true;
|
|
6492
|
+
}
|
|
6493
|
+
if (attributes.fill) {
|
|
6494
|
+
object.parsedStyle.fill = parseColor(attributes.fill);
|
|
6495
|
+
}
|
|
6496
|
+
if (attributes.stroke) {
|
|
6497
|
+
object.parsedStyle.stroke = parseColor(attributes.stroke);
|
|
6498
|
+
}
|
|
6499
|
+
if (attributes.shadowColor) {
|
|
6500
|
+
object.parsedStyle.shadowColor = parseColor(attributes.shadowColor);
|
|
6501
|
+
}
|
|
6502
|
+
if (attributes.filter) {
|
|
6503
|
+
object.parsedStyle.filter = parseFilter(attributes.filter);
|
|
6504
|
+
}
|
|
6505
|
+
// Rect
|
|
6506
|
+
// @ts-ignore
|
|
6507
|
+
if (!util.isNil(attributes.radius)) {
|
|
6705
6508
|
// @ts-ignore
|
|
6706
|
-
|
|
6707
|
-
object.parsedStyle.d = parsePath(
|
|
6708
|
-
// @ts-ignore
|
|
6709
|
-
attributes.d);
|
|
6710
|
-
}
|
|
6711
|
-
// Text
|
|
6712
|
-
if (attributes.textTransform) {
|
|
6713
|
-
this.runtime.CSSPropertySyntaxFactory['<text-transform>'].calculator(null, null, { value: attributes.textTransform }, object, null);
|
|
6714
|
-
}
|
|
6715
|
-
if (!util.isUndefined(attributes.clipPath)) {
|
|
6716
|
-
this.runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
|
|
6717
|
-
}
|
|
6718
|
-
if (attributes.offsetPath) {
|
|
6719
|
-
this.runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
|
|
6720
|
-
}
|
|
6721
|
-
if (attributes.transform) {
|
|
6722
|
-
object.parsedStyle.transform = parseTransform(attributes.transform);
|
|
6723
|
-
}
|
|
6724
|
-
if (attributes.transformOrigin) {
|
|
6725
|
-
object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
|
|
6726
|
-
}
|
|
6727
|
-
// Marker
|
|
6509
|
+
object.parsedStyle.radius = parseDimensionArrayFormat(
|
|
6728
6510
|
// @ts-ignore
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6511
|
+
attributes.radius, 4);
|
|
6512
|
+
}
|
|
6513
|
+
// Polyline
|
|
6514
|
+
if (!util.isNil(attributes.lineDash)) {
|
|
6515
|
+
object.parsedStyle.lineDash = parseDimensionArrayFormat(attributes.lineDash, 2);
|
|
6516
|
+
}
|
|
6517
|
+
// @ts-ignore
|
|
6518
|
+
if (attributes.points) {
|
|
6736
6519
|
// @ts-ignore
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6520
|
+
object.parsedStyle.points = parsePoints(attributes.points);
|
|
6521
|
+
}
|
|
6522
|
+
// Path
|
|
6523
|
+
// @ts-ignore
|
|
6524
|
+
if (attributes.d === '') {
|
|
6525
|
+
object.parsedStyle.d = tslib.__assign({}, EMPTY_PARSED_PATH);
|
|
6526
|
+
}
|
|
6527
|
+
// @ts-ignore
|
|
6528
|
+
if (attributes.d) {
|
|
6529
|
+
object.parsedStyle.d = parsePath(
|
|
6744
6530
|
// @ts-ignore
|
|
6745
|
-
|
|
6746
|
-
object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory['<marker>'].calculator('',
|
|
6747
|
-
// @ts-ignore
|
|
6748
|
-
attributes.markerMid,
|
|
6749
|
-
// @ts-ignore
|
|
6750
|
-
attributes.markerMid, null, null);
|
|
6751
|
-
}
|
|
6752
|
-
if (!util.isNil(attributes.zIndex)) {
|
|
6753
|
-
this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames);
|
|
6754
|
-
}
|
|
6755
|
-
if (!util.isNil(attributes.offsetDistance)) {
|
|
6756
|
-
this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, attributeNames);
|
|
6757
|
-
}
|
|
6758
|
-
if (attributes.transform) {
|
|
6759
|
-
this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames);
|
|
6760
|
-
}
|
|
6761
|
-
if (attributes.transformOrigin) {
|
|
6762
|
-
this.runtime.CSSPropertySyntaxFactory['<transform-origin>'].postProcessor(object, attributeNames);
|
|
6763
|
-
}
|
|
6764
|
-
if (needUpdateGeometry) {
|
|
6765
|
-
object.geometry.dirty = true;
|
|
6766
|
-
object.renderable.boundsDirty = true;
|
|
6767
|
-
object.renderable.renderBoundsDirty = true;
|
|
6768
|
-
if (!options.forceUpdateGeometry) {
|
|
6769
|
-
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6770
|
-
}
|
|
6771
|
-
}
|
|
6531
|
+
attributes.d);
|
|
6772
6532
|
}
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
var attributeNames_1 = Object.keys(attributes);
|
|
6777
|
-
attributeNames_1.forEach(function (attributeName) {
|
|
6778
|
-
var _a;
|
|
6779
|
-
if (!skipUpdateAttribute_1) {
|
|
6780
|
-
object.attributes[attributeName] = attributes[attributeName];
|
|
6781
|
-
}
|
|
6782
|
-
if (!needUpdateGeometry_1 && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
|
|
6783
|
-
needUpdateGeometry_1 = true;
|
|
6784
|
-
}
|
|
6785
|
-
});
|
|
6786
|
-
if (!skipParse) {
|
|
6787
|
-
attributeNames_1.forEach(function (name) {
|
|
6788
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize_1);
|
|
6789
|
-
});
|
|
6790
|
-
}
|
|
6791
|
-
// let hasUnresolvedProperties = false;
|
|
6792
|
-
// parse according to priority
|
|
6793
|
-
// path 50
|
|
6794
|
-
// points 50
|
|
6795
|
-
// text 50
|
|
6796
|
-
// textTransform 51
|
|
6797
|
-
// transform 100
|
|
6798
|
-
// transformOrigin 100
|
|
6799
|
-
if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
|
|
6800
|
-
// uniqueAttributeSet.clear();
|
|
6801
|
-
attributeNames_1 = Array.from(new Set(attributeNames_1.concat(usedAttributes)));
|
|
6802
|
-
}
|
|
6803
|
-
// [
|
|
6804
|
-
// 'path',
|
|
6805
|
-
// 'points',
|
|
6806
|
-
// 'text',
|
|
6807
|
-
// 'textTransform',
|
|
6808
|
-
// 'transform',
|
|
6809
|
-
// 'transformOrigin',
|
|
6810
|
-
// ].forEach((name) => {
|
|
6811
|
-
// const index = attributeNames.indexOf(name);
|
|
6812
|
-
// if (index > -1) {
|
|
6813
|
-
// attributeNames.splice(index, 1);
|
|
6814
|
-
// attributeNames.push(name);
|
|
6815
|
-
// }
|
|
6816
|
-
// });
|
|
6817
|
-
attributeNames_1.forEach(function (name) {
|
|
6818
|
-
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
6819
|
-
if (name in object.computedStyle) {
|
|
6820
|
-
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize_1);
|
|
6821
|
-
}
|
|
6822
|
-
});
|
|
6823
|
-
// if (hasUnresolvedProperties) {
|
|
6824
|
-
// this.dirty = true;
|
|
6825
|
-
// return;
|
|
6826
|
-
// }
|
|
6827
|
-
// update geometry
|
|
6828
|
-
if (needUpdateGeometry_1) {
|
|
6829
|
-
object.geometry.dirty = true;
|
|
6830
|
-
object.renderable.boundsDirty = true;
|
|
6831
|
-
object.renderable.renderBoundsDirty = true;
|
|
6832
|
-
if (!options.forceUpdateGeometry) {
|
|
6833
|
-
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6834
|
-
}
|
|
6835
|
-
}
|
|
6836
|
-
attributeNames_1.forEach(function (name) {
|
|
6837
|
-
if (name in object.parsedStyle) {
|
|
6838
|
-
_this.postProcessProperty(name, object, attributeNames_1);
|
|
6839
|
-
}
|
|
6840
|
-
});
|
|
6841
|
-
if (this.runtime.enableCSSParsing && object.children.length) {
|
|
6842
|
-
attributeNames_1.forEach(function (name) {
|
|
6843
|
-
if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
|
|
6844
|
-
// update children's inheritable
|
|
6845
|
-
object.children.forEach(function (child) {
|
|
6846
|
-
child.internalSetAttribute(name, null, {
|
|
6847
|
-
skipUpdateAttribute: true,
|
|
6848
|
-
skipParse: true,
|
|
6849
|
-
});
|
|
6850
|
-
});
|
|
6851
|
-
}
|
|
6852
|
-
});
|
|
6853
|
-
}
|
|
6533
|
+
// Text
|
|
6534
|
+
if (attributes.textTransform) {
|
|
6535
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.TEXT_TRANSFORM].calculator(null, null, { value: attributes.textTransform }, object, null);
|
|
6854
6536
|
}
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
* string -> parsed value
|
|
6858
|
-
*/
|
|
6859
|
-
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object, memoized) {
|
|
6860
|
-
var metadata = propertyMetadataCache[name];
|
|
6861
|
-
var computed = value;
|
|
6862
|
-
if (value === '' || util.isNil(value)) {
|
|
6863
|
-
value = 'unset';
|
|
6537
|
+
if (!util.isUndefined(attributes.clipPath)) {
|
|
6538
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.DEFINED_PATH].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
|
|
6864
6539
|
}
|
|
6865
|
-
if (
|
|
6866
|
-
|
|
6867
|
-
computed = getOrCreateKeyword(value);
|
|
6540
|
+
if (attributes.offsetPath) {
|
|
6541
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.DEFINED_PATH].calculator('offsetPath', oldOffsetPath, attributes.offsetPath, object, this.runtime);
|
|
6868
6542
|
}
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
|
|
6884
|
-
computed = handler.parser(value, object);
|
|
6885
|
-
}
|
|
6886
|
-
}
|
|
6887
|
-
}
|
|
6543
|
+
if (attributes.transform) {
|
|
6544
|
+
object.parsedStyle.transform = parseTransform(attributes.transform);
|
|
6545
|
+
}
|
|
6546
|
+
if (attributes.transformOrigin) {
|
|
6547
|
+
object.parsedStyle.transformOrigin = parseTransformOrigin(attributes.transformOrigin);
|
|
6548
|
+
}
|
|
6549
|
+
// Marker
|
|
6550
|
+
// @ts-ignore
|
|
6551
|
+
if (attributes.markerStart) {
|
|
6552
|
+
object.parsedStyle.markerStart = this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.MARKER].calculator(null,
|
|
6553
|
+
// @ts-ignore
|
|
6554
|
+
attributes.markerStart,
|
|
6555
|
+
// @ts-ignore
|
|
6556
|
+
attributes.markerStart, null, null);
|
|
6888
6557
|
}
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
var isDocumentElement = object.id === 'g-root';
|
|
6897
|
-
// let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
|
|
6898
|
-
var used = computed;
|
|
6899
|
-
if (metadata) {
|
|
6900
|
-
var syntax = metadata.syntax, inherited = metadata.inh, defaultValue = metadata.d;
|
|
6901
|
-
if (computed instanceof CSSKeywordValue) {
|
|
6902
|
-
var value = computed.value;
|
|
6903
|
-
/**
|
|
6904
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
|
|
6905
|
-
*/
|
|
6906
|
-
if (value === 'unset') {
|
|
6907
|
-
if (inherited && !isDocumentElement) {
|
|
6908
|
-
value = 'inherit';
|
|
6909
|
-
}
|
|
6910
|
-
else {
|
|
6911
|
-
value = 'initial';
|
|
6912
|
-
}
|
|
6913
|
-
}
|
|
6914
|
-
if (value === 'initial') {
|
|
6915
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
6916
|
-
if (!util.isNil(defaultValue)) {
|
|
6917
|
-
computed = this.parseProperty(name, isFunction(defaultValue)
|
|
6918
|
-
? defaultValue(object.nodeName)
|
|
6919
|
-
: defaultValue, object, memoized);
|
|
6920
|
-
}
|
|
6921
|
-
}
|
|
6922
|
-
else if (value === 'inherit') {
|
|
6923
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
6924
|
-
// behave like `inherit`
|
|
6925
|
-
var resolved = this.tryToResolveProperty(object, name, {
|
|
6926
|
-
inherited: true,
|
|
6927
|
-
});
|
|
6928
|
-
if (!util.isNil(resolved)) {
|
|
6929
|
-
// object.parsedStyle[name] = resolved;
|
|
6930
|
-
// return false;
|
|
6931
|
-
return resolved;
|
|
6932
|
-
}
|
|
6933
|
-
else {
|
|
6934
|
-
this.addUnresolveProperty(object, name);
|
|
6935
|
-
return;
|
|
6936
|
-
}
|
|
6937
|
-
}
|
|
6938
|
-
}
|
|
6939
|
-
var handler = syntax && this.getPropertySyntax(syntax);
|
|
6940
|
-
if (handler && handler.calculator) {
|
|
6941
|
-
// convert computed value to used value
|
|
6942
|
-
var oldParsedValue = object.parsedStyle[name];
|
|
6943
|
-
used = handler.calculator(name, oldParsedValue, computed, object, this.runtime);
|
|
6944
|
-
}
|
|
6945
|
-
else if (computed instanceof CSSKeywordValue) {
|
|
6946
|
-
used = computed.value;
|
|
6947
|
-
}
|
|
6948
|
-
else {
|
|
6949
|
-
used = computed;
|
|
6950
|
-
}
|
|
6558
|
+
// @ts-ignore
|
|
6559
|
+
if (attributes.markerEnd) {
|
|
6560
|
+
object.parsedStyle.markerEnd = this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.MARKER].calculator(null,
|
|
6561
|
+
// @ts-ignore
|
|
6562
|
+
attributes.markerEnd,
|
|
6563
|
+
// @ts-ignore
|
|
6564
|
+
attributes.markerEnd, null, null);
|
|
6951
6565
|
}
|
|
6952
|
-
//
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
var handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
|
|
6960
|
-
var propertyHandler = handler;
|
|
6961
|
-
if (propertyHandler && propertyHandler.postProcessor) {
|
|
6962
|
-
propertyHandler.postProcessor(object, attributes);
|
|
6963
|
-
}
|
|
6566
|
+
// @ts-ignore
|
|
6567
|
+
if (attributes.markerMid) {
|
|
6568
|
+
object.parsedStyle.markerMid = this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.MARKER].calculator('',
|
|
6569
|
+
// @ts-ignore
|
|
6570
|
+
attributes.markerMid,
|
|
6571
|
+
// @ts-ignore
|
|
6572
|
+
attributes.markerMid, null, null);
|
|
6964
6573
|
}
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
* resolve later
|
|
6968
|
-
*/
|
|
6969
|
-
DefaultStyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
|
|
6970
|
-
var properties = unresolvedProperties.get(object);
|
|
6971
|
-
if (!properties) {
|
|
6972
|
-
unresolvedProperties.set(object, []);
|
|
6973
|
-
properties = unresolvedProperties.get(object);
|
|
6574
|
+
if (!util.isNil(attributes.zIndex)) {
|
|
6575
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.Z_INDEX].postProcessor(object);
|
|
6974
6576
|
}
|
|
6975
|
-
if (
|
|
6976
|
-
|
|
6577
|
+
if (!util.isNil(attributes.offsetDistance)) {
|
|
6578
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.OFFSET_DISTANCE].postProcessor(object);
|
|
6977
6579
|
}
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
if (options === void 0) { options = {}; }
|
|
6981
|
-
var inherited = options.inherited;
|
|
6982
|
-
if (inherited) {
|
|
6983
|
-
if (object.parentElement &&
|
|
6984
|
-
isPropertyResolved(object.parentElement, name)) {
|
|
6985
|
-
// const computedValue = object.parentElement.computedStyle[name];
|
|
6986
|
-
var usedValue = object.parentElement.parsedStyle[name];
|
|
6987
|
-
if (
|
|
6988
|
-
// usedValue instanceof CSSKeywordValue &&
|
|
6989
|
-
usedValue === 'unset' ||
|
|
6990
|
-
usedValue === 'initial' ||
|
|
6991
|
-
usedValue === 'inherit') {
|
|
6992
|
-
return;
|
|
6993
|
-
}
|
|
6994
|
-
// else if (
|
|
6995
|
-
// usedValue instanceof CSSUnitValue &&
|
|
6996
|
-
// CSSUnitValue.isRelativeUnit(usedValue.unit)
|
|
6997
|
-
// ) {
|
|
6998
|
-
// return false;
|
|
6999
|
-
// }
|
|
7000
|
-
return usedValue;
|
|
7001
|
-
}
|
|
6580
|
+
if (attributes.transform) {
|
|
6581
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.TRANSFORM].postProcessor(object);
|
|
7002
6582
|
}
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
unresolvedProperties.delete(object);
|
|
6583
|
+
if (attributes.transformOrigin) {
|
|
6584
|
+
this.runtime.CSSPropertySyntaxFactory[exports.PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
|
|
6585
|
+
}
|
|
6586
|
+
if (needUpdateGeometry) {
|
|
6587
|
+
object.geometry.dirty = true;
|
|
6588
|
+
object.renderable.boundsDirty = true;
|
|
6589
|
+
object.renderable.renderBoundsDirty = true;
|
|
6590
|
+
if (!options.forceUpdateGeometry) {
|
|
6591
|
+
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6592
|
+
}
|
|
7014
6593
|
}
|
|
7015
6594
|
};
|
|
7016
6595
|
/**
|
|
@@ -7036,12 +6615,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7036
6615
|
Math.abs(hheight),
|
|
7037
6616
|
hdepth,
|
|
7038
6617
|
];
|
|
7039
|
-
// const halfExtents = vec3.set(
|
|
7040
|
-
// tmpVec3a,
|
|
7041
|
-
// Math.abs(width) / 2,
|
|
7042
|
-
// Math.abs(height) / 2,
|
|
7043
|
-
// depth / 2,
|
|
7044
|
-
// );
|
|
7045
6618
|
// anchor is center by default, don't account for lineWidth here
|
|
7046
6619
|
var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
|
|
7047
6620
|
// lineCap,
|
|
@@ -7061,26 +6634,13 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7061
6634
|
nodeName === exports.Shape.PATH
|
|
7062
6635
|
? Math.SQRT2
|
|
7063
6636
|
: 0.5;
|
|
7064
|
-
// if (lineCap?.value === 'square') {
|
|
7065
|
-
// expansion = Math.SQRT1_2;
|
|
7066
|
-
// }
|
|
7067
|
-
// if (lineJoin?.value === 'miter' && expansion < Math.SQRT2 * miterLimit) {
|
|
7068
|
-
// expansion = Math.SQRT1_2 * miterLimit;
|
|
7069
|
-
// }
|
|
7070
6637
|
// append border only if stroke existed
|
|
7071
6638
|
var hasStroke = stroke && !stroke.isNone;
|
|
7072
6639
|
if (hasStroke) {
|
|
7073
6640
|
var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) *
|
|
7074
6641
|
expansion;
|
|
7075
|
-
// halfExtents[0] += halfLineWidth[0];
|
|
7076
|
-
// halfExtents[1] += halfLineWidth[1];
|
|
7077
6642
|
halfExtents[0] += halfLineWidth;
|
|
7078
6643
|
halfExtents[1] += halfLineWidth;
|
|
7079
|
-
// vec3.add(
|
|
7080
|
-
// halfExtents,
|
|
7081
|
-
// halfExtents,
|
|
7082
|
-
// vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
|
|
7083
|
-
// );
|
|
7084
6644
|
}
|
|
7085
6645
|
geometry_1.renderBounds.update(center, halfExtents);
|
|
7086
6646
|
// account for shadow, only support constant value now
|
|
@@ -7105,7 +6665,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7105
6665
|
var name = _a.name, params = _a.params;
|
|
7106
6666
|
if (name === 'blur') {
|
|
7107
6667
|
var blurRadius = params[0].value;
|
|
7108
|
-
geometry_1.renderBounds.update(geometry_1.renderBounds.center,
|
|
6668
|
+
geometry_1.renderBounds.update(geometry_1.renderBounds.center, glMatrix.vec3.add(geometry_1.renderBounds.halfExtents, geometry_1.renderBounds.halfExtents, [blurRadius, blurRadius, 0]));
|
|
7109
6669
|
}
|
|
7110
6670
|
else if (name === 'drop-shadow') {
|
|
7111
6671
|
var shadowOffsetX = params[0].value;
|
|
@@ -7167,21 +6727,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7167
6727
|
}
|
|
7168
6728
|
}
|
|
7169
6729
|
};
|
|
7170
|
-
DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
|
|
7171
|
-
var metadata = propertyMetadataCache[name];
|
|
7172
|
-
if (!metadata) {
|
|
7173
|
-
return false;
|
|
7174
|
-
}
|
|
7175
|
-
return metadata.inh;
|
|
7176
|
-
};
|
|
7177
6730
|
return DefaultStyleValueRegistry;
|
|
7178
6731
|
}());
|
|
7179
6732
|
|
|
7180
6733
|
var CSSPropertyAngle = /** @class */ (function () {
|
|
7181
6734
|
function CSSPropertyAngle() {
|
|
7182
|
-
this.parser = parseAngle;
|
|
7183
|
-
this.parserUnmemoize = parseAngleUnmemoize;
|
|
7184
|
-
this.parserWithCSSDisabled = null;
|
|
7185
6735
|
this.mixer = mergeNumbers;
|
|
7186
6736
|
}
|
|
7187
6737
|
CSSPropertyAngle.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -7218,7 +6768,6 @@ var CSSPropertyClipPath = /** @class */ (function () {
|
|
|
7218
6768
|
var CSSPropertyColor = /** @class */ (function () {
|
|
7219
6769
|
function CSSPropertyColor() {
|
|
7220
6770
|
this.parser = parseColor;
|
|
7221
|
-
this.parserWithCSSDisabled = parseColor;
|
|
7222
6771
|
this.mixer = mergeColors;
|
|
7223
6772
|
}
|
|
7224
6773
|
CSSPropertyColor.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -7233,7 +6782,6 @@ var CSSPropertyColor = /** @class */ (function () {
|
|
|
7233
6782
|
|
|
7234
6783
|
var CSSPropertyFilter = /** @class */ (function () {
|
|
7235
6784
|
function CSSPropertyFilter() {
|
|
7236
|
-
this.parser = parseFilter;
|
|
7237
6785
|
}
|
|
7238
6786
|
CSSPropertyFilter.prototype.calculator = function (name, oldParsed, parsed) {
|
|
7239
6787
|
// unset or none
|
|
@@ -7254,9 +6802,6 @@ function getFontSize(object) {
|
|
|
7254
6802
|
*/
|
|
7255
6803
|
var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
7256
6804
|
function CSSPropertyLengthOrPercentage() {
|
|
7257
|
-
this.parser = parseLengthOrPercentage;
|
|
7258
|
-
this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
|
|
7259
|
-
this.parserWithCSSDisabled = null;
|
|
7260
6805
|
this.mixer = mergeNumbers;
|
|
7261
6806
|
}
|
|
7262
6807
|
/**
|
|
@@ -7271,7 +6816,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7271
6816
|
return computed;
|
|
7272
6817
|
}
|
|
7273
6818
|
if (CSSUnitValue.isRelativeUnit(computed.unit)) {
|
|
7274
|
-
var registry = runtime.styleValueRegistry;
|
|
7275
6819
|
if (computed.unit === exports.UnitType.kPercentage) {
|
|
7276
6820
|
// TODO: merge dimensions
|
|
7277
6821
|
return 0;
|
|
@@ -7283,12 +6827,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7283
6827
|
fontSize *= computed.value;
|
|
7284
6828
|
return fontSize;
|
|
7285
6829
|
}
|
|
7286
|
-
else {
|
|
7287
|
-
registry.addUnresolveProperty(object, name);
|
|
7288
|
-
}
|
|
7289
|
-
}
|
|
7290
|
-
else {
|
|
7291
|
-
registry.addUnresolveProperty(object, name);
|
|
7292
6830
|
}
|
|
7293
6831
|
return 0;
|
|
7294
6832
|
}
|
|
@@ -7299,12 +6837,6 @@ var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
|
7299
6837
|
fontSize *= computed.value;
|
|
7300
6838
|
return fontSize;
|
|
7301
6839
|
}
|
|
7302
|
-
else {
|
|
7303
|
-
registry.addUnresolveProperty(object, name);
|
|
7304
|
-
}
|
|
7305
|
-
}
|
|
7306
|
-
else {
|
|
7307
|
-
registry.addUnresolveProperty(object, name);
|
|
7308
6840
|
}
|
|
7309
6841
|
return 0;
|
|
7310
6842
|
}
|
|
@@ -7331,17 +6863,6 @@ var CSSPropertyLengthOrPercentage12 = /** @class */ (function () {
|
|
|
7331
6863
|
function CSSPropertyLengthOrPercentage12() {
|
|
7332
6864
|
this.mixer = mergeNumberLists;
|
|
7333
6865
|
}
|
|
7334
|
-
CSSPropertyLengthOrPercentage12.prototype.parser = function (radius) {
|
|
7335
|
-
var parsed = parseDimensionArray(util.isNumber(radius) ? [radius] : radius);
|
|
7336
|
-
var formatted;
|
|
7337
|
-
if (parsed.length === 1) {
|
|
7338
|
-
formatted = [parsed[0], parsed[0]];
|
|
7339
|
-
}
|
|
7340
|
-
else {
|
|
7341
|
-
formatted = [parsed[0], parsed[1]];
|
|
7342
|
-
}
|
|
7343
|
-
return formatted;
|
|
7344
|
-
};
|
|
7345
6866
|
CSSPropertyLengthOrPercentage12.prototype.calculator = function (name, oldParsed, computed) {
|
|
7346
6867
|
return computed.map(function (c) { return c.value; });
|
|
7347
6868
|
};
|
|
@@ -7360,24 +6881,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
|
|
|
7360
6881
|
function CSSPropertyLengthOrPercentage14() {
|
|
7361
6882
|
this.mixer = mergeNumberLists;
|
|
7362
6883
|
}
|
|
7363
|
-
CSSPropertyLengthOrPercentage14.prototype.parser = function (radius) {
|
|
7364
|
-
var parsed = parseDimensionArray(util.isNumber(radius) ? [radius] : radius);
|
|
7365
|
-
var formatted;
|
|
7366
|
-
// format to Tuple<CSSUnitValue>
|
|
7367
|
-
if (parsed.length === 1) {
|
|
7368
|
-
formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
|
|
7369
|
-
}
|
|
7370
|
-
else if (parsed.length === 2) {
|
|
7371
|
-
formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
|
|
7372
|
-
}
|
|
7373
|
-
else if (parsed.length === 3) {
|
|
7374
|
-
formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
|
|
7375
|
-
}
|
|
7376
|
-
else {
|
|
7377
|
-
formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
7378
|
-
}
|
|
7379
|
-
return formatted;
|
|
7380
|
-
};
|
|
7381
6884
|
CSSPropertyLengthOrPercentage14.prototype.calculator = function (name, oldParsed, computed) {
|
|
7382
6885
|
return computed.map(function (c) { return c.value; });
|
|
7383
6886
|
};
|
|
@@ -7405,9 +6908,6 @@ var CSSPropertyMarker = /** @class */ (function () {
|
|
|
7405
6908
|
var CSSPropertyNumber = /** @class */ (function () {
|
|
7406
6909
|
function CSSPropertyNumber() {
|
|
7407
6910
|
this.mixer = mergeNumbers;
|
|
7408
|
-
this.parser = parseNumber;
|
|
7409
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7410
|
-
this.parserWithCSSDisabled = null;
|
|
7411
6911
|
}
|
|
7412
6912
|
CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
|
|
7413
6913
|
return computed.value;
|
|
@@ -7417,9 +6917,6 @@ var CSSPropertyNumber = /** @class */ (function () {
|
|
|
7417
6917
|
|
|
7418
6918
|
var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
7419
6919
|
function CSSPropertyOffsetDistance() {
|
|
7420
|
-
this.parser = parseNumber;
|
|
7421
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7422
|
-
this.parserWithCSSDisabled = null;
|
|
7423
6920
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7424
6921
|
}
|
|
7425
6922
|
CSSPropertyOffsetDistance.prototype.calculator = function (name, oldParsed, computed) {
|
|
@@ -7449,9 +6946,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
|
7449
6946
|
*/
|
|
7450
6947
|
var CSSPropertyOpacity = /** @class */ (function () {
|
|
7451
6948
|
function CSSPropertyOpacity() {
|
|
7452
|
-
this.parser = parseNumber;
|
|
7453
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7454
|
-
this.parserWithCSSDisabled = null;
|
|
7455
6949
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7456
6950
|
}
|
|
7457
6951
|
CSSPropertyOpacity.prototype.calculator = function (name, oldParsed, computed) {
|
|
@@ -7466,7 +6960,6 @@ var CSSPropertyPath = /** @class */ (function () {
|
|
|
7466
6960
|
* path2Curve
|
|
7467
6961
|
*/
|
|
7468
6962
|
this.parser = parsePath;
|
|
7469
|
-
this.parserWithCSSDisabled = parsePath;
|
|
7470
6963
|
this.mixer = mergePaths;
|
|
7471
6964
|
}
|
|
7472
6965
|
CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
|
|
@@ -7490,7 +6983,6 @@ var CSSPropertyPath = /** @class */ (function () {
|
|
|
7490
6983
|
|
|
7491
6984
|
var CSSPropertyPoints = /** @class */ (function () {
|
|
7492
6985
|
function CSSPropertyPoints() {
|
|
7493
|
-
this.parser = parsePoints;
|
|
7494
6986
|
this.mixer = mergePoints;
|
|
7495
6987
|
}
|
|
7496
6988
|
return CSSPropertyPoints;
|
|
@@ -7554,20 +7046,26 @@ var CSSPropertyTextTransform = /** @class */ (function () {
|
|
|
7554
7046
|
return CSSPropertyTextTransform;
|
|
7555
7047
|
}());
|
|
7556
7048
|
|
|
7557
|
-
var
|
|
7558
|
-
|
|
7049
|
+
var definedProps = function (obj) {
|
|
7050
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
7051
|
+
var _b = tslib.__read(_a, 2), v = _b[1];
|
|
7052
|
+
return v !== undefined;
|
|
7053
|
+
}));
|
|
7054
|
+
};
|
|
7055
|
+
|
|
7056
|
+
var CANVAS_Map = new WeakMap();
|
|
7559
7057
|
/**
|
|
7560
7058
|
* destroy existed canvas with the same id
|
|
7561
7059
|
*/
|
|
7562
|
-
function cleanExistedCanvas(container, canvas) {
|
|
7060
|
+
function cleanExistedCanvas(container, canvas, cleanUp) {
|
|
7563
7061
|
if (container) {
|
|
7564
|
-
var
|
|
7565
|
-
? container
|
|
7566
|
-
: container
|
|
7567
|
-
if (
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7062
|
+
var $dom = typeof container === 'string'
|
|
7063
|
+
? document.getElementById(container)
|
|
7064
|
+
: container;
|
|
7065
|
+
if (CANVAS_Map.has($dom))
|
|
7066
|
+
CANVAS_Map.get($dom).destroy(cleanUp);
|
|
7067
|
+
else
|
|
7068
|
+
CANVAS_Map.set($dom, canvas);
|
|
7571
7069
|
}
|
|
7572
7070
|
}
|
|
7573
7071
|
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
@@ -7652,6 +7150,12 @@ var TOUCH_TO_POINTER = {
|
|
|
7652
7150
|
};
|
|
7653
7151
|
var clock = typeof performance === 'object' && performance.now ? performance : Date;
|
|
7654
7152
|
|
|
7153
|
+
function isInFragment(node) {
|
|
7154
|
+
if (node.nodeName === exports.Shape.FRAGMENT)
|
|
7155
|
+
return true;
|
|
7156
|
+
return node.getRootNode().nodeName === exports.Shape.FRAGMENT;
|
|
7157
|
+
}
|
|
7158
|
+
|
|
7655
7159
|
function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
|
|
7656
7160
|
// account for pointerEvents
|
|
7657
7161
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
@@ -7910,114 +7414,102 @@ function createSkewMatrix(skewMatrix, skewX, skewY) {
|
|
|
7910
7414
|
skewMatrix[1] = Math.tan(skewY); // Skew X axis in Y direction
|
|
7911
7415
|
return skewMatrix;
|
|
7912
7416
|
}
|
|
7913
|
-
var
|
|
7914
|
-
var
|
|
7915
|
-
var
|
|
7417
|
+
var $mat4_1 = glMatrix.mat4.create();
|
|
7418
|
+
var $mat4_2 = glMatrix.mat4.create();
|
|
7419
|
+
var parser = {
|
|
7420
|
+
scale: function (d) {
|
|
7421
|
+
glMatrix.mat4.fromScaling($mat4_1, [d[0].value, d[1].value, 1]);
|
|
7422
|
+
},
|
|
7423
|
+
scaleX: function (d) {
|
|
7424
|
+
glMatrix.mat4.fromScaling($mat4_1, [d[0].value, 1, 1]);
|
|
7425
|
+
},
|
|
7426
|
+
scaleY: function (d) {
|
|
7427
|
+
glMatrix.mat4.fromScaling($mat4_1, [1, d[0].value, 1]);
|
|
7428
|
+
},
|
|
7429
|
+
scaleZ: function (d) {
|
|
7430
|
+
glMatrix.mat4.fromScaling($mat4_1, [1, 1, d[0].value]);
|
|
7431
|
+
},
|
|
7432
|
+
scale3d: function (d) {
|
|
7433
|
+
glMatrix.mat4.fromScaling($mat4_1, [d[0].value, d[1].value, d[2].value]);
|
|
7434
|
+
},
|
|
7435
|
+
translate: function (d) {
|
|
7436
|
+
glMatrix.mat4.fromTranslation($mat4_1, [d[0].value, d[1].value, 0]);
|
|
7437
|
+
},
|
|
7438
|
+
translateX: function (d) {
|
|
7439
|
+
glMatrix.mat4.fromTranslation($mat4_1, [d[0].value, 0, 0]);
|
|
7440
|
+
},
|
|
7441
|
+
translateY: function (d) {
|
|
7442
|
+
glMatrix.mat4.fromTranslation($mat4_1, [0, d[0].value, 0]);
|
|
7443
|
+
},
|
|
7444
|
+
translateZ: function (d) {
|
|
7445
|
+
glMatrix.mat4.fromTranslation($mat4_1, [0, 0, d[0].value]);
|
|
7446
|
+
},
|
|
7447
|
+
translate3d: function (d) {
|
|
7448
|
+
glMatrix.mat4.fromTranslation($mat4_1, [d[0].value, d[1].value, d[2].value]);
|
|
7449
|
+
},
|
|
7450
|
+
rotate: function (d) {
|
|
7451
|
+
glMatrix.mat4.fromZRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7452
|
+
},
|
|
7453
|
+
rotateX: function (d) {
|
|
7454
|
+
glMatrix.mat4.fromXRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7455
|
+
},
|
|
7456
|
+
rotateY: function (d) {
|
|
7457
|
+
glMatrix.mat4.fromYRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7458
|
+
},
|
|
7459
|
+
rotateZ: function (d) {
|
|
7460
|
+
glMatrix.mat4.fromZRotation($mat4_1, deg2rad(convertAngleUnit(d[0])));
|
|
7461
|
+
},
|
|
7462
|
+
rotate3d: function (d) {
|
|
7463
|
+
glMatrix.mat4.fromRotation($mat4_1, deg2rad(convertAngleUnit(d[3])), [
|
|
7464
|
+
d[0].value,
|
|
7465
|
+
d[1].value,
|
|
7466
|
+
d[2].value,
|
|
7467
|
+
]);
|
|
7468
|
+
},
|
|
7469
|
+
skew: function (d) {
|
|
7470
|
+
createSkewMatrix($mat4_1, deg2rad(d[0].value), deg2rad(d[1].value));
|
|
7471
|
+
},
|
|
7472
|
+
skewX: function (d) {
|
|
7473
|
+
createSkewMatrix($mat4_1, deg2rad(d[0].value), 0);
|
|
7474
|
+
},
|
|
7475
|
+
skewY: function (d) {
|
|
7476
|
+
createSkewMatrix($mat4_1, 0, deg2rad(d[0].value));
|
|
7477
|
+
},
|
|
7478
|
+
matrix: function (d) {
|
|
7479
|
+
// prettier-ignore
|
|
7480
|
+
glMatrix.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);
|
|
7481
|
+
},
|
|
7482
|
+
matrix3d: function (d) {
|
|
7483
|
+
// @ts-ignore
|
|
7484
|
+
glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([$mat4_1], tslib.__read(d.map(function (s) { return s.value; })), false));
|
|
7485
|
+
},
|
|
7486
|
+
};
|
|
7487
|
+
var $vec3One$1 = glMatrix.vec3.fromValues(1, 1, 1);
|
|
7488
|
+
var $vec3Zero$1 = glMatrix.vec3.create();
|
|
7489
|
+
var optimizer = {
|
|
7490
|
+
translate: function (object, d) {
|
|
7491
|
+
runtime.sceneGraphService.setLocalScale(object, $vec3One$1, false);
|
|
7492
|
+
runtime.sceneGraphService.setLocalEulerAngles(object, $vec3Zero$1, undefined, undefined, false);
|
|
7493
|
+
runtime.sceneGraphService.setLocalPosition(object, [d[0].value, d[1].value, 0], false);
|
|
7494
|
+
runtime.sceneGraphService.dirtifyLocal(object, object.transformable);
|
|
7495
|
+
},
|
|
7496
|
+
};
|
|
7916
7497
|
function parsedTransformToMat4(transform, object) {
|
|
7917
7498
|
if (transform.length) {
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7930
|
-
glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
|
|
7931
|
-
}
|
|
7932
|
-
else if (t === 'scaley') {
|
|
7933
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7934
|
-
glMatrix.mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
|
|
7935
|
-
}
|
|
7936
|
-
else if (t === 'scalez') {
|
|
7937
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7938
|
-
glMatrix.mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
|
|
7939
|
-
}
|
|
7940
|
-
else if (t === 'scale3d') {
|
|
7941
|
-
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
|
|
7942
|
-
1, 1, 1,
|
|
7943
|
-
];
|
|
7944
|
-
glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], newScale[2]]);
|
|
7945
|
-
}
|
|
7946
|
-
else if (t === 'translate') {
|
|
7947
|
-
var newTranslation = d || [Opx, Opx];
|
|
7948
|
-
glMatrix.mat4.fromTranslation(tmpMat2, [
|
|
7949
|
-
newTranslation[0].value,
|
|
7950
|
-
newTranslation[1].value,
|
|
7951
|
-
0,
|
|
7952
|
-
]);
|
|
7953
|
-
}
|
|
7954
|
-
else if (t === 'translatex') {
|
|
7955
|
-
var newTranslation = d || [Opx];
|
|
7956
|
-
glMatrix.mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
|
|
7957
|
-
}
|
|
7958
|
-
else if (t === 'translatey') {
|
|
7959
|
-
var newTranslation = d || [Opx];
|
|
7960
|
-
glMatrix.mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
|
|
7961
|
-
}
|
|
7962
|
-
else if (t === 'translatez') {
|
|
7963
|
-
var newTranslation = d || [Opx];
|
|
7964
|
-
glMatrix.mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
|
|
7965
|
-
}
|
|
7966
|
-
else if (t === 'translate3d') {
|
|
7967
|
-
var newTranslation = d || [Opx, Opx, Opx];
|
|
7968
|
-
glMatrix.mat4.fromTranslation(tmpMat2, [
|
|
7969
|
-
newTranslation[0].value,
|
|
7970
|
-
newTranslation[1].value,
|
|
7971
|
-
newTranslation[2].value,
|
|
7972
|
-
]);
|
|
7973
|
-
}
|
|
7974
|
-
else if (t === 'rotate') {
|
|
7975
|
-
var newAngles = d || [Odeg];
|
|
7976
|
-
glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7977
|
-
}
|
|
7978
|
-
else if (t === 'rotatex') {
|
|
7979
|
-
var newAngles = d || [Odeg];
|
|
7980
|
-
glMatrix.mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7981
|
-
}
|
|
7982
|
-
else if (t === 'rotatey') {
|
|
7983
|
-
var newAngles = d || [Odeg];
|
|
7984
|
-
glMatrix.mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7985
|
-
}
|
|
7986
|
-
else if (t === 'rotatez') {
|
|
7987
|
-
var newAngles = d || [Odeg];
|
|
7988
|
-
glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7989
|
-
}
|
|
7990
|
-
else if (t === 'rotate3d') {
|
|
7991
|
-
var newAngles = d || [Opx, Opx, Opx, Odeg];
|
|
7992
|
-
glMatrix.mat4.fromRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[3])), [
|
|
7993
|
-
newAngles[0].value,
|
|
7994
|
-
newAngles[1].value,
|
|
7995
|
-
newAngles[2].value,
|
|
7996
|
-
]);
|
|
7997
|
-
}
|
|
7998
|
-
else if (t === 'skew') {
|
|
7999
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
|
|
8000
|
-
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
|
|
8001
|
-
}
|
|
8002
|
-
else if (t === 'skewx') {
|
|
8003
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
8004
|
-
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
|
|
8005
|
-
}
|
|
8006
|
-
else if (t === 'skewy') {
|
|
8007
|
-
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
8008
|
-
createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
|
|
8009
|
-
}
|
|
8010
|
-
else if (t === 'matrix') {
|
|
8011
|
-
var _a = tslib.__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];
|
|
8012
|
-
glMatrix.mat4.set(tmpMat2, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1);
|
|
8013
|
-
}
|
|
8014
|
-
else if (t === 'matrix3d') {
|
|
8015
|
-
// @ts-ignore
|
|
8016
|
-
glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([tmpMat2], tslib.__read(d.map(function (s) { return s.value; })), false));
|
|
7499
|
+
if (transform.length === 1 && optimizer[transform[0].t]) {
|
|
7500
|
+
optimizer[transform[0].t](object, transform[0].d);
|
|
7501
|
+
return;
|
|
7502
|
+
}
|
|
7503
|
+
var m = glMatrix.mat4.identity($mat4_2);
|
|
7504
|
+
for (var i = 0; i < transform.length; i++) {
|
|
7505
|
+
var _a = transform[i], t = _a.t, d = _a.d;
|
|
7506
|
+
var p = parser[t];
|
|
7507
|
+
if (p) {
|
|
7508
|
+
p(d);
|
|
7509
|
+
glMatrix.mat4.mul(m, m, $mat4_1);
|
|
8017
7510
|
}
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
object.setLocalTransform(m_1);
|
|
7511
|
+
}
|
|
7512
|
+
object.setLocalTransform(m);
|
|
8021
7513
|
}
|
|
8022
7514
|
else {
|
|
8023
7515
|
object.resetLocalTransform();
|
|
@@ -8057,9 +7549,7 @@ function parsedTransformToMat4(transform, object) {
|
|
|
8057
7549
|
*/
|
|
8058
7550
|
var CSSPropertyTransform = /** @class */ (function () {
|
|
8059
7551
|
function CSSPropertyTransform() {
|
|
8060
|
-
this.parser =
|
|
8061
|
-
this.parserUnmemoize = parseTransformUnmemoize;
|
|
8062
|
-
this.parserWithCSSDisabled = parseTransformUnmemoize;
|
|
7552
|
+
this.parser = parseTransformUnmemoize;
|
|
8063
7553
|
this.mixer = mergeTransforms;
|
|
8064
7554
|
}
|
|
8065
7555
|
CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -8070,8 +7560,7 @@ var CSSPropertyTransform = /** @class */ (function () {
|
|
|
8070
7560
|
return parsed;
|
|
8071
7561
|
};
|
|
8072
7562
|
CSSPropertyTransform.prototype.postProcessor = function (object) {
|
|
8073
|
-
|
|
8074
|
-
parsedTransformToMat4(transform, object);
|
|
7563
|
+
parsedTransformToMat4(object.parsedStyle.transform, object);
|
|
8075
7564
|
};
|
|
8076
7565
|
return CSSPropertyTransform;
|
|
8077
7566
|
}());
|
|
@@ -8083,8 +7572,6 @@ var CSSPropertyTransform = /** @class */ (function () {
|
|
|
8083
7572
|
*/
|
|
8084
7573
|
var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
8085
7574
|
function CSSPropertyTransformOrigin() {
|
|
8086
|
-
this.parser = parseTransformOrigin;
|
|
8087
|
-
this.parserUnmemoize = parseTransformOriginUnmemoize;
|
|
8088
7575
|
}
|
|
8089
7576
|
CSSPropertyTransformOrigin.prototype.postProcessor = function (object) {
|
|
8090
7577
|
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
@@ -8102,8 +7589,6 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
|
8102
7589
|
|
|
8103
7590
|
var CSSPropertyZIndex = /** @class */ (function () {
|
|
8104
7591
|
function CSSPropertyZIndex() {
|
|
8105
|
-
this.parser = parseNumber;
|
|
8106
|
-
this.parserUnmemoize = parseNumberUnmemoize;
|
|
8107
7592
|
}
|
|
8108
7593
|
CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
|
|
8109
7594
|
return computed.value;
|
|
@@ -8262,17 +7747,8 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8262
7747
|
this.globalRuntime = globalRuntime;
|
|
8263
7748
|
}
|
|
8264
7749
|
TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
|
|
8265
|
-
var text = parsedStyle.text
|
|
8266
|
-
return
|
|
8267
|
-
? text &&
|
|
8268
|
-
fontSize &&
|
|
8269
|
-
fontStyle &&
|
|
8270
|
-
fontWeight &&
|
|
8271
|
-
fontVariant &&
|
|
8272
|
-
textAlign &&
|
|
8273
|
-
textBaseline &&
|
|
8274
|
-
!util.isNil(lineWidth)
|
|
8275
|
-
: text;
|
|
7750
|
+
var text = parsedStyle.text;
|
|
7751
|
+
return text;
|
|
8276
7752
|
};
|
|
8277
7753
|
TextUpdater.prototype.update = function (parsedStyle, object) {
|
|
8278
7754
|
var _a, _b;
|
|
@@ -8303,7 +7779,7 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8303
7779
|
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;
|
|
8304
7780
|
var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
|
|
8305
7781
|
parsedStyle.metrics = metrics;
|
|
8306
|
-
var width = metrics.width, height = metrics.height
|
|
7782
|
+
var width = metrics.width, height = metrics.height;
|
|
8307
7783
|
var hwidth = width / 2;
|
|
8308
7784
|
var hheight = height / 2;
|
|
8309
7785
|
// default 'left'
|
|
@@ -8316,18 +7792,12 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8316
7792
|
}
|
|
8317
7793
|
var lineYOffset = y - hheight;
|
|
8318
7794
|
if (textBaseline === 'middle') {
|
|
8319
|
-
// eslint-disable-next-line prefer-destructuring
|
|
8320
7795
|
lineYOffset += hheight;
|
|
8321
7796
|
}
|
|
8322
7797
|
else if (textBaseline === 'top' || textBaseline === 'hanging') {
|
|
8323
7798
|
lineYOffset += hheight * 2;
|
|
8324
7799
|
}
|
|
8325
|
-
else if (textBaseline === 'alphabetic')
|
|
8326
|
-
// prevent calling getImageData for ascent metrics
|
|
8327
|
-
lineYOffset += this.globalRuntime.enableCSSParsing
|
|
8328
|
-
? lineHeight - fontProperties.ascent
|
|
8329
|
-
: 0;
|
|
8330
|
-
}
|
|
7800
|
+
else if (textBaseline === 'alphabetic') ;
|
|
8331
7801
|
else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
|
|
8332
7802
|
lineYOffset += 0;
|
|
8333
7803
|
}
|
|
@@ -8783,7 +8253,7 @@ var CustomEvent = /** @class */ (function (_super) {
|
|
|
8783
8253
|
return CustomEvent;
|
|
8784
8254
|
}(FederatedEvent));
|
|
8785
8255
|
|
|
8786
|
-
var
|
|
8256
|
+
var CANVAS_CACHE = new WeakMap();
|
|
8787
8257
|
/**
|
|
8788
8258
|
* Objects that can receive events and may have listeners for them.
|
|
8789
8259
|
* eg. Element, Canvas, DisplayObject
|
|
@@ -8809,43 +8279,21 @@ var EventTarget = /** @class */ (function () {
|
|
|
8809
8279
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
|
|
8810
8280
|
*/
|
|
8811
8281
|
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
8812
|
-
var
|
|
8813
|
-
var
|
|
8814
|
-
var
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
if (
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
}
|
|
8825
|
-
type = capture ? "".concat(type, "capture") : type;
|
|
8826
|
-
listener = isFunction(listener) ? listener : listener.handleEvent;
|
|
8827
|
-
// compatible with G 3.0
|
|
8828
|
-
if (useDelegatedName) {
|
|
8829
|
-
var originListener_1 = listener;
|
|
8830
|
-
listener = function () {
|
|
8831
|
-
var _a;
|
|
8832
|
-
var args = [];
|
|
8833
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8834
|
-
args[_i] = arguments[_i];
|
|
8835
|
-
}
|
|
8836
|
-
if (((_a = args[0].target) === null || _a === void 0 ? void 0 : _a.name) !== delegatedName) {
|
|
8837
|
-
return;
|
|
8838
|
-
}
|
|
8839
|
-
// @ts-ignore
|
|
8840
|
-
originListener_1.apply(void 0, tslib.__spreadArray([], tslib.__read(args), false));
|
|
8841
|
-
};
|
|
8842
|
-
}
|
|
8843
|
-
if (once) {
|
|
8282
|
+
var _a, _b;
|
|
8283
|
+
var capture = false;
|
|
8284
|
+
var once = false;
|
|
8285
|
+
if (util.isBoolean(options))
|
|
8286
|
+
capture = options;
|
|
8287
|
+
else if (options)
|
|
8288
|
+
(_a = options.capture, capture = _a === void 0 ? false : _a, _b = options.once, once = _b === void 0 ? false : _b);
|
|
8289
|
+
if (capture)
|
|
8290
|
+
type += 'capture';
|
|
8291
|
+
listener = util.isFunction(listener) ? listener : listener.handleEvent;
|
|
8292
|
+
var context = util.isFunction(listener) ? undefined : listener;
|
|
8293
|
+
if (once)
|
|
8844
8294
|
this.emitter.once(type, listener, context);
|
|
8845
|
-
|
|
8846
|
-
else {
|
|
8295
|
+
else
|
|
8847
8296
|
this.emitter.on(type, listener, context);
|
|
8848
|
-
}
|
|
8849
8297
|
return this;
|
|
8850
8298
|
};
|
|
8851
8299
|
/**
|
|
@@ -8863,13 +8311,17 @@ var EventTarget = /** @class */ (function () {
|
|
|
8863
8311
|
return this;
|
|
8864
8312
|
};
|
|
8865
8313
|
EventTarget.prototype.removeAllEventListeners = function () {
|
|
8866
|
-
|
|
8314
|
+
var _a;
|
|
8315
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
|
|
8867
8316
|
};
|
|
8868
8317
|
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8318
|
+
if (!this.emitter)
|
|
8319
|
+
return this;
|
|
8320
|
+
var capture = util.isBoolean(options) ? options : options === null || options === void 0 ? void 0 : options.capture;
|
|
8321
|
+
if (capture)
|
|
8322
|
+
type += 'capture';
|
|
8323
|
+
listener = util.isFunction(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
|
|
8324
|
+
var context = util.isFunction(listener) ? undefined : listener;
|
|
8873
8325
|
this.emitter.off(type, listener, context);
|
|
8874
8326
|
return this;
|
|
8875
8327
|
};
|
|
@@ -8885,36 +8337,34 @@ var EventTarget = /** @class */ (function () {
|
|
|
8885
8337
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
|
|
8886
8338
|
*/
|
|
8887
8339
|
EventTarget.prototype.dispatchEvent = function (e, skipPropagate) {
|
|
8888
|
-
var _a
|
|
8340
|
+
var _a;
|
|
8889
8341
|
if (skipPropagate === void 0) { skipPropagate = false; }
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
}
|
|
8903
|
-
else {
|
|
8904
|
-
canvas = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
8342
|
+
var canvas = CANVAS_CACHE.get(this);
|
|
8343
|
+
if (!canvas) {
|
|
8344
|
+
// @ts-expect-error document may be defined in inherited class
|
|
8345
|
+
if (this.document)
|
|
8346
|
+
canvas = this;
|
|
8347
|
+
// @ts-expect-error defaultView may be defined in inherited class
|
|
8348
|
+
else if (this.defaultView)
|
|
8349
|
+
canvas = this.defaultView;
|
|
8350
|
+
else
|
|
8351
|
+
canvas = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
8352
|
+
if (canvas)
|
|
8353
|
+
CANVAS_CACHE.set(this, canvas);
|
|
8905
8354
|
}
|
|
8906
|
-
// assign event manager
|
|
8907
8355
|
if (canvas) {
|
|
8908
|
-
e.manager = canvas.getEventService()
|
|
8909
|
-
if (!e.manager)
|
|
8356
|
+
e.manager = canvas.getEventService();
|
|
8357
|
+
if (!e.manager)
|
|
8910
8358
|
return false;
|
|
8911
|
-
}
|
|
8912
8359
|
e.defaultPrevented = false;
|
|
8913
|
-
e.path
|
|
8914
|
-
|
|
8360
|
+
if (e.path)
|
|
8361
|
+
e.path.length = 0;
|
|
8362
|
+
// @ts-ignore
|
|
8363
|
+
else
|
|
8364
|
+
e.page = [];
|
|
8365
|
+
if (!skipPropagate)
|
|
8915
8366
|
e.target = this;
|
|
8916
|
-
|
|
8917
|
-
(_b = e.manager) === null || _b === void 0 ? void 0 : _b.dispatchEvent(e, e.type, skipPropagate);
|
|
8367
|
+
e.manager.dispatchEvent(e, e.type, skipPropagate);
|
|
8918
8368
|
}
|
|
8919
8369
|
return !e.defaultPrevented;
|
|
8920
8370
|
};
|
|
@@ -9212,12 +8662,19 @@ var Node = /** @class */ (function (_super) {
|
|
|
9212
8662
|
}
|
|
9213
8663
|
return temp;
|
|
9214
8664
|
};
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
8665
|
+
/**
|
|
8666
|
+
* iterate current node and its descendants
|
|
8667
|
+
* @param callback - callback to execute for each node, return false to break
|
|
8668
|
+
* @param assigned - whether to iterate assigned nodes
|
|
8669
|
+
*/
|
|
8670
|
+
Node.prototype.forEach = function (callback) {
|
|
8671
|
+
var result = callback(this);
|
|
8672
|
+
if (result !== false) {
|
|
8673
|
+
var nodes = this.childNodes;
|
|
8674
|
+
var length_1 = nodes.length;
|
|
8675
|
+
for (var i = 0; i < length_1; i++) {
|
|
8676
|
+
nodes[i].forEach(callback);
|
|
8677
|
+
}
|
|
9221
8678
|
}
|
|
9222
8679
|
};
|
|
9223
8680
|
/**
|
|
@@ -10217,10 +9674,6 @@ var RenderingService = /** @class */ (function () {
|
|
|
10217
9674
|
RenderingService.prototype.renderDisplayObject = function (displayObject, canvasConfig, renderingContext) {
|
|
10218
9675
|
var _this = this;
|
|
10219
9676
|
var _a = canvasConfig.renderer.getConfig(), enableDirtyCheck = _a.enableDirtyCheck, enableCulling = _a.enableCulling;
|
|
10220
|
-
// recalc style values
|
|
10221
|
-
if (this.globalRuntime.enableCSSParsing) {
|
|
10222
|
-
this.globalRuntime.styleValueRegistry.recalc(displayObject);
|
|
10223
|
-
}
|
|
10224
9677
|
// TODO: relayout
|
|
10225
9678
|
// dirtycheck first
|
|
10226
9679
|
var renderable = displayObject.renderable;
|
|
@@ -10427,26 +9880,6 @@ var DefaultSceneGraphSelector = /** @class */ (function () {
|
|
|
10427
9880
|
return DefaultSceneGraphSelector;
|
|
10428
9881
|
}());
|
|
10429
9882
|
|
|
10430
|
-
var MutationEvent = /** @class */ (function (_super) {
|
|
10431
|
-
tslib.__extends(MutationEvent, _super);
|
|
10432
|
-
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
10433
|
-
var _this = _super.call(this, null) || this;
|
|
10434
|
-
_this.relatedNode = relatedNode;
|
|
10435
|
-
_this.prevValue = prevValue;
|
|
10436
|
-
_this.newValue = newValue;
|
|
10437
|
-
_this.attrName = attrName;
|
|
10438
|
-
_this.attrChange = attrChange;
|
|
10439
|
-
_this.prevParsedValue = prevParsedValue;
|
|
10440
|
-
_this.newParsedValue = newParsedValue;
|
|
10441
|
-
_this.type = typeArg;
|
|
10442
|
-
return _this;
|
|
10443
|
-
}
|
|
10444
|
-
MutationEvent.ADDITION = 2;
|
|
10445
|
-
MutationEvent.MODIFICATION = 1;
|
|
10446
|
-
MutationEvent.REMOVAL = 3;
|
|
10447
|
-
return MutationEvent;
|
|
10448
|
-
}(FederatedEvent));
|
|
10449
|
-
|
|
10450
9883
|
/**
|
|
10451
9884
|
* built-in events for element
|
|
10452
9885
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
|
|
@@ -10484,6 +9917,26 @@ exports.ElementEvent = void 0;
|
|
|
10484
9917
|
ElementEvent["CULLED"] = "culled";
|
|
10485
9918
|
})(exports.ElementEvent || (exports.ElementEvent = {}));
|
|
10486
9919
|
|
|
9920
|
+
var MutationEvent = /** @class */ (function (_super) {
|
|
9921
|
+
tslib.__extends(MutationEvent, _super);
|
|
9922
|
+
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
9923
|
+
var _this = _super.call(this, null) || this;
|
|
9924
|
+
_this.relatedNode = relatedNode;
|
|
9925
|
+
_this.prevValue = prevValue;
|
|
9926
|
+
_this.newValue = newValue;
|
|
9927
|
+
_this.attrName = attrName;
|
|
9928
|
+
_this.attrChange = attrChange;
|
|
9929
|
+
_this.prevParsedValue = prevParsedValue;
|
|
9930
|
+
_this.newParsedValue = newParsedValue;
|
|
9931
|
+
_this.type = typeArg;
|
|
9932
|
+
return _this;
|
|
9933
|
+
}
|
|
9934
|
+
MutationEvent.ADDITION = 2;
|
|
9935
|
+
MutationEvent.MODIFICATION = 1;
|
|
9936
|
+
MutationEvent.REMOVAL = 3;
|
|
9937
|
+
return MutationEvent;
|
|
9938
|
+
}(FederatedEvent));
|
|
9939
|
+
|
|
10487
9940
|
function markRenderableDirty(e) {
|
|
10488
9941
|
var renderable = e.renderable;
|
|
10489
9942
|
if (renderable) {
|
|
@@ -10492,260 +9945,45 @@ function markRenderableDirty(e) {
|
|
|
10492
9945
|
}
|
|
10493
9946
|
}
|
|
10494
9947
|
var reparentEvent = new MutationEvent(exports.ElementEvent.REPARENT, null, '', '', '', 0, '', '');
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
if (dirtify) {
|
|
10534
|
-
_this.dirtifyLocal(element, transform);
|
|
10535
|
-
}
|
|
10536
|
-
}
|
|
10537
|
-
};
|
|
10538
|
-
})();
|
|
10539
|
-
/**
|
|
10540
|
-
* rotate in local space
|
|
10541
|
-
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
10542
|
-
*/
|
|
10543
|
-
this.rotateLocal = (function () {
|
|
10544
|
-
var rotation = glMatrix.quat.create();
|
|
10545
|
-
return function (element, degrees, y, z, dirtify) {
|
|
10546
|
-
if (y === void 0) { y = 0; }
|
|
10547
|
-
if (z === void 0) { z = 0; }
|
|
10548
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10549
|
-
if (typeof degrees === 'number') {
|
|
10550
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
10551
|
-
}
|
|
10552
|
-
var transform = element.transformable;
|
|
10553
|
-
glMatrix.quat.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10554
|
-
glMatrix.quat.mul(transform.localRotation, transform.localRotation, rotation);
|
|
10555
|
-
if (dirtify) {
|
|
10556
|
-
_this.dirtifyLocal(element, transform);
|
|
10557
|
-
}
|
|
10558
|
-
};
|
|
10559
|
-
})();
|
|
10560
|
-
/**
|
|
10561
|
-
* set euler angles(degrees) in world space
|
|
10562
|
-
*/
|
|
10563
|
-
this.setEulerAngles = (function () {
|
|
10564
|
-
var invParentRot = glMatrix.quat.create();
|
|
10565
|
-
return function (element, degrees, y, z, dirtify) {
|
|
10566
|
-
if (y === void 0) { y = 0; }
|
|
10567
|
-
if (z === void 0) { z = 0; }
|
|
10568
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10569
|
-
if (typeof degrees === 'number') {
|
|
10570
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
10571
|
-
}
|
|
10572
|
-
var transform = element.transformable;
|
|
10573
|
-
if (element.parentNode === null ||
|
|
10574
|
-
!element.parentNode.transformable) {
|
|
10575
|
-
_this.setLocalEulerAngles(element, degrees);
|
|
10576
|
-
}
|
|
10577
|
-
else {
|
|
10578
|
-
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
10579
|
-
var parentRotation = _this.getRotation(element.parentNode);
|
|
10580
|
-
glMatrix.quat.copy(invParentRot, glMatrix.quat.invert(glMatrix.quat.create(), parentRotation));
|
|
10581
|
-
glMatrix.quat.mul(transform.localRotation, transform.localRotation, invParentRot);
|
|
10582
|
-
if (dirtify) {
|
|
10583
|
-
_this.dirtifyLocal(element, transform);
|
|
10584
|
-
}
|
|
10585
|
-
}
|
|
10586
|
-
};
|
|
10587
|
-
})();
|
|
10588
|
-
/**
|
|
10589
|
-
* translate in local space
|
|
10590
|
-
*
|
|
10591
|
-
* @example
|
|
10592
|
-
* ```
|
|
10593
|
-
* translateLocal(x, y, z)
|
|
10594
|
-
* translateLocal(vec3(x, y, z))
|
|
10595
|
-
* ```
|
|
10596
|
-
*/
|
|
10597
|
-
this.translateLocal = (function () {
|
|
10598
|
-
return function (element, translation, y, z, dirtify) {
|
|
10599
|
-
if (y === void 0) { y = 0; }
|
|
10600
|
-
if (z === void 0) { z = 0; }
|
|
10601
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10602
|
-
if (typeof translation === 'number') {
|
|
10603
|
-
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
10604
|
-
}
|
|
10605
|
-
var transform = element.transformable;
|
|
10606
|
-
if (glMatrix.vec3.equals(translation, glMatrix.vec3.create())) {
|
|
10607
|
-
return;
|
|
10608
|
-
}
|
|
10609
|
-
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
10610
|
-
glMatrix.vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
10611
|
-
if (dirtify) {
|
|
10612
|
-
_this.dirtifyLocal(element, transform);
|
|
10613
|
-
}
|
|
10614
|
-
};
|
|
10615
|
-
})();
|
|
10616
|
-
/**
|
|
10617
|
-
* move to position in world space
|
|
10618
|
-
*
|
|
10619
|
-
* 对应 g 原版的 move/moveTo
|
|
10620
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
10621
|
-
*/
|
|
10622
|
-
this.setPosition = (function () {
|
|
10623
|
-
var parentInvertMatrix = glMatrix.mat4.create();
|
|
10624
|
-
var tmpPosition = glMatrix.vec3.create();
|
|
10625
|
-
return function (element, position, dirtify) {
|
|
10626
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10627
|
-
var transform = element.transformable;
|
|
10628
|
-
tmpPosition[0] = position[0];
|
|
10629
|
-
tmpPosition[1] = position[1];
|
|
10630
|
-
tmpPosition[2] = position[2] || 0;
|
|
10631
|
-
if (glMatrix.vec3.equals(_this.getPosition(element), tmpPosition)) {
|
|
10632
|
-
return;
|
|
10633
|
-
}
|
|
10634
|
-
glMatrix.vec3.copy(transform.position, tmpPosition);
|
|
10635
|
-
if (element.parentNode === null ||
|
|
10636
|
-
!element.parentNode.transformable) {
|
|
10637
|
-
glMatrix.vec3.copy(transform.localPosition, tmpPosition);
|
|
10638
|
-
}
|
|
10639
|
-
else {
|
|
10640
|
-
var parentTransform = element.parentNode.transformable;
|
|
10641
|
-
glMatrix.mat4.copy(parentInvertMatrix, parentTransform.worldTransform);
|
|
10642
|
-
glMatrix.mat4.invert(parentInvertMatrix, parentInvertMatrix);
|
|
10643
|
-
glMatrix.vec3.transformMat4(transform.localPosition, tmpPosition, parentInvertMatrix);
|
|
10644
|
-
}
|
|
10645
|
-
if (dirtify) {
|
|
10646
|
-
_this.dirtifyLocal(element, transform);
|
|
10647
|
-
}
|
|
10648
|
-
};
|
|
10649
|
-
})();
|
|
10650
|
-
/**
|
|
10651
|
-
* move to position in local space
|
|
10652
|
-
*/
|
|
10653
|
-
this.setLocalPosition = (function () {
|
|
10654
|
-
var tmpPosition = glMatrix.vec3.create();
|
|
10655
|
-
return function (element, position, dirtify) {
|
|
10656
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10657
|
-
var transform = element.transformable;
|
|
10658
|
-
tmpPosition[0] = position[0];
|
|
10659
|
-
tmpPosition[1] = position[1];
|
|
10660
|
-
tmpPosition[2] = position[2] || 0;
|
|
10661
|
-
if (glMatrix.vec3.equals(transform.localPosition, tmpPosition)) {
|
|
10662
|
-
return;
|
|
10663
|
-
}
|
|
10664
|
-
glMatrix.vec3.copy(transform.localPosition, tmpPosition);
|
|
10665
|
-
if (dirtify) {
|
|
10666
|
-
_this.dirtifyLocal(element, transform);
|
|
10667
|
-
}
|
|
10668
|
-
};
|
|
10669
|
-
})();
|
|
10670
|
-
/**
|
|
10671
|
-
* translate in world space
|
|
10672
|
-
*
|
|
10673
|
-
* @example
|
|
10674
|
-
* ```
|
|
10675
|
-
* translate(x, y, z)
|
|
10676
|
-
* translate(vec3(x, y, z))
|
|
10677
|
-
* ```
|
|
10678
|
-
*
|
|
10679
|
-
* 对应 g 原版的 translate 2D
|
|
10680
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
10681
|
-
*/
|
|
10682
|
-
this.translate = (function () {
|
|
10683
|
-
var zeroVec3 = glMatrix.vec3.create();
|
|
10684
|
-
var tmpVec3 = glMatrix.vec3.create();
|
|
10685
|
-
var tr = glMatrix.vec3.create();
|
|
10686
|
-
return function (element, translation, y, z, dirtify) {
|
|
10687
|
-
if (y === void 0) { y = 0; }
|
|
10688
|
-
if (z === void 0) { z = 0; }
|
|
10689
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10690
|
-
if (typeof translation === 'number') {
|
|
10691
|
-
translation = glMatrix.vec3.set(tmpVec3, translation, y, z);
|
|
10692
|
-
}
|
|
10693
|
-
if (glMatrix.vec3.equals(translation, zeroVec3)) {
|
|
10694
|
-
return;
|
|
10695
|
-
}
|
|
10696
|
-
glMatrix.vec3.add(tr, _this.getPosition(element), translation);
|
|
10697
|
-
_this.setPosition(element, tr, dirtify);
|
|
10698
|
-
};
|
|
10699
|
-
})();
|
|
10700
|
-
this.setRotation = function () {
|
|
10701
|
-
var parentInvertRotation = glMatrix.quat.create();
|
|
10702
|
-
return function (element, rotation, y, z, w, dirtify) {
|
|
10703
|
-
if (dirtify === void 0) { dirtify = true; }
|
|
10704
|
-
var transform = element.transformable;
|
|
10705
|
-
if (typeof rotation === 'number') {
|
|
10706
|
-
rotation = glMatrix.quat.fromValues(rotation, y, z, w);
|
|
10707
|
-
}
|
|
10708
|
-
if (element.parentNode === null ||
|
|
10709
|
-
!element.parentNode.transformable) {
|
|
10710
|
-
_this.setLocalRotation(element, rotation);
|
|
10711
|
-
}
|
|
10712
|
-
else {
|
|
10713
|
-
var parentRot = _this.getRotation(element.parentNode);
|
|
10714
|
-
glMatrix.quat.copy(parentInvertRotation, parentRot);
|
|
10715
|
-
glMatrix.quat.invert(parentInvertRotation, parentInvertRotation);
|
|
10716
|
-
glMatrix.quat.multiply(transform.localRotation, parentInvertRotation, rotation);
|
|
10717
|
-
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
10718
|
-
if (dirtify) {
|
|
10719
|
-
_this.dirtifyLocal(element, transform);
|
|
10720
|
-
}
|
|
10721
|
-
}
|
|
10722
|
-
};
|
|
10723
|
-
};
|
|
9948
|
+
// Object pooling
|
|
9949
|
+
/** do not modify this objects */
|
|
9950
|
+
var $vec2Zero = glMatrix.vec2.create();
|
|
9951
|
+
/** do not modify this objects */
|
|
9952
|
+
var $vec3Zero = glMatrix.vec3.create();
|
|
9953
|
+
/** do not modify this objects */
|
|
9954
|
+
var $vec3One = glMatrix.vec3.fromValues(1, 1, 1);
|
|
9955
|
+
/** do not modify this objects */
|
|
9956
|
+
var $mat4Identity = glMatrix.mat4.create();
|
|
9957
|
+
/** shared objects */
|
|
9958
|
+
var $vec2 = glMatrix.vec2.create();
|
|
9959
|
+
/** shared objects */
|
|
9960
|
+
var $vec3$1 = glMatrix.vec3.create();
|
|
9961
|
+
/** shared objects */
|
|
9962
|
+
var $mat4 = glMatrix.mat4.create();
|
|
9963
|
+
/** shared objects */
|
|
9964
|
+
var $quat$1 = glMatrix.quat.create();
|
|
9965
|
+
var $setLocalTransform_1 = glMatrix.vec3.create();
|
|
9966
|
+
var $setLocalTransform_2 = glMatrix.quat.create();
|
|
9967
|
+
var $setLocalTransform_3 = glMatrix.vec3.create();
|
|
9968
|
+
var $setLocalPosition = glMatrix.vec3.create();
|
|
9969
|
+
var $setPosition_1 = glMatrix.vec3.create();
|
|
9970
|
+
var $setPosition_ParentInvertMatrix = glMatrix.mat4.create();
|
|
9971
|
+
var $setEulerAngles_InvParentRot = glMatrix.quat.create();
|
|
9972
|
+
var $rotateLocal = glMatrix.quat.create();
|
|
9973
|
+
var $rotate_ParentInvertRotation = glMatrix.quat.create();
|
|
9974
|
+
var $triggerPendingEvents_detail = { affectChildren: true };
|
|
9975
|
+
/**
|
|
9976
|
+
* update transform in scene graph
|
|
9977
|
+
*
|
|
9978
|
+
* @see https://community.khronos.org/t/scene-graphs/50542/7
|
|
9979
|
+
*/
|
|
9980
|
+
var DefaultSceneGraphService = /** @class */ (function () {
|
|
9981
|
+
function DefaultSceneGraphService(runtime) {
|
|
9982
|
+
this.runtime = runtime;
|
|
9983
|
+
// target -> affectChildren
|
|
9984
|
+
this.pendingEvents = new Map();
|
|
9985
|
+
this.boundsChangedEvent = new CustomEvent(exports.ElementEvent.BOUNDS_CHANGED);
|
|
10724
9986
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10725
|
-
this.calcLocalTransform = (function () {
|
|
10726
|
-
var tmpMat = glMatrix.mat4.create();
|
|
10727
|
-
var tmpPosition = glMatrix.vec3.create();
|
|
10728
|
-
var tmpQuat = glMatrix.quat.fromValues(0, 0, 0, 1);
|
|
10729
|
-
return function (transform) {
|
|
10730
|
-
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
10731
|
-
if (hasSkew) {
|
|
10732
|
-
glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, glMatrix.vec3.fromValues(1, 1, 1), transform.origin);
|
|
10733
|
-
// apply skew2D
|
|
10734
|
-
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
10735
|
-
var tmpMat4 = glMatrix.mat4.identity(tmpMat);
|
|
10736
|
-
tmpMat4[4] = Math.tan(transform.localSkew[0]);
|
|
10737
|
-
tmpMat4[1] = Math.tan(transform.localSkew[1]);
|
|
10738
|
-
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, tmpMat4);
|
|
10739
|
-
}
|
|
10740
|
-
var scaling = glMatrix.mat4.fromRotationTranslationScaleOrigin(tmpMat, tmpQuat, tmpPosition, transform.localScale, transform.origin);
|
|
10741
|
-
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, scaling);
|
|
10742
|
-
}
|
|
10743
|
-
else {
|
|
10744
|
-
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
10745
|
-
glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
|
|
10746
|
-
}
|
|
10747
|
-
};
|
|
10748
|
-
})();
|
|
10749
9987
|
}
|
|
10750
9988
|
DefaultSceneGraphService.prototype.matches = function (query, root) {
|
|
10751
9989
|
return this.runtime.sceneGraphSelector.is(query, root);
|
|
@@ -10764,12 +10002,23 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10764
10002
|
detached = child.parentNode !== parent;
|
|
10765
10003
|
this.detach(child);
|
|
10766
10004
|
}
|
|
10005
|
+
var isChildFragment = child.nodeName === exports.Shape.FRAGMENT;
|
|
10006
|
+
var isAttachToFragment = isInFragment(parent);
|
|
10767
10007
|
child.parentNode = parent;
|
|
10768
|
-
|
|
10769
|
-
child.
|
|
10008
|
+
var nodes = isChildFragment
|
|
10009
|
+
? child.childNodes
|
|
10010
|
+
: [child];
|
|
10011
|
+
if (util.isNumber(index)) {
|
|
10012
|
+
nodes.forEach(function (node) {
|
|
10013
|
+
parent.childNodes.splice(index, 0, node);
|
|
10014
|
+
node.parentNode = parent;
|
|
10015
|
+
});
|
|
10770
10016
|
}
|
|
10771
10017
|
else {
|
|
10772
|
-
|
|
10018
|
+
nodes.forEach(function (node) {
|
|
10019
|
+
parent.childNodes.push(node);
|
|
10020
|
+
node.parentNode = parent;
|
|
10021
|
+
});
|
|
10773
10022
|
}
|
|
10774
10023
|
// parent needs re-sort
|
|
10775
10024
|
var sortable = parent.sortable;
|
|
@@ -10783,13 +10032,15 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10783
10032
|
sortable.dirty = true;
|
|
10784
10033
|
sortable.dirtyReason = exports.SortReason.ADDED;
|
|
10785
10034
|
}
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
if (
|
|
10789
|
-
this.
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10035
|
+
if (isAttachToFragment)
|
|
10036
|
+
return;
|
|
10037
|
+
if (isChildFragment)
|
|
10038
|
+
this.dirtifyFragment(child);
|
|
10039
|
+
else {
|
|
10040
|
+
var transform = child.transformable;
|
|
10041
|
+
if (transform) {
|
|
10042
|
+
this.dirtifyWorld(child, transform);
|
|
10043
|
+
}
|
|
10793
10044
|
}
|
|
10794
10045
|
if (detached) {
|
|
10795
10046
|
child.dispatchEvent(reparentEvent);
|
|
@@ -10857,6 +10108,70 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10857
10108
|
originVec[2] = origin[2] || 0;
|
|
10858
10109
|
this.dirtifyLocal(element, transform);
|
|
10859
10110
|
};
|
|
10111
|
+
/**
|
|
10112
|
+
* rotate in world space
|
|
10113
|
+
*/
|
|
10114
|
+
DefaultSceneGraphService.prototype.rotate = function (element, degrees, y, z) {
|
|
10115
|
+
if (y === void 0) { y = 0; }
|
|
10116
|
+
if (z === void 0) { z = 0; }
|
|
10117
|
+
if (typeof degrees === 'number') {
|
|
10118
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
10119
|
+
}
|
|
10120
|
+
var transform = element.transformable;
|
|
10121
|
+
if (element.parentNode === null ||
|
|
10122
|
+
!element.parentNode.transformable) {
|
|
10123
|
+
this.rotateLocal(element, degrees);
|
|
10124
|
+
}
|
|
10125
|
+
else {
|
|
10126
|
+
var rotation = $quat$1;
|
|
10127
|
+
glMatrix.quat.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10128
|
+
var rot = this.getRotation(element);
|
|
10129
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
10130
|
+
glMatrix.quat.copy($rotate_ParentInvertRotation, parentRot);
|
|
10131
|
+
glMatrix.quat.invert($rotate_ParentInvertRotation, $rotate_ParentInvertRotation);
|
|
10132
|
+
glMatrix.quat.multiply(rotation, $rotate_ParentInvertRotation, rotation);
|
|
10133
|
+
glMatrix.quat.multiply(transform.localRotation, rotation, rot);
|
|
10134
|
+
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
10135
|
+
this.dirtifyLocal(element, transform);
|
|
10136
|
+
}
|
|
10137
|
+
};
|
|
10138
|
+
/**
|
|
10139
|
+
* rotate in local space
|
|
10140
|
+
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
10141
|
+
*/
|
|
10142
|
+
DefaultSceneGraphService.prototype.rotateLocal = function (element, degrees, y, z) {
|
|
10143
|
+
if (y === void 0) { y = 0; }
|
|
10144
|
+
if (z === void 0) { z = 0; }
|
|
10145
|
+
if (typeof degrees === 'number') {
|
|
10146
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
10147
|
+
}
|
|
10148
|
+
var transform = element.transformable;
|
|
10149
|
+
glMatrix.quat.fromEuler($rotateLocal, degrees[0], degrees[1], degrees[2]);
|
|
10150
|
+
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $rotateLocal);
|
|
10151
|
+
this.dirtifyLocal(element, transform);
|
|
10152
|
+
};
|
|
10153
|
+
/**
|
|
10154
|
+
* set euler angles(degrees) in world space
|
|
10155
|
+
*/
|
|
10156
|
+
DefaultSceneGraphService.prototype.setEulerAngles = function (element, degrees, y, z) {
|
|
10157
|
+
if (y === void 0) { y = 0; }
|
|
10158
|
+
if (z === void 0) { z = 0; }
|
|
10159
|
+
if (typeof degrees === 'number') {
|
|
10160
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
10161
|
+
}
|
|
10162
|
+
var transform = element.transformable;
|
|
10163
|
+
if (element.parentNode === null ||
|
|
10164
|
+
!element.parentNode.transformable) {
|
|
10165
|
+
this.setLocalEulerAngles(element, degrees);
|
|
10166
|
+
}
|
|
10167
|
+
else {
|
|
10168
|
+
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
10169
|
+
var parentRotation = this.getRotation(element.parentNode);
|
|
10170
|
+
glMatrix.quat.copy($setEulerAngles_InvParentRot, glMatrix.quat.invert($quat$1, parentRotation));
|
|
10171
|
+
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $setEulerAngles_InvParentRot);
|
|
10172
|
+
this.dirtifyLocal(element, transform);
|
|
10173
|
+
}
|
|
10174
|
+
};
|
|
10860
10175
|
/**
|
|
10861
10176
|
* set euler angles(degrees) in local space
|
|
10862
10177
|
*/
|
|
@@ -10874,32 +10189,140 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10874
10189
|
}
|
|
10875
10190
|
};
|
|
10876
10191
|
/**
|
|
10877
|
-
*
|
|
10192
|
+
* translate in local space
|
|
10193
|
+
*
|
|
10194
|
+
* @example
|
|
10195
|
+
* ```
|
|
10196
|
+
* translateLocal(x, y, z)
|
|
10197
|
+
* translateLocal(vec3(x, y, z))
|
|
10198
|
+
* ```
|
|
10199
|
+
*/
|
|
10200
|
+
DefaultSceneGraphService.prototype.translateLocal = function (element, translation, y, z) {
|
|
10201
|
+
if (y === void 0) { y = 0; }
|
|
10202
|
+
if (z === void 0) { z = 0; }
|
|
10203
|
+
if (typeof translation === 'number') {
|
|
10204
|
+
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
10205
|
+
}
|
|
10206
|
+
var transform = element.transformable;
|
|
10207
|
+
if (glMatrix.vec3.equals(translation, $vec3Zero))
|
|
10208
|
+
return;
|
|
10209
|
+
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
10210
|
+
glMatrix.vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
10211
|
+
this.dirtifyLocal(element, transform);
|
|
10212
|
+
};
|
|
10213
|
+
/**
|
|
10214
|
+
* move to position in world space
|
|
10215
|
+
*
|
|
10216
|
+
* 对应 g 原版的 move/moveTo
|
|
10217
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
10218
|
+
*/
|
|
10219
|
+
DefaultSceneGraphService.prototype.setPosition = function (element, position) {
|
|
10220
|
+
var _a;
|
|
10221
|
+
var transform = element.transformable;
|
|
10222
|
+
$setPosition_1[0] = position[0];
|
|
10223
|
+
$setPosition_1[1] = position[1];
|
|
10224
|
+
$setPosition_1[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
|
|
10225
|
+
if (glMatrix.vec3.equals(this.getPosition(element), $setPosition_1)) {
|
|
10226
|
+
return;
|
|
10227
|
+
}
|
|
10228
|
+
glMatrix.vec3.copy(transform.position, $setPosition_1);
|
|
10229
|
+
if (element.parentNode === null ||
|
|
10230
|
+
!element.parentNode.transformable) {
|
|
10231
|
+
glMatrix.vec3.copy(transform.localPosition, $setPosition_1);
|
|
10232
|
+
}
|
|
10233
|
+
else {
|
|
10234
|
+
var parentTransform = element.parentNode.transformable;
|
|
10235
|
+
glMatrix.mat4.copy($setPosition_ParentInvertMatrix, parentTransform.worldTransform);
|
|
10236
|
+
glMatrix.mat4.invert($setPosition_ParentInvertMatrix, $setPosition_ParentInvertMatrix);
|
|
10237
|
+
glMatrix.vec3.transformMat4(transform.localPosition, $setPosition_1, $setPosition_ParentInvertMatrix);
|
|
10238
|
+
}
|
|
10239
|
+
this.dirtifyLocal(element, transform);
|
|
10240
|
+
};
|
|
10241
|
+
/**
|
|
10242
|
+
* move to position in local space
|
|
10878
10243
|
*/
|
|
10879
|
-
DefaultSceneGraphService.prototype.
|
|
10244
|
+
DefaultSceneGraphService.prototype.setLocalPosition = function (element, position, dirtify) {
|
|
10245
|
+
var _a;
|
|
10880
10246
|
if (dirtify === void 0) { dirtify = true; }
|
|
10881
10247
|
var transform = element.transformable;
|
|
10882
|
-
|
|
10248
|
+
$setLocalPosition[0] = position[0];
|
|
10249
|
+
$setLocalPosition[1] = position[1];
|
|
10250
|
+
$setLocalPosition[2] = (_a = position[2]) !== null && _a !== void 0 ? _a : 0;
|
|
10251
|
+
if (glMatrix.vec3.equals(transform.localPosition, $setLocalPosition)) {
|
|
10252
|
+
return;
|
|
10253
|
+
}
|
|
10254
|
+
glMatrix.vec3.copy(transform.localPosition, $setLocalPosition);
|
|
10883
10255
|
if (dirtify) {
|
|
10884
10256
|
this.dirtifyLocal(element, transform);
|
|
10885
10257
|
}
|
|
10886
10258
|
};
|
|
10259
|
+
/**
|
|
10260
|
+
* scale in local space
|
|
10261
|
+
*/
|
|
10262
|
+
DefaultSceneGraphService.prototype.scaleLocal = function (element, scaling) {
|
|
10263
|
+
var _a;
|
|
10264
|
+
var transform = element.transformable;
|
|
10265
|
+
glMatrix.vec3.multiply(transform.localScale, transform.localScale, glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_a = scaling[2]) !== null && _a !== void 0 ? _a : 1));
|
|
10266
|
+
this.dirtifyLocal(element, transform);
|
|
10267
|
+
};
|
|
10887
10268
|
DefaultSceneGraphService.prototype.setLocalScale = function (element, scaling, dirtify) {
|
|
10269
|
+
var _a;
|
|
10888
10270
|
if (dirtify === void 0) { dirtify = true; }
|
|
10889
10271
|
var transform = element.transformable;
|
|
10890
|
-
|
|
10891
|
-
if (glMatrix.vec3.equals(
|
|
10272
|
+
glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_a = scaling[2]) !== null && _a !== void 0 ? _a : transform.localScale[2]);
|
|
10273
|
+
if (glMatrix.vec3.equals($vec3$1, transform.localScale)) {
|
|
10892
10274
|
return;
|
|
10893
10275
|
}
|
|
10894
|
-
glMatrix.vec3.copy(transform.localScale,
|
|
10276
|
+
glMatrix.vec3.copy(transform.localScale, $vec3$1);
|
|
10895
10277
|
if (dirtify) {
|
|
10896
10278
|
this.dirtifyLocal(element, transform);
|
|
10897
10279
|
}
|
|
10898
10280
|
};
|
|
10281
|
+
/**
|
|
10282
|
+
* translate in world space
|
|
10283
|
+
*
|
|
10284
|
+
* @example
|
|
10285
|
+
* ```
|
|
10286
|
+
* translate(x, y, z)
|
|
10287
|
+
* translate(vec3(x, y, z))
|
|
10288
|
+
* ```
|
|
10289
|
+
*
|
|
10290
|
+
* 对应 g 原版的 translate 2D
|
|
10291
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
10292
|
+
*/
|
|
10293
|
+
DefaultSceneGraphService.prototype.translate = function (element, translation, y, z) {
|
|
10294
|
+
if (y === void 0) { y = 0; }
|
|
10295
|
+
if (z === void 0) { z = 0; }
|
|
10296
|
+
if (typeof translation === 'number') {
|
|
10297
|
+
translation = glMatrix.vec3.set($vec3$1, translation, y, z);
|
|
10298
|
+
}
|
|
10299
|
+
if (glMatrix.vec3.equals(translation, $vec3Zero))
|
|
10300
|
+
return;
|
|
10301
|
+
glMatrix.vec3.add($vec3$1, this.getPosition(element), translation);
|
|
10302
|
+
this.setPosition(element, $vec3$1);
|
|
10303
|
+
};
|
|
10304
|
+
DefaultSceneGraphService.prototype.setRotation = function (element, rotation, y, z, w) {
|
|
10305
|
+
var transform = element.transformable;
|
|
10306
|
+
if (typeof rotation === 'number') {
|
|
10307
|
+
rotation = glMatrix.quat.fromValues(rotation, y, z, w);
|
|
10308
|
+
}
|
|
10309
|
+
if (element.parentNode === null ||
|
|
10310
|
+
!element.parentNode.transformable) {
|
|
10311
|
+
this.setLocalRotation(element, rotation);
|
|
10312
|
+
}
|
|
10313
|
+
else {
|
|
10314
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
10315
|
+
glMatrix.quat.copy($quat$1, parentRot);
|
|
10316
|
+
glMatrix.quat.invert($quat$1, $quat$1);
|
|
10317
|
+
glMatrix.quat.multiply(transform.localRotation, $quat$1, rotation);
|
|
10318
|
+
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
10319
|
+
this.dirtifyLocal(element, transform);
|
|
10320
|
+
}
|
|
10321
|
+
};
|
|
10899
10322
|
DefaultSceneGraphService.prototype.setLocalRotation = function (element, rotation, y, z, w, dirtify) {
|
|
10900
10323
|
if (dirtify === void 0) { dirtify = true; }
|
|
10901
10324
|
if (typeof rotation === 'number') {
|
|
10902
|
-
rotation = glMatrix.quat.
|
|
10325
|
+
rotation = glMatrix.quat.set($quat$1, rotation, y, z, w);
|
|
10903
10326
|
}
|
|
10904
10327
|
var transform = element.transformable;
|
|
10905
10328
|
glMatrix.quat.copy(transform.localRotation, rotation);
|
|
@@ -10907,15 +10330,20 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10907
10330
|
this.dirtifyLocal(element, transform);
|
|
10908
10331
|
}
|
|
10909
10332
|
};
|
|
10910
|
-
DefaultSceneGraphService.prototype.setLocalSkew = function (element, skew, y) {
|
|
10333
|
+
DefaultSceneGraphService.prototype.setLocalSkew = function (element, skew, y, dirtify) {
|
|
10334
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10911
10335
|
if (typeof skew === 'number') {
|
|
10912
|
-
skew = glMatrix.vec2.
|
|
10336
|
+
skew = glMatrix.vec2.set($vec2, skew, y);
|
|
10913
10337
|
}
|
|
10914
10338
|
var transform = element.transformable;
|
|
10915
10339
|
glMatrix.vec2.copy(transform.localSkew, skew);
|
|
10916
|
-
|
|
10340
|
+
if (dirtify) {
|
|
10341
|
+
this.dirtifyLocal(element, transform);
|
|
10342
|
+
}
|
|
10917
10343
|
};
|
|
10918
10344
|
DefaultSceneGraphService.prototype.dirtifyLocal = function (element, transform) {
|
|
10345
|
+
if (isInFragment(element))
|
|
10346
|
+
return;
|
|
10919
10347
|
if (!transform.localDirtyFlag) {
|
|
10920
10348
|
transform.localDirtyFlag = true;
|
|
10921
10349
|
if (!transform.dirtyFlag) {
|
|
@@ -10930,11 +10358,43 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10930
10358
|
this.dirtifyWorldInternal(element, transform);
|
|
10931
10359
|
this.dirtifyToRoot(element, true);
|
|
10932
10360
|
};
|
|
10361
|
+
DefaultSceneGraphService.prototype.dirtifyFragment = function (element) {
|
|
10362
|
+
var transform = element.transformable;
|
|
10363
|
+
if (transform) {
|
|
10364
|
+
transform.frozen = false;
|
|
10365
|
+
transform.dirtyFlag = true;
|
|
10366
|
+
transform.localDirtyFlag = true;
|
|
10367
|
+
}
|
|
10368
|
+
var renderable = element.renderable;
|
|
10369
|
+
if (renderable) {
|
|
10370
|
+
renderable.renderBoundsDirty = true;
|
|
10371
|
+
renderable.boundsDirty = true;
|
|
10372
|
+
renderable.dirty = true;
|
|
10373
|
+
}
|
|
10374
|
+
var length = element.childNodes.length;
|
|
10375
|
+
for (var i = 0; i < length; i++) {
|
|
10376
|
+
this.dirtifyFragment(element.childNodes[i]);
|
|
10377
|
+
}
|
|
10378
|
+
if (element.nodeName === exports.Shape.FRAGMENT) {
|
|
10379
|
+
this.pendingEvents.set(element, false);
|
|
10380
|
+
}
|
|
10381
|
+
};
|
|
10933
10382
|
DefaultSceneGraphService.prototype.triggerPendingEvents = function () {
|
|
10934
10383
|
var _this = this;
|
|
10935
|
-
var
|
|
10384
|
+
var triggered = new Set();
|
|
10385
|
+
var skipped = new Set();
|
|
10386
|
+
this.pendingEvents.forEach(function (_, element) {
|
|
10387
|
+
if (element.nodeName === exports.Shape.FRAGMENT) {
|
|
10388
|
+
element.forEach(function (e) {
|
|
10389
|
+
if (e !== element)
|
|
10390
|
+
skipped.add(e);
|
|
10391
|
+
});
|
|
10392
|
+
}
|
|
10393
|
+
});
|
|
10936
10394
|
var trigger = function (element, detail) {
|
|
10937
|
-
if (element.isConnected &&
|
|
10395
|
+
if (element.isConnected &&
|
|
10396
|
+
!triggered.has(element) &&
|
|
10397
|
+
!skipped.has(element)) {
|
|
10938
10398
|
_this.boundsChangedEvent.detail = detail;
|
|
10939
10399
|
_this.boundsChangedEvent.target = element;
|
|
10940
10400
|
if (element.isMutationObserved) {
|
|
@@ -10943,25 +10403,25 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10943
10403
|
else {
|
|
10944
10404
|
element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
|
|
10945
10405
|
}
|
|
10946
|
-
|
|
10406
|
+
triggered.add(element);
|
|
10947
10407
|
}
|
|
10948
10408
|
};
|
|
10949
|
-
this.pendingEvents.forEach(function (
|
|
10950
|
-
|
|
10951
|
-
if (
|
|
10409
|
+
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
10410
|
+
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
10411
|
+
if (affectChildren) {
|
|
10952
10412
|
element.forEach(function (e) {
|
|
10953
|
-
trigger(e,
|
|
10413
|
+
trigger(e, $triggerPendingEvents_detail);
|
|
10954
10414
|
});
|
|
10955
10415
|
}
|
|
10956
|
-
else
|
|
10957
|
-
trigger(element,
|
|
10958
|
-
}
|
|
10416
|
+
else
|
|
10417
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
10959
10418
|
});
|
|
10419
|
+
triggered.clear();
|
|
10420
|
+
skipped.clear();
|
|
10960
10421
|
this.clearPendingEvents();
|
|
10961
|
-
set.clear();
|
|
10962
10422
|
};
|
|
10963
10423
|
DefaultSceneGraphService.prototype.clearPendingEvents = function () {
|
|
10964
|
-
this.pendingEvents
|
|
10424
|
+
this.pendingEvents.clear();
|
|
10965
10425
|
};
|
|
10966
10426
|
DefaultSceneGraphService.prototype.dirtifyToRoot = function (element, affectChildren) {
|
|
10967
10427
|
if (affectChildren === void 0) { affectChildren = false; }
|
|
@@ -10979,10 +10439,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10979
10439
|
markRenderableDirty(e);
|
|
10980
10440
|
});
|
|
10981
10441
|
}
|
|
10982
|
-
// inform dependencies
|
|
10983
10442
|
this.informDependentDisplayObjects(element);
|
|
10984
|
-
|
|
10985
|
-
this.pendingEvents.push([element, { affectChildren: affectChildren }]);
|
|
10443
|
+
this.pendingEvents.set(element, affectChildren);
|
|
10986
10444
|
};
|
|
10987
10445
|
DefaultSceneGraphService.prototype.updateDisplayObjectDependency = function (name, oldPath, newPath, object) {
|
|
10988
10446
|
// clear ref to old clip path
|
|
@@ -11057,6 +10515,45 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11057
10515
|
DefaultSceneGraphService.prototype.getLocalSkew = function (element) {
|
|
11058
10516
|
return element.transformable.localSkew;
|
|
11059
10517
|
};
|
|
10518
|
+
DefaultSceneGraphService.prototype.calcLocalTransform = function (transform) {
|
|
10519
|
+
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
10520
|
+
if (hasSkew) {
|
|
10521
|
+
glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, glMatrix.vec3.fromValues(1, 1, 1), transform.origin);
|
|
10522
|
+
// apply skew2D
|
|
10523
|
+
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
10524
|
+
glMatrix.mat4.identity($mat4);
|
|
10525
|
+
$mat4[4] = Math.tan(transform.localSkew[0]);
|
|
10526
|
+
$mat4[1] = Math.tan(transform.localSkew[1]);
|
|
10527
|
+
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, $mat4);
|
|
10528
|
+
}
|
|
10529
|
+
var scaling = glMatrix.mat4.fromRotationTranslationScaleOrigin($mat4, glMatrix.quat.set($quat$1, 0, 0, 0, 1), glMatrix.vec3.set($vec3$1, 1, 1, 1), transform.localScale, transform.origin);
|
|
10530
|
+
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, scaling);
|
|
10531
|
+
}
|
|
10532
|
+
else {
|
|
10533
|
+
var localTransform = transform.localTransform, localPosition = transform.localPosition, localRotation = transform.localRotation, localScale = transform.localScale, origin_1 = transform.origin;
|
|
10534
|
+
var hasPosition = localPosition[0] !== 0 ||
|
|
10535
|
+
localPosition[1] !== 0 ||
|
|
10536
|
+
localPosition[2] !== 0;
|
|
10537
|
+
var hasRotation = localRotation[3] !== 1 ||
|
|
10538
|
+
localRotation[0] !== 0 ||
|
|
10539
|
+
localRotation[1] !== 0 ||
|
|
10540
|
+
localRotation[2] !== 0;
|
|
10541
|
+
var hasScale = localScale[0] !== 1 || localScale[1] !== 1 || localScale[2] !== 1;
|
|
10542
|
+
var hasOrigin = origin_1[0] !== 0 || origin_1[1] !== 0 || origin_1[2] !== 0;
|
|
10543
|
+
if (!hasRotation && !hasScale && !hasOrigin) {
|
|
10544
|
+
if (hasPosition) {
|
|
10545
|
+
glMatrix.mat4.fromTranslation(localTransform, localPosition);
|
|
10546
|
+
}
|
|
10547
|
+
else {
|
|
10548
|
+
glMatrix.mat4.identity(localTransform);
|
|
10549
|
+
}
|
|
10550
|
+
}
|
|
10551
|
+
else {
|
|
10552
|
+
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
10553
|
+
glMatrix.mat4.fromRotationTranslationScaleOrigin(localTransform, localRotation, localPosition, localScale, origin_1);
|
|
10554
|
+
}
|
|
10555
|
+
}
|
|
10556
|
+
};
|
|
11060
10557
|
DefaultSceneGraphService.prototype.getLocalTransform = function (element) {
|
|
11061
10558
|
var transform = element.transformable;
|
|
11062
10559
|
if (transform.localDirtyFlag) {
|
|
@@ -11066,19 +10563,20 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11066
10563
|
return transform.localTransform;
|
|
11067
10564
|
};
|
|
11068
10565
|
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
11069
|
-
var t = glMatrix.mat4.getTranslation(
|
|
11070
|
-
var r = glMatrix.mat4.getRotation(
|
|
11071
|
-
var s = glMatrix.mat4.getScaling(
|
|
10566
|
+
var t = glMatrix.mat4.getTranslation($setLocalTransform_1, transform);
|
|
10567
|
+
var r = glMatrix.mat4.getRotation($setLocalTransform_2, transform);
|
|
10568
|
+
var s = glMatrix.mat4.getScaling($setLocalTransform_3, transform);
|
|
11072
10569
|
this.setLocalScale(element, s, false);
|
|
11073
10570
|
this.setLocalPosition(element, t, false);
|
|
11074
10571
|
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11075
10572
|
this.dirtifyLocal(element, element.transformable);
|
|
11076
10573
|
};
|
|
11077
10574
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
11078
|
-
this.setLocalScale(element,
|
|
11079
|
-
this.setLocalPosition(element,
|
|
11080
|
-
this.setLocalEulerAngles(element,
|
|
11081
|
-
this.setLocalSkew(element,
|
|
10575
|
+
this.setLocalScale(element, $vec3One, false);
|
|
10576
|
+
this.setLocalPosition(element, $vec3Zero, false);
|
|
10577
|
+
this.setLocalEulerAngles(element, $vec3Zero, undefined, undefined, false);
|
|
10578
|
+
this.setLocalSkew(element, $vec2Zero, undefined, false);
|
|
10579
|
+
this.dirtifyLocal(element, element.transformable);
|
|
11082
10580
|
};
|
|
11083
10581
|
DefaultSceneGraphService.prototype.getTransformedGeometryBounds = function (element, render, existedAABB) {
|
|
11084
10582
|
if (render === void 0) { render = false; }
|
|
@@ -11170,9 +10668,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11170
10668
|
*/
|
|
11171
10669
|
DefaultSceneGraphService.prototype.getLocalBounds = function (element) {
|
|
11172
10670
|
if (element.parentNode) {
|
|
11173
|
-
var parentInvert =
|
|
10671
|
+
var parentInvert = $mat4Identity;
|
|
11174
10672
|
if (element.parentNode.transformable) {
|
|
11175
|
-
parentInvert = glMatrix.mat4.invert(
|
|
10673
|
+
parentInvert = glMatrix.mat4.invert($mat4, this.getWorldTransform(element.parentNode));
|
|
11176
10674
|
}
|
|
11177
10675
|
var bounds = this.getBounds(element);
|
|
11178
10676
|
if (!AABB.isEmpty(bounds)) {
|
|
@@ -11425,19 +10923,12 @@ var TextService = /** @class */ (function () {
|
|
|
11425
10923
|
// dropShadowDistance = 0,
|
|
11426
10924
|
leading = _g === void 0 ? 0 : _g;
|
|
11427
10925
|
var font = toFontString(parsedStyle);
|
|
11428
|
-
// if (runtime.enableCSSParsing) {
|
|
11429
10926
|
var fontProperties = this.measureFont(font, offscreenCanvas);
|
|
11430
10927
|
// fallback in case UA disallow canvas data extraction
|
|
11431
|
-
// (toDataURI, getImageData functions)
|
|
11432
10928
|
if (fontProperties.fontSize === 0) {
|
|
11433
10929
|
fontProperties.fontSize = fontSize;
|
|
11434
10930
|
fontProperties.ascent = fontSize;
|
|
11435
10931
|
}
|
|
11436
|
-
// } else {
|
|
11437
|
-
// fontProperties = {
|
|
11438
|
-
// fontSize,
|
|
11439
|
-
// };
|
|
11440
|
-
// }
|
|
11441
10932
|
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
|
|
11442
10933
|
context.font = font;
|
|
11443
10934
|
// no overflowing by default
|
|
@@ -11759,10 +11250,7 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
|
|
|
11759
11250
|
runtime.styleValueRegistry = new DefaultStyleValueRegistry(runtime);
|
|
11760
11251
|
runtime.layoutRegistry = null;
|
|
11761
11252
|
runtime.globalThis = getGlobalThis();
|
|
11762
|
-
runtime.enableCSSParsing = false;
|
|
11763
|
-
runtime.enableDataset = false;
|
|
11764
11253
|
runtime.enableStyleSyntax = true;
|
|
11765
|
-
runtime.enableAttributeDashCased = false;
|
|
11766
11254
|
runtime.enableSizeAttenuation = false;
|
|
11767
11255
|
|
|
11768
11256
|
var entityCounter = 0;
|
|
@@ -11851,34 +11339,7 @@ var Element = /** @class */ (function (_super) {
|
|
|
11851
11339
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
11852
11340
|
*/
|
|
11853
11341
|
_this.style = {};
|
|
11854
|
-
_this.computedStyle =
|
|
11855
|
-
? {
|
|
11856
|
-
opacity: unsetKeywordValue,
|
|
11857
|
-
fillOpacity: unsetKeywordValue,
|
|
11858
|
-
strokeOpacity: unsetKeywordValue,
|
|
11859
|
-
fill: unsetKeywordValue,
|
|
11860
|
-
stroke: unsetKeywordValue,
|
|
11861
|
-
transform: unsetKeywordValue,
|
|
11862
|
-
transformOrigin: unsetKeywordValue,
|
|
11863
|
-
visibility: unsetKeywordValue,
|
|
11864
|
-
pointerEvents: unsetKeywordValue,
|
|
11865
|
-
lineWidth: unsetKeywordValue,
|
|
11866
|
-
lineCap: unsetKeywordValue,
|
|
11867
|
-
lineJoin: unsetKeywordValue,
|
|
11868
|
-
increasedLineWidthForHitTesting: unsetKeywordValue,
|
|
11869
|
-
fontSize: unsetKeywordValue,
|
|
11870
|
-
fontFamily: unsetKeywordValue,
|
|
11871
|
-
fontStyle: unsetKeywordValue,
|
|
11872
|
-
fontWeight: unsetKeywordValue,
|
|
11873
|
-
fontVariant: unsetKeywordValue,
|
|
11874
|
-
textAlign: unsetKeywordValue,
|
|
11875
|
-
textBaseline: unsetKeywordValue,
|
|
11876
|
-
textTransform: unsetKeywordValue,
|
|
11877
|
-
zIndex: unsetKeywordValue,
|
|
11878
|
-
filter: unsetKeywordValue,
|
|
11879
|
-
shadowType: unsetKeywordValue,
|
|
11880
|
-
}
|
|
11881
|
-
: null;
|
|
11342
|
+
_this.computedStyle = {};
|
|
11882
11343
|
/**
|
|
11883
11344
|
* Renderers will use these used values.
|
|
11884
11345
|
*/
|
|
@@ -12007,7 +11468,12 @@ var Element = /** @class */ (function (_super) {
|
|
|
12007
11468
|
}
|
|
12008
11469
|
runtime.sceneGraphService.attach(child, this, index);
|
|
12009
11470
|
if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
|
|
12010
|
-
this.
|
|
11471
|
+
if (!isInFragment(this) && child.nodeName === exports.Shape.FRAGMENT) {
|
|
11472
|
+
this.ownerDocument.defaultView.mountFragment(child);
|
|
11473
|
+
}
|
|
11474
|
+
else {
|
|
11475
|
+
this.ownerDocument.defaultView.mountChildren(child);
|
|
11476
|
+
}
|
|
12011
11477
|
}
|
|
12012
11478
|
// @ts-ignore
|
|
12013
11479
|
if (this.isMutationObserved) {
|
|
@@ -12121,9 +11587,9 @@ var Element = /** @class */ (function (_super) {
|
|
|
12121
11587
|
this.forEach(function (object) {
|
|
12122
11588
|
if (object !== _this && filter(object)) {
|
|
12123
11589
|
target = object;
|
|
12124
|
-
return
|
|
11590
|
+
return false;
|
|
12125
11591
|
}
|
|
12126
|
-
return
|
|
11592
|
+
return true;
|
|
12127
11593
|
});
|
|
12128
11594
|
return target;
|
|
12129
11595
|
};
|
|
@@ -12281,17 +11747,13 @@ var Element = /** @class */ (function (_super) {
|
|
|
12281
11747
|
*/
|
|
12282
11748
|
Element.prototype.getAttribute = function (name) {
|
|
12283
11749
|
// @see https://github.com/antvis/G/issues/1267
|
|
12284
|
-
if (
|
|
12285
|
-
return
|
|
11750
|
+
if (typeof name === 'symbol') {
|
|
11751
|
+
return undefined;
|
|
12286
11752
|
}
|
|
12287
11753
|
var value = this.attributes[name];
|
|
12288
11754
|
if (value === undefined) {
|
|
12289
|
-
if (runtime.enableAttributeDashCased) {
|
|
12290
|
-
var attributeName = formatAttributeName(name);
|
|
12291
|
-
value = this.attributes[attributeName];
|
|
12292
|
-
}
|
|
12293
11755
|
// if the given attribute does not exist, the value returned will either be null or ""
|
|
12294
|
-
return
|
|
11756
|
+
return value;
|
|
12295
11757
|
}
|
|
12296
11758
|
else {
|
|
12297
11759
|
return value;
|
|
@@ -12363,78 +11825,8 @@ var Proxy = runtime.globalThis.Proxy
|
|
|
12363
11825
|
? runtime.globalThis.Proxy
|
|
12364
11826
|
: function () { };
|
|
12365
11827
|
var mutationEvent = new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
|
|
12366
|
-
var
|
|
12367
|
-
|
|
12368
|
-
fillOpacity: '',
|
|
12369
|
-
strokeOpacity: '',
|
|
12370
|
-
fill: '',
|
|
12371
|
-
stroke: '',
|
|
12372
|
-
transform: '',
|
|
12373
|
-
transformOrigin: '',
|
|
12374
|
-
visibility: '',
|
|
12375
|
-
pointerEvents: '',
|
|
12376
|
-
lineWidth: '',
|
|
12377
|
-
lineCap: '',
|
|
12378
|
-
lineJoin: '',
|
|
12379
|
-
increasedLineWidthForHitTesting: '',
|
|
12380
|
-
fontSize: '',
|
|
12381
|
-
fontFamily: '',
|
|
12382
|
-
fontStyle: '',
|
|
12383
|
-
fontWeight: '',
|
|
12384
|
-
fontVariant: '',
|
|
12385
|
-
textAlign: '',
|
|
12386
|
-
textBaseline: '',
|
|
12387
|
-
textTransform: '',
|
|
12388
|
-
zIndex: '',
|
|
12389
|
-
filter: '',
|
|
12390
|
-
shadowType: '',
|
|
12391
|
-
};
|
|
12392
|
-
var DEFAULT_PARSED_STYLE_PROPS = {
|
|
12393
|
-
fill: noneColor,
|
|
12394
|
-
stroke: noneColor,
|
|
12395
|
-
transform: [],
|
|
12396
|
-
zIndex: 0,
|
|
12397
|
-
filter: [],
|
|
12398
|
-
shadowType: 'outer',
|
|
12399
|
-
miterLimit: 10,
|
|
12400
|
-
};
|
|
12401
|
-
// const DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = {
|
|
12402
|
-
// ...DEFAULT_PARSED_STYLE_PROPS,
|
|
12403
|
-
// opacity: 1,
|
|
12404
|
-
// fillOpacity: 1,
|
|
12405
|
-
// strokeOpacity: 1,
|
|
12406
|
-
// visibility: 'visible',
|
|
12407
|
-
// pointerEvents: 'auto',
|
|
12408
|
-
// lineWidth: 1,
|
|
12409
|
-
// lineCap: 'butt',
|
|
12410
|
-
// lineJoin: 'miter',
|
|
12411
|
-
// increasedLineWidthForHitTesting: 0,
|
|
12412
|
-
// fillRule: 'nonzero',
|
|
12413
|
-
// // TODO: transformOrigin
|
|
12414
|
-
// };
|
|
12415
|
-
var INHERITABLE_BASE_STYLE_PROPS = [
|
|
12416
|
-
'opacity',
|
|
12417
|
-
'fillOpacity',
|
|
12418
|
-
'strokeOpacity',
|
|
12419
|
-
'transformOrigin',
|
|
12420
|
-
'visibility',
|
|
12421
|
-
'pointerEvents',
|
|
12422
|
-
'lineWidth',
|
|
12423
|
-
'lineCap',
|
|
12424
|
-
'lineJoin',
|
|
12425
|
-
'increasedLineWidthForHitTesting',
|
|
12426
|
-
];
|
|
12427
|
-
var INHERITABLE_STYLE_PROPS = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(INHERITABLE_BASE_STYLE_PROPS), false), [
|
|
12428
|
-
'fontSize',
|
|
12429
|
-
'fontFamily',
|
|
12430
|
-
'fontStyle',
|
|
12431
|
-
'fontWeight',
|
|
12432
|
-
'fontVariant',
|
|
12433
|
-
'textAlign',
|
|
12434
|
-
'textBaseline',
|
|
12435
|
-
'textTransform',
|
|
12436
|
-
], false);
|
|
12437
|
-
var DATASET_PREFIX = 'data-';
|
|
11828
|
+
var $vec3 = glMatrix.vec3.create();
|
|
11829
|
+
var $quat = glMatrix.quat.create();
|
|
12438
11830
|
/**
|
|
12439
11831
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
12440
11832
|
*
|
|
@@ -12467,38 +11859,17 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12467
11859
|
// eg. group.get('name')
|
|
12468
11860
|
_this.config = config;
|
|
12469
11861
|
// init scene graph node
|
|
12470
|
-
_this.id =
|
|
12471
|
-
_this.name =
|
|
12472
|
-
if (
|
|
12473
|
-
_this.className =
|
|
11862
|
+
_this.id = config.id || '';
|
|
11863
|
+
_this.name = config.name || '';
|
|
11864
|
+
if (config.className || config.class) {
|
|
11865
|
+
_this.className = config.className || config.class;
|
|
12474
11866
|
}
|
|
12475
|
-
_this.nodeName =
|
|
12476
|
-
if (
|
|
12477
|
-
Object.assign(_this.
|
|
12478
|
-
Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
|
|
12479
|
-
}
|
|
12480
|
-
else if (_this.config.initialParsedStyle) {
|
|
12481
|
-
Object.assign(_this.parsedStyle,
|
|
12482
|
-
// DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,
|
|
12483
|
-
_this.config.initialParsedStyle);
|
|
11867
|
+
_this.nodeName = config.type || exports.Shape.GROUP;
|
|
11868
|
+
if (config.initialParsedStyle) {
|
|
11869
|
+
Object.assign(_this.parsedStyle, config.initialParsedStyle);
|
|
12484
11870
|
}
|
|
12485
11871
|
// start to process attributes
|
|
12486
|
-
_this.initAttributes(
|
|
12487
|
-
if (runtime.enableDataset) {
|
|
12488
|
-
_this.dataset = new Proxy({}, {
|
|
12489
|
-
get: function (target, name) {
|
|
12490
|
-
var formattedName = "".concat(DATASET_PREFIX).concat(kebabize(name));
|
|
12491
|
-
if (target[formattedName] !== undefined) {
|
|
12492
|
-
return target[formattedName];
|
|
12493
|
-
}
|
|
12494
|
-
return _this.getAttribute(formattedName);
|
|
12495
|
-
},
|
|
12496
|
-
set: function (_, prop, value) {
|
|
12497
|
-
_this.setAttribute("".concat(DATASET_PREFIX).concat(kebabize(prop)), value);
|
|
12498
|
-
return true;
|
|
12499
|
-
},
|
|
12500
|
-
});
|
|
12501
|
-
}
|
|
11872
|
+
_this.initAttributes(config.style);
|
|
12502
11873
|
if (runtime.enableStyleSyntax) {
|
|
12503
11874
|
_this.style = new Proxy(
|
|
12504
11875
|
// @ts-ignore
|
|
@@ -12538,13 +11909,6 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12538
11909
|
this.getAnimations().forEach(function (animation) {
|
|
12539
11910
|
animation.cancel();
|
|
12540
11911
|
});
|
|
12541
|
-
// FIXME
|
|
12542
|
-
// this.renderable = null;
|
|
12543
|
-
// this.cullable = null;
|
|
12544
|
-
// this.transformable = null;
|
|
12545
|
-
// this.rBushNode = null;
|
|
12546
|
-
// this.geometry = null;
|
|
12547
|
-
// this.sortable = null;
|
|
12548
11912
|
};
|
|
12549
11913
|
DisplayObject.prototype.cloneNode = function (deep, customCloneFunc) {
|
|
12550
11914
|
var clonedStyle = tslib.__assign({}, this.attributes);
|
|
@@ -12587,39 +11951,16 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12587
11951
|
};
|
|
12588
11952
|
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
12589
11953
|
if (attributes === void 0) { attributes = {}; }
|
|
12590
|
-
var renderable = this.renderable;
|
|
12591
11954
|
var options = {
|
|
12592
11955
|
forceUpdateGeometry: true,
|
|
12593
|
-
// usedAttributes:
|
|
12594
|
-
// // only Group / Text should account for text relative props
|
|
12595
|
-
// this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
|
|
12596
|
-
// ? INHERITABLE_STYLE_PROPS
|
|
12597
|
-
// : INHERITABLE_BASE_STYLE_PROPS,
|
|
12598
11956
|
};
|
|
12599
|
-
|
|
12600
|
-
// @ts-ignore
|
|
12601
|
-
options.usedAttributes = INHERITABLE_STYLE_PROPS;
|
|
12602
|
-
}
|
|
12603
|
-
// account for FCP, process properties as less as possible
|
|
12604
|
-
var formattedAttributes = attributes;
|
|
12605
|
-
if (runtime.enableAttributeDashCased) {
|
|
12606
|
-
// @ts-ignore
|
|
12607
|
-
formattedAttributes = {};
|
|
12608
|
-
for (var name_1 in attributes) {
|
|
12609
|
-
var attributeName = formatAttributeName(name_1);
|
|
12610
|
-
formattedAttributes[attributeName] = attributes[name_1];
|
|
12611
|
-
}
|
|
12612
|
-
}
|
|
12613
|
-
runtime.styleValueRegistry.processProperties(this, formattedAttributes, options);
|
|
11957
|
+
runtime.styleValueRegistry.processProperties(this, attributes, options);
|
|
12614
11958
|
// redraw at next frame
|
|
12615
|
-
renderable.dirty = true;
|
|
11959
|
+
this.renderable.dirty = true;
|
|
12616
11960
|
};
|
|
12617
11961
|
DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
|
|
12618
11962
|
if (force === void 0) { force = false; }
|
|
12619
11963
|
if (memoize === void 0) { memoize = true; }
|
|
12620
|
-
if (runtime.enableAttributeDashCased) {
|
|
12621
|
-
name = formatAttributeName(name);
|
|
12622
|
-
}
|
|
12623
11964
|
// ignore undefined value
|
|
12624
11965
|
if (util.isUndefined(value)) {
|
|
12625
11966
|
return;
|
|
@@ -12681,7 +12022,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12681
12022
|
DisplayObject.prototype.setOrigin = function (position, y, z) {
|
|
12682
12023
|
if (y === void 0) { y = 0; }
|
|
12683
12024
|
if (z === void 0) { z = 0; }
|
|
12684
|
-
runtime.sceneGraphService.setOrigin(this, createVec3(position, y, z));
|
|
12025
|
+
runtime.sceneGraphService.setOrigin(this, createVec3(position, y, z, false));
|
|
12685
12026
|
return this;
|
|
12686
12027
|
};
|
|
12687
12028
|
DisplayObject.prototype.getOrigin = function () {
|
|
@@ -12693,7 +12034,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12693
12034
|
DisplayObject.prototype.setPosition = function (position, y, z) {
|
|
12694
12035
|
if (y === void 0) { y = 0; }
|
|
12695
12036
|
if (z === void 0) { z = 0; }
|
|
12696
|
-
runtime.sceneGraphService.setPosition(this, createVec3(position, y, z));
|
|
12037
|
+
runtime.sceneGraphService.setPosition(this, createVec3(position, y, z, false));
|
|
12697
12038
|
return this;
|
|
12698
12039
|
};
|
|
12699
12040
|
/**
|
|
@@ -12702,7 +12043,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12702
12043
|
DisplayObject.prototype.setLocalPosition = function (position, y, z) {
|
|
12703
12044
|
if (y === void 0) { y = 0; }
|
|
12704
12045
|
if (z === void 0) { z = 0; }
|
|
12705
|
-
runtime.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
|
|
12046
|
+
runtime.sceneGraphService.setLocalPosition(this, createVec3(position, y, z, false));
|
|
12706
12047
|
return this;
|
|
12707
12048
|
};
|
|
12708
12049
|
/**
|
|
@@ -12711,7 +12052,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12711
12052
|
DisplayObject.prototype.translate = function (position, y, z) {
|
|
12712
12053
|
if (y === void 0) { y = 0; }
|
|
12713
12054
|
if (z === void 0) { z = 0; }
|
|
12714
|
-
runtime.sceneGraphService.translate(this, createVec3(position, y, z));
|
|
12055
|
+
runtime.sceneGraphService.translate(this, createVec3(position, y, z, false));
|
|
12715
12056
|
return this;
|
|
12716
12057
|
};
|
|
12717
12058
|
/**
|
|
@@ -12720,7 +12061,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12720
12061
|
DisplayObject.prototype.translateLocal = function (position, y, z) {
|
|
12721
12062
|
if (y === void 0) { y = 0; }
|
|
12722
12063
|
if (z === void 0) { z = 0; }
|
|
12723
|
-
runtime.sceneGraphService.translateLocal(this, createVec3(position, y, z));
|
|
12064
|
+
runtime.sceneGraphService.translateLocal(this, createVec3(position, y, z, false));
|
|
12724
12065
|
return this;
|
|
12725
12066
|
};
|
|
12726
12067
|
DisplayObject.prototype.getPosition = function () {
|
|
@@ -12744,7 +12085,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12744
12085
|
if (typeof scaling === 'number') {
|
|
12745
12086
|
y = y || scaling;
|
|
12746
12087
|
z = z || scaling;
|
|
12747
|
-
scaling = createVec3(scaling, y, z);
|
|
12088
|
+
scaling = createVec3(scaling, y, z, false);
|
|
12748
12089
|
}
|
|
12749
12090
|
runtime.sceneGraphService.scaleLocal(this, scaling);
|
|
12750
12091
|
return this;
|
|
@@ -12756,7 +12097,7 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12756
12097
|
if (typeof scaling === 'number') {
|
|
12757
12098
|
y = y || scaling;
|
|
12758
12099
|
z = z || scaling;
|
|
12759
|
-
scaling = createVec3(scaling, y, z);
|
|
12100
|
+
scaling = createVec3(scaling, y, z, false);
|
|
12760
12101
|
}
|
|
12761
12102
|
runtime.sceneGraphService.setLocalScale(this, scaling);
|
|
12762
12103
|
return this;
|
|
@@ -12777,14 +12118,14 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12777
12118
|
* only return degrees of Z axis in world space
|
|
12778
12119
|
*/
|
|
12779
12120
|
DisplayObject.prototype.getEulerAngles = function () {
|
|
12780
|
-
var _a = tslib.__read(getEuler(
|
|
12121
|
+
var _a = tslib.__read(getEuler($vec3, runtime.sceneGraphService.getWorldTransform(this)), 3), ez = _a[2];
|
|
12781
12122
|
return rad2deg(ez);
|
|
12782
12123
|
};
|
|
12783
12124
|
/**
|
|
12784
12125
|
* only return degrees of Z axis in local space
|
|
12785
12126
|
*/
|
|
12786
12127
|
DisplayObject.prototype.getLocalEulerAngles = function () {
|
|
12787
|
-
var _a = tslib.__read(getEuler(
|
|
12128
|
+
var _a = tslib.__read(getEuler($vec3, runtime.sceneGraphService.getLocalRotation(this)), 3), ez = _a[2];
|
|
12788
12129
|
return rad2deg(ez);
|
|
12789
12130
|
};
|
|
12790
12131
|
/**
|
|
@@ -12880,10 +12221,8 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12880
12221
|
* shortcut for Used value of `visibility`
|
|
12881
12222
|
*/
|
|
12882
12223
|
DisplayObject.prototype.isVisible = function () {
|
|
12883
|
-
var _a
|
|
12884
|
-
return
|
|
12885
|
-
? ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible'
|
|
12886
|
-
: ((_b = this.parsedStyle) === null || _b === void 0 ? void 0 : _b.visibility) !== 'hidden';
|
|
12224
|
+
var _a;
|
|
12225
|
+
return ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) !== 'hidden';
|
|
12887
12226
|
};
|
|
12888
12227
|
Object.defineProperty(DisplayObject.prototype, "interactive", {
|
|
12889
12228
|
get: function () {
|
|
@@ -12964,10 +12303,10 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12964
12303
|
*/
|
|
12965
12304
|
DisplayObject.prototype.getMatrix = function (transformMat4) {
|
|
12966
12305
|
var transform = transformMat4 || this.getWorldTransform();
|
|
12967
|
-
var _a = tslib.__read(glMatrix.mat4.getTranslation(
|
|
12968
|
-
var _b = tslib.__read(glMatrix.mat4.getScaling(
|
|
12969
|
-
var rotation = glMatrix.mat4.getRotation(
|
|
12970
|
-
var _c = tslib.__read(getEuler(
|
|
12306
|
+
var _a = tslib.__read(glMatrix.mat4.getTranslation($vec3, transform), 2), tx = _a[0], ty = _a[1];
|
|
12307
|
+
var _b = tslib.__read(glMatrix.mat4.getScaling($vec3, transform), 2), sx = _b[0], sy = _b[1];
|
|
12308
|
+
var rotation = glMatrix.mat4.getRotation($quat, transform);
|
|
12309
|
+
var _c = tslib.__read(getEuler($vec3, rotation), 3), eux = _c[0], euz = _c[2];
|
|
12971
12310
|
// gimbal lock at 90 degrees
|
|
12972
12311
|
return fromRotationTranslationScale(eux || euz, tx, ty, sx, sy);
|
|
12973
12312
|
};
|
|
@@ -13003,28 +12342,18 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
13003
12342
|
* @deprecated
|
|
13004
12343
|
*/
|
|
13005
12344
|
DisplayObject.prototype.show = function () {
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
}
|
|
13009
|
-
else {
|
|
13010
|
-
this.forEach(function (object) {
|
|
13011
|
-
object.style.visibility = 'visible';
|
|
13012
|
-
});
|
|
13013
|
-
}
|
|
12345
|
+
this.forEach(function (object) {
|
|
12346
|
+
object.style.visibility = 'visible';
|
|
12347
|
+
});
|
|
13014
12348
|
};
|
|
13015
12349
|
/**
|
|
13016
12350
|
* Use `visibility: hidden` instead.
|
|
13017
12351
|
* @deprecated
|
|
13018
12352
|
*/
|
|
13019
12353
|
DisplayObject.prototype.hide = function () {
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
}
|
|
13023
|
-
else {
|
|
13024
|
-
this.forEach(function (object) {
|
|
13025
|
-
object.style.visibility = 'hidden';
|
|
13026
|
-
});
|
|
13027
|
-
}
|
|
12354
|
+
this.forEach(function (object) {
|
|
12355
|
+
object.style.visibility = 'hidden';
|
|
12356
|
+
});
|
|
13028
12357
|
};
|
|
13029
12358
|
/**
|
|
13030
12359
|
* Use `childElementCount` instead.
|
|
@@ -13139,8 +12468,7 @@ var CustomElement = /** @class */ (function (_super) {
|
|
|
13139
12468
|
if (_a === void 0) { _a = {}; }
|
|
13140
12469
|
var _this = this;
|
|
13141
12470
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13142
|
-
_this = _super.call(this, tslib.__assign({ style:
|
|
13143
|
-
? tslib.__assign({}, style) : tslib.__assign({}, style) }, rest)) || this;
|
|
12471
|
+
_this = _super.call(this, tslib.__assign({ style: style }, rest)) || this;
|
|
13144
12472
|
// static get observedAttributes(): string[] {
|
|
13145
12473
|
// return [];
|
|
13146
12474
|
// }
|
|
@@ -13159,6 +12487,23 @@ var Ellipse = /** @class */ (function (_super) {
|
|
|
13159
12487
|
return Ellipse;
|
|
13160
12488
|
}(DisplayObject));
|
|
13161
12489
|
|
|
12490
|
+
/**
|
|
12491
|
+
* 节点片段,用于包裹多个节点并批量操作
|
|
12492
|
+
*
|
|
12493
|
+
* 向 Fragment 或者根节点为 Fragment 的节点添加子节点时,不会触发渲染和事件。
|
|
12494
|
+
*
|
|
12495
|
+
* 当 Fragment 被挂载到 Canvas 中的节点时,其子节点会一次性被渲染,并触发合并事件。
|
|
12496
|
+
*
|
|
12497
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
|
12498
|
+
*/
|
|
12499
|
+
var Fragment = /** @class */ (function (_super) {
|
|
12500
|
+
tslib.__extends(Fragment, _super);
|
|
12501
|
+
function Fragment() {
|
|
12502
|
+
return _super.call(this, { type: exports.Shape.FRAGMENT }) || this;
|
|
12503
|
+
}
|
|
12504
|
+
return Fragment;
|
|
12505
|
+
}(DisplayObject));
|
|
12506
|
+
|
|
13162
12507
|
/**
|
|
13163
12508
|
* its attributes are inherited by its children.
|
|
13164
12509
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
|
|
@@ -13188,8 +12533,7 @@ var HTML = /** @class */ (function (_super) {
|
|
|
13188
12533
|
if (_a === void 0) { _a = {}; }
|
|
13189
12534
|
var _this = this;
|
|
13190
12535
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13191
|
-
_this = _super.call(this, tslib.__assign({ type: exports.Shape.HTML, style:
|
|
13192
|
-
? tslib.__assign({ x: '', y: '', width: 'auto', height: 'auto', innerHTML: '' }, style) : tslib.__assign({}, style) }, rest)) || this;
|
|
12536
|
+
_this = _super.call(this, tslib.__assign({ type: exports.Shape.HTML, style: style }, rest)) || this;
|
|
13193
12537
|
_this.cullable.enable = false;
|
|
13194
12538
|
return _this;
|
|
13195
12539
|
}
|
|
@@ -13381,13 +12725,10 @@ var Path = /** @class */ (function (_super) {
|
|
|
13381
12725
|
if (_a === void 0) { _a = {}; }
|
|
13382
12726
|
var _this = this;
|
|
13383
12727
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13384
|
-
_this = _super.call(this, tslib.__assign({ type: exports.Shape.PATH, style:
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
miterLimit: 4,
|
|
13389
|
-
d: tslib.__assign({}, EMPTY_PARSED_PATH),
|
|
13390
|
-
} }, rest)) || this;
|
|
12728
|
+
_this = _super.call(this, tslib.__assign({ type: exports.Shape.PATH, style: style, initialParsedStyle: {
|
|
12729
|
+
miterLimit: 4,
|
|
12730
|
+
d: tslib.__assign({}, EMPTY_PARSED_PATH),
|
|
12731
|
+
} }, rest)) || this;
|
|
13391
12732
|
_this.markerStartAngle = 0;
|
|
13392
12733
|
_this.markerEndAngle = 0;
|
|
13393
12734
|
/**
|
|
@@ -13582,18 +12923,15 @@ var Polygon = /** @class */ (function (_super) {
|
|
|
13582
12923
|
if (_a === void 0) { _a = {}; }
|
|
13583
12924
|
var _this = this;
|
|
13584
12925
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13585
|
-
_this = _super.call(this, tslib.__assign({ type: exports.Shape.POLYGON, style:
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
miterLimit: 4,
|
|
13595
|
-
isClosed: true,
|
|
13596
|
-
} }, rest)) || this;
|
|
12926
|
+
_this = _super.call(this, tslib.__assign({ type: exports.Shape.POLYGON, style: style, initialParsedStyle: {
|
|
12927
|
+
points: {
|
|
12928
|
+
points: [],
|
|
12929
|
+
totalLength: 0,
|
|
12930
|
+
segments: [],
|
|
12931
|
+
},
|
|
12932
|
+
miterLimit: 4,
|
|
12933
|
+
isClosed: true,
|
|
12934
|
+
} }, rest)) || this;
|
|
13597
12935
|
_this.markerStartAngle = 0;
|
|
13598
12936
|
_this.markerEndAngle = 0;
|
|
13599
12937
|
/**
|
|
@@ -13728,18 +13066,15 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13728
13066
|
function Polyline(_a) {
|
|
13729
13067
|
if (_a === void 0) { _a = {}; }
|
|
13730
13068
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13731
|
-
return _super.call(this, tslib.__assign({ type: exports.Shape.POLYLINE, style:
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
miterLimit: 4,
|
|
13741
|
-
isClosed: false,
|
|
13742
|
-
} }, rest)) || this;
|
|
13069
|
+
return _super.call(this, tslib.__assign({ type: exports.Shape.POLYLINE, style: style, initialParsedStyle: {
|
|
13070
|
+
points: {
|
|
13071
|
+
points: [],
|
|
13072
|
+
totalLength: 0,
|
|
13073
|
+
segments: [],
|
|
13074
|
+
},
|
|
13075
|
+
miterLimit: 4,
|
|
13076
|
+
isClosed: false,
|
|
13077
|
+
} }, rest)) || this;
|
|
13743
13078
|
}
|
|
13744
13079
|
Polyline.prototype.getTotalLength = function () {
|
|
13745
13080
|
return getOrCalculatePolylineTotalLength(this);
|
|
@@ -13823,16 +13158,8 @@ var Text = /** @class */ (function (_super) {
|
|
|
13823
13158
|
function Text(_a) {
|
|
13824
13159
|
if (_a === void 0) { _a = {}; }
|
|
13825
13160
|
var style = _a.style, rest = tslib.__rest(_a, ["style"]);
|
|
13826
|
-
return _super.call(this, tslib.__assign({ type: exports.Shape.TEXT, style:
|
|
13827
|
-
|
|
13828
|
-
// whiteSpace: 'pre',
|
|
13829
|
-
wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : tslib.__assign({ fill: 'black' }, style) }, rest)) || this;
|
|
13830
|
-
}
|
|
13831
|
-
// lengthAdjust: SVGAnimatedEnumeration;
|
|
13832
|
-
// textLength: SVGAnimatedLength;
|
|
13833
|
-
// getCharNumAtPosition(point?: DOMPointInit): number {
|
|
13834
|
-
// throw new Error('Method not implemented.');
|
|
13835
|
-
// }
|
|
13161
|
+
return _super.call(this, tslib.__assign({ type: exports.Shape.TEXT, style: tslib.__assign({ fill: 'black' }, style) }, rest)) || this;
|
|
13162
|
+
}
|
|
13836
13163
|
/**
|
|
13837
13164
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
|
|
13838
13165
|
*/
|
|
@@ -13841,27 +13168,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
13841
13168
|
this.getGeometryBounds();
|
|
13842
13169
|
return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
|
|
13843
13170
|
};
|
|
13844
|
-
// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
13845
|
-
// throw new Error('Method not implemented.');
|
|
13846
|
-
// }
|
|
13847
|
-
// getExtentOfChar(charnum: number): DOMRect {
|
|
13848
|
-
// throw new Error('Method not implemented.');
|
|
13849
|
-
// }
|
|
13850
|
-
// getNumberOfChars(): number {
|
|
13851
|
-
// throw new Error('Method not implemented.');
|
|
13852
|
-
// }
|
|
13853
|
-
// getRotationOfChar(charnum: number): number {
|
|
13854
|
-
// throw new Error('Method not implemented.');
|
|
13855
|
-
// }
|
|
13856
|
-
// getStartPositionOfChar(charnum: number): DOMPoint {
|
|
13857
|
-
// throw new Error('Method not implemented.');
|
|
13858
|
-
// }
|
|
13859
|
-
// getSubStringLength(charnum: number, nchars: number): number {
|
|
13860
|
-
// throw new Error('Method not implemented.');
|
|
13861
|
-
// }
|
|
13862
|
-
// selectSubString(charnum: number, nchars: number): void {
|
|
13863
|
-
// throw new Error('Method not implemented.');
|
|
13864
|
-
// }
|
|
13865
13171
|
Text.prototype.getLineBoundingRects = function () {
|
|
13866
13172
|
var _a;
|
|
13867
13173
|
this.getGeometryBounds();
|
|
@@ -14039,7 +13345,7 @@ var Document = /** @class */ (function (_super) {
|
|
|
14039
13345
|
BUILT_IN_PROPERTIES.forEach(function (_a) {
|
|
14040
13346
|
var n = _a.n, inh = _a.inh, d = _a.d;
|
|
14041
13347
|
if (inh && d) {
|
|
14042
|
-
initialStyle[n] = isFunction(d) ? d(exports.Shape.GROUP) : d;
|
|
13348
|
+
initialStyle[n] = util.isFunction(d) ? d(exports.Shape.GROUP) : d;
|
|
14043
13349
|
}
|
|
14044
13350
|
});
|
|
14045
13351
|
// like <html> in DOM tree
|
|
@@ -14816,10 +14122,7 @@ var FrustumCullingStrategy = /** @class */ (function () {
|
|
|
14816
14122
|
|
|
14817
14123
|
var PrepareRendererPlugin = /** @class */ (function () {
|
|
14818
14124
|
function PrepareRendererPlugin() {
|
|
14819
|
-
|
|
14820
|
-
* sync to RBush later
|
|
14821
|
-
*/
|
|
14822
|
-
this.toSync = new Set();
|
|
14125
|
+
this.syncTasks = new Map();
|
|
14823
14126
|
this.isFirstTimeRendering = true;
|
|
14824
14127
|
this.syncing = false;
|
|
14825
14128
|
this.isFirstTimeRenderingFinished = false;
|
|
@@ -14836,21 +14139,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14836
14139
|
renderingService.dirtify();
|
|
14837
14140
|
};
|
|
14838
14141
|
var handleBoundsChanged = function (e) {
|
|
14839
|
-
|
|
14840
|
-
var object = e.target;
|
|
14841
|
-
if (affectChildren) {
|
|
14842
|
-
object.forEach(function (node) {
|
|
14843
|
-
_this.toSync.add(node);
|
|
14844
|
-
});
|
|
14845
|
-
}
|
|
14846
|
-
var p = object;
|
|
14847
|
-
while (p) {
|
|
14848
|
-
if (p.renderable) {
|
|
14849
|
-
_this.toSync.add(p);
|
|
14850
|
-
}
|
|
14851
|
-
p = p.parentElement;
|
|
14852
|
-
}
|
|
14853
|
-
// this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
|
|
14142
|
+
_this.syncTasks.set(e.target, e.detail.affectChildren);
|
|
14854
14143
|
renderingService.dirtify();
|
|
14855
14144
|
};
|
|
14856
14145
|
var handleMounted = function (e) {
|
|
@@ -14858,12 +14147,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14858
14147
|
if (runtime.enableSizeAttenuation) {
|
|
14859
14148
|
runtime.styleValueRegistry.updateSizeAttenuation(object, canvas.getCamera().getZoom());
|
|
14860
14149
|
}
|
|
14861
|
-
if (runtime.enableCSSParsing) {
|
|
14862
|
-
// recalc style values
|
|
14863
|
-
runtime.styleValueRegistry.recalc(object);
|
|
14864
|
-
}
|
|
14865
|
-
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
14866
|
-
renderingService.dirtify();
|
|
14867
14150
|
};
|
|
14868
14151
|
var handleUnmounted = function (e) {
|
|
14869
14152
|
var object = e.target;
|
|
@@ -14871,7 +14154,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14871
14154
|
if (rBushNode.aabb) {
|
|
14872
14155
|
_this.rBush.remove(rBushNode.aabb);
|
|
14873
14156
|
}
|
|
14874
|
-
_this.
|
|
14157
|
+
_this.syncTasks.delete(object);
|
|
14875
14158
|
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
14876
14159
|
renderingService.dirtify();
|
|
14877
14160
|
};
|
|
@@ -14886,7 +14169,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14886
14169
|
canvas.removeEventListener(exports.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
14887
14170
|
canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
14888
14171
|
canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14889
|
-
_this.
|
|
14172
|
+
_this.syncTasks.clear();
|
|
14890
14173
|
});
|
|
14891
14174
|
var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
|
|
14892
14175
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
@@ -14903,60 +14186,78 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14903
14186
|
}
|
|
14904
14187
|
});
|
|
14905
14188
|
};
|
|
14189
|
+
PrepareRendererPlugin.prototype.syncNode = function (node, force) {
|
|
14190
|
+
if (force === void 0) { force = false; }
|
|
14191
|
+
if (!node.isConnected)
|
|
14192
|
+
return;
|
|
14193
|
+
var rBushNode = node.rBushNode;
|
|
14194
|
+
// clear dirty node
|
|
14195
|
+
if (rBushNode.aabb)
|
|
14196
|
+
this.rBush.remove(rBushNode.aabb);
|
|
14197
|
+
var renderBounds = node.getRenderBounds();
|
|
14198
|
+
if (renderBounds) {
|
|
14199
|
+
var renderable = node.renderable;
|
|
14200
|
+
if (force) {
|
|
14201
|
+
if (!renderable.dirtyRenderBounds) {
|
|
14202
|
+
renderable.dirtyRenderBounds = new AABB();
|
|
14203
|
+
}
|
|
14204
|
+
// save last dirty aabb
|
|
14205
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14206
|
+
}
|
|
14207
|
+
var _a = tslib.__read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14208
|
+
var _b = tslib.__read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14209
|
+
if (!rBushNode.aabb) {
|
|
14210
|
+
rBushNode.aabb = {};
|
|
14211
|
+
}
|
|
14212
|
+
rBushNode.aabb.displayObject = node;
|
|
14213
|
+
rBushNode.aabb.minX = minX;
|
|
14214
|
+
rBushNode.aabb.minY = minY;
|
|
14215
|
+
rBushNode.aabb.maxX = maxX;
|
|
14216
|
+
rBushNode.aabb.maxY = maxY;
|
|
14217
|
+
}
|
|
14218
|
+
if (rBushNode.aabb) {
|
|
14219
|
+
// TODO: NaN occurs when width/height of Rect is 0
|
|
14220
|
+
if (!isNaN(rBushNode.aabb.maxX) &&
|
|
14221
|
+
!isNaN(rBushNode.aabb.maxX) &&
|
|
14222
|
+
!isNaN(rBushNode.aabb.minX) &&
|
|
14223
|
+
!isNaN(rBushNode.aabb.minY)) {
|
|
14224
|
+
return rBushNode.aabb;
|
|
14225
|
+
}
|
|
14226
|
+
}
|
|
14227
|
+
};
|
|
14906
14228
|
PrepareRendererPlugin.prototype.syncRTree = function (force) {
|
|
14907
14229
|
var _this = this;
|
|
14908
14230
|
if (force === void 0) { force = false; }
|
|
14909
|
-
if (!force && (this.syncing || this.
|
|
14231
|
+
if (!force && (this.syncing || this.syncTasks.size === 0)) {
|
|
14910
14232
|
return;
|
|
14911
14233
|
}
|
|
14912
14234
|
this.syncing = true;
|
|
14913
14235
|
// bounds changed, need re-inserting its children
|
|
14914
14236
|
var bulk = [];
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
.
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
_this.rBush.remove(rBushNode.aabb);
|
|
14923
|
-
}
|
|
14924
|
-
var renderBounds = node.getRenderBounds();
|
|
14925
|
-
if (renderBounds) {
|
|
14926
|
-
var renderable = node.renderable;
|
|
14927
|
-
if (force) {
|
|
14928
|
-
if (!renderable.dirtyRenderBounds) {
|
|
14929
|
-
renderable.dirtyRenderBounds = new AABB();
|
|
14930
|
-
}
|
|
14931
|
-
// save last dirty aabb
|
|
14932
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14933
|
-
}
|
|
14934
|
-
var _a = tslib.__read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14935
|
-
var _b = tslib.__read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14936
|
-
if (!rBushNode.aabb) {
|
|
14937
|
-
rBushNode.aabb = {};
|
|
14237
|
+
var synced = new Set();
|
|
14238
|
+
var sync = function (node) {
|
|
14239
|
+
if (!synced.has(node) && node.renderable) {
|
|
14240
|
+
var aabb = _this.syncNode(node, force);
|
|
14241
|
+
if (aabb) {
|
|
14242
|
+
bulk.push(aabb);
|
|
14243
|
+
synced.add(node);
|
|
14938
14244
|
}
|
|
14939
|
-
rBushNode.aabb.displayObject = node;
|
|
14940
|
-
rBushNode.aabb.minX = minX;
|
|
14941
|
-
rBushNode.aabb.minY = minY;
|
|
14942
|
-
rBushNode.aabb.maxX = maxX;
|
|
14943
|
-
rBushNode.aabb.maxY = maxY;
|
|
14944
14245
|
}
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14246
|
+
};
|
|
14247
|
+
this.syncTasks.forEach(function (affectChildren, node) {
|
|
14248
|
+
if (affectChildren) {
|
|
14249
|
+
node.forEach(sync);
|
|
14250
|
+
}
|
|
14251
|
+
var parent = node;
|
|
14252
|
+
while (parent) {
|
|
14253
|
+
sync(parent);
|
|
14254
|
+
parent = parent.parentElement;
|
|
14953
14255
|
}
|
|
14954
14256
|
});
|
|
14955
14257
|
// use bulk inserting, which is ~2-3 times faster
|
|
14956
14258
|
// @see https://github.com/mourner/rbush#bulk-inserting-data
|
|
14957
14259
|
this.rBush.load(bulk);
|
|
14958
14260
|
bulk.length = 0;
|
|
14959
|
-
this.toSync.clear();
|
|
14960
14261
|
this.syncing = false;
|
|
14961
14262
|
};
|
|
14962
14263
|
PrepareRendererPlugin.tag = 'Prepare';
|
|
@@ -15012,9 +14313,9 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15012
14313
|
_this.document.defaultView = _this;
|
|
15013
14314
|
// create registry of custom elements
|
|
15014
14315
|
_this.customElements = new CustomElementRegistry();
|
|
15015
|
-
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;
|
|
14316
|
+
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;
|
|
15016
14317
|
if (!supportsMutipleCanvasesInOneContainer) {
|
|
15017
|
-
cleanExistedCanvas(container, _this);
|
|
14318
|
+
cleanExistedCanvas(container, _this, cleanUpOnDestroy);
|
|
15018
14319
|
}
|
|
15019
14320
|
var canvasWidth = width;
|
|
15020
14321
|
var canvasHeight = height;
|
|
@@ -15075,6 +14376,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15075
14376
|
document: document,
|
|
15076
14377
|
supportsCSSTransform: supportsCSSTransform,
|
|
15077
14378
|
useNativeClickEvent: useNativeClickEvent,
|
|
14379
|
+
cleanUpOnDestroy: cleanUpOnDestroy,
|
|
15078
14380
|
alwaysTriggerPointerEventOnCanvas: alwaysTriggerPointerEventOnCanvas,
|
|
15079
14381
|
});
|
|
15080
14382
|
_this.initDefaultCamera(canvasWidth, canvasHeight, renderer.clipSpaceNearZ);
|
|
@@ -15185,7 +14487,8 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15185
14487
|
*/
|
|
15186
14488
|
Canvas.prototype.destroy = function (cleanUp, skipTriggerEvent) {
|
|
15187
14489
|
if (cleanUp === void 0) { cleanUp = true; }
|
|
15188
|
-
if (skipTriggerEvent ===
|
|
14490
|
+
if (skipTriggerEvent === undefined)
|
|
14491
|
+
skipTriggerEvent = this.getConfig().fastCleanExistingCanvas;
|
|
15189
14492
|
if (!skipTriggerEvent) {
|
|
15190
14493
|
this.dispatchEvent(new CustomEvent(exports.CanvasEvent.BEFORE_DESTROY));
|
|
15191
14494
|
}
|
|
@@ -15214,6 +14517,17 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15214
14517
|
if (!skipTriggerEvent) {
|
|
15215
14518
|
this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));
|
|
15216
14519
|
}
|
|
14520
|
+
var clearEventRetain = function (event) {
|
|
14521
|
+
event.currentTarget = null;
|
|
14522
|
+
event.manager = null;
|
|
14523
|
+
event.target = null;
|
|
14524
|
+
};
|
|
14525
|
+
clearEventRetain(mountedEvent);
|
|
14526
|
+
clearEventRetain(unmountedEvent);
|
|
14527
|
+
clearEventRetain(beforeRenderEvent);
|
|
14528
|
+
clearEventRetain(rerenderEvent);
|
|
14529
|
+
clearEventRetain(afterRenderEvent);
|
|
14530
|
+
this.cancelAnimationFrame(this.frameId);
|
|
15217
14531
|
};
|
|
15218
14532
|
/**
|
|
15219
14533
|
* compatible with G 3.0
|
|
@@ -15421,35 +14735,41 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15421
14735
|
}
|
|
15422
14736
|
}
|
|
15423
14737
|
};
|
|
15424
|
-
Canvas.prototype.mountChildren = function (
|
|
14738
|
+
Canvas.prototype.mountChildren = function (child, skipTriggerEvent) {
|
|
15425
14739
|
var _this = this;
|
|
14740
|
+
if (skipTriggerEvent === void 0) { skipTriggerEvent = isInFragment(child); }
|
|
15426
14741
|
if (this.inited) {
|
|
15427
|
-
if (!
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
if (
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
14742
|
+
if (!child.isConnected) {
|
|
14743
|
+
child.ownerDocument = this.document;
|
|
14744
|
+
child.isConnected = true;
|
|
14745
|
+
if (!skipTriggerEvent) {
|
|
14746
|
+
if (child.isMutationObserved) {
|
|
14747
|
+
child.dispatchEvent(mountedEvent);
|
|
14748
|
+
}
|
|
14749
|
+
else {
|
|
14750
|
+
mountedEvent.target = child;
|
|
14751
|
+
this.dispatchEvent(mountedEvent, true);
|
|
14752
|
+
}
|
|
15436
14753
|
}
|
|
15437
14754
|
}
|
|
15438
14755
|
}
|
|
15439
14756
|
else {
|
|
15440
|
-
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: ',
|
|
14757
|
+
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);
|
|
15441
14758
|
}
|
|
15442
14759
|
// recursively mount children
|
|
15443
|
-
|
|
15444
|
-
_this.mountChildren(
|
|
14760
|
+
child.childNodes.forEach(function (c) {
|
|
14761
|
+
_this.mountChildren(c, skipTriggerEvent);
|
|
15445
14762
|
});
|
|
15446
14763
|
// trigger after mounted
|
|
15447
|
-
if (
|
|
15448
|
-
if (
|
|
15449
|
-
|
|
14764
|
+
if (child.isCustomElement) {
|
|
14765
|
+
if (child.connectedCallback) {
|
|
14766
|
+
child.connectedCallback();
|
|
15450
14767
|
}
|
|
15451
14768
|
}
|
|
15452
14769
|
};
|
|
14770
|
+
Canvas.prototype.mountFragment = function (child) {
|
|
14771
|
+
this.mountChildren(child, false);
|
|
14772
|
+
};
|
|
15453
14773
|
Canvas.prototype.client2Viewport = function (client) {
|
|
15454
14774
|
return this.getEventService().client2Viewport(client);
|
|
15455
14775
|
};
|
|
@@ -15511,6 +14831,7 @@ exports.FederatedEvent = FederatedEvent;
|
|
|
15511
14831
|
exports.FederatedMouseEvent = FederatedMouseEvent;
|
|
15512
14832
|
exports.FederatedPointerEvent = FederatedPointerEvent;
|
|
15513
14833
|
exports.FederatedWheelEvent = FederatedWheelEvent;
|
|
14834
|
+
exports.Fragment = Fragment;
|
|
15514
14835
|
exports.Frustum = Frustum;
|
|
15515
14836
|
exports.Group = Group;
|
|
15516
14837
|
exports.GroupUpdater = GroupUpdater;
|