poly-extrude 0.9.0 → 0.10.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/poly-extrude.js +1856 -2219
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -4
- package/dist/poly-extrude.mjs +1856 -2219
- package/package.json +1 -1
- package/src/math/Quaternion.js +7 -7
- package/src/path.js +11 -14
- package/src/tube.js +3 -7
- package/src/util.js +13 -0
package/dist/poly-extrude.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.10.0
|
3
3
|
*/
|
4
4
|
var earcut$2 = {exports: {}};
|
5
5
|
|
@@ -664,2507 +664,2154 @@ earcut.flatten = function (data) {
|
|
664
664
|
|
665
665
|
var earcut$1 = earcut$2.exports;
|
666
666
|
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
var i = 1;
|
675
|
-
var prev;
|
676
|
-
var cur;
|
677
|
-
var len = ring.length;
|
678
|
-
|
679
|
-
while (i < len) {
|
680
|
-
prev = cur || ring[0];
|
681
|
-
cur = ring[i];
|
682
|
-
sum += (cur[0] - prev[0]) * (cur[1] + prev[1]);
|
683
|
-
i++;
|
667
|
+
function _defineProperties(target, props) {
|
668
|
+
for (var i = 0; i < props.length; i++) {
|
669
|
+
var descriptor = props[i];
|
670
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
671
|
+
descriptor.configurable = true;
|
672
|
+
if ("value" in descriptor) descriptor.writable = true;
|
673
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
684
674
|
}
|
685
|
-
|
686
|
-
return sum > 0;
|
687
675
|
}
|
688
676
|
|
689
|
-
function
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
677
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
678
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
679
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
680
|
+
Object.defineProperty(Constructor, "prototype", {
|
681
|
+
writable: false
|
682
|
+
});
|
683
|
+
return Constructor;
|
694
684
|
}
|
695
685
|
|
696
|
-
function
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
out[0] = x / d;
|
702
|
-
out[1] = y / d;
|
703
|
-
out[2] = z / d;
|
704
|
-
return out;
|
686
|
+
function _inheritsLoose(subClass, superClass) {
|
687
|
+
subClass.prototype = Object.create(superClass.prototype);
|
688
|
+
subClass.prototype.constructor = subClass;
|
689
|
+
|
690
|
+
_setPrototypeOf(subClass, superClass);
|
705
691
|
}
|
706
692
|
|
707
|
-
function
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
bz = v2[2];
|
714
|
-
out[0] = ay * bz - az * by;
|
715
|
-
out[1] = az * bx - ax * bz;
|
716
|
-
out[2] = ax * by - ay * bx;
|
717
|
-
return out;
|
693
|
+
function _setPrototypeOf(o, p) {
|
694
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
695
|
+
o.__proto__ = p;
|
696
|
+
return o;
|
697
|
+
};
|
698
|
+
return _setPrototypeOf(o, p);
|
718
699
|
}
|
719
700
|
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
701
|
+
// code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js
|
702
|
+
// import { clamp } from './MathUtils.js';
|
703
|
+
var Quaternion = /*#__PURE__*/function () {
|
704
|
+
function Quaternion(x, y, z, w) {
|
705
|
+
if (x === void 0) {
|
706
|
+
x = 0;
|
707
|
+
}
|
726
708
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
var v21 = [];
|
731
|
-
var v32 = [];
|
732
|
-
var n = [];
|
733
|
-
var len = indices.length;
|
734
|
-
var normals = new Float32Array(position.length);
|
735
|
-
var f = 0;
|
709
|
+
if (y === void 0) {
|
710
|
+
y = 0;
|
711
|
+
}
|
736
712
|
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
// const i3 = indices[f++] * 3;
|
741
|
-
// const i1 = indices[f];
|
742
|
-
// const i2 = indices[f + 1];
|
743
|
-
// const i3 = indices[f + 2];
|
744
|
-
var a = indices[f],
|
745
|
-
b = indices[f + 1],
|
746
|
-
c = indices[f + 2];
|
747
|
-
var i1 = a * 3,
|
748
|
-
i2 = b * 3,
|
749
|
-
i3 = c * 3;
|
750
|
-
v3Set(p1, position[i1], position[i1 + 1], position[i1 + 2]);
|
751
|
-
v3Set(p2, position[i2], position[i2 + 1], position[i2 + 2]);
|
752
|
-
v3Set(p3, position[i3], position[i3 + 1], position[i3 + 2]);
|
753
|
-
v3Sub(v32, p3, p2);
|
754
|
-
v3Sub(v21, p1, p2);
|
755
|
-
v3Cross(n, v32, v21); // Already be weighted by the triangle area
|
713
|
+
if (z === void 0) {
|
714
|
+
z = 0;
|
715
|
+
}
|
756
716
|
|
757
|
-
|
758
|
-
|
759
|
-
normals[i2 + _i] += n[_i];
|
760
|
-
normals[i3 + _i] += n[_i];
|
717
|
+
if (w === void 0) {
|
718
|
+
w = 1;
|
761
719
|
}
|
762
720
|
|
763
|
-
|
721
|
+
this.isQuaternion = true;
|
722
|
+
this._x = x;
|
723
|
+
this._y = y;
|
724
|
+
this._z = z;
|
725
|
+
this._w = w;
|
764
726
|
}
|
765
727
|
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
}
|
728
|
+
Quaternion.slerpFlat = function slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
|
729
|
+
// fuzz-free, array-based Quaternion SLERP operation
|
730
|
+
var x0 = src0[srcOffset0 + 0],
|
731
|
+
y0 = src0[srcOffset0 + 1],
|
732
|
+
z0 = src0[srcOffset0 + 2],
|
733
|
+
w0 = src0[srcOffset0 + 3];
|
734
|
+
var x1 = src1[srcOffset1 + 0],
|
735
|
+
y1 = src1[srcOffset1 + 1],
|
736
|
+
z1 = src1[srcOffset1 + 2],
|
737
|
+
w1 = src1[srcOffset1 + 3];
|
777
738
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
uv: results[0].uv,
|
786
|
-
indices: results[0].indices,
|
787
|
-
results: results
|
788
|
-
};
|
789
|
-
return _result;
|
790
|
-
}
|
739
|
+
if (t === 0) {
|
740
|
+
dst[dstOffset + 0] = x0;
|
741
|
+
dst[dstOffset + 1] = y0;
|
742
|
+
dst[dstOffset + 2] = z0;
|
743
|
+
dst[dstOffset + 3] = w0;
|
744
|
+
return;
|
745
|
+
}
|
791
746
|
|
792
|
-
|
793
|
-
|
747
|
+
if (t === 1) {
|
748
|
+
dst[dstOffset + 0] = x1;
|
749
|
+
dst[dstOffset + 1] = y1;
|
750
|
+
dst[dstOffset + 2] = z1;
|
751
|
+
dst[dstOffset + 3] = w1;
|
752
|
+
return;
|
753
|
+
}
|
794
754
|
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
ilen += indices.length;
|
801
|
-
}
|
755
|
+
if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
|
756
|
+
var s = 1 - t;
|
757
|
+
var cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
|
758
|
+
dir = cos >= 0 ? 1 : -1,
|
759
|
+
sqrSin = 1 - cos * cos; // Skip the Slerp for tiny steps to avoid numeric problems:
|
802
760
|
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
};
|
810
|
-
var pOffset = 0,
|
811
|
-
pCount = 0,
|
812
|
-
iIdx = 0,
|
813
|
-
uvOffset = 0;
|
761
|
+
if (sqrSin > Number.EPSILON) {
|
762
|
+
var sin = Math.sqrt(sqrSin),
|
763
|
+
len = Math.atan2(sin, cos * dir);
|
764
|
+
s = Math.sin(s * len) / sin;
|
765
|
+
t = Math.sin(t * len) / sin;
|
766
|
+
}
|
814
767
|
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
uv = _results$_i.uv;
|
821
|
-
result.position.set(_position, pOffset);
|
822
|
-
result.normal.set(normal, pOffset);
|
823
|
-
result.uv.set(uv, uvOffset);
|
824
|
-
var j = 0;
|
825
|
-
var len1 = _indices.length;
|
768
|
+
var tDir = t * dir;
|
769
|
+
x0 = x0 * s + x1 * tDir;
|
770
|
+
y0 = y0 * s + y1 * tDir;
|
771
|
+
z0 = z0 * s + z1 * tDir;
|
772
|
+
w0 = w0 * s + w1 * tDir; // Normalize in case we just did a lerp:
|
826
773
|
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
774
|
+
if (s === 1 - t) {
|
775
|
+
var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
|
776
|
+
x0 *= f;
|
777
|
+
y0 *= f;
|
778
|
+
z0 *= f;
|
779
|
+
w0 *= f;
|
780
|
+
}
|
832
781
|
}
|
833
782
|
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
return result;
|
840
|
-
}
|
841
|
-
function radToDeg(rad) {
|
842
|
-
return rad * 180 / Math.PI;
|
843
|
-
}
|
844
|
-
function degToRad(angle) {
|
845
|
-
return angle / 180 * Math.PI;
|
846
|
-
} // https://github.com/mrdoob/three.js/blob/16f13e3b07e31d0e9a00df7c3366bbe0e464588c/src/geometries/ExtrudeGeometry.js?_pjax=%23js-repo-pjax-container#L736
|
783
|
+
dst[dstOffset] = x0;
|
784
|
+
dst[dstOffset + 1] = y0;
|
785
|
+
dst[dstOffset + 2] = z0;
|
786
|
+
dst[dstOffset + 3] = w0;
|
787
|
+
};
|
847
788
|
|
848
|
-
function
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
var d_y = vertices[idx4 + 1];
|
864
|
-
var d_z = vertices[idx4 + 2];
|
865
|
-
var uIndex = uvs.length - 1;
|
866
|
-
|
867
|
-
if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {
|
868
|
-
uvs[++uIndex] = a_x;
|
869
|
-
uvs[++uIndex] = 1 - a_z;
|
870
|
-
uvs[++uIndex] = b_x;
|
871
|
-
uvs[++uIndex] = 1 - b_z;
|
872
|
-
uvs[++uIndex] = c_x;
|
873
|
-
uvs[++uIndex] = 1 - c_z;
|
874
|
-
uvs[++uIndex] = d_x;
|
875
|
-
uvs[++uIndex] = 1 - d_z; // uvs.push(a_x, 1 - a_z);
|
876
|
-
// uvs.push(b_x, 1 - b_z);
|
877
|
-
// uvs.push(c_x, 1 - c_z);
|
878
|
-
// uvs.push(d_x, 1 - d_z);
|
879
|
-
} else {
|
880
|
-
uvs[++uIndex] = a_y;
|
881
|
-
uvs[++uIndex] = 1 - a_z;
|
882
|
-
uvs[++uIndex] = b_y;
|
883
|
-
uvs[++uIndex] = 1 - b_z;
|
884
|
-
uvs[++uIndex] = c_y;
|
885
|
-
uvs[++uIndex] = 1 - c_z;
|
886
|
-
uvs[++uIndex] = d_y;
|
887
|
-
uvs[++uIndex] = 1 - d_z; // uvs.push(a_y, 1 - a_z);
|
888
|
-
// uvs.push(b_y, 1 - b_z);
|
889
|
-
// uvs.push(c_y, 1 - c_z);
|
890
|
-
// uvs.push(d_y, 1 - d_z);
|
891
|
-
}
|
892
|
-
}
|
789
|
+
Quaternion.multiplyQuaternionsFlat = function multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
|
790
|
+
var x0 = src0[srcOffset0];
|
791
|
+
var y0 = src0[srcOffset0 + 1];
|
792
|
+
var z0 = src0[srcOffset0 + 2];
|
793
|
+
var w0 = src0[srcOffset0 + 3];
|
794
|
+
var x1 = src1[srcOffset1];
|
795
|
+
var y1 = src1[srcOffset1 + 1];
|
796
|
+
var z1 = src1[srcOffset1 + 2];
|
797
|
+
var w1 = src1[srcOffset1 + 3];
|
798
|
+
dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
|
799
|
+
dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
|
800
|
+
dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
|
801
|
+
dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
|
802
|
+
return dst;
|
803
|
+
};
|
893
804
|
|
894
|
-
|
895
|
-
options = Object.assign({}, {
|
896
|
-
depth: 2
|
897
|
-
}, options);
|
898
|
-
var results = polygons.map(function (polygon) {
|
899
|
-
for (var i = 0, len = polygon.length; i < len; i++) {
|
900
|
-
var ring = polygon[i];
|
901
|
-
validateRing(ring);
|
805
|
+
var _proto = Quaternion.prototype;
|
902
806
|
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
polygon[i] = ring.reverse();
|
909
|
-
}
|
807
|
+
_proto.set = function set(x, y, z, w) {
|
808
|
+
this._x = x;
|
809
|
+
this._y = y;
|
810
|
+
this._z = z;
|
811
|
+
this._w = w;
|
910
812
|
|
911
|
-
|
912
|
-
ring.splice(ring.length - 1, 1);
|
913
|
-
}
|
914
|
-
}
|
813
|
+
this._onChangeCallback();
|
915
814
|
|
916
|
-
|
917
|
-
|
918
|
-
var triangles = earcut$1(result.flatVertices, result.holes, 2);
|
919
|
-
generateTopAndBottom$1(result, triangles);
|
920
|
-
generateSides$1(result, options);
|
921
|
-
result.position = new Float32Array(result.points);
|
922
|
-
result.indices = new Uint32Array(result.indices);
|
923
|
-
result.uv = new Float32Array(result.uv);
|
924
|
-
result.normal = generateNormal(result.indices, result.position);
|
925
|
-
return result;
|
926
|
-
});
|
927
|
-
var result = merge(results);
|
928
|
-
result.polygons = polygons;
|
929
|
-
return result;
|
930
|
-
}
|
815
|
+
return this;
|
816
|
+
};
|
931
817
|
|
932
|
-
function
|
933
|
-
|
934
|
-
|
818
|
+
_proto.clone = function clone() {
|
819
|
+
return new this.constructor(this._x, this._y, this._z, this._w);
|
820
|
+
};
|
935
821
|
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
indices[i] = a;
|
942
|
-
indices[i + 1] = b;
|
943
|
-
indices[i + 2] = c; // bottom
|
822
|
+
_proto.copy = function copy(quaternion) {
|
823
|
+
this._x = quaternion.x;
|
824
|
+
this._y = quaternion.y;
|
825
|
+
this._z = quaternion.z;
|
826
|
+
this._w = quaternion.w;
|
944
827
|
|
945
|
-
|
946
|
-
var a1 = count + a,
|
947
|
-
b1 = count + b,
|
948
|
-
c1 = count + c;
|
949
|
-
indices[idx] = a1;
|
950
|
-
indices[idx + 1] = b1;
|
951
|
-
indices[idx + 2] = c1;
|
952
|
-
}
|
828
|
+
this._onChangeCallback();
|
953
829
|
|
954
|
-
|
955
|
-
}
|
830
|
+
return this;
|
831
|
+
};
|
956
832
|
|
957
|
-
function
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
uv = result.uv;
|
962
|
-
var depth = options.depth;
|
963
|
-
var pIndex = points.length - 1;
|
964
|
-
var iIndex = indices.length - 1;
|
833
|
+
_proto.setFromEuler = function setFromEuler(euler, update) {
|
834
|
+
if (update === void 0) {
|
835
|
+
update = true;
|
836
|
+
}
|
965
837
|
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
838
|
+
var x = euler._x,
|
839
|
+
y = euler._y,
|
840
|
+
z = euler._z,
|
841
|
+
order = euler._order; // http://www.mathworks.com/matlabcentral/fileexchange/
|
842
|
+
// 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
|
843
|
+
// content/SpinCalc.m
|
970
844
|
|
971
|
-
|
972
|
-
|
973
|
-
|
845
|
+
var cos = Math.cos;
|
846
|
+
var sin = Math.sin;
|
847
|
+
var c1 = cos(x / 2);
|
848
|
+
var c2 = cos(y / 2);
|
849
|
+
var c3 = cos(z / 2);
|
850
|
+
var s1 = sin(x / 2);
|
851
|
+
var s2 = sin(y / 2);
|
852
|
+
var s3 = sin(z / 2);
|
974
853
|
|
975
|
-
|
976
|
-
|
977
|
-
|
854
|
+
switch (order) {
|
855
|
+
case 'XYZ':
|
856
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
857
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
858
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
859
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
860
|
+
break;
|
978
861
|
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
z2 = v2[2] || 0;
|
986
|
-
points[++pIndex] = x1;
|
987
|
-
points[++pIndex] = y1;
|
988
|
-
points[++pIndex] = z1 + depth;
|
989
|
-
points[++pIndex] = x2;
|
990
|
-
points[++pIndex] = y2;
|
991
|
-
points[++pIndex] = z2 + depth;
|
992
|
-
points[++pIndex] = x1;
|
993
|
-
points[++pIndex] = y1;
|
994
|
-
points[++pIndex] = z1;
|
995
|
-
points[++pIndex] = x2;
|
996
|
-
points[++pIndex] = y2;
|
997
|
-
points[++pIndex] = z2; // points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
|
862
|
+
case 'YXZ':
|
863
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
864
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
865
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
866
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
867
|
+
break;
|
998
868
|
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
869
|
+
case 'ZXY':
|
870
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
871
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
872
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
873
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
874
|
+
break;
|
1004
875
|
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
876
|
+
case 'ZYX':
|
877
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
878
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
879
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
880
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
881
|
+
break;
|
1011
882
|
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
883
|
+
case 'YZX':
|
884
|
+
this._x = s1 * c2 * c3 + c1 * s2 * s3;
|
885
|
+
this._y = c1 * s2 * c3 + s1 * c2 * s3;
|
886
|
+
this._z = c1 * c2 * s3 - s1 * s2 * c3;
|
887
|
+
this._w = c1 * c2 * c3 - s1 * s2 * s3;
|
888
|
+
break;
|
1017
889
|
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
890
|
+
case 'XZY':
|
891
|
+
this._x = s1 * c2 * c3 - c1 * s2 * s3;
|
892
|
+
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
893
|
+
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
894
|
+
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
895
|
+
break;
|
1022
896
|
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
}
|
897
|
+
default:
|
898
|
+
console.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order);
|
899
|
+
}
|
1027
900
|
|
1028
|
-
|
1029
|
-
|
901
|
+
if (update === true) this._onChangeCallback();
|
902
|
+
return this;
|
903
|
+
};
|
1030
904
|
|
1031
|
-
function
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
var depth = options.depth;
|
1041
|
-
var idx0 = 0,
|
1042
|
-
idx1 = 0,
|
1043
|
-
idx2 = 0;
|
1044
|
-
|
1045
|
-
for (var i = 0; i < len; i++) {
|
1046
|
-
var ring = polygon[i];
|
905
|
+
_proto.setFromAxisAngle = function setFromAxisAngle(axis, angle) {
|
906
|
+
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
|
907
|
+
// assumes axis is normalized
|
908
|
+
var halfAngle = angle / 2,
|
909
|
+
s = Math.sin(halfAngle);
|
910
|
+
this._x = axis.x * s;
|
911
|
+
this._y = axis.y * s;
|
912
|
+
this._z = axis.z * s;
|
913
|
+
this._w = Math.cos(halfAngle);
|
1047
914
|
|
1048
|
-
|
1049
|
-
holes.push(idx0 / 2);
|
1050
|
-
}
|
915
|
+
this._onChangeCallback();
|
1051
916
|
|
1052
|
-
|
1053
|
-
|
917
|
+
return this;
|
918
|
+
};
|
1054
919
|
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
920
|
+
_proto.setFromRotationMatrix = function setFromRotationMatrix(m) {
|
921
|
+
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
|
922
|
+
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
923
|
+
var te = m.elements,
|
924
|
+
m11 = te[0],
|
925
|
+
m12 = te[4],
|
926
|
+
m13 = te[8],
|
927
|
+
m21 = te[1],
|
928
|
+
m22 = te[5],
|
929
|
+
m23 = te[9],
|
930
|
+
m31 = te[2],
|
931
|
+
m32 = te[6],
|
932
|
+
m33 = te[10],
|
933
|
+
trace = m11 + m22 + m33;
|
1062
934
|
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
935
|
+
if (trace > 0) {
|
936
|
+
var s = 0.5 / Math.sqrt(trace + 1.0);
|
937
|
+
this._w = 0.25 / s;
|
938
|
+
this._x = (m32 - m23) * s;
|
939
|
+
this._y = (m13 - m31) * s;
|
940
|
+
this._z = (m21 - m12) * s;
|
941
|
+
} else if (m11 > m22 && m11 > m33) {
|
942
|
+
var _s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
|
1066
943
|
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
uv[uOffset + idx2 + 1] = y;
|
1074
|
-
idx1 += 3;
|
1075
|
-
idx2 += 2;
|
1076
|
-
j++;
|
1077
|
-
}
|
1078
|
-
}
|
944
|
+
this._w = (m32 - m23) / _s;
|
945
|
+
this._x = 0.25 * _s;
|
946
|
+
this._y = (m12 + m21) / _s;
|
947
|
+
this._z = (m13 + m31) / _s;
|
948
|
+
} else if (m22 > m33) {
|
949
|
+
var _s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
|
1079
950
|
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
};
|
1087
|
-
}
|
951
|
+
this._w = (m13 - m31) / _s2;
|
952
|
+
this._x = (m12 + m21) / _s2;
|
953
|
+
this._y = 0.25 * _s2;
|
954
|
+
this._z = (m23 + m32) / _s2;
|
955
|
+
} else {
|
956
|
+
var _s3 = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
|
1088
957
|
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
}
|
958
|
+
this._w = (m21 - m12) / _s3;
|
959
|
+
this._x = (m13 + m31) / _s3;
|
960
|
+
this._y = (m23 + m32) / _s3;
|
961
|
+
this._z = 0.25 * _s3;
|
962
|
+
}
|
1094
963
|
|
1095
|
-
|
1096
|
-
var len = ring.length;
|
1097
|
-
var _ring$ = ring[0],
|
1098
|
-
x1 = _ring$[0],
|
1099
|
-
y1 = _ring$[1],
|
1100
|
-
_ring = ring[len - 1],
|
1101
|
-
x2 = _ring[0],
|
1102
|
-
y2 = _ring[1];
|
1103
|
-
return x1 === x2 && y1 === y2;
|
1104
|
-
}
|
964
|
+
this._onChangeCallback();
|
1105
965
|
|
1106
|
-
|
1107
|
-
|
1108
|
-
options.depth = Math.max(0, options.depth);
|
1109
|
-
options.sideDepth = Math.max(0, options.sideDepth);
|
1110
|
-
}
|
966
|
+
return this;
|
967
|
+
};
|
1111
968
|
|
1112
|
-
function
|
1113
|
-
|
1114
|
-
|
1115
|
-
lineWidth: 1,
|
1116
|
-
bottomStickGround: false
|
1117
|
-
}, options);
|
1118
|
-
checkOptions(options);
|
1119
|
-
var results = lines.map(function (line) {
|
1120
|
-
var result = expandLine(line, options);
|
1121
|
-
result.line = line;
|
1122
|
-
generateTopAndBottom(result, options);
|
1123
|
-
generateSides(result, options);
|
1124
|
-
result.position = new Float32Array(result.points);
|
1125
|
-
result.indices = new Uint32Array(result.indices);
|
1126
|
-
result.uv = new Float32Array(result.uv);
|
1127
|
-
result.normal = generateNormal(result.indices, result.position);
|
1128
|
-
return result;
|
1129
|
-
});
|
1130
|
-
var result = merge(results);
|
1131
|
-
result.lines = lines;
|
1132
|
-
return result;
|
1133
|
-
}
|
1134
|
-
function extrudeSlopes(lines, options) {
|
1135
|
-
options = Object.assign({}, {
|
1136
|
-
depth: 2,
|
1137
|
-
lineWidth: 1,
|
1138
|
-
side: 'left',
|
1139
|
-
sideDepth: 0,
|
1140
|
-
bottomStickGround: false
|
1141
|
-
}, options);
|
1142
|
-
checkOptions(options);
|
1143
|
-
var _options = options,
|
1144
|
-
depth = _options.depth,
|
1145
|
-
side = _options.side,
|
1146
|
-
sideDepth = _options.sideDepth;
|
1147
|
-
var results = lines.map(function (line) {
|
1148
|
-
var tempResult = expandLine(line, options);
|
1149
|
-
tempResult.line = line;
|
1150
|
-
var leftPoints = tempResult.leftPoints,
|
1151
|
-
rightPoints = tempResult.rightPoints;
|
1152
|
-
var result = {
|
1153
|
-
line: line
|
1154
|
-
};
|
1155
|
-
var depths;
|
969
|
+
_proto.setFromUnitVectors = function setFromUnitVectors(vFrom, vTo) {
|
970
|
+
// assumes direction vectors vFrom and vTo are normalized
|
971
|
+
var r = vFrom.dot(vTo) + 1;
|
1156
972
|
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
973
|
+
if (r < Number.EPSILON) {
|
974
|
+
// vFrom and vTo point in opposite directions
|
975
|
+
r = 0;
|
1160
976
|
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
977
|
+
if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
|
978
|
+
this._x = -vFrom.y;
|
979
|
+
this._y = vFrom.x;
|
980
|
+
this._z = 0;
|
981
|
+
this._w = r;
|
982
|
+
} else {
|
983
|
+
this._x = 0;
|
984
|
+
this._y = -vFrom.z;
|
985
|
+
this._z = vFrom.y;
|
986
|
+
this._w = r;
|
987
|
+
}
|
1165
988
|
} else {
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
989
|
+
// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
|
990
|
+
this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
|
991
|
+
this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
|
992
|
+
this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
|
993
|
+
this._w = r;
|
1169
994
|
}
|
1170
995
|
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
result.uv = new Float32Array(result.uv);
|
1177
|
-
result.normal = generateNormal(result.indices, result.position);
|
1178
|
-
return result;
|
1179
|
-
});
|
1180
|
-
var result = merge(results);
|
1181
|
-
result.lines = lines;
|
1182
|
-
return result;
|
1183
|
-
}
|
996
|
+
return this.normalize();
|
997
|
+
} // angleTo(q) {
|
998
|
+
// return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
|
999
|
+
// }
|
1000
|
+
;
|
1184
1001
|
|
1185
|
-
function
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1002
|
+
_proto.rotateTowards = function rotateTowards(q, step) {
|
1003
|
+
var angle = this.angleTo(q);
|
1004
|
+
if (angle === 0) return this;
|
1005
|
+
var t = Math.min(1, step / angle);
|
1006
|
+
this.slerp(q, t);
|
1007
|
+
return this;
|
1008
|
+
};
|
1191
1009
|
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
}
|
1010
|
+
_proto.identity = function identity() {
|
1011
|
+
return this.set(0, 0, 0, 1);
|
1012
|
+
};
|
1196
1013
|
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
rightPoints = result.rightPoints;
|
1202
|
-
var i = 0,
|
1203
|
-
len = leftPoints.length;
|
1014
|
+
_proto.invert = function invert() {
|
1015
|
+
// quaternion is assumed to have unit length
|
1016
|
+
return this.conjugate();
|
1017
|
+
};
|
1204
1018
|
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
x1 = _leftPoints$i[0],
|
1210
|
-
y1 = _leftPoints$i[1],
|
1211
|
-
z1 = _leftPoints$i[2];
|
1212
|
-
points[idx0] = x1;
|
1213
|
-
points[idx0 + 1] = y1;
|
1214
|
-
points[idx0 + 2] = lz + z1; // top right
|
1019
|
+
_proto.conjugate = function conjugate() {
|
1020
|
+
this._x *= -1;
|
1021
|
+
this._y *= -1;
|
1022
|
+
this._z *= -1;
|
1215
1023
|
|
1216
|
-
|
1217
|
-
x2 = _rightPoints$i[0],
|
1218
|
-
y2 = _rightPoints$i[1],
|
1219
|
-
z2 = _rightPoints$i[2];
|
1220
|
-
var idx1 = len * 3 + idx0;
|
1221
|
-
points[idx1] = x2;
|
1222
|
-
points[idx1 + 1] = y2;
|
1223
|
-
points[idx1 + 2] = rz + z2; // bottom left
|
1024
|
+
this._onChangeCallback();
|
1224
1025
|
|
1225
|
-
|
1226
|
-
|
1227
|
-
points[idx2 + 1] = y1;
|
1228
|
-
points[idx2 + 2] = z1;
|
1026
|
+
return this;
|
1027
|
+
};
|
1229
1028
|
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1029
|
+
_proto.dot = function dot(v) {
|
1030
|
+
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
|
1031
|
+
};
|
1233
1032
|
|
1033
|
+
_proto.lengthSq = function lengthSq() {
|
1034
|
+
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
|
1035
|
+
};
|
1234
1036
|
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
points[idx3 + 2] = z2;
|
1037
|
+
_proto.length = function length() {
|
1038
|
+
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
1039
|
+
};
|
1239
1040
|
|
1240
|
-
|
1241
|
-
|
1041
|
+
_proto.normalize = function normalize() {
|
1042
|
+
var l = this.length();
|
1043
|
+
|
1044
|
+
if (l === 0) {
|
1045
|
+
this._x = 0;
|
1046
|
+
this._y = 0;
|
1047
|
+
this._z = 0;
|
1048
|
+
this._w = 1;
|
1049
|
+
} else {
|
1050
|
+
l = 1 / l;
|
1051
|
+
this._x = this._x * l;
|
1052
|
+
this._y = this._y * l;
|
1053
|
+
this._z = this._z * l;
|
1054
|
+
this._w = this._w * l;
|
1242
1055
|
}
|
1243
1056
|
|
1244
|
-
|
1245
|
-
}
|
1057
|
+
this._onChangeCallback();
|
1246
1058
|
|
1247
|
-
|
1248
|
-
|
1249
|
-
var uIndex = uv.length - 1;
|
1059
|
+
return this;
|
1060
|
+
};
|
1250
1061
|
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
uv[++uIndex] = x;
|
1255
|
-
uv[++uIndex] = y; // uvs.push(x, y);
|
1062
|
+
_proto.multiply = function multiply(q) {
|
1063
|
+
return this.multiplyQuaternions(this, q);
|
1064
|
+
};
|
1256
1065
|
|
1257
|
-
|
1258
|
-
|
1066
|
+
_proto.premultiply = function premultiply(q) {
|
1067
|
+
return this.multiplyQuaternions(q, this);
|
1068
|
+
};
|
1259
1069
|
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1070
|
+
_proto.multiplyQuaternions = function multiplyQuaternions(a, b) {
|
1071
|
+
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
1072
|
+
var qax = a._x,
|
1073
|
+
qay = a._y,
|
1074
|
+
qaz = a._z,
|
1075
|
+
qaw = a._w;
|
1076
|
+
var qbx = b._x,
|
1077
|
+
qby = b._y,
|
1078
|
+
qbz = b._z,
|
1079
|
+
qbw = b._w;
|
1080
|
+
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
|
1081
|
+
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
|
1082
|
+
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
|
1083
|
+
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
|
1263
1084
|
|
1264
|
-
|
1265
|
-
// top
|
1266
|
-
// left1 left2 right1,right2
|
1267
|
-
var a1 = i,
|
1268
|
-
b1 = i + 1,
|
1269
|
-
c1 = a1 + len,
|
1270
|
-
d1 = b1 + len;
|
1271
|
-
indices[++iIndex] = a1;
|
1272
|
-
indices[++iIndex] = c1;
|
1273
|
-
indices[++iIndex] = b1;
|
1274
|
-
indices[++iIndex] = c1;
|
1275
|
-
indices[++iIndex] = d1;
|
1276
|
-
indices[++iIndex] = b1; // index.push(a1, c1, b1);
|
1277
|
-
// index.push(c1, d1, b1);
|
1278
|
-
// bottom
|
1279
|
-
// left1 left2 right1,right2
|
1085
|
+
this._onChangeCallback();
|
1280
1086
|
|
1281
|
-
|
1282
|
-
|
1283
|
-
b2 = a2 + 1,
|
1284
|
-
c2 = a2 + len,
|
1285
|
-
d2 = b2 + len;
|
1286
|
-
indices[++iIndex] = a2;
|
1287
|
-
indices[++iIndex] = c2;
|
1288
|
-
indices[++iIndex] = b2;
|
1289
|
-
indices[++iIndex] = c2;
|
1290
|
-
indices[++iIndex] = d2;
|
1291
|
-
indices[++iIndex] = b2; // index.push(a2, c2, b2);
|
1292
|
-
// index.push(c2, d2, b2);
|
1087
|
+
return this;
|
1088
|
+
};
|
1293
1089
|
|
1294
|
-
|
1295
|
-
|
1090
|
+
_proto.slerp = function slerp(qb, t) {
|
1091
|
+
if (t === 0) return this;
|
1092
|
+
if (t === 1) return this.copy(qb);
|
1093
|
+
var x = this._x,
|
1094
|
+
y = this._y,
|
1095
|
+
z = this._z,
|
1096
|
+
w = this._w; // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
|
1296
1097
|
|
1297
|
-
|
1298
|
-
result.points = points;
|
1299
|
-
result.uv = uv;
|
1098
|
+
var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
|
1300
1099
|
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1100
|
+
if (cosHalfTheta < 0) {
|
1101
|
+
this._w = -qb._w;
|
1102
|
+
this._x = -qb._x;
|
1103
|
+
this._y = -qb._y;
|
1104
|
+
this._z = -qb._z;
|
1105
|
+
cosHalfTheta = -cosHalfTheta;
|
1106
|
+
} else {
|
1107
|
+
this.copy(qb);
|
1108
|
+
}
|
1304
1109
|
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1110
|
+
if (cosHalfTheta >= 1.0) {
|
1111
|
+
this._w = w;
|
1112
|
+
this._x = x;
|
1113
|
+
this._y = y;
|
1114
|
+
this._z = z;
|
1115
|
+
return this;
|
1309
1116
|
}
|
1310
|
-
}
|
1311
|
-
}
|
1312
1117
|
|
1313
|
-
|
1314
|
-
var points = result.points,
|
1315
|
-
indices = result.indices,
|
1316
|
-
leftPoints = result.leftPoints,
|
1317
|
-
rightPoints = result.rightPoints,
|
1318
|
-
uv = result.uv;
|
1319
|
-
var z = options.depth;
|
1320
|
-
var bottomStickGround = options.bottomStickGround;
|
1321
|
-
var rings = [leftPoints, rightPoints];
|
1322
|
-
var depthsEnable = result.depths;
|
1323
|
-
var pIndex = points.length - 1;
|
1324
|
-
var iIndex = indices.length - 1;
|
1118
|
+
var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
|
1325
1119
|
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1120
|
+
if (sqrSinHalfTheta <= Number.EPSILON) {
|
1121
|
+
var s = 1 - t;
|
1122
|
+
this._w = s * w + t * this._w;
|
1123
|
+
this._x = s * x + t * this._x;
|
1124
|
+
this._y = s * y + t * this._y;
|
1125
|
+
this._z = s * z + t * this._z;
|
1126
|
+
this.normalize(); // normalize calls _onChangeCallback()
|
1329
1127
|
|
1330
|
-
|
1331
|
-
|
1332
|
-
points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
|
1333
|
-
points[++pIndex] = v2[0];
|
1334
|
-
points[++pIndex] = v2[1];
|
1335
|
-
points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
|
1336
|
-
// bottom
|
1128
|
+
return this;
|
1129
|
+
}
|
1337
1130
|
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1131
|
+
var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
|
1132
|
+
var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
|
1133
|
+
var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta,
|
1134
|
+
ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
|
1135
|
+
this._w = w * ratioA + this._w * ratioB;
|
1136
|
+
this._x = x * ratioA + this._x * ratioB;
|
1137
|
+
this._y = y * ratioA + this._y * ratioB;
|
1138
|
+
this._z = z * ratioA + this._z * ratioB;
|
1344
1139
|
|
1345
|
-
|
1346
|
-
b = idx + 3,
|
1347
|
-
c = idx,
|
1348
|
-
d = idx + 1;
|
1349
|
-
indices[++iIndex] = a;
|
1350
|
-
indices[++iIndex] = c;
|
1351
|
-
indices[++iIndex] = b;
|
1352
|
-
indices[++iIndex] = c;
|
1353
|
-
indices[++iIndex] = d;
|
1354
|
-
indices[++iIndex] = b; // index.push(a, c, b, c, d, b);
|
1140
|
+
this._onChangeCallback();
|
1355
1141
|
|
1356
|
-
|
1357
|
-
}
|
1142
|
+
return this;
|
1143
|
+
};
|
1358
1144
|
|
1359
|
-
|
1360
|
-
|
1145
|
+
_proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
|
1146
|
+
return this.copy(qa).slerp(qb, t);
|
1147
|
+
};
|
1361
1148
|
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1149
|
+
_proto.random = function random() {
|
1150
|
+
// sets this quaternion to a uniform random unit quaternnion
|
1151
|
+
// Ken Shoemake
|
1152
|
+
// Uniform random rotations
|
1153
|
+
// D. Kirk, editor, Graphics Gems III, pages 124-132. Academic Press, New York, 1992.
|
1154
|
+
var theta1 = 2 * Math.PI * Math.random();
|
1155
|
+
var theta2 = 2 * Math.PI * Math.random();
|
1156
|
+
var x0 = Math.random();
|
1157
|
+
var r1 = Math.sqrt(1 - x0);
|
1158
|
+
var r2 = Math.sqrt(x0);
|
1159
|
+
return this.set(r1 * Math.sin(theta1), r1 * Math.cos(theta1), r2 * Math.sin(theta2), r2 * Math.cos(theta2));
|
1160
|
+
};
|
1368
1161
|
|
1369
|
-
|
1370
|
-
|
1162
|
+
_proto.equals = function equals(quaternion) {
|
1163
|
+
return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
|
1164
|
+
};
|
1371
1165
|
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
j++;
|
1377
|
-
}
|
1378
|
-
}
|
1166
|
+
_proto.fromArray = function fromArray(array, offset) {
|
1167
|
+
if (offset === void 0) {
|
1168
|
+
offset = 0;
|
1169
|
+
}
|
1379
1170
|
|
1380
|
-
|
1381
|
-
|
1171
|
+
this._x = array[offset];
|
1172
|
+
this._y = array[offset + 1];
|
1173
|
+
this._z = array[offset + 2];
|
1174
|
+
this._w = array[offset + 3];
|
1382
1175
|
|
1383
|
-
|
1384
|
-
var _v = vs[_i],
|
1385
|
-
_v2 = vs[_i + 1];
|
1386
|
-
addOneSideIndex(_v, _v2);
|
1387
|
-
}
|
1388
|
-
}
|
1176
|
+
this._onChangeCallback();
|
1389
1177
|
|
1390
|
-
|
1391
|
-
|
1392
|
-
y: 0
|
1393
|
-
},
|
1394
|
-
TEMPV2 = {
|
1395
|
-
x: 0,
|
1396
|
-
y: 0
|
1397
|
-
};
|
1398
|
-
function expandLine(line, options) {
|
1399
|
-
// let preAngle = 0;
|
1400
|
-
var radius = options.lineWidth / 2;
|
1401
|
-
var points = [],
|
1402
|
-
leftPoints = [],
|
1403
|
-
rightPoints = [];
|
1404
|
-
var len = line.length;
|
1405
|
-
var i = 0;
|
1178
|
+
return this;
|
1179
|
+
};
|
1406
1180
|
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1181
|
+
_proto.toArray = function toArray(array, offset) {
|
1182
|
+
if (array === void 0) {
|
1183
|
+
array = [];
|
1184
|
+
}
|
1411
1185
|
|
1412
|
-
if (
|
1413
|
-
|
1414
|
-
p2 = line[len - 1];
|
1186
|
+
if (offset === void 0) {
|
1187
|
+
offset = 0;
|
1415
1188
|
}
|
1416
1189
|
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1190
|
+
array[offset] = this._x;
|
1191
|
+
array[offset + 1] = this._y;
|
1192
|
+
array[offset + 2] = this._z;
|
1193
|
+
array[offset + 3] = this._w;
|
1194
|
+
return array;
|
1195
|
+
};
|
1422
1196
|
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
var p0 = line[i - 1];
|
1429
|
-
TEMPV1.x = p0[0] - p1[0];
|
1430
|
-
TEMPV1.y = p0[1] - p1[1];
|
1431
|
-
TEMPV2.x = p2[0] - p1[0];
|
1432
|
-
TEMPV2.y = p2[1] - p1[1];
|
1433
|
-
var vAngle = getAngle(TEMPV1, TEMPV2);
|
1434
|
-
rAngle = angle - vAngle / 2;
|
1435
|
-
}
|
1197
|
+
_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index) {
|
1198
|
+
this._x = attribute.getX(index);
|
1199
|
+
this._y = attribute.getY(index);
|
1200
|
+
this._z = attribute.getZ(index);
|
1201
|
+
this._w = attribute.getW(index);
|
1436
1202
|
|
1437
|
-
|
1438
|
-
var p3 = currentp;
|
1439
|
-
var x = Math.cos(rRad) + p3[0],
|
1440
|
-
y = Math.sin(rRad) + p3[1];
|
1441
|
-
var p4 = [x, y];
|
1203
|
+
this._onChangeCallback();
|
1442
1204
|
|
1443
|
-
|
1444
|
-
|
1445
|
-
line2 = _translateLine[1];
|
1205
|
+
return this;
|
1206
|
+
};
|
1446
1207
|
|
1447
|
-
|
1448
|
-
|
1208
|
+
_proto.toJSON = function toJSON() {
|
1209
|
+
return this.toArray();
|
1210
|
+
};
|
1449
1211
|
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1212
|
+
_proto._onChange = function _onChange(callback) {
|
1213
|
+
this._onChangeCallback = callback;
|
1214
|
+
return this;
|
1215
|
+
} // _onChangeCallback() { }
|
1216
|
+
// * [Symbol.iterator]() {
|
1217
|
+
// yield this._x;
|
1218
|
+
// yield this._y;
|
1219
|
+
// yield this._z;
|
1220
|
+
// yield this._w;
|
1221
|
+
// }
|
1222
|
+
;
|
1454
1223
|
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1224
|
+
_createClass(Quaternion, [{
|
1225
|
+
key: "x",
|
1226
|
+
get: function get() {
|
1227
|
+
return this._x;
|
1228
|
+
},
|
1229
|
+
set: function set(value) {
|
1230
|
+
this._x = value;
|
1458
1231
|
|
1459
|
-
|
1460
|
-
op2 = [point2[0], point2[1]];
|
1232
|
+
this._onChangeCallback();
|
1461
1233
|
}
|
1234
|
+
}, {
|
1235
|
+
key: "y",
|
1236
|
+
get: function get() {
|
1237
|
+
return this._y;
|
1238
|
+
},
|
1239
|
+
set: function set(value) {
|
1240
|
+
this._y = value;
|
1462
1241
|
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1242
|
+
this._onChangeCallback();
|
1243
|
+
}
|
1244
|
+
}, {
|
1245
|
+
key: "z",
|
1246
|
+
get: function get() {
|
1247
|
+
return this._z;
|
1248
|
+
},
|
1249
|
+
set: function set(value) {
|
1250
|
+
this._z = value;
|
1467
1251
|
|
1468
|
-
|
1469
|
-
leftPoints.push(op1);
|
1470
|
-
rightPoints.push(op2);
|
1471
|
-
} else {
|
1472
|
-
leftPoints.push(op2);
|
1473
|
-
rightPoints.push(op1);
|
1252
|
+
this._onChangeCallback();
|
1474
1253
|
}
|
1254
|
+
}, {
|
1255
|
+
key: "w",
|
1256
|
+
get: function get() {
|
1257
|
+
return this._w;
|
1258
|
+
},
|
1259
|
+
set: function set(value) {
|
1260
|
+
this._w = value;
|
1475
1261
|
|
1476
|
-
|
1477
|
-
|
1262
|
+
this._onChangeCallback();
|
1263
|
+
}
|
1264
|
+
}]);
|
1478
1265
|
|
1479
|
-
return
|
1480
|
-
|
1481
|
-
leftPoints: leftPoints,
|
1482
|
-
rightPoints: rightPoints
|
1483
|
-
};
|
1484
|
-
} // eslint-disable-next-line no-unused-vars
|
1266
|
+
return Quaternion;
|
1267
|
+
}();
|
1485
1268
|
|
1486
|
-
|
1487
|
-
var x1 = _ref.x,
|
1488
|
-
y1 = _ref.y;
|
1489
|
-
var x2 = _ref2.x,
|
1490
|
-
y2 = _ref2.y;
|
1491
|
-
var dot = x1 * x2 + y1 * y2;
|
1492
|
-
var det = x1 * y2 - y1 * x2;
|
1493
|
-
var angle = Math.atan2(det, dot) / Math.PI * 180;
|
1494
|
-
return (angle + 360) % 360;
|
1495
|
-
};
|
1269
|
+
// import * as MathUtils from './MathUtils.js';
|
1496
1270
|
|
1497
|
-
|
1498
|
-
var x1 = p1[0],
|
1499
|
-
y1 = p1[1];
|
1500
|
-
var x2 = p2[0],
|
1501
|
-
y2 = p2[1];
|
1502
|
-
var x = p[0],
|
1503
|
-
y = p[1];
|
1504
|
-
return (y1 - y2) * x + (x2 - x1) * y + x1 * y2 - x2 * y1 > 0;
|
1505
|
-
}
|
1506
|
-
/**
|
1507
|
-
* 平移线
|
1508
|
-
* @param {*} p1
|
1509
|
-
* @param {*} p2
|
1510
|
-
* @param {*} distance
|
1511
|
-
* @returns
|
1512
|
-
*/
|
1271
|
+
var _quaternion = new Quaternion();
|
1513
1272
|
|
1514
|
-
function
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
var offsetX = Math.cos(rad1) * distance,
|
1520
|
-
offsetY = Math.sin(rad1) * distance;
|
1521
|
-
var tp1 = [p1[0] + offsetX, p1[1] + offsetY];
|
1522
|
-
var tp2 = [p2[0] + offsetX, p2[1] + offsetY];
|
1523
|
-
var rad2 = rad - Math.PI / 2;
|
1524
|
-
offsetX = Math.cos(rad2) * distance;
|
1525
|
-
offsetY = Math.sin(rad2) * distance;
|
1526
|
-
var tp3 = [p1[0] + offsetX, p1[1] + offsetY];
|
1527
|
-
var tp4 = [p2[0] + offsetX, p2[1] + offsetY];
|
1528
|
-
return [[tp1, tp2], [tp3, tp4]];
|
1529
|
-
}
|
1530
|
-
/**
|
1531
|
-
* 直线交点
|
1532
|
-
* @param {*} p1
|
1533
|
-
* @param {*} p2
|
1534
|
-
* @param {*} p3
|
1535
|
-
* @param {*} p4
|
1536
|
-
* @returns
|
1537
|
-
*/
|
1273
|
+
var Vector3 = /*#__PURE__*/function () {
|
1274
|
+
function Vector3(x, y, z) {
|
1275
|
+
if (x === void 0) {
|
1276
|
+
x = 0;
|
1277
|
+
}
|
1538
1278
|
|
1279
|
+
if (y === void 0) {
|
1280
|
+
y = 0;
|
1281
|
+
}
|
1539
1282
|
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
var dx2 = p4[0] - p3[0],
|
1544
|
-
dy2 = p4[1] - p3[1];
|
1283
|
+
if (z === void 0) {
|
1284
|
+
z = 0;
|
1285
|
+
}
|
1545
1286
|
|
1546
|
-
|
1547
|
-
|
1287
|
+
this.x = x;
|
1288
|
+
this.y = y;
|
1289
|
+
this.z = z;
|
1548
1290
|
}
|
1549
1291
|
|
1550
|
-
|
1551
|
-
return null;
|
1552
|
-
}
|
1292
|
+
var _proto = Vector3.prototype;
|
1553
1293
|
|
1554
|
-
|
1555
|
-
|
1556
|
-
var b1 = p1[1] - k1 * p1[0];
|
1557
|
-
var b2 = p3[1] - k2 * p3[0];
|
1558
|
-
var x, y;
|
1294
|
+
_proto.set = function set(x, y, z) {
|
1295
|
+
if (z === undefined) z = this.z; // sprite.scale.set(x,y)
|
1559
1296
|
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
}
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
uIdx = 0;
|
1601
|
-
var offset = circlePointsLen * 3,
|
1602
|
-
uOffset = circlePointsLen * 2;
|
1603
|
-
var indices = [],
|
1604
|
-
uv = [];
|
1605
|
-
var iIndex = indices.length - 1;
|
1606
|
-
|
1607
|
-
for (var i = -1; i < radialSegments; i++) {
|
1608
|
-
var rad = aRad * i;
|
1609
|
-
var x = Math.cos(rad) * radius + centerx,
|
1610
|
-
y = Math.sin(rad) * radius + centery; // bottom vertices
|
1611
|
-
|
1612
|
-
points[idx] = x;
|
1613
|
-
points[idx + 1] = y;
|
1614
|
-
points[idx + 2] = 0; // top vertices
|
1615
|
-
|
1616
|
-
points[idx + offset] = x;
|
1617
|
-
points[idx + 1 + offset] = y;
|
1618
|
-
points[idx + 2 + offset] = height;
|
1619
|
-
var u = 0,
|
1620
|
-
v = 0;
|
1621
|
-
u = 0.5 + x / radius / 2;
|
1622
|
-
v = 0.5 + y / radius / 2;
|
1623
|
-
uv[uIdx] = u;
|
1624
|
-
uv[uIdx + 1] = v;
|
1625
|
-
uv[uIdx + uOffset] = u;
|
1626
|
-
uv[uIdx + 1 + uOffset] = v;
|
1627
|
-
idx += 3;
|
1628
|
-
uIdx += 2;
|
1629
|
-
|
1630
|
-
if (i > 1) {
|
1631
|
-
// bottom indices
|
1632
|
-
// indices.push(0, i - 1, i);
|
1633
|
-
indices[++iIndex] = 0;
|
1634
|
-
indices[++iIndex] = i - 1;
|
1635
|
-
indices[++iIndex] = i;
|
1636
|
-
}
|
1637
|
-
}
|
1638
|
-
|
1639
|
-
idx -= 3;
|
1640
|
-
points[idx] = points[0];
|
1641
|
-
points[idx + 1] = points[1];
|
1642
|
-
points[idx + 2] = points[2];
|
1643
|
-
var pointsLen = points.length;
|
1644
|
-
points[pointsLen - 3] = points[0];
|
1645
|
-
points[pointsLen - 2] = points[1];
|
1646
|
-
points[pointsLen - 1] = height;
|
1647
|
-
var indicesLen = indices.length; // top indices
|
1648
|
-
|
1649
|
-
iIndex = indices.length - 1;
|
1297
|
+
this.x = x;
|
1298
|
+
this.y = y;
|
1299
|
+
this.z = z;
|
1300
|
+
return this;
|
1301
|
+
} // setScalar(scalar) {
|
1302
|
+
// this.x = scalar;
|
1303
|
+
// this.y = scalar;
|
1304
|
+
// this.z = scalar;
|
1305
|
+
// return this;
|
1306
|
+
// }
|
1307
|
+
// setX(x) {
|
1308
|
+
// this.x = x;
|
1309
|
+
// return this;
|
1310
|
+
// }
|
1311
|
+
// setY(y) {
|
1312
|
+
// this.y = y;
|
1313
|
+
// return this;
|
1314
|
+
// }
|
1315
|
+
// setZ(z) {
|
1316
|
+
// this.z = z;
|
1317
|
+
// return this;
|
1318
|
+
// }
|
1319
|
+
// setComponent(index, value) {
|
1320
|
+
// switch (index) {
|
1321
|
+
// case 0: this.x = value; break;
|
1322
|
+
// case 1: this.y = value; break;
|
1323
|
+
// case 2: this.z = value; break;
|
1324
|
+
// default: throw new Error('index is out of range: ' + index);
|
1325
|
+
// }
|
1326
|
+
// return this;
|
1327
|
+
// }
|
1328
|
+
// getComponent(index) {
|
1329
|
+
// switch (index) {
|
1330
|
+
// case 0: return this.x;
|
1331
|
+
// case 1: return this.y;
|
1332
|
+
// case 2: return this.z;
|
1333
|
+
// default: throw new Error('index is out of range: ' + index);
|
1334
|
+
// }
|
1335
|
+
// }
|
1336
|
+
;
|
1650
1337
|
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
}
|
1338
|
+
_proto.clone = function clone() {
|
1339
|
+
return new this.constructor(this.x, this.y, this.z);
|
1340
|
+
};
|
1655
1341
|
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1342
|
+
_proto.copy = function copy(v) {
|
1343
|
+
this.x = v.x;
|
1344
|
+
this.y = v.y;
|
1345
|
+
this.z = v.z;
|
1346
|
+
return this;
|
1347
|
+
};
|
1662
1348
|
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
sidePoints[++pIndex] = y1;
|
1670
|
-
sidePoints[++pIndex] = height;
|
1671
|
-
sidePoints[++pIndex] = x2;
|
1672
|
-
sidePoints[++pIndex] = y2;
|
1673
|
-
sidePoints[++pIndex] = height;
|
1674
|
-
sidePoints[++pIndex] = x1;
|
1675
|
-
sidePoints[++pIndex] = y1;
|
1676
|
-
sidePoints[++pIndex] = 0;
|
1677
|
-
sidePoints[++pIndex] = x2;
|
1678
|
-
sidePoints[++pIndex] = y2;
|
1679
|
-
sidePoints[++pIndex] = 0;
|
1680
|
-
var a = idx + 2,
|
1681
|
-
b = idx + 3,
|
1682
|
-
c = idx,
|
1683
|
-
d = idx + 1; // indices.push(a, c, b, c, d, b);
|
1349
|
+
_proto.add = function add(v) {
|
1350
|
+
this.x += v.x;
|
1351
|
+
this.y += v.y;
|
1352
|
+
this.z += v.z;
|
1353
|
+
return this;
|
1354
|
+
};
|
1684
1355
|
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1356
|
+
_proto.addScalar = function addScalar(s) {
|
1357
|
+
this.x += s;
|
1358
|
+
this.y += s;
|
1359
|
+
this.z += s;
|
1360
|
+
return this;
|
1361
|
+
};
|
1691
1362
|
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
uv[++uvIndex] = height / radius / 2;
|
1699
|
-
uv[++uvIndex] = u1;
|
1700
|
-
uv[++uvIndex] = 0;
|
1701
|
-
uv[++uvIndex] = u2;
|
1702
|
-
uv[++uvIndex] = 0; // uvs.push(u1, height / radius / 2, u2, height / radius / 2, u1, 0, u2, 0);
|
1363
|
+
_proto.addVectors = function addVectors(a, b) {
|
1364
|
+
this.x = a.x + b.x;
|
1365
|
+
this.y = a.y + b.y;
|
1366
|
+
this.z = a.z + b.z;
|
1367
|
+
return this;
|
1368
|
+
};
|
1703
1369
|
|
1704
|
-
|
1705
|
-
|
1370
|
+
_proto.addScaledVector = function addScaledVector(v, s) {
|
1371
|
+
this.x += v.x * s;
|
1372
|
+
this.y += v.y * s;
|
1373
|
+
this.z += v.z * s;
|
1374
|
+
return this;
|
1375
|
+
};
|
1706
1376
|
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
points: points,
|
1713
|
-
indices: new Uint32Array(indices),
|
1714
|
-
position: position,
|
1715
|
-
normal: normal,
|
1716
|
-
uv: new Float32Array(uv)
|
1377
|
+
_proto.sub = function sub(v) {
|
1378
|
+
this.x -= v.x;
|
1379
|
+
this.y -= v.y;
|
1380
|
+
this.z -= v.z;
|
1381
|
+
return this;
|
1717
1382
|
};
|
1718
|
-
}
|
1719
1383
|
|
1720
|
-
function
|
1721
|
-
|
1384
|
+
_proto.subScalar = function subScalar(s) {
|
1385
|
+
this.x -= s;
|
1386
|
+
this.y -= s;
|
1387
|
+
this.z -= s;
|
1388
|
+
return this;
|
1389
|
+
};
|
1722
1390
|
|
1723
|
-
|
1724
|
-
|
1391
|
+
_proto.subVectors = function subVectors(a, b) {
|
1392
|
+
this.x = a.x - b.x;
|
1393
|
+
this.y = a.y - b.y;
|
1394
|
+
this.z = a.z - b.z;
|
1395
|
+
return this;
|
1725
1396
|
};
|
1726
1397
|
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
1734
|
-
|
1735
|
-
function define(obj, key, value) {
|
1736
|
-
return Object.defineProperty(obj, key, {
|
1737
|
-
value: value,
|
1738
|
-
enumerable: !0,
|
1739
|
-
configurable: !0,
|
1740
|
-
writable: !0
|
1741
|
-
}), obj[key];
|
1742
|
-
}
|
1398
|
+
_proto.multiply = function multiply(v) {
|
1399
|
+
this.x *= v.x;
|
1400
|
+
this.y *= v.y;
|
1401
|
+
this.z *= v.z;
|
1402
|
+
return this;
|
1403
|
+
};
|
1743
1404
|
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
}
|
1405
|
+
_proto.multiplyScalar = function multiplyScalar(scalar) {
|
1406
|
+
this.x *= scalar;
|
1407
|
+
this.y *= scalar;
|
1408
|
+
this.z *= scalar;
|
1409
|
+
return this;
|
1410
|
+
};
|
1751
1411
|
|
1752
|
-
function
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
return
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
if ("completed" === state) {
|
1762
|
-
if ("throw" === method) throw arg;
|
1763
|
-
return doneResult();
|
1764
|
-
}
|
1412
|
+
_proto.multiplyVectors = function multiplyVectors(a, b) {
|
1413
|
+
this.x = a.x * b.x;
|
1414
|
+
this.y = a.y * b.y;
|
1415
|
+
this.z = a.z * b.z;
|
1416
|
+
return this;
|
1417
|
+
} // applyEuler(euler) {
|
1418
|
+
// return this.applyQuaternion(_quaternion.setFromEuler(euler));
|
1419
|
+
// }
|
1420
|
+
;
|
1765
1421
|
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
context.dispatchException(context.arg);
|
1781
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
1782
|
-
state = "executing";
|
1783
|
-
var record = tryCatch(innerFn, self, context);
|
1784
|
-
|
1785
|
-
if ("normal" === record.type) {
|
1786
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
1787
|
-
return {
|
1788
|
-
value: record.arg,
|
1789
|
-
done: context.done
|
1790
|
-
};
|
1791
|
-
}
|
1792
|
-
|
1793
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
1794
|
-
}
|
1795
|
-
};
|
1796
|
-
}(innerFn, self, context), generator;
|
1797
|
-
}
|
1798
|
-
|
1799
|
-
function tryCatch(fn, obj, arg) {
|
1800
|
-
try {
|
1801
|
-
return {
|
1802
|
-
type: "normal",
|
1803
|
-
arg: fn.call(obj, arg)
|
1804
|
-
};
|
1805
|
-
} catch (err) {
|
1806
|
-
return {
|
1807
|
-
type: "throw",
|
1808
|
-
arg: err
|
1809
|
-
};
|
1810
|
-
}
|
1811
|
-
}
|
1812
|
-
|
1813
|
-
exports.wrap = wrap;
|
1814
|
-
var ContinueSentinel = {};
|
1815
|
-
|
1816
|
-
function Generator() {}
|
1817
|
-
|
1818
|
-
function GeneratorFunction() {}
|
1819
|
-
|
1820
|
-
function GeneratorFunctionPrototype() {}
|
1422
|
+
_proto.applyAxisAngle = function applyAxisAngle(axis, angle) {
|
1423
|
+
return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));
|
1424
|
+
} // applyMatrix3(m) {
|
1425
|
+
// const x = this.x, y = this.y, z = this.z;
|
1426
|
+
// const e = m.elements;
|
1427
|
+
// this.x = e[0] * x + e[3] * y + e[6] * z;
|
1428
|
+
// this.y = e[1] * x + e[4] * y + e[7] * z;
|
1429
|
+
// this.z = e[2] * x + e[5] * y + e[8] * z;
|
1430
|
+
// return this;
|
1431
|
+
// }
|
1432
|
+
// applyNormalMatrix(m) {
|
1433
|
+
// return this.applyMatrix3(m).normalize();
|
1434
|
+
// }
|
1435
|
+
;
|
1821
1436
|
|
1822
|
-
|
1823
|
-
|
1437
|
+
_proto.applyMatrix4 = function applyMatrix4(m) {
|
1438
|
+
var x = this.x,
|
1439
|
+
y = this.y,
|
1440
|
+
z = this.z;
|
1441
|
+
var e = m.elements;
|
1442
|
+
var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
1443
|
+
this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
|
1444
|
+
this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
|
1445
|
+
this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
|
1824
1446
|
return this;
|
1825
|
-
}
|
1826
|
-
var getProto = Object.getPrototypeOf,
|
1827
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
1828
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
1829
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
1830
|
-
|
1831
|
-
function defineIteratorMethods(prototype) {
|
1832
|
-
["next", "throw", "return"].forEach(function (method) {
|
1833
|
-
define(prototype, method, function (arg) {
|
1834
|
-
return this._invoke(method, arg);
|
1835
|
-
});
|
1836
|
-
});
|
1837
|
-
}
|
1838
|
-
|
1839
|
-
function AsyncIterator(generator, PromiseImpl) {
|
1840
|
-
function invoke(method, arg, resolve, reject) {
|
1841
|
-
var record = tryCatch(generator[method], generator, arg);
|
1842
|
-
|
1843
|
-
if ("throw" !== record.type) {
|
1844
|
-
var result = record.arg,
|
1845
|
-
value = result.value;
|
1846
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
1847
|
-
invoke("next", value, resolve, reject);
|
1848
|
-
}, function (err) {
|
1849
|
-
invoke("throw", err, resolve, reject);
|
1850
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
1851
|
-
result.value = unwrapped, resolve(result);
|
1852
|
-
}, function (error) {
|
1853
|
-
return invoke("throw", error, resolve, reject);
|
1854
|
-
});
|
1855
|
-
}
|
1856
|
-
|
1857
|
-
reject(record.arg);
|
1858
|
-
}
|
1859
|
-
|
1860
|
-
var previousPromise;
|
1861
|
-
|
1862
|
-
this._invoke = function (method, arg) {
|
1863
|
-
function callInvokeWithMethodAndArg() {
|
1864
|
-
return new PromiseImpl(function (resolve, reject) {
|
1865
|
-
invoke(method, arg, resolve, reject);
|
1866
|
-
});
|
1867
|
-
}
|
1868
|
-
|
1869
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
1870
|
-
};
|
1871
|
-
}
|
1872
|
-
|
1873
|
-
function maybeInvokeDelegate(delegate, context) {
|
1874
|
-
var method = delegate.iterator[context.method];
|
1875
|
-
|
1876
|
-
if (undefined === method) {
|
1877
|
-
if (context.delegate = null, "throw" === context.method) {
|
1878
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
1879
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
1880
|
-
}
|
1881
|
-
|
1882
|
-
return ContinueSentinel;
|
1883
|
-
}
|
1884
|
-
|
1885
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
1886
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
1887
|
-
var info = record.arg;
|
1888
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
1889
|
-
}
|
1890
|
-
|
1891
|
-
function pushTryEntry(locs) {
|
1892
|
-
var entry = {
|
1893
|
-
tryLoc: locs[0]
|
1894
|
-
};
|
1895
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
1896
|
-
}
|
1897
|
-
|
1898
|
-
function resetTryEntry(entry) {
|
1899
|
-
var record = entry.completion || {};
|
1900
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
1901
|
-
}
|
1902
|
-
|
1903
|
-
function Context(tryLocsList) {
|
1904
|
-
this.tryEntries = [{
|
1905
|
-
tryLoc: "root"
|
1906
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
1907
|
-
}
|
1908
|
-
|
1909
|
-
function values(iterable) {
|
1910
|
-
if (iterable) {
|
1911
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
1912
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
1913
|
-
if ("function" == typeof iterable.next) return iterable;
|
1914
|
-
|
1915
|
-
if (!isNaN(iterable.length)) {
|
1916
|
-
var i = -1,
|
1917
|
-
next = function next() {
|
1918
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
1919
|
-
|
1920
|
-
return next.value = undefined, next.done = !0, next;
|
1921
|
-
};
|
1922
|
-
|
1923
|
-
return next.next = next;
|
1924
|
-
}
|
1925
|
-
}
|
1447
|
+
};
|
1926
1448
|
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1449
|
+
_proto.applyQuaternion = function applyQuaternion(q) {
|
1450
|
+
var x = this.x,
|
1451
|
+
y = this.y,
|
1452
|
+
z = this.z;
|
1453
|
+
var qx = q.x,
|
1454
|
+
qy = q.y,
|
1455
|
+
qz = q.z,
|
1456
|
+
qw = q.w; // calculate quat * vector
|
1931
1457
|
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
};
|
1937
|
-
}
|
1458
|
+
var ix = qw * x + qy * z - qz * y;
|
1459
|
+
var iy = qw * y + qz * x - qx * z;
|
1460
|
+
var iz = qw * z + qx * y - qy * x;
|
1461
|
+
var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat
|
1938
1462
|
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
}, exports.mark = function (genFun) {
|
1943
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
1944
|
-
}, exports.awrap = function (arg) {
|
1945
|
-
return {
|
1946
|
-
__await: arg
|
1947
|
-
};
|
1948
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
1949
|
-
return this;
|
1950
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
1951
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
1952
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
1953
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
1954
|
-
return result.done ? result.value : iter.next();
|
1955
|
-
});
|
1956
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
1463
|
+
this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
1464
|
+
this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
1465
|
+
this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
1957
1466
|
return this;
|
1958
|
-
}
|
1959
|
-
|
1960
|
-
}
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
}
|
1974
|
-
|
1975
|
-
reset: function (skipTempReset) {
|
1976
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
1977
|
-
},
|
1978
|
-
stop: function () {
|
1979
|
-
this.done = !0;
|
1980
|
-
var rootRecord = this.tryEntries[0].completion;
|
1981
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
1982
|
-
return this.rval;
|
1983
|
-
},
|
1984
|
-
dispatchException: function (exception) {
|
1985
|
-
if (this.done) throw exception;
|
1986
|
-
var context = this;
|
1987
|
-
|
1988
|
-
function handle(loc, caught) {
|
1989
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
1990
|
-
}
|
1991
|
-
|
1992
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1993
|
-
var entry = this.tryEntries[i],
|
1994
|
-
record = entry.completion;
|
1995
|
-
if ("root" === entry.tryLoc) return handle("end");
|
1996
|
-
|
1997
|
-
if (entry.tryLoc <= this.prev) {
|
1998
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
1999
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
2000
|
-
|
2001
|
-
if (hasCatch && hasFinally) {
|
2002
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
2003
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
2004
|
-
} else if (hasCatch) {
|
2005
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
2006
|
-
} else {
|
2007
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
2008
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
2009
|
-
}
|
2010
|
-
}
|
2011
|
-
}
|
2012
|
-
},
|
2013
|
-
abrupt: function (type, arg) {
|
2014
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2015
|
-
var entry = this.tryEntries[i];
|
2016
|
-
|
2017
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
2018
|
-
var finallyEntry = entry;
|
2019
|
-
break;
|
2020
|
-
}
|
2021
|
-
}
|
2022
|
-
|
2023
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
2024
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
2025
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
2026
|
-
},
|
2027
|
-
complete: function (record, afterLoc) {
|
2028
|
-
if ("throw" === record.type) throw record.arg;
|
2029
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
2030
|
-
},
|
2031
|
-
finish: function (finallyLoc) {
|
2032
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2033
|
-
var entry = this.tryEntries[i];
|
2034
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
2035
|
-
}
|
2036
|
-
},
|
2037
|
-
catch: function (tryLoc) {
|
2038
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2039
|
-
var entry = this.tryEntries[i];
|
2040
|
-
|
2041
|
-
if (entry.tryLoc === tryLoc) {
|
2042
|
-
var record = entry.completion;
|
2043
|
-
|
2044
|
-
if ("throw" === record.type) {
|
2045
|
-
var thrown = record.arg;
|
2046
|
-
resetTryEntry(entry);
|
2047
|
-
}
|
2048
|
-
|
2049
|
-
return thrown;
|
2050
|
-
}
|
2051
|
-
}
|
2052
|
-
|
2053
|
-
throw new Error("illegal catch attempt");
|
2054
|
-
},
|
2055
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
2056
|
-
return this.delegate = {
|
2057
|
-
iterator: values(iterable),
|
2058
|
-
resultName: resultName,
|
2059
|
-
nextLoc: nextLoc
|
2060
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
2061
|
-
}
|
2062
|
-
}, exports;
|
2063
|
-
}
|
2064
|
-
|
2065
|
-
function _defineProperties(target, props) {
|
2066
|
-
for (var i = 0; i < props.length; i++) {
|
2067
|
-
var descriptor = props[i];
|
2068
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
2069
|
-
descriptor.configurable = true;
|
2070
|
-
if ("value" in descriptor) descriptor.writable = true;
|
2071
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
2072
|
-
}
|
2073
|
-
}
|
1467
|
+
} // project(camera) {
|
1468
|
+
// return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
|
1469
|
+
// }
|
1470
|
+
// unproject(camera) {
|
1471
|
+
// return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
|
1472
|
+
// }
|
1473
|
+
// transformDirection(m) {
|
1474
|
+
// // input: THREE.Matrix4 affine matrix
|
1475
|
+
// // vector interpreted as a direction
|
1476
|
+
// const x = this.x, y = this.y, z = this.z;
|
1477
|
+
// const e = m.elements;
|
1478
|
+
// this.x = e[0] * x + e[4] * y + e[8] * z;
|
1479
|
+
// this.y = e[1] * x + e[5] * y + e[9] * z;
|
1480
|
+
// this.z = e[2] * x + e[6] * y + e[10] * z;
|
1481
|
+
// return this.normalize();
|
1482
|
+
// }
|
1483
|
+
;
|
2074
1484
|
|
2075
|
-
function
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
}
|
2081
|
-
return Constructor;
|
2082
|
-
}
|
1485
|
+
_proto.divide = function divide(v) {
|
1486
|
+
this.x /= v.x;
|
1487
|
+
this.y /= v.y;
|
1488
|
+
this.z /= v.z;
|
1489
|
+
return this;
|
1490
|
+
};
|
2083
1491
|
|
2084
|
-
function
|
2085
|
-
|
2086
|
-
|
1492
|
+
_proto.divideScalar = function divideScalar(scalar) {
|
1493
|
+
return this.multiplyScalar(1 / scalar);
|
1494
|
+
};
|
2087
1495
|
|
2088
|
-
|
2089
|
-
|
1496
|
+
_proto.min = function min(v) {
|
1497
|
+
this.x = Math.min(this.x, v.x);
|
1498
|
+
this.y = Math.min(this.y, v.y);
|
1499
|
+
this.z = Math.min(this.z, v.z);
|
1500
|
+
return this;
|
1501
|
+
};
|
2090
1502
|
|
2091
|
-
function
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
1503
|
+
_proto.max = function max(v) {
|
1504
|
+
this.x = Math.max(this.x, v.x);
|
1505
|
+
this.y = Math.max(this.y, v.y);
|
1506
|
+
this.z = Math.max(this.z, v.z);
|
1507
|
+
return this;
|
2095
1508
|
};
|
2096
|
-
return _setPrototypeOf(o, p);
|
2097
|
-
}
|
2098
1509
|
|
2099
|
-
|
2100
|
-
//
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
1510
|
+
_proto.clamp = function clamp(min, max) {
|
1511
|
+
// assumes min < max, componentwise
|
1512
|
+
this.x = Math.max(min.x, Math.min(max.x, this.x));
|
1513
|
+
this.y = Math.max(min.y, Math.min(max.y, this.y));
|
1514
|
+
this.z = Math.max(min.z, Math.min(max.z, this.z));
|
1515
|
+
return this;
|
1516
|
+
};
|
2106
1517
|
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
1518
|
+
_proto.clampScalar = function clampScalar(minVal, maxVal) {
|
1519
|
+
this.x = Math.max(minVal, Math.min(maxVal, this.x));
|
1520
|
+
this.y = Math.max(minVal, Math.min(maxVal, this.y));
|
1521
|
+
this.z = Math.max(minVal, Math.min(maxVal, this.z));
|
1522
|
+
return this;
|
1523
|
+
};
|
2110
1524
|
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
1525
|
+
_proto.clampLength = function clampLength(min, max) {
|
1526
|
+
var length = this.length();
|
1527
|
+
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
|
1528
|
+
} // floor() {
|
1529
|
+
// this.x = Math.floor(this.x);
|
1530
|
+
// this.y = Math.floor(this.y);
|
1531
|
+
// this.z = Math.floor(this.z);
|
1532
|
+
// return this;
|
1533
|
+
// }
|
1534
|
+
// ceil() {
|
1535
|
+
// this.x = Math.ceil(this.x);
|
1536
|
+
// this.y = Math.ceil(this.y);
|
1537
|
+
// this.z = Math.ceil(this.z);
|
1538
|
+
// return this;
|
1539
|
+
// }
|
1540
|
+
// round() {
|
1541
|
+
// this.x = Math.round(this.x);
|
1542
|
+
// this.y = Math.round(this.y);
|
1543
|
+
// this.z = Math.round(this.z);
|
1544
|
+
// return this;
|
1545
|
+
// }
|
1546
|
+
// roundToZero() {
|
1547
|
+
// this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x);
|
1548
|
+
// this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y);
|
1549
|
+
// this.z = (this.z < 0) ? Math.ceil(this.z) : Math.floor(this.z);
|
1550
|
+
// return this;
|
1551
|
+
// }
|
1552
|
+
// negate() {
|
1553
|
+
// this.x = -this.x;
|
1554
|
+
// this.y = -this.y;
|
1555
|
+
// this.z = -this.z;
|
1556
|
+
// return this;
|
1557
|
+
// }
|
1558
|
+
;
|
2114
1559
|
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
1560
|
+
_proto.dot = function dot(v) {
|
1561
|
+
return this.x * v.x + this.y * v.y + this.z * v.z;
|
1562
|
+
} // TODO lengthSquared?
|
1563
|
+
;
|
2118
1564
|
|
2119
|
-
|
2120
|
-
this.
|
2121
|
-
|
2122
|
-
this._z = z;
|
2123
|
-
this._w = w;
|
2124
|
-
}
|
1565
|
+
_proto.lengthSq = function lengthSq() {
|
1566
|
+
return this.x * this.x + this.y * this.y + this.z * this.z;
|
1567
|
+
};
|
2125
1568
|
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
var x1 = src1[srcOffset1 + 0],
|
2133
|
-
y1 = src1[srcOffset1 + 1],
|
2134
|
-
z1 = src1[srcOffset1 + 2],
|
2135
|
-
w1 = src1[srcOffset1 + 3];
|
1569
|
+
_proto.length = function length() {
|
1570
|
+
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
1571
|
+
} // manhattanLength() {
|
1572
|
+
// return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
1573
|
+
// }
|
1574
|
+
;
|
2136
1575
|
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
dst[dstOffset + 2] = z0;
|
2141
|
-
dst[dstOffset + 3] = w0;
|
2142
|
-
return;
|
2143
|
-
}
|
1576
|
+
_proto.normalize = function normalize() {
|
1577
|
+
return this.divideScalar(this.length() || 1);
|
1578
|
+
};
|
2144
1579
|
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
dst[dstOffset + 2] = z1;
|
2149
|
-
dst[dstOffset + 3] = w1;
|
2150
|
-
return;
|
2151
|
-
}
|
1580
|
+
_proto.setLength = function setLength(length) {
|
1581
|
+
return this.normalize().multiplyScalar(length);
|
1582
|
+
};
|
2152
1583
|
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
1584
|
+
_proto.lerp = function lerp(v, alpha) {
|
1585
|
+
this.x += (v.x - this.x) * alpha;
|
1586
|
+
this.y += (v.y - this.y) * alpha;
|
1587
|
+
this.z += (v.z - this.z) * alpha;
|
1588
|
+
return this;
|
1589
|
+
};
|
2158
1590
|
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
1591
|
+
_proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
|
1592
|
+
this.x = v1.x + (v2.x - v1.x) * alpha;
|
1593
|
+
this.y = v1.y + (v2.y - v1.y) * alpha;
|
1594
|
+
this.z = v1.z + (v2.z - v1.z) * alpha;
|
1595
|
+
return this;
|
1596
|
+
};
|
2165
1597
|
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
z0 = z0 * s + z1 * tDir;
|
2170
|
-
w0 = w0 * s + w1 * tDir; // Normalize in case we just did a lerp:
|
1598
|
+
_proto.cross = function cross(v) {
|
1599
|
+
return this.crossVectors(this, v);
|
1600
|
+
};
|
2171
1601
|
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
1602
|
+
_proto.crossVectors = function crossVectors(a, b) {
|
1603
|
+
var ax = a.x,
|
1604
|
+
ay = a.y,
|
1605
|
+
az = a.z;
|
1606
|
+
var bx = b.x,
|
1607
|
+
by = b.y,
|
1608
|
+
bz = b.z;
|
1609
|
+
this.x = ay * bz - az * by;
|
1610
|
+
this.y = az * bx - ax * bz;
|
1611
|
+
this.z = ax * by - ay * bx;
|
1612
|
+
return this;
|
1613
|
+
} // projectOnVector(v) {
|
1614
|
+
// const denominator = v.lengthSq();
|
1615
|
+
// if (denominator === 0) return this.set(0, 0, 0);
|
1616
|
+
// const scalar = v.dot(this) / denominator;
|
1617
|
+
// return this.copy(v).multiplyScalar(scalar);
|
1618
|
+
// }
|
1619
|
+
// projectOnPlane(planeNormal) {
|
1620
|
+
// _vector.copy(this).projectOnVector(planeNormal);
|
1621
|
+
// return this.sub(_vector);
|
1622
|
+
// }
|
1623
|
+
// reflect(normal) {
|
1624
|
+
// // reflect incident vector off plane orthogonal to normal
|
1625
|
+
// // normal is assumed to have unit length
|
1626
|
+
// return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
|
1627
|
+
// }
|
1628
|
+
// angleTo(v) {
|
1629
|
+
// const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
|
1630
|
+
// if (denominator === 0) return Math.PI / 2;
|
1631
|
+
// const theta = this.dot(v) / denominator;
|
1632
|
+
// // clamp, to handle numerical problems
|
1633
|
+
// return Math.acos(MathUtils.clamp(theta, -1, 1));
|
1634
|
+
// }
|
1635
|
+
;
|
2180
1636
|
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
1637
|
+
_proto.distanceTo = function distanceTo(v) {
|
1638
|
+
return Math.sqrt(this.distanceToSquared(v));
|
1639
|
+
} // distanceToSquared(v) {
|
1640
|
+
// const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
|
1641
|
+
// return dx * dx + dy * dy + dz * dz;
|
1642
|
+
// }
|
1643
|
+
// manhattanDistanceTo(v) {
|
1644
|
+
// return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
|
1645
|
+
// }
|
1646
|
+
// setFromSpherical(s) {
|
1647
|
+
// return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
|
1648
|
+
// }
|
1649
|
+
// setFromSphericalCoords(radius, phi, theta) {
|
1650
|
+
// const sinPhiRadius = Math.sin(phi) * radius;
|
1651
|
+
// this.x = sinPhiRadius * Math.sin(theta);
|
1652
|
+
// this.y = Math.cos(phi) * radius;
|
1653
|
+
// this.z = sinPhiRadius * Math.cos(theta);
|
1654
|
+
// return this;
|
1655
|
+
// }
|
1656
|
+
// setFromCylindrical(c) {
|
1657
|
+
// return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
|
1658
|
+
// }
|
1659
|
+
// setFromCylindricalCoords(radius, theta, y) {
|
1660
|
+
// this.x = radius * Math.sin(theta);
|
1661
|
+
// this.y = y;
|
1662
|
+
// this.z = radius * Math.cos(theta);
|
1663
|
+
// return this;
|
1664
|
+
// }
|
1665
|
+
// setFromMatrixPosition(m) {
|
1666
|
+
// const e = m.elements;
|
1667
|
+
// this.x = e[12];
|
1668
|
+
// this.y = e[13];
|
1669
|
+
// this.z = e[14];
|
1670
|
+
// return this;
|
1671
|
+
// }
|
1672
|
+
// setFromMatrixScale(m) {
|
1673
|
+
// const sx = this.setFromMatrixColumn(m, 0).length();
|
1674
|
+
// const sy = this.setFromMatrixColumn(m, 1).length();
|
1675
|
+
// const sz = this.setFromMatrixColumn(m, 2).length();
|
1676
|
+
// this.x = sx;
|
1677
|
+
// this.y = sy;
|
1678
|
+
// this.z = sz;
|
1679
|
+
// return this;
|
1680
|
+
// }
|
1681
|
+
// setFromMatrixColumn(m, index) {
|
1682
|
+
// return this.fromArray(m.elements, index * 4);
|
1683
|
+
// }
|
1684
|
+
// setFromMatrix3Column(m, index) {
|
1685
|
+
// return this.fromArray(m.elements, index * 3);
|
1686
|
+
// }
|
1687
|
+
// setFromEuler(e) {
|
1688
|
+
// this.x = e._x;
|
1689
|
+
// this.y = e._y;
|
1690
|
+
// this.z = e._z;
|
1691
|
+
// return this;
|
1692
|
+
// }
|
1693
|
+
// setFromColor(c) {
|
1694
|
+
// this.x = c.r;
|
1695
|
+
// this.y = c.g;
|
1696
|
+
// this.z = c.b;
|
1697
|
+
// return this;
|
1698
|
+
// }
|
1699
|
+
;
|
2186
1700
|
|
2187
|
-
|
2188
|
-
|
2189
|
-
var y0 = src0[srcOffset0 + 1];
|
2190
|
-
var z0 = src0[srcOffset0 + 2];
|
2191
|
-
var w0 = src0[srcOffset0 + 3];
|
2192
|
-
var x1 = src1[srcOffset1];
|
2193
|
-
var y1 = src1[srcOffset1 + 1];
|
2194
|
-
var z1 = src1[srcOffset1 + 2];
|
2195
|
-
var w1 = src1[srcOffset1 + 3];
|
2196
|
-
dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
|
2197
|
-
dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
|
2198
|
-
dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
|
2199
|
-
dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
|
2200
|
-
return dst;
|
1701
|
+
_proto.equals = function equals(v) {
|
1702
|
+
return v.x === this.x && v.y === this.y && v.z === this.z;
|
2201
1703
|
};
|
2202
1704
|
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
this._y = y;
|
2208
|
-
this._z = z;
|
2209
|
-
this._w = w;
|
1705
|
+
_proto.fromArray = function fromArray(array, offset) {
|
1706
|
+
if (offset === void 0) {
|
1707
|
+
offset = 0;
|
1708
|
+
}
|
2210
1709
|
|
2211
|
-
this.
|
1710
|
+
this.x = array[offset];
|
1711
|
+
this.y = array[offset + 1];
|
1712
|
+
this.z = array[offset + 2];
|
1713
|
+
return this;
|
1714
|
+
} // toArray(array = [], offset = 0) {
|
1715
|
+
// array[offset] = this.x;
|
1716
|
+
// array[offset + 1] = this.y;
|
1717
|
+
// array[offset + 2] = this.z;
|
1718
|
+
// return array;
|
1719
|
+
// }
|
1720
|
+
// fromBufferAttribute(attribute, index) {
|
1721
|
+
// this.x = attribute.getX(index);
|
1722
|
+
// this.y = attribute.getY(index);
|
1723
|
+
// this.z = attribute.getZ(index);
|
1724
|
+
// return this;
|
1725
|
+
// }
|
1726
|
+
;
|
2212
1727
|
|
1728
|
+
_proto.random = function random() {
|
1729
|
+
this.x = Math.random();
|
1730
|
+
this.y = Math.random();
|
1731
|
+
this.z = Math.random();
|
2213
1732
|
return this;
|
2214
|
-
}
|
1733
|
+
} // randomDirection() {
|
1734
|
+
// // Derived from https://mathworld.wolfram.com/SpherePointPicking.html
|
1735
|
+
// const u = (Math.random() - 0.5) * 2;
|
1736
|
+
// const t = Math.random() * Math.PI * 2;
|
1737
|
+
// const f = Math.sqrt(1 - u ** 2);
|
1738
|
+
// this.x = f * Math.cos(t);
|
1739
|
+
// this.y = f * Math.sin(t);
|
1740
|
+
// this.z = u;
|
1741
|
+
// return this;
|
1742
|
+
// }
|
1743
|
+
;
|
2215
1744
|
|
2216
|
-
|
2217
|
-
|
2218
|
-
};
|
1745
|
+
return Vector3;
|
1746
|
+
}();
|
2219
1747
|
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
1748
|
+
/**
|
1749
|
+
* https://github.com/Turfjs/turf/blob/master/packages/turf-boolean-clockwise/index.ts
|
1750
|
+
* @param {*} ring
|
1751
|
+
* @returns
|
1752
|
+
*/
|
2225
1753
|
|
2226
|
-
|
1754
|
+
function isClockwise(ring) {
|
1755
|
+
var sum = 0;
|
1756
|
+
var i = 1;
|
1757
|
+
var prev;
|
1758
|
+
var cur;
|
1759
|
+
var len = ring.length;
|
2227
1760
|
|
2228
|
-
|
2229
|
-
|
1761
|
+
while (i < len) {
|
1762
|
+
prev = cur || ring[0];
|
1763
|
+
cur = ring[i];
|
1764
|
+
sum += (cur[0] - prev[0]) * (cur[1] + prev[1]);
|
1765
|
+
i++;
|
1766
|
+
}
|
2230
1767
|
|
2231
|
-
|
2232
|
-
|
2233
|
-
update = true;
|
2234
|
-
}
|
1768
|
+
return sum > 0;
|
1769
|
+
}
|
2235
1770
|
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
1771
|
+
function v3Sub(out, v1, v2) {
|
1772
|
+
out[0] = v1[0] - v2[0];
|
1773
|
+
out[1] = v1[1] - v2[1];
|
1774
|
+
out[2] = v1[2] - v2[2];
|
1775
|
+
return out;
|
1776
|
+
}
|
2242
1777
|
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
1778
|
+
function v3Normalize(out, v) {
|
1779
|
+
var x = v[0];
|
1780
|
+
var y = v[1];
|
1781
|
+
var z = v[2];
|
1782
|
+
var d = Math.sqrt(x * x + y * y + z * z) || 1;
|
1783
|
+
out[0] = x / d;
|
1784
|
+
out[1] = y / d;
|
1785
|
+
out[2] = z / d;
|
1786
|
+
return out;
|
1787
|
+
}
|
2251
1788
|
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
1789
|
+
function v3Cross(out, v1, v2) {
|
1790
|
+
var ax = v1[0],
|
1791
|
+
ay = v1[1],
|
1792
|
+
az = v1[2],
|
1793
|
+
bx = v2[0],
|
1794
|
+
by = v2[1],
|
1795
|
+
bz = v2[2];
|
1796
|
+
out[0] = ay * bz - az * by;
|
1797
|
+
out[1] = az * bx - ax * bz;
|
1798
|
+
out[2] = ax * by - ay * bx;
|
1799
|
+
return out;
|
1800
|
+
}
|
2259
1801
|
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
1802
|
+
function generateNormal(indices, position) {
|
1803
|
+
function v3Set(p, a, b, c) {
|
1804
|
+
p[0] = a;
|
1805
|
+
p[1] = b;
|
1806
|
+
p[2] = c;
|
1807
|
+
}
|
2266
1808
|
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
1809
|
+
var p1 = [];
|
1810
|
+
var p2 = [];
|
1811
|
+
var p3 = [];
|
1812
|
+
var v21 = [];
|
1813
|
+
var v32 = [];
|
1814
|
+
var n = [];
|
1815
|
+
var len = indices.length;
|
1816
|
+
var normals = new Float32Array(position.length);
|
1817
|
+
var f = 0;
|
2273
1818
|
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
1819
|
+
while (f < len) {
|
1820
|
+
// const i1 = indices[f++] * 3;
|
1821
|
+
// const i2 = indices[f++] * 3;
|
1822
|
+
// const i3 = indices[f++] * 3;
|
1823
|
+
// const i1 = indices[f];
|
1824
|
+
// const i2 = indices[f + 1];
|
1825
|
+
// const i3 = indices[f + 2];
|
1826
|
+
var a = indices[f],
|
1827
|
+
b = indices[f + 1],
|
1828
|
+
c = indices[f + 2];
|
1829
|
+
var i1 = a * 3,
|
1830
|
+
i2 = b * 3,
|
1831
|
+
i3 = c * 3;
|
1832
|
+
v3Set(p1, position[i1], position[i1 + 1], position[i1 + 2]);
|
1833
|
+
v3Set(p2, position[i2], position[i2 + 1], position[i2 + 2]);
|
1834
|
+
v3Set(p3, position[i3], position[i3 + 1], position[i3 + 2]);
|
1835
|
+
v3Sub(v32, p3, p2);
|
1836
|
+
v3Sub(v21, p1, p2);
|
1837
|
+
v3Cross(n, v32, v21); // Already be weighted by the triangle area
|
2280
1838
|
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
break;
|
1839
|
+
for (var _i = 0; _i < 3; _i++) {
|
1840
|
+
normals[i1 + _i] += n[_i];
|
1841
|
+
normals[i2 + _i] += n[_i];
|
1842
|
+
normals[i3 + _i] += n[_i];
|
1843
|
+
}
|
2287
1844
|
|
2288
|
-
|
2289
|
-
|
2290
|
-
this._y = c1 * s2 * c3 - s1 * c2 * s3;
|
2291
|
-
this._z = c1 * c2 * s3 + s1 * s2 * c3;
|
2292
|
-
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
2293
|
-
break;
|
1845
|
+
f += 3;
|
1846
|
+
}
|
2294
1847
|
|
2295
|
-
|
2296
|
-
|
2297
|
-
}
|
1848
|
+
var i = 0;
|
1849
|
+
var l = normals.length;
|
2298
1850
|
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
1851
|
+
while (i < l) {
|
1852
|
+
v3Set(n, normals[i], normals[i + 1], normals[i + 2]);
|
1853
|
+
v3Normalize(n, n);
|
1854
|
+
normals[i] = n[0] || 0;
|
1855
|
+
normals[i + 1] = n[1] || 0;
|
1856
|
+
normals[i + 2] = n[2] || 0;
|
1857
|
+
i += 3;
|
1858
|
+
}
|
2302
1859
|
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
1860
|
+
return normals;
|
1861
|
+
}
|
1862
|
+
function merge(results) {
|
1863
|
+
if (results.length === 1) {
|
1864
|
+
var _result = {
|
1865
|
+
position: results[0].position,
|
1866
|
+
normal: results[0].normal,
|
1867
|
+
uv: results[0].uv,
|
1868
|
+
indices: results[0].indices,
|
1869
|
+
results: results
|
1870
|
+
};
|
1871
|
+
return _result;
|
1872
|
+
}
|
2312
1873
|
|
2313
|
-
|
1874
|
+
var plen = 0,
|
1875
|
+
ilen = 0;
|
2314
1876
|
|
2315
|
-
|
1877
|
+
for (var i = 0, len = results.length; i < len; i++) {
|
1878
|
+
var _results$i = results[i],
|
1879
|
+
position = _results$i.position,
|
1880
|
+
indices = _results$i.indices;
|
1881
|
+
plen += position.length;
|
1882
|
+
ilen += indices.length;
|
1883
|
+
}
|
1884
|
+
|
1885
|
+
var result = {
|
1886
|
+
position: new Float32Array(plen),
|
1887
|
+
normal: new Float32Array(plen),
|
1888
|
+
uv: new Float32Array(plen / 3 * 2),
|
1889
|
+
indices: new Uint32Array(ilen),
|
1890
|
+
results: results
|
2316
1891
|
};
|
1892
|
+
var pOffset = 0,
|
1893
|
+
pCount = 0,
|
1894
|
+
iIdx = 0,
|
1895
|
+
uvOffset = 0;
|
2317
1896
|
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
m32 = te[6],
|
2330
|
-
m33 = te[10],
|
2331
|
-
trace = m11 + m22 + m33;
|
1897
|
+
for (var _i2 = 0, _len = results.length; _i2 < _len; _i2++) {
|
1898
|
+
var _results$_i = results[_i2],
|
1899
|
+
_position = _results$_i.position,
|
1900
|
+
_indices = _results$_i.indices,
|
1901
|
+
normal = _results$_i.normal,
|
1902
|
+
uv = _results$_i.uv;
|
1903
|
+
result.position.set(_position, pOffset);
|
1904
|
+
result.normal.set(normal, pOffset);
|
1905
|
+
result.uv.set(uv, uvOffset);
|
1906
|
+
var j = 0;
|
1907
|
+
var len1 = _indices.length;
|
2332
1908
|
|
2333
|
-
|
2334
|
-
var
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
} else if (m11 > m22 && m11 > m33) {
|
2340
|
-
var _s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
|
1909
|
+
while (j < len1) {
|
1910
|
+
var pIndex = _indices[j] + pCount;
|
1911
|
+
result.indices[iIdx] = pIndex;
|
1912
|
+
iIdx++;
|
1913
|
+
j++;
|
1914
|
+
}
|
2341
1915
|
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
} else if (m22 > m33) {
|
2347
|
-
var _s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
|
1916
|
+
uvOffset += uv.length;
|
1917
|
+
pOffset += _position.length;
|
1918
|
+
pCount += _position.length / 3;
|
1919
|
+
}
|
2348
1920
|
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
1921
|
+
return result;
|
1922
|
+
}
|
1923
|
+
function radToDeg(rad) {
|
1924
|
+
return rad * 180 / Math.PI;
|
1925
|
+
}
|
1926
|
+
function degToRad(angle) {
|
1927
|
+
return angle / 180 * Math.PI;
|
1928
|
+
} // https://github.com/mrdoob/three.js/blob/16f13e3b07e31d0e9a00df7c3366bbe0e464588c/src/geometries/ExtrudeGeometry.js?_pjax=%23js-repo-pjax-container#L736
|
2355
1929
|
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
1930
|
+
function generateSideWallUV(uvs, vertices, indexA, indexB, indexC, indexD) {
|
1931
|
+
var idx1 = indexA * 3,
|
1932
|
+
idx2 = indexB * 3,
|
1933
|
+
idx3 = indexC * 3,
|
1934
|
+
idx4 = indexD * 3;
|
1935
|
+
var a_x = vertices[idx1];
|
1936
|
+
var a_y = vertices[idx1 + 1];
|
1937
|
+
var a_z = vertices[idx1 + 2];
|
1938
|
+
var b_x = vertices[idx2];
|
1939
|
+
var b_y = vertices[idx2 + 1];
|
1940
|
+
var b_z = vertices[idx2 + 2];
|
1941
|
+
var c_x = vertices[idx3];
|
1942
|
+
var c_y = vertices[idx3 + 1];
|
1943
|
+
var c_z = vertices[idx3 + 2];
|
1944
|
+
var d_x = vertices[idx4];
|
1945
|
+
var d_y = vertices[idx4 + 1];
|
1946
|
+
var d_z = vertices[idx4 + 2];
|
1947
|
+
var uIndex = uvs.length - 1;
|
2361
1948
|
|
2362
|
-
|
1949
|
+
if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {
|
1950
|
+
uvs[++uIndex] = a_x;
|
1951
|
+
uvs[++uIndex] = 1 - a_z;
|
1952
|
+
uvs[++uIndex] = b_x;
|
1953
|
+
uvs[++uIndex] = 1 - b_z;
|
1954
|
+
uvs[++uIndex] = c_x;
|
1955
|
+
uvs[++uIndex] = 1 - c_z;
|
1956
|
+
uvs[++uIndex] = d_x;
|
1957
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_x, 1 - a_z);
|
1958
|
+
// uvs.push(b_x, 1 - b_z);
|
1959
|
+
// uvs.push(c_x, 1 - c_z);
|
1960
|
+
// uvs.push(d_x, 1 - d_z);
|
1961
|
+
} else {
|
1962
|
+
uvs[++uIndex] = a_y;
|
1963
|
+
uvs[++uIndex] = 1 - a_z;
|
1964
|
+
uvs[++uIndex] = b_y;
|
1965
|
+
uvs[++uIndex] = 1 - b_z;
|
1966
|
+
uvs[++uIndex] = c_y;
|
1967
|
+
uvs[++uIndex] = 1 - c_z;
|
1968
|
+
uvs[++uIndex] = d_y;
|
1969
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_y, 1 - a_z);
|
1970
|
+
// uvs.push(b_y, 1 - b_z);
|
1971
|
+
// uvs.push(c_y, 1 - c_z);
|
1972
|
+
// uvs.push(d_y, 1 - d_z);
|
1973
|
+
}
|
1974
|
+
}
|
1975
|
+
function line2Vectors(line) {
|
1976
|
+
var points = [];
|
2363
1977
|
|
2364
|
-
|
2365
|
-
|
1978
|
+
for (var i = 0, len = line.length; i < len; i++) {
|
1979
|
+
var p = line[i];
|
1980
|
+
var x = p[0],
|
1981
|
+
y = p[1],
|
1982
|
+
z = p[2];
|
1983
|
+
var v = new Vector3(x, y, z || 0);
|
1984
|
+
points[i] = v;
|
1985
|
+
}
|
2366
1986
|
|
2367
|
-
|
2368
|
-
|
2369
|
-
var r = vFrom.dot(vTo) + 1;
|
1987
|
+
return points;
|
1988
|
+
}
|
2370
1989
|
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
1990
|
+
function extrudePolygons(polygons, options) {
|
1991
|
+
options = Object.assign({}, {
|
1992
|
+
depth: 2
|
1993
|
+
}, options);
|
1994
|
+
var results = polygons.map(function (polygon) {
|
1995
|
+
for (var i = 0, len = polygon.length; i < len; i++) {
|
1996
|
+
var ring = polygon[i];
|
1997
|
+
validateRing(ring);
|
2374
1998
|
|
2375
|
-
if (
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
1999
|
+
if (i === 0) {
|
2000
|
+
if (!isClockwise(ring)) {
|
2001
|
+
polygon[i] = ring.reverse();
|
2002
|
+
}
|
2003
|
+
} else if (isClockwise(ring)) {
|
2004
|
+
polygon[i] = ring.reverse();
|
2005
|
+
}
|
2006
|
+
|
2007
|
+
if (isClosedRing(ring)) {
|
2008
|
+
ring.splice(ring.length - 1, 1);
|
2385
2009
|
}
|
2386
|
-
} else {
|
2387
|
-
// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
|
2388
|
-
this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
|
2389
|
-
this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
|
2390
|
-
this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
|
2391
|
-
this._w = r;
|
2392
2010
|
}
|
2393
2011
|
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2012
|
+
var result = flatVertices(polygon, options);
|
2013
|
+
result.polygon = polygon;
|
2014
|
+
var triangles = earcut$1(result.flatVertices, result.holes, 2);
|
2015
|
+
generateTopAndBottom$1(result, triangles);
|
2016
|
+
generateSides$1(result, options);
|
2017
|
+
result.position = new Float32Array(result.points);
|
2018
|
+
result.indices = new Uint32Array(result.indices);
|
2019
|
+
result.uv = new Float32Array(result.uv);
|
2020
|
+
result.normal = generateNormal(result.indices, result.position);
|
2021
|
+
return result;
|
2022
|
+
});
|
2023
|
+
var result = merge(results);
|
2024
|
+
result.polygons = polygons;
|
2025
|
+
return result;
|
2026
|
+
}
|
2399
2027
|
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
var t = Math.min(1, step / angle);
|
2404
|
-
this.slerp(q, t);
|
2405
|
-
return this;
|
2406
|
-
};
|
2028
|
+
function generateTopAndBottom$1(result, triangles) {
|
2029
|
+
var indices = [];
|
2030
|
+
var count = result.count;
|
2407
2031
|
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2032
|
+
for (var i = 0, len = triangles.length; i < len; i += 3) {
|
2033
|
+
// top
|
2034
|
+
var a = triangles[i],
|
2035
|
+
b = triangles[i + 1],
|
2036
|
+
c = triangles[i + 2];
|
2037
|
+
indices[i] = a;
|
2038
|
+
indices[i + 1] = b;
|
2039
|
+
indices[i + 2] = c; // bottom
|
2411
2040
|
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2041
|
+
var idx = len + i;
|
2042
|
+
var a1 = count + a,
|
2043
|
+
b1 = count + b,
|
2044
|
+
c1 = count + c;
|
2045
|
+
indices[idx] = a1;
|
2046
|
+
indices[idx + 1] = b1;
|
2047
|
+
indices[idx + 2] = c1;
|
2048
|
+
}
|
2416
2049
|
|
2417
|
-
|
2418
|
-
|
2419
|
-
this._y *= -1;
|
2420
|
-
this._z *= -1;
|
2050
|
+
result.indices = indices;
|
2051
|
+
}
|
2421
2052
|
|
2422
|
-
|
2053
|
+
function generateSides$1(result, options) {
|
2054
|
+
var points = result.points,
|
2055
|
+
indices = result.indices,
|
2056
|
+
polygon = result.polygon,
|
2057
|
+
uv = result.uv;
|
2058
|
+
var depth = options.depth;
|
2059
|
+
var pIndex = points.length - 1;
|
2060
|
+
var iIndex = indices.length - 1;
|
2061
|
+
|
2062
|
+
for (var i = 0, len = polygon.length; i < len; i++) {
|
2063
|
+
var ring = polygon[i];
|
2064
|
+
var j = 0;
|
2065
|
+
var len1 = ring.length;
|
2423
2066
|
|
2424
|
-
|
2425
|
-
|
2067
|
+
while (j < len1) {
|
2068
|
+
var v1 = ring[j];
|
2069
|
+
var v2 = ring[j + 1];
|
2426
2070
|
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2071
|
+
if (j === len1 - 1) {
|
2072
|
+
v2 = ring[0];
|
2073
|
+
}
|
2430
2074
|
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2075
|
+
var idx = points.length / 3;
|
2076
|
+
var x1 = v1[0],
|
2077
|
+
y1 = v1[1],
|
2078
|
+
z1 = v1[2] || 0,
|
2079
|
+
x2 = v2[0],
|
2080
|
+
y2 = v2[1],
|
2081
|
+
z2 = v2[2] || 0;
|
2082
|
+
points[++pIndex] = x1;
|
2083
|
+
points[++pIndex] = y1;
|
2084
|
+
points[++pIndex] = z1 + depth;
|
2085
|
+
points[++pIndex] = x2;
|
2086
|
+
points[++pIndex] = y2;
|
2087
|
+
points[++pIndex] = z2 + depth;
|
2088
|
+
points[++pIndex] = x1;
|
2089
|
+
points[++pIndex] = y1;
|
2090
|
+
points[++pIndex] = z1;
|
2091
|
+
points[++pIndex] = x2;
|
2092
|
+
points[++pIndex] = y2;
|
2093
|
+
points[++pIndex] = z2; // points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
|
2434
2094
|
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2095
|
+
var a = idx + 2,
|
2096
|
+
b = idx + 3,
|
2097
|
+
c = idx,
|
2098
|
+
d = idx + 1; // points.push(p3, p4, p1, p2);
|
2099
|
+
// index.push(a, c, b, c, d, b);
|
2438
2100
|
|
2439
|
-
|
2440
|
-
|
2101
|
+
indices[++iIndex] = a;
|
2102
|
+
indices[++iIndex] = c;
|
2103
|
+
indices[++iIndex] = b;
|
2104
|
+
indices[++iIndex] = c;
|
2105
|
+
indices[++iIndex] = d;
|
2106
|
+
indices[++iIndex] = b; // index.push(c, d, b);
|
2441
2107
|
|
2442
|
-
|
2443
|
-
|
2444
|
-
this._y = 0;
|
2445
|
-
this._z = 0;
|
2446
|
-
this._w = 1;
|
2447
|
-
} else {
|
2448
|
-
l = 1 / l;
|
2449
|
-
this._x = this._x * l;
|
2450
|
-
this._y = this._y * l;
|
2451
|
-
this._z = this._z * l;
|
2452
|
-
this._w = this._w * l;
|
2108
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
2109
|
+
j++;
|
2453
2110
|
}
|
2111
|
+
}
|
2112
|
+
}
|
2454
2113
|
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2114
|
+
function calPolygonPointsCount(polygon) {
|
2115
|
+
var count = 0;
|
2116
|
+
var i = 0;
|
2117
|
+
var len = polygon.length;
|
2459
2118
|
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2119
|
+
while (i < len) {
|
2120
|
+
count += polygon[i].length;
|
2121
|
+
i++;
|
2122
|
+
}
|
2463
2123
|
|
2464
|
-
|
2465
|
-
|
2466
|
-
};
|
2124
|
+
return count;
|
2125
|
+
}
|
2467
2126
|
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
|
2127
|
+
function flatVertices(polygon, options) {
|
2128
|
+
var count = calPolygonPointsCount(polygon);
|
2129
|
+
var len = polygon.length;
|
2130
|
+
var holes = [],
|
2131
|
+
flatVertices = new Float32Array(count * 2),
|
2132
|
+
points = [],
|
2133
|
+
uv = [];
|
2134
|
+
var pOffset = count * 3,
|
2135
|
+
uOffset = count * 2;
|
2136
|
+
var depth = options.depth;
|
2137
|
+
var idx0 = 0,
|
2138
|
+
idx1 = 0,
|
2139
|
+
idx2 = 0;
|
2482
2140
|
|
2483
|
-
|
2141
|
+
for (var i = 0; i < len; i++) {
|
2142
|
+
var ring = polygon[i];
|
2484
2143
|
|
2485
|
-
|
2486
|
-
|
2144
|
+
if (i > 0) {
|
2145
|
+
holes.push(idx0 / 2);
|
2146
|
+
}
|
2487
2147
|
|
2488
|
-
|
2489
|
-
|
2490
|
-
if (t === 1) return this.copy(qb);
|
2491
|
-
var x = this._x,
|
2492
|
-
y = this._y,
|
2493
|
-
z = this._z,
|
2494
|
-
w = this._w; // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
|
2148
|
+
var j = 0;
|
2149
|
+
var len1 = ring.length;
|
2495
2150
|
|
2496
|
-
|
2151
|
+
while (j < len1) {
|
2152
|
+
var c = ring[j];
|
2153
|
+
var x = c[0],
|
2154
|
+
y = c[1],
|
2155
|
+
z = c[2] || 0;
|
2156
|
+
flatVertices[idx0++] = x;
|
2157
|
+
flatVertices[idx0++] = y; // top vertices
|
2497
2158
|
|
2498
|
-
|
2499
|
-
|
2500
|
-
|
2501
|
-
this._y = -qb._y;
|
2502
|
-
this._z = -qb._z;
|
2503
|
-
cosHalfTheta = -cosHalfTheta;
|
2504
|
-
} else {
|
2505
|
-
this.copy(qb);
|
2506
|
-
}
|
2159
|
+
points[idx1] = x;
|
2160
|
+
points[idx1 + 1] = y;
|
2161
|
+
points[idx1 + 2] = depth + z; // bottom vertices
|
2507
2162
|
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2163
|
+
points[pOffset + idx1] = x;
|
2164
|
+
points[pOffset + idx1 + 1] = y;
|
2165
|
+
points[pOffset + idx1 + 2] = z;
|
2166
|
+
uv[idx2] = x;
|
2167
|
+
uv[idx2 + 1] = y;
|
2168
|
+
uv[uOffset + idx2] = x;
|
2169
|
+
uv[uOffset + idx2 + 1] = y;
|
2170
|
+
idx1 += 3;
|
2171
|
+
idx2 += 2;
|
2172
|
+
j++;
|
2514
2173
|
}
|
2174
|
+
}
|
2515
2175
|
|
2516
|
-
|
2176
|
+
return {
|
2177
|
+
flatVertices: flatVertices,
|
2178
|
+
holes: holes,
|
2179
|
+
points: points,
|
2180
|
+
count: count,
|
2181
|
+
uv: uv
|
2182
|
+
};
|
2183
|
+
}
|
2517
2184
|
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
this._z = s * z + t * this._z;
|
2524
|
-
this.normalize(); // normalize calls _onChangeCallback()
|
2185
|
+
function validateRing(ring) {
|
2186
|
+
if (!isClosedRing(ring)) {
|
2187
|
+
ring.push(ring[0]);
|
2188
|
+
}
|
2189
|
+
}
|
2525
2190
|
|
2526
|
-
|
2527
|
-
|
2191
|
+
function isClosedRing(ring) {
|
2192
|
+
var len = ring.length;
|
2193
|
+
var _ring$ = ring[0],
|
2194
|
+
x1 = _ring$[0],
|
2195
|
+
y1 = _ring$[1],
|
2196
|
+
_ring = ring[len - 1],
|
2197
|
+
x2 = _ring[0],
|
2198
|
+
y2 = _ring[1];
|
2199
|
+
return x1 === x2 && y1 === y2;
|
2200
|
+
}
|
2528
2201
|
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
this._x = x * ratioA + this._x * ratioB;
|
2535
|
-
this._y = y * ratioA + this._y * ratioB;
|
2536
|
-
this._z = z * ratioA + this._z * ratioB;
|
2202
|
+
function checkOptions(options) {
|
2203
|
+
options.lineWidth = Math.max(0, options.lineWidth);
|
2204
|
+
options.depth = Math.max(0, options.depth);
|
2205
|
+
options.sideDepth = Math.max(0, options.sideDepth);
|
2206
|
+
}
|
2537
2207
|
|
2538
|
-
|
2208
|
+
function extrudePolylines(lines, options) {
|
2209
|
+
options = Object.assign({}, {
|
2210
|
+
depth: 2,
|
2211
|
+
lineWidth: 1,
|
2212
|
+
bottomStickGround: false
|
2213
|
+
}, options);
|
2214
|
+
checkOptions(options);
|
2215
|
+
var results = lines.map(function (line) {
|
2216
|
+
var result = expandLine(line, options);
|
2217
|
+
result.line = line;
|
2218
|
+
generateTopAndBottom(result, options);
|
2219
|
+
generateSides(result, options);
|
2220
|
+
result.position = new Float32Array(result.points);
|
2221
|
+
result.indices = new Uint32Array(result.indices);
|
2222
|
+
result.uv = new Float32Array(result.uv);
|
2223
|
+
result.normal = generateNormal(result.indices, result.position);
|
2224
|
+
return result;
|
2225
|
+
});
|
2226
|
+
var result = merge(results);
|
2227
|
+
result.lines = lines;
|
2228
|
+
return result;
|
2229
|
+
}
|
2230
|
+
function extrudeSlopes(lines, options) {
|
2231
|
+
options = Object.assign({}, {
|
2232
|
+
depth: 2,
|
2233
|
+
lineWidth: 1,
|
2234
|
+
side: 'left',
|
2235
|
+
sideDepth: 0,
|
2236
|
+
bottomStickGround: false
|
2237
|
+
}, options);
|
2238
|
+
checkOptions(options);
|
2239
|
+
var _options = options,
|
2240
|
+
depth = _options.depth,
|
2241
|
+
side = _options.side,
|
2242
|
+
sideDepth = _options.sideDepth;
|
2243
|
+
var results = lines.map(function (line) {
|
2244
|
+
var tempResult = expandLine(line, options);
|
2245
|
+
tempResult.line = line;
|
2246
|
+
var leftPoints = tempResult.leftPoints,
|
2247
|
+
rightPoints = tempResult.rightPoints;
|
2248
|
+
var result = {
|
2249
|
+
line: line
|
2250
|
+
};
|
2251
|
+
var depths;
|
2539
2252
|
|
2540
|
-
|
2541
|
-
|
2253
|
+
for (var i = 0, len = line.length; i < len; i++) {
|
2254
|
+
line[i][2] = line[i][2] || 0;
|
2255
|
+
}
|
2542
2256
|
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2257
|
+
if (side === 'left') {
|
2258
|
+
result.leftPoints = leftPoints;
|
2259
|
+
result.rightPoints = line;
|
2260
|
+
depths = [sideDepth, depth];
|
2261
|
+
} else {
|
2262
|
+
result.leftPoints = line;
|
2263
|
+
result.rightPoints = rightPoints;
|
2264
|
+
depths = [depth, sideDepth];
|
2265
|
+
}
|
2546
2266
|
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2267
|
+
result.depths = depths;
|
2268
|
+
generateTopAndBottom(result, options);
|
2269
|
+
generateSides(result, options);
|
2270
|
+
result.position = new Float32Array(result.points);
|
2271
|
+
result.indices = new Uint32Array(result.indices);
|
2272
|
+
result.uv = new Float32Array(result.uv);
|
2273
|
+
result.normal = generateNormal(result.indices, result.position);
|
2274
|
+
return result;
|
2275
|
+
});
|
2276
|
+
var result = merge(results);
|
2277
|
+
result.lines = lines;
|
2278
|
+
return result;
|
2279
|
+
}
|
2559
2280
|
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2281
|
+
function generateTopAndBottom(result, options) {
|
2282
|
+
var bottomStickGround = options.bottomStickGround;
|
2283
|
+
var z = options.depth;
|
2284
|
+
var depths = result.depths;
|
2285
|
+
var lz = z,
|
2286
|
+
rz = z;
|
2563
2287
|
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2288
|
+
if (depths) {
|
2289
|
+
lz = depths[0];
|
2290
|
+
rz = depths[1];
|
2291
|
+
}
|
2568
2292
|
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2293
|
+
var points = [],
|
2294
|
+
indices = [],
|
2295
|
+
uv = [];
|
2296
|
+
var leftPoints = result.leftPoints,
|
2297
|
+
rightPoints = result.rightPoints;
|
2298
|
+
var i = 0,
|
2299
|
+
len = leftPoints.length;
|
2573
2300
|
|
2574
|
-
|
2301
|
+
while (i < len) {
|
2302
|
+
// top left
|
2303
|
+
var idx0 = i * 3;
|
2304
|
+
var _leftPoints$i = leftPoints[i],
|
2305
|
+
x1 = _leftPoints$i[0],
|
2306
|
+
y1 = _leftPoints$i[1],
|
2307
|
+
z1 = _leftPoints$i[2];
|
2308
|
+
points[idx0] = x1;
|
2309
|
+
points[idx0 + 1] = y1;
|
2310
|
+
points[idx0 + 2] = lz + z1; // top right
|
2575
2311
|
|
2576
|
-
|
2577
|
-
|
2312
|
+
var _rightPoints$i = rightPoints[i],
|
2313
|
+
x2 = _rightPoints$i[0],
|
2314
|
+
y2 = _rightPoints$i[1],
|
2315
|
+
z2 = _rightPoints$i[2];
|
2316
|
+
var idx1 = len * 3 + idx0;
|
2317
|
+
points[idx1] = x2;
|
2318
|
+
points[idx1 + 1] = y2;
|
2319
|
+
points[idx1 + 2] = rz + z2; // bottom left
|
2578
2320
|
|
2579
|
-
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2321
|
+
var idx2 = len * 2 * 3 + idx0;
|
2322
|
+
points[idx2] = x1;
|
2323
|
+
points[idx2 + 1] = y1;
|
2324
|
+
points[idx2 + 2] = z1;
|
2583
2325
|
|
2584
|
-
if (
|
2585
|
-
|
2586
|
-
}
|
2326
|
+
if (bottomStickGround) {
|
2327
|
+
points[idx2 + 2] = 0;
|
2328
|
+
} // bottom right
|
2587
2329
|
|
2588
|
-
array[offset] = this._x;
|
2589
|
-
array[offset + 1] = this._y;
|
2590
|
-
array[offset + 2] = this._z;
|
2591
|
-
array[offset + 3] = this._w;
|
2592
|
-
return array;
|
2593
|
-
};
|
2594
2330
|
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2599
|
-
this._w = attribute.getW(index);
|
2331
|
+
var idx3 = len * 2 * 3 + len * 3 + idx0;
|
2332
|
+
points[idx3] = x2;
|
2333
|
+
points[idx3 + 1] = y2;
|
2334
|
+
points[idx3 + 2] = z2;
|
2600
2335
|
|
2601
|
-
|
2336
|
+
if (bottomStickGround) {
|
2337
|
+
points[idx3 + 2] = 0;
|
2338
|
+
}
|
2602
2339
|
|
2603
|
-
|
2604
|
-
}
|
2340
|
+
i++;
|
2341
|
+
}
|
2605
2342
|
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2343
|
+
i = 0;
|
2344
|
+
len = points.length;
|
2345
|
+
var uIndex = uv.length - 1;
|
2609
2346
|
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2347
|
+
while (i < len) {
|
2348
|
+
var x = points[i],
|
2349
|
+
y = points[i + 1];
|
2350
|
+
uv[++uIndex] = x;
|
2351
|
+
uv[++uIndex] = y; // uvs.push(x, y);
|
2614
2352
|
|
2615
|
-
|
2353
|
+
i += 3;
|
2354
|
+
}
|
2616
2355
|
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
switch (_context.prev = _context.next) {
|
2621
|
-
case 0:
|
2622
|
-
_context.next = 2;
|
2623
|
-
return this._x;
|
2356
|
+
i = 0;
|
2357
|
+
len = leftPoints.length;
|
2358
|
+
var iIndex = indices.length - 1;
|
2624
2359
|
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2360
|
+
while (i < len - 1) {
|
2361
|
+
// top
|
2362
|
+
// left1 left2 right1,right2
|
2363
|
+
var a1 = i,
|
2364
|
+
b1 = i + 1,
|
2365
|
+
c1 = a1 + len,
|
2366
|
+
d1 = b1 + len;
|
2367
|
+
indices[++iIndex] = a1;
|
2368
|
+
indices[++iIndex] = c1;
|
2369
|
+
indices[++iIndex] = b1;
|
2370
|
+
indices[++iIndex] = c1;
|
2371
|
+
indices[++iIndex] = d1;
|
2372
|
+
indices[++iIndex] = b1; // index.push(a1, c1, b1);
|
2373
|
+
// index.push(c1, d1, b1);
|
2374
|
+
// bottom
|
2375
|
+
// left1 left2 right1,right2
|
2628
2376
|
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2377
|
+
var len2 = len * 2;
|
2378
|
+
var a2 = i + len2,
|
2379
|
+
b2 = a2 + 1,
|
2380
|
+
c2 = a2 + len,
|
2381
|
+
d2 = b2 + len;
|
2382
|
+
indices[++iIndex] = a2;
|
2383
|
+
indices[++iIndex] = c2;
|
2384
|
+
indices[++iIndex] = b2;
|
2385
|
+
indices[++iIndex] = c2;
|
2386
|
+
indices[++iIndex] = d2;
|
2387
|
+
indices[++iIndex] = b2; // index.push(a2, c2, b2);
|
2388
|
+
// index.push(c2, d2, b2);
|
2632
2389
|
|
2633
|
-
|
2634
|
-
|
2635
|
-
return this._w;
|
2390
|
+
i++;
|
2391
|
+
}
|
2636
2392
|
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
}
|
2641
|
-
}
|
2642
|
-
}, _callee, this);
|
2643
|
-
});
|
2393
|
+
result.indices = indices;
|
2394
|
+
result.points = points;
|
2395
|
+
result.uv = uv;
|
2644
2396
|
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
return this._x;
|
2649
|
-
},
|
2650
|
-
set: function set(value) {
|
2651
|
-
this._x = value;
|
2397
|
+
if (depths) {
|
2398
|
+
len = leftPoints.length;
|
2399
|
+
i = 0;
|
2652
2400
|
|
2653
|
-
|
2401
|
+
while (i < len) {
|
2402
|
+
leftPoints[i].depth = lz;
|
2403
|
+
rightPoints[i].depth = rz;
|
2404
|
+
i++;
|
2654
2405
|
}
|
2655
|
-
}
|
2656
|
-
|
2657
|
-
get: function get() {
|
2658
|
-
return this._y;
|
2659
|
-
},
|
2660
|
-
set: function set(value) {
|
2661
|
-
this._y = value;
|
2406
|
+
}
|
2407
|
+
}
|
2662
2408
|
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2409
|
+
function generateSides(result, options) {
|
2410
|
+
var points = result.points,
|
2411
|
+
indices = result.indices,
|
2412
|
+
leftPoints = result.leftPoints,
|
2413
|
+
rightPoints = result.rightPoints,
|
2414
|
+
uv = result.uv;
|
2415
|
+
var z = options.depth;
|
2416
|
+
var bottomStickGround = options.bottomStickGround;
|
2417
|
+
var rings = [leftPoints, rightPoints];
|
2418
|
+
var depthsEnable = result.depths;
|
2419
|
+
var pIndex = points.length - 1;
|
2420
|
+
var iIndex = indices.length - 1;
|
2672
2421
|
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
key: "w",
|
2677
|
-
get: function get() {
|
2678
|
-
return this._w;
|
2679
|
-
},
|
2680
|
-
set: function set(value) {
|
2681
|
-
this._w = value;
|
2422
|
+
function addOneSideIndex(v1, v2) {
|
2423
|
+
var idx = points.length / 3; // let pIndex = points.length - 1;
|
2424
|
+
// top
|
2682
2425
|
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2426
|
+
points[++pIndex] = v1[0];
|
2427
|
+
points[++pIndex] = v1[1];
|
2428
|
+
points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
|
2429
|
+
points[++pIndex] = v2[0];
|
2430
|
+
points[++pIndex] = v2[1];
|
2431
|
+
points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
|
2432
|
+
// bottom
|
2433
|
+
|
2434
|
+
points[++pIndex] = v1[0];
|
2435
|
+
points[++pIndex] = v1[1];
|
2436
|
+
points[++pIndex] = bottomStickGround ? 0 : v1[2];
|
2437
|
+
points[++pIndex] = v2[0];
|
2438
|
+
points[++pIndex] = v2[1];
|
2439
|
+
points[++pIndex] = bottomStickGround ? 0 : v2[2]; // points.push(v1[0], v1[1], v1[2], v2[0], v2[1], v2[2]);
|
2686
2440
|
|
2687
|
-
|
2688
|
-
|
2441
|
+
var a = idx + 2,
|
2442
|
+
b = idx + 3,
|
2443
|
+
c = idx,
|
2444
|
+
d = idx + 1;
|
2445
|
+
indices[++iIndex] = a;
|
2446
|
+
indices[++iIndex] = c;
|
2447
|
+
indices[++iIndex] = b;
|
2448
|
+
indices[++iIndex] = c;
|
2449
|
+
indices[++iIndex] = d;
|
2450
|
+
indices[++iIndex] = b; // index.push(a, c, b, c, d, b);
|
2689
2451
|
|
2690
|
-
|
2452
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
2453
|
+
}
|
2691
2454
|
|
2692
|
-
var
|
2455
|
+
for (var i = 0, _len = rings.length; i < _len; i++) {
|
2456
|
+
var ring = rings[i];
|
2693
2457
|
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2458
|
+
if (i > 0) {
|
2459
|
+
ring = ring.map(function (p) {
|
2460
|
+
return p;
|
2461
|
+
});
|
2462
|
+
ring = ring.reverse();
|
2698
2463
|
}
|
2699
2464
|
|
2700
|
-
|
2701
|
-
|
2702
|
-
}
|
2465
|
+
var j = 0;
|
2466
|
+
var len1 = ring.length - 1;
|
2703
2467
|
|
2704
|
-
|
2705
|
-
|
2468
|
+
while (j < len1) {
|
2469
|
+
var v1 = ring[j];
|
2470
|
+
var v2 = ring[j + 1];
|
2471
|
+
addOneSideIndex(v1, v2);
|
2472
|
+
j++;
|
2706
2473
|
}
|
2707
|
-
|
2708
|
-
this.x = x;
|
2709
|
-
this.y = y;
|
2710
|
-
this.z = z;
|
2711
2474
|
}
|
2712
2475
|
|
2713
|
-
var
|
2714
|
-
|
2715
|
-
_proto.set = function set(x, y, z) {
|
2716
|
-
if (z === undefined) z = this.z; // sprite.scale.set(x,y)
|
2717
|
-
|
2718
|
-
this.x = x;
|
2719
|
-
this.y = y;
|
2720
|
-
this.z = z;
|
2721
|
-
return this;
|
2722
|
-
} // setScalar(scalar) {
|
2723
|
-
// this.x = scalar;
|
2724
|
-
// this.y = scalar;
|
2725
|
-
// this.z = scalar;
|
2726
|
-
// return this;
|
2727
|
-
// }
|
2728
|
-
// setX(x) {
|
2729
|
-
// this.x = x;
|
2730
|
-
// return this;
|
2731
|
-
// }
|
2732
|
-
// setY(y) {
|
2733
|
-
// this.y = y;
|
2734
|
-
// return this;
|
2735
|
-
// }
|
2736
|
-
// setZ(z) {
|
2737
|
-
// this.z = z;
|
2738
|
-
// return this;
|
2739
|
-
// }
|
2740
|
-
// setComponent(index, value) {
|
2741
|
-
// switch (index) {
|
2742
|
-
// case 0: this.x = value; break;
|
2743
|
-
// case 1: this.y = value; break;
|
2744
|
-
// case 2: this.z = value; break;
|
2745
|
-
// default: throw new Error('index is out of range: ' + index);
|
2746
|
-
// }
|
2747
|
-
// return this;
|
2748
|
-
// }
|
2749
|
-
// getComponent(index) {
|
2750
|
-
// switch (index) {
|
2751
|
-
// case 0: return this.x;
|
2752
|
-
// case 1: return this.y;
|
2753
|
-
// case 2: return this.z;
|
2754
|
-
// default: throw new Error('index is out of range: ' + index);
|
2755
|
-
// }
|
2756
|
-
// }
|
2757
|
-
;
|
2758
|
-
|
2759
|
-
_proto.clone = function clone() {
|
2760
|
-
return new this.constructor(this.x, this.y, this.z);
|
2761
|
-
};
|
2762
|
-
|
2763
|
-
_proto.copy = function copy(v) {
|
2764
|
-
this.x = v.x;
|
2765
|
-
this.y = v.y;
|
2766
|
-
this.z = v.z;
|
2767
|
-
return this;
|
2768
|
-
};
|
2769
|
-
|
2770
|
-
_proto.add = function add(v) {
|
2771
|
-
this.x += v.x;
|
2772
|
-
this.y += v.y;
|
2773
|
-
this.z += v.z;
|
2774
|
-
return this;
|
2775
|
-
};
|
2476
|
+
var len = leftPoints.length;
|
2477
|
+
var vs = [rightPoints[0], leftPoints[0], leftPoints[len - 1], rightPoints[len - 1]];
|
2776
2478
|
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2479
|
+
for (var _i = 0; _i < vs.length; _i += 2) {
|
2480
|
+
var _v = vs[_i],
|
2481
|
+
_v2 = vs[_i + 1];
|
2482
|
+
addOneSideIndex(_v, _v2);
|
2483
|
+
}
|
2484
|
+
}
|
2783
2485
|
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2486
|
+
var TEMPV1 = {
|
2487
|
+
x: 0,
|
2488
|
+
y: 0
|
2489
|
+
},
|
2490
|
+
TEMPV2 = {
|
2491
|
+
x: 0,
|
2492
|
+
y: 0
|
2493
|
+
};
|
2494
|
+
function expandLine(line, options) {
|
2495
|
+
// let preAngle = 0;
|
2496
|
+
var radius = options.lineWidth / 2;
|
2497
|
+
var points = [],
|
2498
|
+
leftPoints = [],
|
2499
|
+
rightPoints = [];
|
2500
|
+
var len = line.length;
|
2501
|
+
var i = 0;
|
2790
2502
|
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
return this;
|
2796
|
-
};
|
2503
|
+
while (i < len) {
|
2504
|
+
var p1 = line[i],
|
2505
|
+
p2 = line[i + 1];
|
2506
|
+
var currentp = line[i]; // last vertex
|
2797
2507
|
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
return this;
|
2803
|
-
};
|
2508
|
+
if (i === len - 1) {
|
2509
|
+
p1 = line[len - 2];
|
2510
|
+
p2 = line[len - 1];
|
2511
|
+
}
|
2804
2512
|
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
};
|
2513
|
+
var dy = p2[1] - p1[1],
|
2514
|
+
dx = p2[0] - p1[0];
|
2515
|
+
var rAngle = 0;
|
2516
|
+
var rad = Math.atan(dy / dx);
|
2517
|
+
var angle = radToDeg(rad); // preAngle = angle;
|
2811
2518
|
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2519
|
+
if (i === 0 || i === len - 1) {
|
2520
|
+
rAngle = angle;
|
2521
|
+
rAngle -= 90;
|
2522
|
+
} else {
|
2523
|
+
// 至少3个顶点才会触发
|
2524
|
+
var p0 = line[i - 1];
|
2525
|
+
TEMPV1.x = p0[0] - p1[0];
|
2526
|
+
TEMPV1.y = p0[1] - p1[1];
|
2527
|
+
TEMPV2.x = p2[0] - p1[0];
|
2528
|
+
TEMPV2.y = p2[1] - p1[1];
|
2529
|
+
var vAngle = getAngle(TEMPV1, TEMPV2);
|
2530
|
+
rAngle = angle - vAngle / 2;
|
2531
|
+
}
|
2818
2532
|
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
};
|
2533
|
+
var rRad = degToRad(rAngle);
|
2534
|
+
var p3 = currentp;
|
2535
|
+
var x = Math.cos(rRad) + p3[0],
|
2536
|
+
y = Math.sin(rRad) + p3[1];
|
2537
|
+
var p4 = [x, y];
|
2825
2538
|
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
this.z *= scalar;
|
2830
|
-
return this;
|
2831
|
-
};
|
2539
|
+
var _translateLine = translateLine(p1, p2, radius),
|
2540
|
+
line1 = _translateLine[0],
|
2541
|
+
line2 = _translateLine[1];
|
2832
2542
|
|
2833
|
-
|
2834
|
-
|
2835
|
-
this.y = a.y * b.y;
|
2836
|
-
this.z = a.z * b.z;
|
2837
|
-
return this;
|
2838
|
-
} // applyEuler(euler) {
|
2839
|
-
// return this.applyQuaternion(_quaternion.setFromEuler(euler));
|
2840
|
-
// }
|
2841
|
-
;
|
2543
|
+
var op1 = lineIntersection(line1[0], line1[1], p3, p4);
|
2544
|
+
var op2 = lineIntersection(line2[0], line2[1], p3, p4); // 平行,回头路
|
2842
2545
|
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
// const e = m.elements;
|
2848
|
-
// this.x = e[0] * x + e[3] * y + e[6] * z;
|
2849
|
-
// this.y = e[1] * x + e[4] * y + e[7] * z;
|
2850
|
-
// this.z = e[2] * x + e[5] * y + e[8] * z;
|
2851
|
-
// return this;
|
2852
|
-
// }
|
2853
|
-
// applyNormalMatrix(m) {
|
2854
|
-
// return this.applyMatrix3(m).normalize();
|
2855
|
-
// }
|
2856
|
-
;
|
2546
|
+
if (!op1 || !op2) {
|
2547
|
+
var len1 = points.length;
|
2548
|
+
var point1 = points[len1 - 2];
|
2549
|
+
var point2 = points[len1 - 1];
|
2857
2550
|
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
2861
|
-
z = this.z;
|
2862
|
-
var e = m.elements;
|
2863
|
-
var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
2864
|
-
this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
|
2865
|
-
this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
|
2866
|
-
this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
|
2867
|
-
return this;
|
2868
|
-
};
|
2551
|
+
if (!point1 || !point2) {
|
2552
|
+
continue;
|
2553
|
+
}
|
2869
2554
|
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
z = this.z;
|
2874
|
-
var qx = q.x,
|
2875
|
-
qy = q.y,
|
2876
|
-
qz = q.z,
|
2877
|
-
qw = q.w; // calculate quat * vector
|
2555
|
+
op1 = [point1[0], point1[1]];
|
2556
|
+
op2 = [point2[0], point2[1]];
|
2557
|
+
}
|
2878
2558
|
|
2879
|
-
|
2880
|
-
|
2881
|
-
var iz = qw * z + qx * y - qy * x;
|
2882
|
-
var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat
|
2559
|
+
op1[2] = currentp[2] || 0;
|
2560
|
+
op2[2] = currentp[2] || 0; // const [op1, op2] = calOffsetPoint(rRad, radius, p1);
|
2883
2561
|
|
2884
|
-
|
2885
|
-
this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
2886
|
-
this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
2887
|
-
return this;
|
2888
|
-
} // project(camera) {
|
2889
|
-
// return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
|
2890
|
-
// }
|
2891
|
-
// unproject(camera) {
|
2892
|
-
// return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
|
2893
|
-
// }
|
2894
|
-
// transformDirection(m) {
|
2895
|
-
// // input: THREE.Matrix4 affine matrix
|
2896
|
-
// // vector interpreted as a direction
|
2897
|
-
// const x = this.x, y = this.y, z = this.z;
|
2898
|
-
// const e = m.elements;
|
2899
|
-
// this.x = e[0] * x + e[4] * y + e[8] * z;
|
2900
|
-
// this.y = e[1] * x + e[5] * y + e[9] * z;
|
2901
|
-
// this.z = e[2] * x + e[6] * y + e[10] * z;
|
2902
|
-
// return this.normalize();
|
2903
|
-
// }
|
2904
|
-
;
|
2562
|
+
points.push(op1, op2);
|
2905
2563
|
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2564
|
+
if (leftOnLine(op1, p1, p2)) {
|
2565
|
+
leftPoints.push(op1);
|
2566
|
+
rightPoints.push(op2);
|
2567
|
+
} else {
|
2568
|
+
leftPoints.push(op2);
|
2569
|
+
rightPoints.push(op1);
|
2570
|
+
}
|
2912
2571
|
|
2913
|
-
|
2914
|
-
|
2915
|
-
};
|
2572
|
+
i++;
|
2573
|
+
}
|
2916
2574
|
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
return this;
|
2575
|
+
return {
|
2576
|
+
offsetPoints: points,
|
2577
|
+
leftPoints: leftPoints,
|
2578
|
+
rightPoints: rightPoints
|
2922
2579
|
};
|
2580
|
+
} // eslint-disable-next-line no-unused-vars
|
2923
2581
|
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2582
|
+
var getAngle = function getAngle(_ref, _ref2) {
|
2583
|
+
var x1 = _ref.x,
|
2584
|
+
y1 = _ref.y;
|
2585
|
+
var x2 = _ref2.x,
|
2586
|
+
y2 = _ref2.y;
|
2587
|
+
var dot = x1 * x2 + y1 * y2;
|
2588
|
+
var det = x1 * y2 - y1 * x2;
|
2589
|
+
var angle = Math.atan2(det, dot) / Math.PI * 180;
|
2590
|
+
return (angle + 360) % 360;
|
2591
|
+
};
|
2930
2592
|
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2593
|
+
function leftOnLine(p, p1, p2) {
|
2594
|
+
var x1 = p1[0],
|
2595
|
+
y1 = p1[1];
|
2596
|
+
var x2 = p2[0],
|
2597
|
+
y2 = p2[1];
|
2598
|
+
var x = p[0],
|
2599
|
+
y = p[1];
|
2600
|
+
return (y1 - y2) * x + (x2 - x1) * y + x1 * y2 - x2 * y1 > 0;
|
2601
|
+
}
|
2602
|
+
/**
|
2603
|
+
* 平移线
|
2604
|
+
* @param {*} p1
|
2605
|
+
* @param {*} p2
|
2606
|
+
* @param {*} distance
|
2607
|
+
* @returns
|
2608
|
+
*/
|
2938
2609
|
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2610
|
+
function translateLine(p1, p2, distance) {
|
2611
|
+
var dy = p2[1] - p1[1],
|
2612
|
+
dx = p2[0] - p1[0];
|
2613
|
+
var rad = Math.atan2(dy, dx);
|
2614
|
+
var rad1 = rad + Math.PI / 2;
|
2615
|
+
var offsetX = Math.cos(rad1) * distance,
|
2616
|
+
offsetY = Math.sin(rad1) * distance;
|
2617
|
+
var tp1 = [p1[0] + offsetX, p1[1] + offsetY];
|
2618
|
+
var tp2 = [p2[0] + offsetX, p2[1] + offsetY];
|
2619
|
+
var rad2 = rad - Math.PI / 2;
|
2620
|
+
offsetX = Math.cos(rad2) * distance;
|
2621
|
+
offsetY = Math.sin(rad2) * distance;
|
2622
|
+
var tp3 = [p1[0] + offsetX, p1[1] + offsetY];
|
2623
|
+
var tp4 = [p2[0] + offsetX, p2[1] + offsetY];
|
2624
|
+
return [[tp1, tp2], [tp3, tp4]];
|
2625
|
+
}
|
2626
|
+
/**
|
2627
|
+
* 直线交点
|
2628
|
+
* @param {*} p1
|
2629
|
+
* @param {*} p2
|
2630
|
+
* @param {*} p3
|
2631
|
+
* @param {*} p4
|
2632
|
+
* @returns
|
2633
|
+
*/
|
2945
2634
|
|
2946
|
-
_proto.clampLength = function clampLength(min, max) {
|
2947
|
-
var length = this.length();
|
2948
|
-
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
|
2949
|
-
} // floor() {
|
2950
|
-
// this.x = Math.floor(this.x);
|
2951
|
-
// this.y = Math.floor(this.y);
|
2952
|
-
// this.z = Math.floor(this.z);
|
2953
|
-
// return this;
|
2954
|
-
// }
|
2955
|
-
// ceil() {
|
2956
|
-
// this.x = Math.ceil(this.x);
|
2957
|
-
// this.y = Math.ceil(this.y);
|
2958
|
-
// this.z = Math.ceil(this.z);
|
2959
|
-
// return this;
|
2960
|
-
// }
|
2961
|
-
// round() {
|
2962
|
-
// this.x = Math.round(this.x);
|
2963
|
-
// this.y = Math.round(this.y);
|
2964
|
-
// this.z = Math.round(this.z);
|
2965
|
-
// return this;
|
2966
|
-
// }
|
2967
|
-
// roundToZero() {
|
2968
|
-
// this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x);
|
2969
|
-
// this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y);
|
2970
|
-
// this.z = (this.z < 0) ? Math.ceil(this.z) : Math.floor(this.z);
|
2971
|
-
// return this;
|
2972
|
-
// }
|
2973
|
-
// negate() {
|
2974
|
-
// this.x = -this.x;
|
2975
|
-
// this.y = -this.y;
|
2976
|
-
// this.z = -this.z;
|
2977
|
-
// return this;
|
2978
|
-
// }
|
2979
|
-
;
|
2980
2635
|
|
2981
|
-
|
2982
|
-
|
2983
|
-
|
2984
|
-
|
2636
|
+
function lineIntersection(p1, p2, p3, p4) {
|
2637
|
+
var dx1 = p2[0] - p1[0],
|
2638
|
+
dy1 = p2[1] - p1[1];
|
2639
|
+
var dx2 = p4[0] - p3[0],
|
2640
|
+
dy2 = p4[1] - p3[1];
|
2985
2641
|
|
2986
|
-
|
2987
|
-
return
|
2988
|
-
}
|
2642
|
+
if (dx1 === 0 && dx2 === 0) {
|
2643
|
+
return null;
|
2644
|
+
}
|
2989
2645
|
|
2990
|
-
|
2991
|
-
return
|
2992
|
-
}
|
2993
|
-
// return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
2994
|
-
// }
|
2995
|
-
;
|
2646
|
+
if (dy1 === 0 && dy2 === 0) {
|
2647
|
+
return null;
|
2648
|
+
}
|
2996
2649
|
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
2650
|
+
var k1 = dy1 / dx1;
|
2651
|
+
var k2 = dy2 / dx2;
|
2652
|
+
var b1 = p1[1] - k1 * p1[0];
|
2653
|
+
var b2 = p3[1] - k2 * p3[0];
|
2654
|
+
var x, y;
|
2655
|
+
|
2656
|
+
if (dx1 === 0) {
|
2657
|
+
x = p1[0];
|
2658
|
+
y = k2 * x + b2;
|
2659
|
+
} else if (dx2 === 0) {
|
2660
|
+
x = p3[0];
|
2661
|
+
y = k1 * x + b1;
|
2662
|
+
} else if (dy1 === 0) {
|
2663
|
+
y = p1[1];
|
2664
|
+
x = (y - b2) / k2;
|
2665
|
+
} else if (dy2 === 0) {
|
2666
|
+
y = p3[1];
|
2667
|
+
x = (y - b1) / k1;
|
2668
|
+
} else {
|
2669
|
+
x = (b2 - b1) / (k1 - k2);
|
2670
|
+
y = k1 * x + b1;
|
2671
|
+
}
|
2672
|
+
|
2673
|
+
return [x, y];
|
2674
|
+
}
|
2675
|
+
|
2676
|
+
function cylinder(point, options) {
|
2677
|
+
if (options === void 0) {
|
2678
|
+
options = {};
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
options = Object.assign({}, {
|
2682
|
+
radius: 1,
|
2683
|
+
height: 2,
|
2684
|
+
radialSegments: 6
|
2685
|
+
}, options);
|
2686
|
+
var radialSegments = Math.round(Math.max(4, options.radialSegments));
|
2687
|
+
var _options = options,
|
2688
|
+
radius = _options.radius,
|
2689
|
+
height = _options.height;
|
2690
|
+
var aRad = 360 / radialSegments / 360 * Math.PI * 2;
|
2691
|
+
var circlePointsLen = radialSegments + 1;
|
2692
|
+
var points = new Float32Array(circlePointsLen * 3 * 2);
|
2693
|
+
var centerx = point[0],
|
2694
|
+
centery = point[1];
|
2695
|
+
var idx = 0,
|
2696
|
+
uIdx = 0;
|
2697
|
+
var offset = circlePointsLen * 3,
|
2698
|
+
uOffset = circlePointsLen * 2;
|
2699
|
+
var indices = [],
|
2700
|
+
uv = [];
|
2701
|
+
var iIndex = indices.length - 1;
|
2702
|
+
|
2703
|
+
for (var i = -1; i < radialSegments; i++) {
|
2704
|
+
var rad = aRad * i;
|
2705
|
+
var x = Math.cos(rad) * radius + centerx,
|
2706
|
+
y = Math.sin(rad) * radius + centery; // bottom vertices
|
3000
2707
|
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
2708
|
+
points[idx] = x;
|
2709
|
+
points[idx + 1] = y;
|
2710
|
+
points[idx + 2] = 0; // top vertices
|
3004
2711
|
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
2712
|
+
points[idx + offset] = x;
|
2713
|
+
points[idx + 1 + offset] = y;
|
2714
|
+
points[idx + 2 + offset] = height;
|
2715
|
+
var u = 0,
|
2716
|
+
v = 0;
|
2717
|
+
u = 0.5 + x / radius / 2;
|
2718
|
+
v = 0.5 + y / radius / 2;
|
2719
|
+
uv[uIdx] = u;
|
2720
|
+
uv[uIdx + 1] = v;
|
2721
|
+
uv[uIdx + uOffset] = u;
|
2722
|
+
uv[uIdx + 1 + uOffset] = v;
|
2723
|
+
idx += 3;
|
2724
|
+
uIdx += 2;
|
3011
2725
|
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
2726
|
+
if (i > 1) {
|
2727
|
+
// bottom indices
|
2728
|
+
// indices.push(0, i - 1, i);
|
2729
|
+
indices[++iIndex] = 0;
|
2730
|
+
indices[++iIndex] = i - 1;
|
2731
|
+
indices[++iIndex] = i;
|
2732
|
+
}
|
2733
|
+
}
|
3018
2734
|
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
2735
|
+
idx -= 3;
|
2736
|
+
points[idx] = points[0];
|
2737
|
+
points[idx + 1] = points[1];
|
2738
|
+
points[idx + 2] = points[2];
|
2739
|
+
var pointsLen = points.length;
|
2740
|
+
points[pointsLen - 3] = points[0];
|
2741
|
+
points[pointsLen - 2] = points[1];
|
2742
|
+
points[pointsLen - 1] = height;
|
2743
|
+
var indicesLen = indices.length; // top indices
|
3022
2744
|
|
3023
|
-
|
3024
|
-
var ax = a.x,
|
3025
|
-
ay = a.y,
|
3026
|
-
az = a.z;
|
3027
|
-
var bx = b.x,
|
3028
|
-
by = b.y,
|
3029
|
-
bz = b.z;
|
3030
|
-
this.x = ay * bz - az * by;
|
3031
|
-
this.y = az * bx - ax * bz;
|
3032
|
-
this.z = ax * by - ay * bx;
|
3033
|
-
return this;
|
3034
|
-
} // projectOnVector(v) {
|
3035
|
-
// const denominator = v.lengthSq();
|
3036
|
-
// if (denominator === 0) return this.set(0, 0, 0);
|
3037
|
-
// const scalar = v.dot(this) / denominator;
|
3038
|
-
// return this.copy(v).multiplyScalar(scalar);
|
3039
|
-
// }
|
3040
|
-
// projectOnPlane(planeNormal) {
|
3041
|
-
// _vector.copy(this).projectOnVector(planeNormal);
|
3042
|
-
// return this.sub(_vector);
|
3043
|
-
// }
|
3044
|
-
// reflect(normal) {
|
3045
|
-
// // reflect incident vector off plane orthogonal to normal
|
3046
|
-
// // normal is assumed to have unit length
|
3047
|
-
// return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
|
3048
|
-
// }
|
3049
|
-
// angleTo(v) {
|
3050
|
-
// const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
|
3051
|
-
// if (denominator === 0) return Math.PI / 2;
|
3052
|
-
// const theta = this.dot(v) / denominator;
|
3053
|
-
// // clamp, to handle numerical problems
|
3054
|
-
// return Math.acos(MathUtils.clamp(theta, -1, 1));
|
3055
|
-
// }
|
3056
|
-
;
|
2745
|
+
iIndex = indices.length - 1;
|
3057
2746
|
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
// return dx * dx + dy * dy + dz * dz;
|
3063
|
-
// }
|
3064
|
-
// manhattanDistanceTo(v) {
|
3065
|
-
// return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
|
3066
|
-
// }
|
3067
|
-
// setFromSpherical(s) {
|
3068
|
-
// return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
|
3069
|
-
// }
|
3070
|
-
// setFromSphericalCoords(radius, phi, theta) {
|
3071
|
-
// const sinPhiRadius = Math.sin(phi) * radius;
|
3072
|
-
// this.x = sinPhiRadius * Math.sin(theta);
|
3073
|
-
// this.y = Math.cos(phi) * radius;
|
3074
|
-
// this.z = sinPhiRadius * Math.cos(theta);
|
3075
|
-
// return this;
|
3076
|
-
// }
|
3077
|
-
// setFromCylindrical(c) {
|
3078
|
-
// return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
|
3079
|
-
// }
|
3080
|
-
// setFromCylindricalCoords(radius, theta, y) {
|
3081
|
-
// this.x = radius * Math.sin(theta);
|
3082
|
-
// this.y = y;
|
3083
|
-
// this.z = radius * Math.cos(theta);
|
3084
|
-
// return this;
|
3085
|
-
// }
|
3086
|
-
// setFromMatrixPosition(m) {
|
3087
|
-
// const e = m.elements;
|
3088
|
-
// this.x = e[12];
|
3089
|
-
// this.y = e[13];
|
3090
|
-
// this.z = e[14];
|
3091
|
-
// return this;
|
3092
|
-
// }
|
3093
|
-
// setFromMatrixScale(m) {
|
3094
|
-
// const sx = this.setFromMatrixColumn(m, 0).length();
|
3095
|
-
// const sy = this.setFromMatrixColumn(m, 1).length();
|
3096
|
-
// const sz = this.setFromMatrixColumn(m, 2).length();
|
3097
|
-
// this.x = sx;
|
3098
|
-
// this.y = sy;
|
3099
|
-
// this.z = sz;
|
3100
|
-
// return this;
|
3101
|
-
// }
|
3102
|
-
// setFromMatrixColumn(m, index) {
|
3103
|
-
// return this.fromArray(m.elements, index * 4);
|
3104
|
-
// }
|
3105
|
-
// setFromMatrix3Column(m, index) {
|
3106
|
-
// return this.fromArray(m.elements, index * 3);
|
3107
|
-
// }
|
3108
|
-
// setFromEuler(e) {
|
3109
|
-
// this.x = e._x;
|
3110
|
-
// this.y = e._y;
|
3111
|
-
// this.z = e._z;
|
3112
|
-
// return this;
|
3113
|
-
// }
|
3114
|
-
// setFromColor(c) {
|
3115
|
-
// this.x = c.r;
|
3116
|
-
// this.y = c.g;
|
3117
|
-
// this.z = c.b;
|
3118
|
-
// return this;
|
3119
|
-
// }
|
3120
|
-
;
|
2747
|
+
for (var _i = 0; _i < indicesLen; _i++) {
|
2748
|
+
var index = indices[_i];
|
2749
|
+
indices[++iIndex] = index + circlePointsLen; // indices.push(index + circlePointsLen);
|
2750
|
+
}
|
3121
2751
|
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
2752
|
+
var sidePoints = new Float32Array((circlePointsLen * 3 * 2 - 6) * 2);
|
2753
|
+
var pIndex = -1;
|
2754
|
+
idx = circlePointsLen * 2;
|
2755
|
+
uIdx = 0;
|
2756
|
+
iIndex = indices.length - 1;
|
2757
|
+
var uvIndex = uv.length - 1;
|
3125
2758
|
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
2759
|
+
for (var _i2 = 0, len = points.length / 2; _i2 < len - 3; _i2 += 3) {
|
2760
|
+
var x1 = points[_i2],
|
2761
|
+
y1 = points[_i2 + 1],
|
2762
|
+
x2 = points[_i2 + 3],
|
2763
|
+
y2 = points[_i2 + 4];
|
2764
|
+
sidePoints[++pIndex] = x1;
|
2765
|
+
sidePoints[++pIndex] = y1;
|
2766
|
+
sidePoints[++pIndex] = height;
|
2767
|
+
sidePoints[++pIndex] = x2;
|
2768
|
+
sidePoints[++pIndex] = y2;
|
2769
|
+
sidePoints[++pIndex] = height;
|
2770
|
+
sidePoints[++pIndex] = x1;
|
2771
|
+
sidePoints[++pIndex] = y1;
|
2772
|
+
sidePoints[++pIndex] = 0;
|
2773
|
+
sidePoints[++pIndex] = x2;
|
2774
|
+
sidePoints[++pIndex] = y2;
|
2775
|
+
sidePoints[++pIndex] = 0;
|
2776
|
+
var a = idx + 2,
|
2777
|
+
b = idx + 3,
|
2778
|
+
c = idx,
|
2779
|
+
d = idx + 1; // indices.push(a, c, b, c, d, b);
|
3130
2780
|
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
// array[offset + 1] = this.y;
|
3138
|
-
// array[offset + 2] = this.z;
|
3139
|
-
// return array;
|
3140
|
-
// }
|
3141
|
-
// fromBufferAttribute(attribute, index) {
|
3142
|
-
// this.x = attribute.getX(index);
|
3143
|
-
// this.y = attribute.getY(index);
|
3144
|
-
// this.z = attribute.getZ(index);
|
3145
|
-
// return this;
|
3146
|
-
// }
|
3147
|
-
;
|
2781
|
+
indices[++iIndex] = c;
|
2782
|
+
indices[++iIndex] = a;
|
2783
|
+
indices[++iIndex] = d;
|
2784
|
+
indices[++iIndex] = a;
|
2785
|
+
indices[++iIndex] = b;
|
2786
|
+
indices[++iIndex] = d; // indices.push(c, a, d, a, b, d);
|
3148
2787
|
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
// this.y = f * Math.sin(t);
|
3161
|
-
// this.z = u;
|
3162
|
-
// return this;
|
3163
|
-
// }
|
3164
|
-
;
|
2788
|
+
idx += 4;
|
2789
|
+
var u1 = uIdx / circlePointsLen,
|
2790
|
+
u2 = (uIdx + 1) / circlePointsLen;
|
2791
|
+
uv[++uvIndex] = u1;
|
2792
|
+
uv[++uvIndex] = height / radius / 2;
|
2793
|
+
uv[++uvIndex] = u2;
|
2794
|
+
uv[++uvIndex] = height / radius / 2;
|
2795
|
+
uv[++uvIndex] = u1;
|
2796
|
+
uv[++uvIndex] = 0;
|
2797
|
+
uv[++uvIndex] = u2;
|
2798
|
+
uv[++uvIndex] = 0; // uvs.push(u1, height / radius / 2, u2, height / radius / 2, u1, 0, u2, 0);
|
3165
2799
|
|
3166
|
-
|
3167
|
-
}
|
2800
|
+
uIdx++;
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
var position = new Float32Array(points.length + sidePoints.length);
|
2804
|
+
position.set(points, 0);
|
2805
|
+
position.set(sidePoints, points.length);
|
2806
|
+
var normal = generateNormal(indices, position);
|
2807
|
+
return {
|
2808
|
+
points: points,
|
2809
|
+
indices: new Uint32Array(indices),
|
2810
|
+
position: position,
|
2811
|
+
normal: normal,
|
2812
|
+
uv: new Float32Array(uv)
|
2813
|
+
};
|
2814
|
+
}
|
3168
2815
|
|
3169
2816
|
/* eslint-disable no-tabs */
|
3170
2817
|
/**
|
@@ -4459,6 +4106,13 @@ var PathPointList = /*#__PURE__*/function () {
|
|
4459
4106
|
}();
|
4460
4107
|
|
4461
4108
|
var UP$1 = new Vector3(0, 0, 1);
|
4109
|
+
var right = new Vector3();
|
4110
|
+
var left = new Vector3(); // for sharp corners
|
4111
|
+
|
4112
|
+
var leftOffset = new Vector3();
|
4113
|
+
var rightOffset = new Vector3();
|
4114
|
+
var tempPoint1 = new Vector3();
|
4115
|
+
var tempPoint2 = new Vector3();
|
4462
4116
|
function expandPaths(lines, options) {
|
4463
4117
|
options = Object.assign({}, {
|
4464
4118
|
lineWidth: 1,
|
@@ -4466,12 +4120,7 @@ function expandPaths(lines, options) {
|
|
4466
4120
|
cornerSplit: 10
|
4467
4121
|
}, options);
|
4468
4122
|
var results = lines.map(function (line) {
|
4469
|
-
var points = line
|
4470
|
-
var x = p[0],
|
4471
|
-
y = p[1],
|
4472
|
-
z = p[2];
|
4473
|
-
return new Vector3(x, y, z || 0);
|
4474
|
-
});
|
4123
|
+
var points = line2Vectors(line);
|
4475
4124
|
var pathPointList = new PathPointList();
|
4476
4125
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP$1);
|
4477
4126
|
var result = generatePathVertexData(pathPointList, options);
|
@@ -4509,13 +4158,6 @@ function generatePathVertexData(pathPointList, options) {
|
|
4509
4158
|
var uv = [];
|
4510
4159
|
var indices = [];
|
4511
4160
|
var verticesCount = 0;
|
4512
|
-
var right = new Vector3();
|
4513
|
-
var left = new Vector3(); // for sharp corners
|
4514
|
-
|
4515
|
-
var leftOffset = new Vector3();
|
4516
|
-
var rightOffset = new Vector3();
|
4517
|
-
var tempPoint1 = new Vector3();
|
4518
|
-
var tempPoint2 = new Vector3();
|
4519
4161
|
var pIndex = position.length - 1;
|
4520
4162
|
var nIndex = normal.length - 1;
|
4521
4163
|
var uIndex = uv.length - 1;
|
@@ -4793,6 +4435,7 @@ function generatePathVertexData(pathPointList, options) {
|
|
4793
4435
|
}
|
4794
4436
|
|
4795
4437
|
var UP = new Vector3(0, 0, 1);
|
4438
|
+
var normalDir = new Vector3();
|
4796
4439
|
function expandTubes(lines, options) {
|
4797
4440
|
options = Object.assign({}, {
|
4798
4441
|
radius: 1,
|
@@ -4801,12 +4444,7 @@ function expandTubes(lines, options) {
|
|
4801
4444
|
startRad: -Math.PI / 4
|
4802
4445
|
}, options);
|
4803
4446
|
var results = lines.map(function (line) {
|
4804
|
-
var points = line
|
4805
|
-
var x = p[0],
|
4806
|
-
y = p[1],
|
4807
|
-
z = p[2];
|
4808
|
-
return new Vector3(x, y, z || 0);
|
4809
|
-
});
|
4447
|
+
var points = line2Vectors(line);
|
4810
4448
|
var pathPointList = new PathPointList();
|
4811
4449
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
|
4812
4450
|
var result = generateTubeVertexData(pathPointList, options);
|
@@ -4844,7 +4482,6 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4844
4482
|
|
4845
4483
|
var indices = [];
|
4846
4484
|
var verticesCount = 0;
|
4847
|
-
var normalDir = new Vector3();
|
4848
4485
|
var pIndex = -1;
|
4849
4486
|
var nIndex = -1;
|
4850
4487
|
var uIndex = -1;
|