globe.gl 2.32.6 → 2.33.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/globe.gl.js +2173 -1820
- package/dist/globe.gl.js.map +1 -1
- package/dist/globe.gl.min.js +5 -5
- package/package.json +4 -4
package/dist/globe.gl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 2.
|
|
1
|
+
// Version 2.33.0 globe.gl - https://github.com/vasturiano/globe.gl
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
* Copyright 2010-2024 Three.js Authors
|
|
129
129
|
* SPDX-License-Identifier: MIT
|
|
130
130
|
*/
|
|
131
|
-
const REVISION = '
|
|
131
|
+
const REVISION = '169';
|
|
132
132
|
|
|
133
133
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
134
134
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -1651,6 +1651,38 @@
|
|
|
1651
1651
|
|
|
1652
1652
|
}
|
|
1653
1653
|
|
|
1654
|
+
function toNormalizedProjectionMatrix( projectionMatrix ) {
|
|
1655
|
+
|
|
1656
|
+
const m = projectionMatrix.elements;
|
|
1657
|
+
|
|
1658
|
+
// Convert [-1, 1] to [0, 1] projection matrix
|
|
1659
|
+
m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
|
|
1660
|
+
m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
|
|
1661
|
+
m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
|
|
1662
|
+
m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
|
|
1663
|
+
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
function toReversedProjectionMatrix( projectionMatrix ) {
|
|
1667
|
+
|
|
1668
|
+
const m = projectionMatrix.elements;
|
|
1669
|
+
const isPerspectiveMatrix = m[ 11 ] === - 1;
|
|
1670
|
+
|
|
1671
|
+
// Reverse [0, 1] projection matrix
|
|
1672
|
+
if ( isPerspectiveMatrix ) {
|
|
1673
|
+
|
|
1674
|
+
m[ 10 ] = - m[ 10 ] - 1;
|
|
1675
|
+
m[ 14 ] = - m[ 14 ];
|
|
1676
|
+
|
|
1677
|
+
} else {
|
|
1678
|
+
|
|
1679
|
+
m[ 10 ] = - m[ 10 ];
|
|
1680
|
+
m[ 14 ] = - m[ 14 ] + 1;
|
|
1681
|
+
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1654
1686
|
/**
|
|
1655
1687
|
* Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
|
|
1656
1688
|
* or clipping. Based on W3C specifications for sRGB and Display P3,
|
|
@@ -8210,6 +8242,10 @@
|
|
|
8210
8242
|
const _vbp = /*@__PURE__*/ new Vector3();
|
|
8211
8243
|
const _vcp = /*@__PURE__*/ new Vector3();
|
|
8212
8244
|
|
|
8245
|
+
const _v40 = /*@__PURE__*/ new Vector4();
|
|
8246
|
+
const _v41 = /*@__PURE__*/ new Vector4();
|
|
8247
|
+
const _v42 = /*@__PURE__*/ new Vector4();
|
|
8248
|
+
|
|
8213
8249
|
class Triangle {
|
|
8214
8250
|
|
|
8215
8251
|
constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {
|
|
@@ -8304,6 +8340,25 @@
|
|
|
8304
8340
|
|
|
8305
8341
|
}
|
|
8306
8342
|
|
|
8343
|
+
static getInterpolatedAttribute( attr, i1, i2, i3, barycoord, target ) {
|
|
8344
|
+
|
|
8345
|
+
_v40.setScalar( 0 );
|
|
8346
|
+
_v41.setScalar( 0 );
|
|
8347
|
+
_v42.setScalar( 0 );
|
|
8348
|
+
|
|
8349
|
+
_v40.fromBufferAttribute( attr, i1 );
|
|
8350
|
+
_v41.fromBufferAttribute( attr, i2 );
|
|
8351
|
+
_v42.fromBufferAttribute( attr, i3 );
|
|
8352
|
+
|
|
8353
|
+
target.setScalar( 0 );
|
|
8354
|
+
target.addScaledVector( _v40, barycoord.x );
|
|
8355
|
+
target.addScaledVector( _v41, barycoord.y );
|
|
8356
|
+
target.addScaledVector( _v42, barycoord.z );
|
|
8357
|
+
|
|
8358
|
+
return target;
|
|
8359
|
+
|
|
8360
|
+
}
|
|
8361
|
+
|
|
8307
8362
|
static isFrontFacing( a, b, c, direction ) {
|
|
8308
8363
|
|
|
8309
8364
|
_v0$2.subVectors( c, b );
|
|
@@ -9750,7 +9805,6 @@
|
|
|
9750
9805
|
this.normalized = normalized;
|
|
9751
9806
|
|
|
9752
9807
|
this.usage = StaticDrawUsage;
|
|
9753
|
-
this._updateRange = { offset: 0, count: - 1 };
|
|
9754
9808
|
this.updateRanges = [];
|
|
9755
9809
|
this.gpuType = FloatType;
|
|
9756
9810
|
|
|
@@ -9766,13 +9820,6 @@
|
|
|
9766
9820
|
|
|
9767
9821
|
}
|
|
9768
9822
|
|
|
9769
|
-
get updateRange() {
|
|
9770
|
-
|
|
9771
|
-
warnOnce( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
|
|
9772
|
-
return this._updateRange;
|
|
9773
|
-
|
|
9774
|
-
}
|
|
9775
|
-
|
|
9776
9823
|
setUsage( value ) {
|
|
9777
9824
|
|
|
9778
9825
|
this.usage = value;
|
|
@@ -11213,14 +11260,6 @@
|
|
|
11213
11260
|
const _tempA = /*@__PURE__*/ new Vector3();
|
|
11214
11261
|
const _morphA = /*@__PURE__*/ new Vector3();
|
|
11215
11262
|
|
|
11216
|
-
const _uvA$1 = /*@__PURE__*/ new Vector2();
|
|
11217
|
-
const _uvB$1 = /*@__PURE__*/ new Vector2();
|
|
11218
|
-
const _uvC$1 = /*@__PURE__*/ new Vector2();
|
|
11219
|
-
|
|
11220
|
-
const _normalA = /*@__PURE__*/ new Vector3();
|
|
11221
|
-
const _normalB = /*@__PURE__*/ new Vector3();
|
|
11222
|
-
const _normalC = /*@__PURE__*/ new Vector3();
|
|
11223
|
-
|
|
11224
11263
|
const _intersectionPoint = /*@__PURE__*/ new Vector3();
|
|
11225
11264
|
const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
|
|
11226
11265
|
|
|
@@ -11563,33 +11602,24 @@
|
|
|
11563
11602
|
|
|
11564
11603
|
if ( intersection ) {
|
|
11565
11604
|
|
|
11566
|
-
|
|
11605
|
+
const barycoord = new Vector3();
|
|
11606
|
+
Triangle.getBarycoord( _intersectionPoint, _vA$1, _vB$1, _vC$1, barycoord );
|
|
11567
11607
|
|
|
11568
|
-
|
|
11569
|
-
_uvB$1.fromBufferAttribute( uv, b );
|
|
11570
|
-
_uvC$1.fromBufferAttribute( uv, c );
|
|
11608
|
+
if ( uv ) {
|
|
11571
11609
|
|
|
11572
|
-
intersection.uv = Triangle.
|
|
11610
|
+
intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
|
|
11573
11611
|
|
|
11574
11612
|
}
|
|
11575
11613
|
|
|
11576
11614
|
if ( uv1 ) {
|
|
11577
11615
|
|
|
11578
|
-
|
|
11579
|
-
_uvB$1.fromBufferAttribute( uv1, b );
|
|
11580
|
-
_uvC$1.fromBufferAttribute( uv1, c );
|
|
11581
|
-
|
|
11582
|
-
intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
|
|
11616
|
+
intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
|
|
11583
11617
|
|
|
11584
11618
|
}
|
|
11585
11619
|
|
|
11586
11620
|
if ( normal ) {
|
|
11587
11621
|
|
|
11588
|
-
|
|
11589
|
-
_normalB.fromBufferAttribute( normal, b );
|
|
11590
|
-
_normalC.fromBufferAttribute( normal, c );
|
|
11591
|
-
|
|
11592
|
-
intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _normalA, _normalB, _normalC, new Vector3() );
|
|
11622
|
+
intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
|
|
11593
11623
|
|
|
11594
11624
|
if ( intersection.normal.dot( ray.direction ) > 0 ) {
|
|
11595
11625
|
|
|
@@ -11610,6 +11640,7 @@
|
|
|
11610
11640
|
Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal );
|
|
11611
11641
|
|
|
11612
11642
|
intersection.face = face;
|
|
11643
|
+
intersection.barycoord = barycoord;
|
|
11613
11644
|
|
|
11614
11645
|
}
|
|
11615
11646
|
|
|
@@ -13253,40 +13284,71 @@
|
|
|
13253
13284
|
function updateBuffer( buffer, attribute, bufferType ) {
|
|
13254
13285
|
|
|
13255
13286
|
const array = attribute.array;
|
|
13256
|
-
const updateRange = attribute._updateRange; // @deprecated, r159
|
|
13257
13287
|
const updateRanges = attribute.updateRanges;
|
|
13258
13288
|
|
|
13259
13289
|
gl.bindBuffer( bufferType, buffer );
|
|
13260
13290
|
|
|
13261
|
-
if (
|
|
13291
|
+
if ( updateRanges.length === 0 ) {
|
|
13262
13292
|
|
|
13263
13293
|
// Not using update ranges
|
|
13264
13294
|
gl.bufferSubData( bufferType, 0, array );
|
|
13265
13295
|
|
|
13266
|
-
}
|
|
13296
|
+
} else {
|
|
13267
13297
|
|
|
13268
|
-
|
|
13298
|
+
// Before applying update ranges, we merge any adjacent / overlapping
|
|
13299
|
+
// ranges to reduce load on `gl.bufferSubData`. Empirically, this has led
|
|
13300
|
+
// to performance improvements for applications which make heavy use of
|
|
13301
|
+
// update ranges. Likely due to GPU command overhead.
|
|
13302
|
+
//
|
|
13303
|
+
// Note that to reduce garbage collection between frames, we merge the
|
|
13304
|
+
// update ranges in-place. This is safe because this method will clear the
|
|
13305
|
+
// update ranges once updated.
|
|
13269
13306
|
|
|
13270
|
-
|
|
13307
|
+
updateRanges.sort( ( a, b ) => a.start - b.start );
|
|
13308
|
+
|
|
13309
|
+
// To merge the update ranges in-place, we work from left to right in the
|
|
13310
|
+
// existing updateRanges array, merging ranges. This may result in a final
|
|
13311
|
+
// array which is smaller than the original. This index tracks the last
|
|
13312
|
+
// index representing a merged range, any data after this index can be
|
|
13313
|
+
// trimmed once the merge algorithm is completed.
|
|
13314
|
+
let mergeIndex = 0;
|
|
13315
|
+
|
|
13316
|
+
for ( let i = 1; i < updateRanges.length; i ++ ) {
|
|
13271
13317
|
|
|
13318
|
+
const previousRange = updateRanges[ mergeIndex ];
|
|
13272
13319
|
const range = updateRanges[ i ];
|
|
13273
13320
|
|
|
13274
|
-
|
|
13275
|
-
|
|
13321
|
+
// We add one here to merge adjacent ranges. This is safe because ranges
|
|
13322
|
+
// operate over positive integers.
|
|
13323
|
+
if ( range.start <= previousRange.start + previousRange.count + 1 ) {
|
|
13324
|
+
|
|
13325
|
+
previousRange.count = Math.max(
|
|
13326
|
+
previousRange.count,
|
|
13327
|
+
range.start + range.count - previousRange.start
|
|
13328
|
+
);
|
|
13329
|
+
|
|
13330
|
+
} else {
|
|
13331
|
+
|
|
13332
|
+
++ mergeIndex;
|
|
13333
|
+
updateRanges[ mergeIndex ] = range;
|
|
13334
|
+
|
|
13335
|
+
}
|
|
13276
13336
|
|
|
13277
13337
|
}
|
|
13278
13338
|
|
|
13279
|
-
|
|
13339
|
+
// Trim the array to only contain the merged ranges.
|
|
13340
|
+
updateRanges.length = mergeIndex + 1;
|
|
13280
13341
|
|
|
13281
|
-
|
|
13342
|
+
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
13282
13343
|
|
|
13283
|
-
|
|
13284
|
-
if ( updateRange.count !== - 1 ) {
|
|
13344
|
+
const range = updateRanges[ i ];
|
|
13285
13345
|
|
|
13286
|
-
|
|
13287
|
-
|
|
13346
|
+
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
13347
|
+
array, range.start, range.count );
|
|
13288
13348
|
|
|
13289
|
-
|
|
13349
|
+
}
|
|
13350
|
+
|
|
13351
|
+
attribute.clearUpdateRanges();
|
|
13290
13352
|
|
|
13291
13353
|
}
|
|
13292
13354
|
|
|
@@ -13747,7 +13809,7 @@
|
|
|
13747
13809
|
|
|
13748
13810
|
const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
|
|
13749
13811
|
|
|
13750
|
-
const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix
|
|
13812
|
+
const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
|
|
13751
13813
|
|
|
13752
13814
|
const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
|
|
13753
13815
|
|
|
@@ -15513,6 +15575,14 @@
|
|
|
15513
15575
|
}
|
|
15514
15576
|
|
|
15515
15577
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
15578
|
+
const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
15579
|
+
|
|
15580
|
+
if ( reverseDepthBuffer === true ) {
|
|
15581
|
+
|
|
15582
|
+
const ext = extensions.get( 'EXT_clip_control' );
|
|
15583
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
15584
|
+
|
|
15585
|
+
}
|
|
15516
15586
|
|
|
15517
15587
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
15518
15588
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
@@ -15540,6 +15610,7 @@
|
|
|
15540
15610
|
|
|
15541
15611
|
precision: precision,
|
|
15542
15612
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
15613
|
+
reverseDepthBuffer: reverseDepthBuffer,
|
|
15543
15614
|
|
|
15544
15615
|
maxTextures: maxTextures,
|
|
15545
15616
|
maxVertexTextures: maxVertexTextures,
|
|
@@ -19557,6 +19628,7 @@
|
|
|
19557
19628
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19558
19629
|
|
|
19559
19630
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
19631
|
+
parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
19560
19632
|
|
|
19561
19633
|
'uniform mat4 modelMatrix;',
|
|
19562
19634
|
'uniform mat4 modelViewMatrix;',
|
|
@@ -19722,6 +19794,7 @@
|
|
|
19722
19794
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
19723
19795
|
|
|
19724
19796
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
19797
|
+
parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
19725
19798
|
|
|
19726
19799
|
'uniform mat4 viewMatrix;',
|
|
19727
19800
|
'uniform vec3 cameraPosition;',
|
|
@@ -20114,6 +20187,7 @@
|
|
|
20114
20187
|
const programs = [];
|
|
20115
20188
|
|
|
20116
20189
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
20190
|
+
const reverseDepthBuffer = capabilities.reverseDepthBuffer;
|
|
20117
20191
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
20118
20192
|
|
|
20119
20193
|
let precision = capabilities.precision;
|
|
@@ -20405,6 +20479,7 @@
|
|
|
20405
20479
|
|
|
20406
20480
|
sizeAttenuation: material.sizeAttenuation === true,
|
|
20407
20481
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
20482
|
+
reverseDepthBuffer: reverseDepthBuffer,
|
|
20408
20483
|
|
|
20409
20484
|
skinning: object.isSkinnedMesh === true,
|
|
20410
20485
|
|
|
@@ -20624,38 +20699,40 @@
|
|
|
20624
20699
|
_programLayers.enable( 2 );
|
|
20625
20700
|
if ( parameters.logarithmicDepthBuffer )
|
|
20626
20701
|
_programLayers.enable( 3 );
|
|
20627
|
-
if ( parameters.
|
|
20702
|
+
if ( parameters.reverseDepthBuffer )
|
|
20628
20703
|
_programLayers.enable( 4 );
|
|
20629
|
-
if ( parameters.
|
|
20704
|
+
if ( parameters.skinning )
|
|
20630
20705
|
_programLayers.enable( 5 );
|
|
20631
|
-
if ( parameters.
|
|
20706
|
+
if ( parameters.morphTargets )
|
|
20632
20707
|
_programLayers.enable( 6 );
|
|
20633
|
-
if ( parameters.
|
|
20708
|
+
if ( parameters.morphNormals )
|
|
20634
20709
|
_programLayers.enable( 7 );
|
|
20635
|
-
if ( parameters.
|
|
20710
|
+
if ( parameters.morphColors )
|
|
20636
20711
|
_programLayers.enable( 8 );
|
|
20637
|
-
if ( parameters.
|
|
20712
|
+
if ( parameters.premultipliedAlpha )
|
|
20638
20713
|
_programLayers.enable( 9 );
|
|
20639
|
-
if ( parameters.
|
|
20714
|
+
if ( parameters.shadowMapEnabled )
|
|
20640
20715
|
_programLayers.enable( 10 );
|
|
20641
|
-
if ( parameters.
|
|
20716
|
+
if ( parameters.doubleSided )
|
|
20642
20717
|
_programLayers.enable( 11 );
|
|
20643
|
-
if ( parameters.
|
|
20718
|
+
if ( parameters.flipSided )
|
|
20644
20719
|
_programLayers.enable( 12 );
|
|
20645
|
-
if ( parameters.
|
|
20720
|
+
if ( parameters.useDepthPacking )
|
|
20646
20721
|
_programLayers.enable( 13 );
|
|
20647
|
-
if ( parameters.
|
|
20722
|
+
if ( parameters.dithering )
|
|
20648
20723
|
_programLayers.enable( 14 );
|
|
20649
|
-
if ( parameters.
|
|
20724
|
+
if ( parameters.transmission )
|
|
20650
20725
|
_programLayers.enable( 15 );
|
|
20651
|
-
if ( parameters.
|
|
20726
|
+
if ( parameters.sheen )
|
|
20652
20727
|
_programLayers.enable( 16 );
|
|
20653
|
-
if ( parameters.
|
|
20728
|
+
if ( parameters.opaque )
|
|
20654
20729
|
_programLayers.enable( 17 );
|
|
20655
|
-
if ( parameters.
|
|
20730
|
+
if ( parameters.pointsUvs )
|
|
20656
20731
|
_programLayers.enable( 18 );
|
|
20657
|
-
if ( parameters.
|
|
20732
|
+
if ( parameters.decodeVideoTexture )
|
|
20658
20733
|
_programLayers.enable( 19 );
|
|
20734
|
+
if ( parameters.alphaToCoverage )
|
|
20735
|
+
_programLayers.enable( 20 );
|
|
20659
20736
|
|
|
20660
20737
|
array.push( _programLayers.mask );
|
|
20661
20738
|
|
|
@@ -22213,6 +22290,18 @@
|
|
|
22213
22290
|
|
|
22214
22291
|
}
|
|
22215
22292
|
|
|
22293
|
+
const reversedFuncs = {
|
|
22294
|
+
[ NeverDepth ]: AlwaysDepth,
|
|
22295
|
+
[ LessDepth ]: GreaterDepth,
|
|
22296
|
+
[ EqualDepth ]: NotEqualDepth,
|
|
22297
|
+
[ LessEqualDepth ]: GreaterEqualDepth,
|
|
22298
|
+
|
|
22299
|
+
[ AlwaysDepth ]: NeverDepth,
|
|
22300
|
+
[ GreaterDepth ]: LessDepth,
|
|
22301
|
+
[ NotEqualDepth ]: EqualDepth,
|
|
22302
|
+
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
22303
|
+
};
|
|
22304
|
+
|
|
22216
22305
|
function WebGLState( gl ) {
|
|
22217
22306
|
|
|
22218
22307
|
function ColorBuffer() {
|
|
@@ -22277,6 +22366,7 @@
|
|
|
22277
22366
|
function DepthBuffer() {
|
|
22278
22367
|
|
|
22279
22368
|
let locked = false;
|
|
22369
|
+
let reversed = false;
|
|
22280
22370
|
|
|
22281
22371
|
let currentDepthMask = null;
|
|
22282
22372
|
let currentDepthFunc = null;
|
|
@@ -22284,6 +22374,12 @@
|
|
|
22284
22374
|
|
|
22285
22375
|
return {
|
|
22286
22376
|
|
|
22377
|
+
setReversed: function ( value ) {
|
|
22378
|
+
|
|
22379
|
+
reversed = value;
|
|
22380
|
+
|
|
22381
|
+
},
|
|
22382
|
+
|
|
22287
22383
|
setTest: function ( depthTest ) {
|
|
22288
22384
|
|
|
22289
22385
|
if ( depthTest ) {
|
|
@@ -22311,6 +22407,8 @@
|
|
|
22311
22407
|
|
|
22312
22408
|
setFunc: function ( depthFunc ) {
|
|
22313
22409
|
|
|
22410
|
+
if ( reversed ) depthFunc = reversedFuncs[ depthFunc ];
|
|
22411
|
+
|
|
22314
22412
|
if ( currentDepthFunc !== depthFunc ) {
|
|
22315
22413
|
|
|
22316
22414
|
switch ( depthFunc ) {
|
|
@@ -23781,6 +23879,28 @@
|
|
|
23781
23879
|
|
|
23782
23880
|
}
|
|
23783
23881
|
|
|
23882
|
+
if ( glFormat === _gl.RGB_INTEGER ) {
|
|
23883
|
+
|
|
23884
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
|
|
23885
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
|
|
23886
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
|
|
23887
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
|
|
23888
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
|
|
23889
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
|
|
23890
|
+
|
|
23891
|
+
}
|
|
23892
|
+
|
|
23893
|
+
if ( glFormat === _gl.RGBA_INTEGER ) {
|
|
23894
|
+
|
|
23895
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
|
|
23896
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
|
|
23897
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
|
|
23898
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
|
|
23899
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
|
|
23900
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
|
|
23901
|
+
|
|
23902
|
+
}
|
|
23903
|
+
|
|
23784
23904
|
if ( glFormat === _gl.RGB ) {
|
|
23785
23905
|
|
|
23786
23906
|
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
@@ -28374,6 +28494,7 @@ void main() {
|
|
|
28374
28494
|
|
|
28375
28495
|
// camera matrices cache
|
|
28376
28496
|
|
|
28497
|
+
const _currentProjectionMatrix = new Matrix4();
|
|
28377
28498
|
const _projScreenMatrix = new Matrix4();
|
|
28378
28499
|
|
|
28379
28500
|
const _vector3 = new Vector3();
|
|
@@ -28469,6 +28590,8 @@ void main() {
|
|
|
28469
28590
|
|
|
28470
28591
|
state = new WebGLState( _gl );
|
|
28471
28592
|
|
|
28593
|
+
if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
28594
|
+
|
|
28472
28595
|
info = new WebGLInfo( _gl );
|
|
28473
28596
|
properties = new WebGLProperties();
|
|
28474
28597
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
@@ -28768,7 +28891,13 @@ void main() {
|
|
|
28768
28891
|
|
|
28769
28892
|
}
|
|
28770
28893
|
|
|
28771
|
-
if ( depth )
|
|
28894
|
+
if ( depth ) {
|
|
28895
|
+
|
|
28896
|
+
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
28897
|
+
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
28898
|
+
|
|
28899
|
+
}
|
|
28900
|
+
|
|
28772
28901
|
if ( stencil ) {
|
|
28773
28902
|
|
|
28774
28903
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -29157,6 +29286,12 @@ void main() {
|
|
|
29157
29286
|
|
|
29158
29287
|
scene.traverse( function ( object ) {
|
|
29159
29288
|
|
|
29289
|
+
if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
|
|
29290
|
+
|
|
29291
|
+
return;
|
|
29292
|
+
|
|
29293
|
+
}
|
|
29294
|
+
|
|
29160
29295
|
const material = object.material;
|
|
29161
29296
|
|
|
29162
29297
|
if ( material ) {
|
|
@@ -30143,7 +30278,21 @@ void main() {
|
|
|
30143
30278
|
|
|
30144
30279
|
// common camera uniforms
|
|
30145
30280
|
|
|
30146
|
-
|
|
30281
|
+
if ( capabilities.reverseDepthBuffer ) {
|
|
30282
|
+
|
|
30283
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
30284
|
+
|
|
30285
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
30286
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
30287
|
+
|
|
30288
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
30289
|
+
|
|
30290
|
+
} else {
|
|
30291
|
+
|
|
30292
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
30293
|
+
|
|
30294
|
+
}
|
|
30295
|
+
|
|
30147
30296
|
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
30148
30297
|
|
|
30149
30298
|
const uCamPos = p_uniforms.map.cameraPosition;
|
|
@@ -30624,61 +30773,55 @@ void main() {
|
|
|
30624
30773
|
|
|
30625
30774
|
if ( framebuffer ) {
|
|
30626
30775
|
|
|
30627
|
-
|
|
30628
|
-
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
const texture = renderTarget.texture;
|
|
30632
|
-
const textureFormat = texture.format;
|
|
30633
|
-
const textureType = texture.type;
|
|
30634
|
-
|
|
30635
|
-
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
30636
|
-
|
|
30637
|
-
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
30776
|
+
const texture = renderTarget.texture;
|
|
30777
|
+
const textureFormat = texture.format;
|
|
30778
|
+
const textureType = texture.type;
|
|
30638
30779
|
|
|
30639
|
-
|
|
30780
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
30640
30781
|
|
|
30641
|
-
|
|
30782
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
30642
30783
|
|
|
30643
|
-
|
|
30784
|
+
}
|
|
30644
30785
|
|
|
30645
|
-
|
|
30786
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
30646
30787
|
|
|
30647
|
-
|
|
30648
|
-
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
30788
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
30649
30789
|
|
|
30650
|
-
|
|
30651
|
-
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
30652
|
-
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
30653
|
-
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
30654
|
-
_gl.flush();
|
|
30790
|
+
}
|
|
30655
30791
|
|
|
30656
|
-
|
|
30657
|
-
|
|
30658
|
-
await probeAsync( _gl, sync, 4 );
|
|
30792
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
30793
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
30659
30794
|
|
|
30660
|
-
|
|
30795
|
+
// set the active frame buffer to the one we want to read
|
|
30796
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
30661
30797
|
|
|
30662
|
-
|
|
30663
|
-
|
|
30798
|
+
const glBuffer = _gl.createBuffer();
|
|
30799
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
30800
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
30801
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
30664
30802
|
|
|
30665
|
-
|
|
30803
|
+
// reset the frame buffer to the currently set buffer before waiting
|
|
30804
|
+
const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
30805
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
|
|
30666
30806
|
|
|
30667
|
-
|
|
30668
|
-
|
|
30807
|
+
// check if the commands have finished every 8 ms
|
|
30808
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
30669
30809
|
|
|
30670
|
-
|
|
30810
|
+
_gl.flush();
|
|
30671
30811
|
|
|
30672
|
-
|
|
30812
|
+
await probeAsync( _gl, sync, 4 );
|
|
30673
30813
|
|
|
30674
|
-
|
|
30814
|
+
// read the data and delete the buffer
|
|
30815
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
30816
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
30817
|
+
_gl.deleteBuffer( glBuffer );
|
|
30818
|
+
_gl.deleteSync( sync );
|
|
30675
30819
|
|
|
30676
|
-
|
|
30820
|
+
return buffer;
|
|
30677
30821
|
|
|
30678
|
-
|
|
30822
|
+
} else {
|
|
30679
30823
|
|
|
30680
|
-
|
|
30681
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
30824
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
|
|
30682
30825
|
|
|
30683
30826
|
}
|
|
30684
30827
|
|
|
@@ -31097,7 +31240,6 @@ void main() {
|
|
|
31097
31240
|
this.count = array !== undefined ? array.length / stride : 0;
|
|
31098
31241
|
|
|
31099
31242
|
this.usage = StaticDrawUsage;
|
|
31100
|
-
this._updateRange = { offset: 0, count: - 1 };
|
|
31101
31243
|
this.updateRanges = [];
|
|
31102
31244
|
|
|
31103
31245
|
this.version = 0;
|
|
@@ -31114,13 +31256,6 @@ void main() {
|
|
|
31114
31256
|
|
|
31115
31257
|
}
|
|
31116
31258
|
|
|
31117
|
-
get updateRange() {
|
|
31118
|
-
|
|
31119
|
-
warnOnce( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
|
|
31120
|
-
return this._updateRange;
|
|
31121
|
-
|
|
31122
|
-
}
|
|
31123
|
-
|
|
31124
31259
|
setUsage( value ) {
|
|
31125
31260
|
|
|
31126
31261
|
this.usage = value;
|
|
@@ -31677,7 +31812,7 @@ void main() {
|
|
|
31677
31812
|
const _vEnd = /*@__PURE__*/ new Vector3();
|
|
31678
31813
|
|
|
31679
31814
|
const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
|
|
31680
|
-
const _ray$1 = /*@__PURE__*/ new Ray();
|
|
31815
|
+
const _ray$1$1 = /*@__PURE__*/ new Ray();
|
|
31681
31816
|
const _sphere$1 = /*@__PURE__*/ new Sphere();
|
|
31682
31817
|
|
|
31683
31818
|
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
|
@@ -31764,7 +31899,7 @@ void main() {
|
|
|
31764
31899
|
//
|
|
31765
31900
|
|
|
31766
31901
|
_inverseMatrix$1.copy( matrixWorld ).invert();
|
|
31767
|
-
_ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
31902
|
+
_ray$1$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
31768
31903
|
|
|
31769
31904
|
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
31770
31905
|
const localThresholdSq = localThreshold * localThreshold;
|
|
@@ -31785,7 +31920,7 @@ void main() {
|
|
|
31785
31920
|
const a = index.getX( i );
|
|
31786
31921
|
const b = index.getX( i + 1 );
|
|
31787
31922
|
|
|
31788
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
31923
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, a, b );
|
|
31789
31924
|
|
|
31790
31925
|
if ( intersect ) {
|
|
31791
31926
|
|
|
@@ -31800,7 +31935,7 @@ void main() {
|
|
|
31800
31935
|
const a = index.getX( end - 1 );
|
|
31801
31936
|
const b = index.getX( start );
|
|
31802
31937
|
|
|
31803
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
31938
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, a, b );
|
|
31804
31939
|
|
|
31805
31940
|
if ( intersect ) {
|
|
31806
31941
|
|
|
@@ -31817,7 +31952,7 @@ void main() {
|
|
|
31817
31952
|
|
|
31818
31953
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
31819
31954
|
|
|
31820
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
|
|
31955
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, i, i + 1 );
|
|
31821
31956
|
|
|
31822
31957
|
if ( intersect ) {
|
|
31823
31958
|
|
|
@@ -31829,7 +31964,7 @@ void main() {
|
|
|
31829
31964
|
|
|
31830
31965
|
if ( this.isLineLoop ) {
|
|
31831
31966
|
|
|
31832
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
|
|
31967
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, end - 1, start );
|
|
31833
31968
|
|
|
31834
31969
|
if ( intersect ) {
|
|
31835
31970
|
|
|
@@ -31902,6 +32037,7 @@ void main() {
|
|
|
31902
32037
|
index: a,
|
|
31903
32038
|
face: null,
|
|
31904
32039
|
faceIndex: null,
|
|
32040
|
+
barycoord: null,
|
|
31905
32041
|
object: object
|
|
31906
32042
|
|
|
31907
32043
|
};
|
|
@@ -34090,12 +34226,19 @@ void main() {
|
|
|
34090
34226
|
|
|
34091
34227
|
// faces
|
|
34092
34228
|
|
|
34093
|
-
|
|
34094
|
-
indices.push( b, c, d );
|
|
34229
|
+
if ( radiusTop > 0 ) {
|
|
34095
34230
|
|
|
34096
|
-
|
|
34231
|
+
indices.push( a, b, d );
|
|
34232
|
+
groupCount += 3;
|
|
34097
34233
|
|
|
34098
|
-
|
|
34234
|
+
}
|
|
34235
|
+
|
|
34236
|
+
if ( radiusBottom > 0 ) {
|
|
34237
|
+
|
|
34238
|
+
indices.push( b, c, d );
|
|
34239
|
+
groupCount += 3;
|
|
34240
|
+
|
|
34241
|
+
}
|
|
34099
34242
|
|
|
34100
34243
|
}
|
|
34101
34244
|
|
|
@@ -34346,14 +34489,14 @@ void main() {
|
|
|
34346
34489
|
|
|
34347
34490
|
const hasHoles = holeIndices && holeIndices.length;
|
|
34348
34491
|
const outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length;
|
|
34349
|
-
let outerNode = linkedList( data, 0, outerLen, dim, true );
|
|
34492
|
+
let outerNode = linkedList$1( data, 0, outerLen, dim, true );
|
|
34350
34493
|
const triangles = [];
|
|
34351
34494
|
|
|
34352
34495
|
if ( ! outerNode || outerNode.next === outerNode.prev ) return triangles;
|
|
34353
34496
|
|
|
34354
34497
|
let minX, minY, maxX, maxY, x, y, invSize;
|
|
34355
34498
|
|
|
34356
|
-
if ( hasHoles ) outerNode = eliminateHoles( data, holeIndices, outerNode, dim );
|
|
34499
|
+
if ( hasHoles ) outerNode = eliminateHoles$1( data, holeIndices, outerNode, dim );
|
|
34357
34500
|
|
|
34358
34501
|
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
34359
34502
|
if ( data.length > 80 * dim ) {
|
|
@@ -34378,7 +34521,7 @@ void main() {
|
|
|
34378
34521
|
|
|
34379
34522
|
}
|
|
34380
34523
|
|
|
34381
|
-
earcutLinked( outerNode, triangles, dim, minX, minY, invSize, 0 );
|
|
34524
|
+
earcutLinked$1( outerNode, triangles, dim, minX, minY, invSize, 0 );
|
|
34382
34525
|
|
|
34383
34526
|
return triangles;
|
|
34384
34527
|
|
|
@@ -34387,23 +34530,23 @@ void main() {
|
|
|
34387
34530
|
};
|
|
34388
34531
|
|
|
34389
34532
|
// create a circular doubly linked list from polygon points in the specified winding order
|
|
34390
|
-
function linkedList( data, start, end, dim, clockwise ) {
|
|
34533
|
+
function linkedList$1( data, start, end, dim, clockwise ) {
|
|
34391
34534
|
|
|
34392
34535
|
let i, last;
|
|
34393
34536
|
|
|
34394
|
-
if ( clockwise === ( signedArea( data, start, end, dim ) > 0 ) ) {
|
|
34537
|
+
if ( clockwise === ( signedArea$1( data, start, end, dim ) > 0 ) ) {
|
|
34395
34538
|
|
|
34396
|
-
for ( i = start; i < end; i += dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last );
|
|
34539
|
+
for ( i = start; i < end; i += dim ) last = insertNode$1( i, data[ i ], data[ i + 1 ], last );
|
|
34397
34540
|
|
|
34398
34541
|
} else {
|
|
34399
34542
|
|
|
34400
|
-
for ( i = end - dim; i >= start; i -= dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last );
|
|
34543
|
+
for ( i = end - dim; i >= start; i -= dim ) last = insertNode$1( i, data[ i ], data[ i + 1 ], last );
|
|
34401
34544
|
|
|
34402
34545
|
}
|
|
34403
34546
|
|
|
34404
|
-
if ( last && equals( last, last.next ) ) {
|
|
34547
|
+
if ( last && equals$1( last, last.next ) ) {
|
|
34405
34548
|
|
|
34406
|
-
removeNode( last );
|
|
34549
|
+
removeNode$1( last );
|
|
34407
34550
|
last = last.next;
|
|
34408
34551
|
|
|
34409
34552
|
}
|
|
@@ -34413,7 +34556,7 @@ void main() {
|
|
|
34413
34556
|
}
|
|
34414
34557
|
|
|
34415
34558
|
// eliminate colinear or duplicate points
|
|
34416
|
-
function filterPoints( start, end ) {
|
|
34559
|
+
function filterPoints$1( start, end ) {
|
|
34417
34560
|
|
|
34418
34561
|
if ( ! start ) return start;
|
|
34419
34562
|
if ( ! end ) end = start;
|
|
@@ -34424,9 +34567,9 @@ void main() {
|
|
|
34424
34567
|
|
|
34425
34568
|
again = false;
|
|
34426
34569
|
|
|
34427
|
-
if ( ! p.steiner && ( equals( p, p.next ) || area( p.prev, p, p.next ) === 0 ) ) {
|
|
34570
|
+
if ( ! p.steiner && ( equals$1( p, p.next ) || area$1( p.prev, p, p.next ) === 0 ) ) {
|
|
34428
34571
|
|
|
34429
|
-
removeNode( p );
|
|
34572
|
+
removeNode$1( p );
|
|
34430
34573
|
p = end = p.prev;
|
|
34431
34574
|
if ( p === p.next ) break;
|
|
34432
34575
|
again = true;
|
|
@@ -34444,12 +34587,12 @@ void main() {
|
|
|
34444
34587
|
}
|
|
34445
34588
|
|
|
34446
34589
|
// main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
34447
|
-
function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) {
|
|
34590
|
+
function earcutLinked$1( ear, triangles, dim, minX, minY, invSize, pass ) {
|
|
34448
34591
|
|
|
34449
34592
|
if ( ! ear ) return;
|
|
34450
34593
|
|
|
34451
34594
|
// interlink polygon nodes in z-order
|
|
34452
|
-
if ( ! pass && invSize ) indexCurve( ear, minX, minY, invSize );
|
|
34595
|
+
if ( ! pass && invSize ) indexCurve$1( ear, minX, minY, invSize );
|
|
34453
34596
|
|
|
34454
34597
|
let stop = ear,
|
|
34455
34598
|
prev, next;
|
|
@@ -34460,14 +34603,14 @@ void main() {
|
|
|
34460
34603
|
prev = ear.prev;
|
|
34461
34604
|
next = ear.next;
|
|
34462
34605
|
|
|
34463
|
-
if ( invSize ? isEarHashed( ear, minX, minY, invSize ) : isEar( ear ) ) {
|
|
34606
|
+
if ( invSize ? isEarHashed$1( ear, minX, minY, invSize ) : isEar$1( ear ) ) {
|
|
34464
34607
|
|
|
34465
34608
|
// cut off the triangle
|
|
34466
34609
|
triangles.push( prev.i / dim | 0 );
|
|
34467
34610
|
triangles.push( ear.i / dim | 0 );
|
|
34468
34611
|
triangles.push( next.i / dim | 0 );
|
|
34469
34612
|
|
|
34470
|
-
removeNode( ear );
|
|
34613
|
+
removeNode$1( ear );
|
|
34471
34614
|
|
|
34472
34615
|
// skipping the next vertex leads to less sliver triangles
|
|
34473
34616
|
ear = next.next;
|
|
@@ -34485,20 +34628,20 @@ void main() {
|
|
|
34485
34628
|
// try filtering points and slicing again
|
|
34486
34629
|
if ( ! pass ) {
|
|
34487
34630
|
|
|
34488
|
-
earcutLinked( filterPoints( ear ), triangles, dim, minX, minY, invSize, 1 );
|
|
34631
|
+
earcutLinked$1( filterPoints$1( ear ), triangles, dim, minX, minY, invSize, 1 );
|
|
34489
34632
|
|
|
34490
34633
|
// if this didn't work, try curing all small self-intersections locally
|
|
34491
34634
|
|
|
34492
34635
|
} else if ( pass === 1 ) {
|
|
34493
34636
|
|
|
34494
|
-
ear = cureLocalIntersections( filterPoints( ear ), triangles, dim );
|
|
34495
|
-
earcutLinked( ear, triangles, dim, minX, minY, invSize, 2 );
|
|
34637
|
+
ear = cureLocalIntersections$1( filterPoints$1( ear ), triangles, dim );
|
|
34638
|
+
earcutLinked$1( ear, triangles, dim, minX, minY, invSize, 2 );
|
|
34496
34639
|
|
|
34497
34640
|
// as a last resort, try splitting the remaining polygon into two
|
|
34498
34641
|
|
|
34499
34642
|
} else if ( pass === 2 ) {
|
|
34500
34643
|
|
|
34501
|
-
splitEarcut( ear, triangles, dim, minX, minY, invSize );
|
|
34644
|
+
splitEarcut$1( ear, triangles, dim, minX, minY, invSize );
|
|
34502
34645
|
|
|
34503
34646
|
}
|
|
34504
34647
|
|
|
@@ -34511,13 +34654,13 @@ void main() {
|
|
|
34511
34654
|
}
|
|
34512
34655
|
|
|
34513
34656
|
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
34514
|
-
function isEar( ear ) {
|
|
34657
|
+
function isEar$1( ear ) {
|
|
34515
34658
|
|
|
34516
34659
|
const a = ear.prev,
|
|
34517
34660
|
b = ear,
|
|
34518
34661
|
c = ear.next;
|
|
34519
34662
|
|
|
34520
|
-
if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
|
|
34663
|
+
if ( area$1( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
|
|
34521
34664
|
|
|
34522
34665
|
// now make sure we don't have other points inside the potential ear
|
|
34523
34666
|
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
@@ -34532,8 +34675,8 @@ void main() {
|
|
|
34532
34675
|
while ( p !== a ) {
|
|
34533
34676
|
|
|
34534
34677
|
if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
34535
|
-
pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) &&
|
|
34536
|
-
area( p.prev, p, p.next ) >= 0 ) return false;
|
|
34678
|
+
pointInTriangle$1( ax, ay, bx, by, cx, cy, p.x, p.y ) &&
|
|
34679
|
+
area$1( p.prev, p, p.next ) >= 0 ) return false;
|
|
34537
34680
|
p = p.next;
|
|
34538
34681
|
|
|
34539
34682
|
}
|
|
@@ -34542,13 +34685,13 @@ void main() {
|
|
|
34542
34685
|
|
|
34543
34686
|
}
|
|
34544
34687
|
|
|
34545
|
-
function isEarHashed( ear, minX, minY, invSize ) {
|
|
34688
|
+
function isEarHashed$1( ear, minX, minY, invSize ) {
|
|
34546
34689
|
|
|
34547
34690
|
const a = ear.prev,
|
|
34548
34691
|
b = ear,
|
|
34549
34692
|
c = ear.next;
|
|
34550
34693
|
|
|
34551
|
-
if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
|
|
34694
|
+
if ( area$1( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
|
|
34552
34695
|
|
|
34553
34696
|
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
34554
34697
|
|
|
@@ -34559,8 +34702,8 @@ void main() {
|
|
|
34559
34702
|
y1 = ay > by ? ( ay > cy ? ay : cy ) : ( by > cy ? by : cy );
|
|
34560
34703
|
|
|
34561
34704
|
// z-order range for the current triangle bbox;
|
|
34562
|
-
const minZ = zOrder( x0, y0, minX, minY, invSize ),
|
|
34563
|
-
maxZ = zOrder( x1, y1, minX, minY, invSize );
|
|
34705
|
+
const minZ = zOrder$1( x0, y0, minX, minY, invSize ),
|
|
34706
|
+
maxZ = zOrder$1( x1, y1, minX, minY, invSize );
|
|
34564
34707
|
|
|
34565
34708
|
let p = ear.prevZ,
|
|
34566
34709
|
n = ear.nextZ;
|
|
@@ -34569,11 +34712,11 @@ void main() {
|
|
|
34569
34712
|
while ( p && p.z >= minZ && n && n.z <= maxZ ) {
|
|
34570
34713
|
|
|
34571
34714
|
if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
34572
|
-
pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) && area( p.prev, p, p.next ) >= 0 ) return false;
|
|
34715
|
+
pointInTriangle$1( ax, ay, bx, by, cx, cy, p.x, p.y ) && area$1( p.prev, p, p.next ) >= 0 ) return false;
|
|
34573
34716
|
p = p.prevZ;
|
|
34574
34717
|
|
|
34575
34718
|
if ( n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
34576
|
-
pointInTriangle( ax, ay, bx, by, cx, cy, n.x, n.y ) && area( n.prev, n, n.next ) >= 0 ) return false;
|
|
34719
|
+
pointInTriangle$1( ax, ay, bx, by, cx, cy, n.x, n.y ) && area$1( n.prev, n, n.next ) >= 0 ) return false;
|
|
34577
34720
|
n = n.nextZ;
|
|
34578
34721
|
|
|
34579
34722
|
}
|
|
@@ -34582,7 +34725,7 @@ void main() {
|
|
|
34582
34725
|
while ( p && p.z >= minZ ) {
|
|
34583
34726
|
|
|
34584
34727
|
if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
34585
|
-
pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) && area( p.prev, p, p.next ) >= 0 ) return false;
|
|
34728
|
+
pointInTriangle$1( ax, ay, bx, by, cx, cy, p.x, p.y ) && area$1( p.prev, p, p.next ) >= 0 ) return false;
|
|
34586
34729
|
p = p.prevZ;
|
|
34587
34730
|
|
|
34588
34731
|
}
|
|
@@ -34591,7 +34734,7 @@ void main() {
|
|
|
34591
34734
|
while ( n && n.z <= maxZ ) {
|
|
34592
34735
|
|
|
34593
34736
|
if ( n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
34594
|
-
pointInTriangle( ax, ay, bx, by, cx, cy, n.x, n.y ) && area( n.prev, n, n.next ) >= 0 ) return false;
|
|
34737
|
+
pointInTriangle$1( ax, ay, bx, by, cx, cy, n.x, n.y ) && area$1( n.prev, n, n.next ) >= 0 ) return false;
|
|
34595
34738
|
n = n.nextZ;
|
|
34596
34739
|
|
|
34597
34740
|
}
|
|
@@ -34601,7 +34744,7 @@ void main() {
|
|
|
34601
34744
|
}
|
|
34602
34745
|
|
|
34603
34746
|
// go through all polygon nodes and cure small local self-intersections
|
|
34604
|
-
function cureLocalIntersections( start, triangles, dim ) {
|
|
34747
|
+
function cureLocalIntersections$1( start, triangles, dim ) {
|
|
34605
34748
|
|
|
34606
34749
|
let p = start;
|
|
34607
34750
|
do {
|
|
@@ -34609,15 +34752,15 @@ void main() {
|
|
|
34609
34752
|
const a = p.prev,
|
|
34610
34753
|
b = p.next.next;
|
|
34611
34754
|
|
|
34612
|
-
if ( ! equals( a, b ) && intersects( a, p, p.next, b ) && locallyInside( a, b ) && locallyInside( b, a ) ) {
|
|
34755
|
+
if ( ! equals$1( a, b ) && intersects$1( a, p, p.next, b ) && locallyInside$1( a, b ) && locallyInside$1( b, a ) ) {
|
|
34613
34756
|
|
|
34614
34757
|
triangles.push( a.i / dim | 0 );
|
|
34615
34758
|
triangles.push( p.i / dim | 0 );
|
|
34616
34759
|
triangles.push( b.i / dim | 0 );
|
|
34617
34760
|
|
|
34618
34761
|
// remove two nodes involved
|
|
34619
|
-
removeNode( p );
|
|
34620
|
-
removeNode( p.next );
|
|
34762
|
+
removeNode$1( p );
|
|
34763
|
+
removeNode$1( p.next );
|
|
34621
34764
|
|
|
34622
34765
|
p = start = b;
|
|
34623
34766
|
|
|
@@ -34627,12 +34770,12 @@ void main() {
|
|
|
34627
34770
|
|
|
34628
34771
|
} while ( p !== start );
|
|
34629
34772
|
|
|
34630
|
-
return filterPoints( p );
|
|
34773
|
+
return filterPoints$1( p );
|
|
34631
34774
|
|
|
34632
34775
|
}
|
|
34633
34776
|
|
|
34634
34777
|
// try splitting polygon into two and triangulate them independently
|
|
34635
|
-
function splitEarcut( start, triangles, dim, minX, minY, invSize ) {
|
|
34778
|
+
function splitEarcut$1( start, triangles, dim, minX, minY, invSize ) {
|
|
34636
34779
|
|
|
34637
34780
|
// look for a valid diagonal that divides the polygon into two
|
|
34638
34781
|
let a = start;
|
|
@@ -34641,18 +34784,18 @@ void main() {
|
|
|
34641
34784
|
let b = a.next.next;
|
|
34642
34785
|
while ( b !== a.prev ) {
|
|
34643
34786
|
|
|
34644
|
-
if ( a.i !== b.i && isValidDiagonal( a, b ) ) {
|
|
34787
|
+
if ( a.i !== b.i && isValidDiagonal$1( a, b ) ) {
|
|
34645
34788
|
|
|
34646
34789
|
// split the polygon in two by the diagonal
|
|
34647
|
-
let c = splitPolygon( a, b );
|
|
34790
|
+
let c = splitPolygon$1( a, b );
|
|
34648
34791
|
|
|
34649
34792
|
// filter colinear points around the cuts
|
|
34650
|
-
a = filterPoints( a, a.next );
|
|
34651
|
-
c = filterPoints( c, c.next );
|
|
34793
|
+
a = filterPoints$1( a, a.next );
|
|
34794
|
+
c = filterPoints$1( c, c.next );
|
|
34652
34795
|
|
|
34653
34796
|
// run earcut on each half
|
|
34654
|
-
earcutLinked( a, triangles, dim, minX, minY, invSize, 0 );
|
|
34655
|
-
earcutLinked( c, triangles, dim, minX, minY, invSize, 0 );
|
|
34797
|
+
earcutLinked$1( a, triangles, dim, minX, minY, invSize, 0 );
|
|
34798
|
+
earcutLinked$1( c, triangles, dim, minX, minY, invSize, 0 );
|
|
34656
34799
|
return;
|
|
34657
34800
|
|
|
34658
34801
|
}
|
|
@@ -34668,7 +34811,7 @@ void main() {
|
|
|
34668
34811
|
}
|
|
34669
34812
|
|
|
34670
34813
|
// link every hole into the outer loop, producing a single-ring polygon without holes
|
|
34671
|
-
function eliminateHoles( data, holeIndices, outerNode, dim ) {
|
|
34814
|
+
function eliminateHoles$1( data, holeIndices, outerNode, dim ) {
|
|
34672
34815
|
|
|
34673
34816
|
const queue = [];
|
|
34674
34817
|
let i, len, start, end, list;
|
|
@@ -34677,18 +34820,18 @@ void main() {
|
|
|
34677
34820
|
|
|
34678
34821
|
start = holeIndices[ i ] * dim;
|
|
34679
34822
|
end = i < len - 1 ? holeIndices[ i + 1 ] * dim : data.length;
|
|
34680
|
-
list = linkedList( data, start, end, dim, false );
|
|
34823
|
+
list = linkedList$1( data, start, end, dim, false );
|
|
34681
34824
|
if ( list === list.next ) list.steiner = true;
|
|
34682
|
-
queue.push( getLeftmost( list ) );
|
|
34825
|
+
queue.push( getLeftmost$1( list ) );
|
|
34683
34826
|
|
|
34684
34827
|
}
|
|
34685
34828
|
|
|
34686
|
-
queue.sort( compareX );
|
|
34829
|
+
queue.sort( compareX$1 );
|
|
34687
34830
|
|
|
34688
34831
|
// process holes from left to right
|
|
34689
34832
|
for ( i = 0; i < queue.length; i ++ ) {
|
|
34690
34833
|
|
|
34691
|
-
outerNode = eliminateHole( queue[ i ], outerNode );
|
|
34834
|
+
outerNode = eliminateHole$1( queue[ i ], outerNode );
|
|
34692
34835
|
|
|
34693
34836
|
}
|
|
34694
34837
|
|
|
@@ -34696,32 +34839,32 @@ void main() {
|
|
|
34696
34839
|
|
|
34697
34840
|
}
|
|
34698
34841
|
|
|
34699
|
-
function compareX( a, b ) {
|
|
34842
|
+
function compareX$1( a, b ) {
|
|
34700
34843
|
|
|
34701
34844
|
return a.x - b.x;
|
|
34702
34845
|
|
|
34703
34846
|
}
|
|
34704
34847
|
|
|
34705
34848
|
// find a bridge between vertices that connects hole with an outer ring and link it
|
|
34706
|
-
function eliminateHole( hole, outerNode ) {
|
|
34849
|
+
function eliminateHole$1( hole, outerNode ) {
|
|
34707
34850
|
|
|
34708
|
-
const bridge = findHoleBridge( hole, outerNode );
|
|
34851
|
+
const bridge = findHoleBridge$1( hole, outerNode );
|
|
34709
34852
|
if ( ! bridge ) {
|
|
34710
34853
|
|
|
34711
34854
|
return outerNode;
|
|
34712
34855
|
|
|
34713
34856
|
}
|
|
34714
34857
|
|
|
34715
|
-
const bridgeReverse = splitPolygon( bridge, hole );
|
|
34858
|
+
const bridgeReverse = splitPolygon$1( bridge, hole );
|
|
34716
34859
|
|
|
34717
34860
|
// filter collinear points around the cuts
|
|
34718
|
-
filterPoints( bridgeReverse, bridgeReverse.next );
|
|
34719
|
-
return filterPoints( bridge, bridge.next );
|
|
34861
|
+
filterPoints$1( bridgeReverse, bridgeReverse.next );
|
|
34862
|
+
return filterPoints$1( bridge, bridge.next );
|
|
34720
34863
|
|
|
34721
34864
|
}
|
|
34722
34865
|
|
|
34723
34866
|
// David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
34724
|
-
function findHoleBridge( hole, outerNode ) {
|
|
34867
|
+
function findHoleBridge$1( hole, outerNode ) {
|
|
34725
34868
|
|
|
34726
34869
|
let p = outerNode,
|
|
34727
34870
|
qx = - Infinity,
|
|
@@ -34766,11 +34909,11 @@ void main() {
|
|
|
34766
34909
|
do {
|
|
34767
34910
|
|
|
34768
34911
|
if ( hx >= p.x && p.x >= mx && hx !== p.x &&
|
|
34769
|
-
pointInTriangle( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) {
|
|
34912
|
+
pointInTriangle$1( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) {
|
|
34770
34913
|
|
|
34771
34914
|
tan = Math.abs( hy - p.y ) / ( hx - p.x ); // tangential
|
|
34772
34915
|
|
|
34773
|
-
if ( locallyInside( p, hole ) && ( tan < tanMin || ( tan === tanMin && ( p.x > m.x || ( p.x === m.x && sectorContainsSector( m, p ) ) ) ) ) ) {
|
|
34916
|
+
if ( locallyInside$1( p, hole ) && ( tan < tanMin || ( tan === tanMin && ( p.x > m.x || ( p.x === m.x && sectorContainsSector$1( m, p ) ) ) ) ) ) {
|
|
34774
34917
|
|
|
34775
34918
|
m = p;
|
|
34776
34919
|
tanMin = tan;
|
|
@@ -34788,19 +34931,19 @@ void main() {
|
|
|
34788
34931
|
}
|
|
34789
34932
|
|
|
34790
34933
|
// whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
34791
|
-
function sectorContainsSector( m, p ) {
|
|
34934
|
+
function sectorContainsSector$1( m, p ) {
|
|
34792
34935
|
|
|
34793
|
-
return area( m.prev, m, p.prev ) < 0 && area( p.next, m, m.next ) < 0;
|
|
34936
|
+
return area$1( m.prev, m, p.prev ) < 0 && area$1( p.next, m, m.next ) < 0;
|
|
34794
34937
|
|
|
34795
34938
|
}
|
|
34796
34939
|
|
|
34797
34940
|
// interlink polygon nodes in z-order
|
|
34798
|
-
function indexCurve( start, minX, minY, invSize ) {
|
|
34941
|
+
function indexCurve$1( start, minX, minY, invSize ) {
|
|
34799
34942
|
|
|
34800
34943
|
let p = start;
|
|
34801
34944
|
do {
|
|
34802
34945
|
|
|
34803
|
-
if ( p.z === 0 ) p.z = zOrder( p.x, p.y, minX, minY, invSize );
|
|
34946
|
+
if ( p.z === 0 ) p.z = zOrder$1( p.x, p.y, minX, minY, invSize );
|
|
34804
34947
|
p.prevZ = p.prev;
|
|
34805
34948
|
p.nextZ = p.next;
|
|
34806
34949
|
p = p.next;
|
|
@@ -34810,13 +34953,13 @@ void main() {
|
|
|
34810
34953
|
p.prevZ.nextZ = null;
|
|
34811
34954
|
p.prevZ = null;
|
|
34812
34955
|
|
|
34813
|
-
sortLinked( p );
|
|
34956
|
+
sortLinked$1( p );
|
|
34814
34957
|
|
|
34815
34958
|
}
|
|
34816
34959
|
|
|
34817
34960
|
// Simon Tatham's linked list merge sort algorithm
|
|
34818
34961
|
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
34819
|
-
function sortLinked( list ) {
|
|
34962
|
+
function sortLinked$1( list ) {
|
|
34820
34963
|
|
|
34821
34964
|
let i, p, q, e, tail, numMerges, pSize, qSize,
|
|
34822
34965
|
inSize = 1;
|
|
@@ -34881,7 +35024,7 @@ void main() {
|
|
|
34881
35024
|
}
|
|
34882
35025
|
|
|
34883
35026
|
// z-order of a point given coords and inverse of the longer side of data bbox
|
|
34884
|
-
function zOrder( x, y, minX, minY, invSize ) {
|
|
35027
|
+
function zOrder$1( x, y, minX, minY, invSize ) {
|
|
34885
35028
|
|
|
34886
35029
|
// coords are transformed into non-negative 15-bit integer range
|
|
34887
35030
|
x = ( x - minX ) * invSize | 0;
|
|
@@ -34902,7 +35045,7 @@ void main() {
|
|
|
34902
35045
|
}
|
|
34903
35046
|
|
|
34904
35047
|
// find the leftmost node of a polygon ring
|
|
34905
|
-
function getLeftmost( start ) {
|
|
35048
|
+
function getLeftmost$1( start ) {
|
|
34906
35049
|
|
|
34907
35050
|
let p = start,
|
|
34908
35051
|
leftmost = start;
|
|
@@ -34918,7 +35061,7 @@ void main() {
|
|
|
34918
35061
|
}
|
|
34919
35062
|
|
|
34920
35063
|
// check if a point lies within a convex triangle
|
|
34921
|
-
function pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) {
|
|
35064
|
+
function pointInTriangle$1( ax, ay, bx, by, cx, cy, px, py ) {
|
|
34922
35065
|
|
|
34923
35066
|
return ( cx - px ) * ( ay - py ) >= ( ax - px ) * ( cy - py ) &&
|
|
34924
35067
|
( ax - px ) * ( by - py ) >= ( bx - px ) * ( ay - py ) &&
|
|
@@ -34927,69 +35070,69 @@ void main() {
|
|
|
34927
35070
|
}
|
|
34928
35071
|
|
|
34929
35072
|
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
34930
|
-
function isValidDiagonal( a, b ) {
|
|
35073
|
+
function isValidDiagonal$1( a, b ) {
|
|
34931
35074
|
|
|
34932
|
-
return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // dones't intersect other edges
|
|
34933
|
-
( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible
|
|
34934
|
-
( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors
|
|
34935
|
-
equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case
|
|
35075
|
+
return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon$1( a, b ) && // dones't intersect other edges
|
|
35076
|
+
( locallyInside$1( a, b ) && locallyInside$1( b, a ) && middleInside$1( a, b ) && // locally visible
|
|
35077
|
+
( area$1( a.prev, a, b.prev ) || area$1( a, b.prev, b ) ) || // does not create opposite-facing sectors
|
|
35078
|
+
equals$1( a, b ) && area$1( a.prev, a, a.next ) > 0 && area$1( b.prev, b, b.next ) > 0 ); // special zero-length case
|
|
34936
35079
|
|
|
34937
35080
|
}
|
|
34938
35081
|
|
|
34939
35082
|
// signed area of a triangle
|
|
34940
|
-
function area( p, q, r ) {
|
|
35083
|
+
function area$1( p, q, r ) {
|
|
34941
35084
|
|
|
34942
35085
|
return ( q.y - p.y ) * ( r.x - q.x ) - ( q.x - p.x ) * ( r.y - q.y );
|
|
34943
35086
|
|
|
34944
35087
|
}
|
|
34945
35088
|
|
|
34946
35089
|
// check if two points are equal
|
|
34947
|
-
function equals( p1, p2 ) {
|
|
35090
|
+
function equals$1( p1, p2 ) {
|
|
34948
35091
|
|
|
34949
35092
|
return p1.x === p2.x && p1.y === p2.y;
|
|
34950
35093
|
|
|
34951
35094
|
}
|
|
34952
35095
|
|
|
34953
35096
|
// check if two segments intersect
|
|
34954
|
-
function intersects( p1, q1, p2, q2 ) {
|
|
35097
|
+
function intersects$1( p1, q1, p2, q2 ) {
|
|
34955
35098
|
|
|
34956
|
-
const o1 = sign$
|
|
34957
|
-
const o2 = sign$
|
|
34958
|
-
const o3 = sign$
|
|
34959
|
-
const o4 = sign$
|
|
35099
|
+
const o1 = sign$3( area$1( p1, q1, p2 ) );
|
|
35100
|
+
const o2 = sign$3( area$1( p1, q1, q2 ) );
|
|
35101
|
+
const o3 = sign$3( area$1( p2, q2, p1 ) );
|
|
35102
|
+
const o4 = sign$3( area$1( p2, q2, q1 ) );
|
|
34960
35103
|
|
|
34961
35104
|
if ( o1 !== o2 && o3 !== o4 ) return true; // general case
|
|
34962
35105
|
|
|
34963
|
-
if ( o1 === 0 && onSegment( p1, p2, q1 ) ) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
34964
|
-
if ( o2 === 0 && onSegment( p1, q2, q1 ) ) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
34965
|
-
if ( o3 === 0 && onSegment( p2, p1, q2 ) ) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
34966
|
-
if ( o4 === 0 && onSegment( p2, q1, q2 ) ) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
35106
|
+
if ( o1 === 0 && onSegment$1( p1, p2, q1 ) ) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
35107
|
+
if ( o2 === 0 && onSegment$1( p1, q2, q1 ) ) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
35108
|
+
if ( o3 === 0 && onSegment$1( p2, p1, q2 ) ) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
35109
|
+
if ( o4 === 0 && onSegment$1( p2, q1, q2 ) ) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
34967
35110
|
|
|
34968
35111
|
return false;
|
|
34969
35112
|
|
|
34970
35113
|
}
|
|
34971
35114
|
|
|
34972
35115
|
// for collinear points p, q, r, check if point q lies on segment pr
|
|
34973
|
-
function onSegment( p, q, r ) {
|
|
35116
|
+
function onSegment$1( p, q, r ) {
|
|
34974
35117
|
|
|
34975
35118
|
return q.x <= Math.max( p.x, r.x ) && q.x >= Math.min( p.x, r.x ) && q.y <= Math.max( p.y, r.y ) && q.y >= Math.min( p.y, r.y );
|
|
34976
35119
|
|
|
34977
35120
|
}
|
|
34978
35121
|
|
|
34979
|
-
function sign$
|
|
35122
|
+
function sign$3( num ) {
|
|
34980
35123
|
|
|
34981
35124
|
return num > 0 ? 1 : num < 0 ? - 1 : 0;
|
|
34982
35125
|
|
|
34983
35126
|
}
|
|
34984
35127
|
|
|
34985
35128
|
// check if a polygon diagonal intersects any polygon segments
|
|
34986
|
-
function intersectsPolygon( a, b ) {
|
|
35129
|
+
function intersectsPolygon$1( a, b ) {
|
|
34987
35130
|
|
|
34988
35131
|
let p = a;
|
|
34989
35132
|
do {
|
|
34990
35133
|
|
|
34991
35134
|
if ( p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
|
|
34992
|
-
intersects( p, p.next, a, b ) ) return true;
|
|
35135
|
+
intersects$1( p, p.next, a, b ) ) return true;
|
|
34993
35136
|
p = p.next;
|
|
34994
35137
|
|
|
34995
35138
|
} while ( p !== a );
|
|
@@ -34999,16 +35142,16 @@ void main() {
|
|
|
34999
35142
|
}
|
|
35000
35143
|
|
|
35001
35144
|
// check if a polygon diagonal is locally inside the polygon
|
|
35002
|
-
function locallyInside( a, b ) {
|
|
35145
|
+
function locallyInside$1( a, b ) {
|
|
35003
35146
|
|
|
35004
|
-
return area( a.prev, a, a.next ) < 0 ?
|
|
35005
|
-
area( a, b, a.next ) >= 0 && area( a, a.prev, b ) >= 0 :
|
|
35006
|
-
area( a, b, a.prev ) < 0 || area( a, a.next, b ) < 0;
|
|
35147
|
+
return area$1( a.prev, a, a.next ) < 0 ?
|
|
35148
|
+
area$1( a, b, a.next ) >= 0 && area$1( a, a.prev, b ) >= 0 :
|
|
35149
|
+
area$1( a, b, a.prev ) < 0 || area$1( a, a.next, b ) < 0;
|
|
35007
35150
|
|
|
35008
35151
|
}
|
|
35009
35152
|
|
|
35010
35153
|
// check if the middle point of a polygon diagonal is inside the polygon
|
|
35011
|
-
function middleInside( a, b ) {
|
|
35154
|
+
function middleInside$1( a, b ) {
|
|
35012
35155
|
|
|
35013
35156
|
let p = a,
|
|
35014
35157
|
inside = false;
|
|
@@ -35029,7 +35172,7 @@ void main() {
|
|
|
35029
35172
|
|
|
35030
35173
|
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
35031
35174
|
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
35032
|
-
function splitPolygon( a, b ) {
|
|
35175
|
+
function splitPolygon$1( a, b ) {
|
|
35033
35176
|
|
|
35034
35177
|
const a2 = new Node( a.i, a.x, a.y ),
|
|
35035
35178
|
b2 = new Node( b.i, b.x, b.y ),
|
|
@@ -35053,7 +35196,7 @@ void main() {
|
|
|
35053
35196
|
}
|
|
35054
35197
|
|
|
35055
35198
|
// create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
35056
|
-
function insertNode( i, x, y, last ) {
|
|
35199
|
+
function insertNode$1( i, x, y, last ) {
|
|
35057
35200
|
|
|
35058
35201
|
const p = new Node( i, x, y );
|
|
35059
35202
|
|
|
@@ -35075,7 +35218,7 @@ void main() {
|
|
|
35075
35218
|
|
|
35076
35219
|
}
|
|
35077
35220
|
|
|
35078
|
-
function removeNode( p ) {
|
|
35221
|
+
function removeNode$1( p ) {
|
|
35079
35222
|
|
|
35080
35223
|
p.next.prev = p.prev;
|
|
35081
35224
|
p.prev.next = p.next;
|
|
@@ -35110,7 +35253,7 @@ void main() {
|
|
|
35110
35253
|
|
|
35111
35254
|
}
|
|
35112
35255
|
|
|
35113
|
-
function signedArea( data, start, end, dim ) {
|
|
35256
|
+
function signedArea$1( data, start, end, dim ) {
|
|
35114
35257
|
|
|
35115
35258
|
let sum = 0;
|
|
35116
35259
|
for ( let i = start, j = end - dim; i < end; i += dim ) {
|
|
@@ -37454,7 +37597,7 @@ void main() {
|
|
|
37454
37597
|
|
|
37455
37598
|
function now$2() {
|
|
37456
37599
|
|
|
37457
|
-
return
|
|
37600
|
+
return performance.now();
|
|
37458
37601
|
|
|
37459
37602
|
}
|
|
37460
37603
|
|
|
@@ -38105,7 +38248,7 @@ void main() {
|
|
|
38105
38248
|
|
|
38106
38249
|
class Controls extends EventDispatcher {
|
|
38107
38250
|
|
|
38108
|
-
constructor( object, domElement ) {
|
|
38251
|
+
constructor( object, domElement = null ) {
|
|
38109
38252
|
|
|
38110
38253
|
super();
|
|
38111
38254
|
|
|
@@ -40172,6 +40315,619 @@ void main() {
|
|
|
40172
40315
|
*/
|
|
40173
40316
|
TWEEN.update.bind(TWEEN);
|
|
40174
40317
|
|
|
40318
|
+
function earcut(data, holeIndices, dim = 2) {
|
|
40319
|
+
|
|
40320
|
+
const hasHoles = holeIndices && holeIndices.length;
|
|
40321
|
+
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
40322
|
+
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
40323
|
+
const triangles = [];
|
|
40324
|
+
|
|
40325
|
+
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
|
|
40326
|
+
|
|
40327
|
+
let minX, minY, invSize;
|
|
40328
|
+
|
|
40329
|
+
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
40330
|
+
|
|
40331
|
+
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
40332
|
+
if (data.length > 80 * dim) {
|
|
40333
|
+
minX = Infinity;
|
|
40334
|
+
minY = Infinity;
|
|
40335
|
+
let maxX = -Infinity;
|
|
40336
|
+
let maxY = -Infinity;
|
|
40337
|
+
|
|
40338
|
+
for (let i = dim; i < outerLen; i += dim) {
|
|
40339
|
+
const x = data[i];
|
|
40340
|
+
const y = data[i + 1];
|
|
40341
|
+
if (x < minX) minX = x;
|
|
40342
|
+
if (y < minY) minY = y;
|
|
40343
|
+
if (x > maxX) maxX = x;
|
|
40344
|
+
if (y > maxY) maxY = y;
|
|
40345
|
+
}
|
|
40346
|
+
|
|
40347
|
+
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
|
|
40348
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
40349
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
40350
|
+
}
|
|
40351
|
+
|
|
40352
|
+
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
|
|
40353
|
+
|
|
40354
|
+
return triangles;
|
|
40355
|
+
}
|
|
40356
|
+
|
|
40357
|
+
// create a circular doubly linked list from polygon points in the specified winding order
|
|
40358
|
+
function linkedList(data, start, end, dim, clockwise) {
|
|
40359
|
+
let last;
|
|
40360
|
+
|
|
40361
|
+
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
|
|
40362
|
+
for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
40363
|
+
} else {
|
|
40364
|
+
for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
40365
|
+
}
|
|
40366
|
+
|
|
40367
|
+
if (last && equals(last, last.next)) {
|
|
40368
|
+
removeNode(last);
|
|
40369
|
+
last = last.next;
|
|
40370
|
+
}
|
|
40371
|
+
|
|
40372
|
+
return last;
|
|
40373
|
+
}
|
|
40374
|
+
|
|
40375
|
+
// eliminate colinear or duplicate points
|
|
40376
|
+
function filterPoints(start, end) {
|
|
40377
|
+
if (!start) return start;
|
|
40378
|
+
if (!end) end = start;
|
|
40379
|
+
|
|
40380
|
+
let p = start,
|
|
40381
|
+
again;
|
|
40382
|
+
do {
|
|
40383
|
+
again = false;
|
|
40384
|
+
|
|
40385
|
+
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
40386
|
+
removeNode(p);
|
|
40387
|
+
p = end = p.prev;
|
|
40388
|
+
if (p === p.next) break;
|
|
40389
|
+
again = true;
|
|
40390
|
+
|
|
40391
|
+
} else {
|
|
40392
|
+
p = p.next;
|
|
40393
|
+
}
|
|
40394
|
+
} while (again || p !== end);
|
|
40395
|
+
|
|
40396
|
+
return end;
|
|
40397
|
+
}
|
|
40398
|
+
|
|
40399
|
+
// main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
40400
|
+
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
|
|
40401
|
+
if (!ear) return;
|
|
40402
|
+
|
|
40403
|
+
// interlink polygon nodes in z-order
|
|
40404
|
+
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
|
|
40405
|
+
|
|
40406
|
+
let stop = ear;
|
|
40407
|
+
|
|
40408
|
+
// iterate through ears, slicing them one by one
|
|
40409
|
+
while (ear.prev !== ear.next) {
|
|
40410
|
+
const prev = ear.prev;
|
|
40411
|
+
const next = ear.next;
|
|
40412
|
+
|
|
40413
|
+
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
40414
|
+
triangles.push(prev.i, ear.i, next.i); // cut off the triangle
|
|
40415
|
+
|
|
40416
|
+
removeNode(ear);
|
|
40417
|
+
|
|
40418
|
+
// skipping the next vertex leads to less sliver triangles
|
|
40419
|
+
ear = next.next;
|
|
40420
|
+
stop = next.next;
|
|
40421
|
+
|
|
40422
|
+
continue;
|
|
40423
|
+
}
|
|
40424
|
+
|
|
40425
|
+
ear = next;
|
|
40426
|
+
|
|
40427
|
+
// if we looped through the whole remaining polygon and can't find any more ears
|
|
40428
|
+
if (ear === stop) {
|
|
40429
|
+
// try filtering points and slicing again
|
|
40430
|
+
if (!pass) {
|
|
40431
|
+
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
40432
|
+
|
|
40433
|
+
// if this didn't work, try curing all small self-intersections locally
|
|
40434
|
+
} else if (pass === 1) {
|
|
40435
|
+
ear = cureLocalIntersections(filterPoints(ear), triangles);
|
|
40436
|
+
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
40437
|
+
|
|
40438
|
+
// as a last resort, try splitting the remaining polygon into two
|
|
40439
|
+
} else if (pass === 2) {
|
|
40440
|
+
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
40441
|
+
}
|
|
40442
|
+
|
|
40443
|
+
break;
|
|
40444
|
+
}
|
|
40445
|
+
}
|
|
40446
|
+
}
|
|
40447
|
+
|
|
40448
|
+
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
40449
|
+
function isEar(ear) {
|
|
40450
|
+
const a = ear.prev,
|
|
40451
|
+
b = ear,
|
|
40452
|
+
c = ear.next;
|
|
40453
|
+
|
|
40454
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
40455
|
+
|
|
40456
|
+
// now make sure we don't have other points inside the potential ear
|
|
40457
|
+
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
40458
|
+
|
|
40459
|
+
// triangle bbox; min & max are calculated like this for speed
|
|
40460
|
+
const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
40461
|
+
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
40462
|
+
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
40463
|
+
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
40464
|
+
|
|
40465
|
+
let p = c.next;
|
|
40466
|
+
while (p !== a) {
|
|
40467
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
40468
|
+
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
|
|
40469
|
+
area(p.prev, p, p.next) >= 0) return false;
|
|
40470
|
+
p = p.next;
|
|
40471
|
+
}
|
|
40472
|
+
|
|
40473
|
+
return true;
|
|
40474
|
+
}
|
|
40475
|
+
|
|
40476
|
+
function isEarHashed(ear, minX, minY, invSize) {
|
|
40477
|
+
const a = ear.prev,
|
|
40478
|
+
b = ear,
|
|
40479
|
+
c = ear.next;
|
|
40480
|
+
|
|
40481
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
40482
|
+
|
|
40483
|
+
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
40484
|
+
|
|
40485
|
+
// triangle bbox; min & max are calculated like this for speed
|
|
40486
|
+
const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
40487
|
+
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
40488
|
+
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
40489
|
+
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
40490
|
+
|
|
40491
|
+
// z-order range for the current triangle bbox;
|
|
40492
|
+
const minZ = zOrder(x0, y0, minX, minY, invSize),
|
|
40493
|
+
maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
40494
|
+
|
|
40495
|
+
let p = ear.prevZ,
|
|
40496
|
+
n = ear.nextZ;
|
|
40497
|
+
|
|
40498
|
+
// look for points inside the triangle in both directions
|
|
40499
|
+
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
40500
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
40501
|
+
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
40502
|
+
p = p.prevZ;
|
|
40503
|
+
|
|
40504
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
40505
|
+
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
40506
|
+
n = n.nextZ;
|
|
40507
|
+
}
|
|
40508
|
+
|
|
40509
|
+
// look for remaining points in decreasing z-order
|
|
40510
|
+
while (p && p.z >= minZ) {
|
|
40511
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
40512
|
+
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
40513
|
+
p = p.prevZ;
|
|
40514
|
+
}
|
|
40515
|
+
|
|
40516
|
+
// look for remaining points in increasing z-order
|
|
40517
|
+
while (n && n.z <= maxZ) {
|
|
40518
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
40519
|
+
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
40520
|
+
n = n.nextZ;
|
|
40521
|
+
}
|
|
40522
|
+
|
|
40523
|
+
return true;
|
|
40524
|
+
}
|
|
40525
|
+
|
|
40526
|
+
// go through all polygon nodes and cure small local self-intersections
|
|
40527
|
+
function cureLocalIntersections(start, triangles) {
|
|
40528
|
+
let p = start;
|
|
40529
|
+
do {
|
|
40530
|
+
const a = p.prev,
|
|
40531
|
+
b = p.next.next;
|
|
40532
|
+
|
|
40533
|
+
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
40534
|
+
|
|
40535
|
+
triangles.push(a.i, p.i, b.i);
|
|
40536
|
+
|
|
40537
|
+
// remove two nodes involved
|
|
40538
|
+
removeNode(p);
|
|
40539
|
+
removeNode(p.next);
|
|
40540
|
+
|
|
40541
|
+
p = start = b;
|
|
40542
|
+
}
|
|
40543
|
+
p = p.next;
|
|
40544
|
+
} while (p !== start);
|
|
40545
|
+
|
|
40546
|
+
return filterPoints(p);
|
|
40547
|
+
}
|
|
40548
|
+
|
|
40549
|
+
// try splitting polygon into two and triangulate them independently
|
|
40550
|
+
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
40551
|
+
// look for a valid diagonal that divides the polygon into two
|
|
40552
|
+
let a = start;
|
|
40553
|
+
do {
|
|
40554
|
+
let b = a.next.next;
|
|
40555
|
+
while (b !== a.prev) {
|
|
40556
|
+
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
40557
|
+
// split the polygon in two by the diagonal
|
|
40558
|
+
let c = splitPolygon(a, b);
|
|
40559
|
+
|
|
40560
|
+
// filter colinear points around the cuts
|
|
40561
|
+
a = filterPoints(a, a.next);
|
|
40562
|
+
c = filterPoints(c, c.next);
|
|
40563
|
+
|
|
40564
|
+
// run earcut on each half
|
|
40565
|
+
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
40566
|
+
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
40567
|
+
return;
|
|
40568
|
+
}
|
|
40569
|
+
b = b.next;
|
|
40570
|
+
}
|
|
40571
|
+
a = a.next;
|
|
40572
|
+
} while (a !== start);
|
|
40573
|
+
}
|
|
40574
|
+
|
|
40575
|
+
// link every hole into the outer loop, producing a single-ring polygon without holes
|
|
40576
|
+
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
40577
|
+
const queue = [];
|
|
40578
|
+
|
|
40579
|
+
for (let i = 0, len = holeIndices.length; i < len; i++) {
|
|
40580
|
+
const start = holeIndices[i] * dim;
|
|
40581
|
+
const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
40582
|
+
const list = linkedList(data, start, end, dim, false);
|
|
40583
|
+
if (list === list.next) list.steiner = true;
|
|
40584
|
+
queue.push(getLeftmost(list));
|
|
40585
|
+
}
|
|
40586
|
+
|
|
40587
|
+
queue.sort(compareX);
|
|
40588
|
+
|
|
40589
|
+
// process holes from left to right
|
|
40590
|
+
for (let i = 0; i < queue.length; i++) {
|
|
40591
|
+
outerNode = eliminateHole(queue[i], outerNode);
|
|
40592
|
+
}
|
|
40593
|
+
|
|
40594
|
+
return outerNode;
|
|
40595
|
+
}
|
|
40596
|
+
|
|
40597
|
+
function compareX(a, b) {
|
|
40598
|
+
return a.x - b.x;
|
|
40599
|
+
}
|
|
40600
|
+
|
|
40601
|
+
// find a bridge between vertices that connects hole with an outer ring and and link it
|
|
40602
|
+
function eliminateHole(hole, outerNode) {
|
|
40603
|
+
const bridge = findHoleBridge(hole, outerNode);
|
|
40604
|
+
if (!bridge) {
|
|
40605
|
+
return outerNode;
|
|
40606
|
+
}
|
|
40607
|
+
|
|
40608
|
+
const bridgeReverse = splitPolygon(bridge, hole);
|
|
40609
|
+
|
|
40610
|
+
// filter collinear points around the cuts
|
|
40611
|
+
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
40612
|
+
return filterPoints(bridge, bridge.next);
|
|
40613
|
+
}
|
|
40614
|
+
|
|
40615
|
+
// David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
40616
|
+
function findHoleBridge(hole, outerNode) {
|
|
40617
|
+
let p = outerNode;
|
|
40618
|
+
const hx = hole.x;
|
|
40619
|
+
const hy = hole.y;
|
|
40620
|
+
let qx = -Infinity;
|
|
40621
|
+
let m;
|
|
40622
|
+
|
|
40623
|
+
// find a segment intersected by a ray from the hole's leftmost point to the left;
|
|
40624
|
+
// segment's endpoint with lesser x will be potential connection point
|
|
40625
|
+
do {
|
|
40626
|
+
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
40627
|
+
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
40628
|
+
if (x <= hx && x > qx) {
|
|
40629
|
+
qx = x;
|
|
40630
|
+
m = p.x < p.next.x ? p : p.next;
|
|
40631
|
+
if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
|
|
40632
|
+
}
|
|
40633
|
+
}
|
|
40634
|
+
p = p.next;
|
|
40635
|
+
} while (p !== outerNode);
|
|
40636
|
+
|
|
40637
|
+
if (!m) return null;
|
|
40638
|
+
|
|
40639
|
+
// look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
40640
|
+
// if there are no points found, we have a valid connection;
|
|
40641
|
+
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
40642
|
+
|
|
40643
|
+
const stop = m;
|
|
40644
|
+
const mx = m.x;
|
|
40645
|
+
const my = m.y;
|
|
40646
|
+
let tanMin = Infinity;
|
|
40647
|
+
|
|
40648
|
+
p = m;
|
|
40649
|
+
|
|
40650
|
+
do {
|
|
40651
|
+
if (hx >= p.x && p.x >= mx && hx !== p.x &&
|
|
40652
|
+
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
40653
|
+
|
|
40654
|
+
const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
40655
|
+
|
|
40656
|
+
if (locallyInside(p, hole) &&
|
|
40657
|
+
(tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
|
|
40658
|
+
m = p;
|
|
40659
|
+
tanMin = tan;
|
|
40660
|
+
}
|
|
40661
|
+
}
|
|
40662
|
+
|
|
40663
|
+
p = p.next;
|
|
40664
|
+
} while (p !== stop);
|
|
40665
|
+
|
|
40666
|
+
return m;
|
|
40667
|
+
}
|
|
40668
|
+
|
|
40669
|
+
// whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
40670
|
+
function sectorContainsSector(m, p) {
|
|
40671
|
+
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
40672
|
+
}
|
|
40673
|
+
|
|
40674
|
+
// interlink polygon nodes in z-order
|
|
40675
|
+
function indexCurve(start, minX, minY, invSize) {
|
|
40676
|
+
let p = start;
|
|
40677
|
+
do {
|
|
40678
|
+
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
40679
|
+
p.prevZ = p.prev;
|
|
40680
|
+
p.nextZ = p.next;
|
|
40681
|
+
p = p.next;
|
|
40682
|
+
} while (p !== start);
|
|
40683
|
+
|
|
40684
|
+
p.prevZ.nextZ = null;
|
|
40685
|
+
p.prevZ = null;
|
|
40686
|
+
|
|
40687
|
+
sortLinked(p);
|
|
40688
|
+
}
|
|
40689
|
+
|
|
40690
|
+
// Simon Tatham's linked list merge sort algorithm
|
|
40691
|
+
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
40692
|
+
function sortLinked(list) {
|
|
40693
|
+
let numMerges;
|
|
40694
|
+
let inSize = 1;
|
|
40695
|
+
|
|
40696
|
+
do {
|
|
40697
|
+
let p = list;
|
|
40698
|
+
let e;
|
|
40699
|
+
list = null;
|
|
40700
|
+
let tail = null;
|
|
40701
|
+
numMerges = 0;
|
|
40702
|
+
|
|
40703
|
+
while (p) {
|
|
40704
|
+
numMerges++;
|
|
40705
|
+
let q = p;
|
|
40706
|
+
let pSize = 0;
|
|
40707
|
+
for (let i = 0; i < inSize; i++) {
|
|
40708
|
+
pSize++;
|
|
40709
|
+
q = q.nextZ;
|
|
40710
|
+
if (!q) break;
|
|
40711
|
+
}
|
|
40712
|
+
let qSize = inSize;
|
|
40713
|
+
|
|
40714
|
+
while (pSize > 0 || (qSize > 0 && q)) {
|
|
40715
|
+
|
|
40716
|
+
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
40717
|
+
e = p;
|
|
40718
|
+
p = p.nextZ;
|
|
40719
|
+
pSize--;
|
|
40720
|
+
} else {
|
|
40721
|
+
e = q;
|
|
40722
|
+
q = q.nextZ;
|
|
40723
|
+
qSize--;
|
|
40724
|
+
}
|
|
40725
|
+
|
|
40726
|
+
if (tail) tail.nextZ = e;
|
|
40727
|
+
else list = e;
|
|
40728
|
+
|
|
40729
|
+
e.prevZ = tail;
|
|
40730
|
+
tail = e;
|
|
40731
|
+
}
|
|
40732
|
+
|
|
40733
|
+
p = q;
|
|
40734
|
+
}
|
|
40735
|
+
|
|
40736
|
+
tail.nextZ = null;
|
|
40737
|
+
inSize *= 2;
|
|
40738
|
+
|
|
40739
|
+
} while (numMerges > 1);
|
|
40740
|
+
|
|
40741
|
+
return list;
|
|
40742
|
+
}
|
|
40743
|
+
|
|
40744
|
+
// z-order of a point given coords and inverse of the longer side of data bbox
|
|
40745
|
+
function zOrder(x, y, minX, minY, invSize) {
|
|
40746
|
+
// coords are transformed into non-negative 15-bit integer range
|
|
40747
|
+
x = (x - minX) * invSize | 0;
|
|
40748
|
+
y = (y - minY) * invSize | 0;
|
|
40749
|
+
|
|
40750
|
+
x = (x | (x << 8)) & 0x00FF00FF;
|
|
40751
|
+
x = (x | (x << 4)) & 0x0F0F0F0F;
|
|
40752
|
+
x = (x | (x << 2)) & 0x33333333;
|
|
40753
|
+
x = (x | (x << 1)) & 0x55555555;
|
|
40754
|
+
|
|
40755
|
+
y = (y | (y << 8)) & 0x00FF00FF;
|
|
40756
|
+
y = (y | (y << 4)) & 0x0F0F0F0F;
|
|
40757
|
+
y = (y | (y << 2)) & 0x33333333;
|
|
40758
|
+
y = (y | (y << 1)) & 0x55555555;
|
|
40759
|
+
|
|
40760
|
+
return x | (y << 1);
|
|
40761
|
+
}
|
|
40762
|
+
|
|
40763
|
+
// find the leftmost node of a polygon ring
|
|
40764
|
+
function getLeftmost(start) {
|
|
40765
|
+
let p = start,
|
|
40766
|
+
leftmost = start;
|
|
40767
|
+
do {
|
|
40768
|
+
if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
|
|
40769
|
+
p = p.next;
|
|
40770
|
+
} while (p !== start);
|
|
40771
|
+
|
|
40772
|
+
return leftmost;
|
|
40773
|
+
}
|
|
40774
|
+
|
|
40775
|
+
// check if a point lies within a convex triangle
|
|
40776
|
+
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
40777
|
+
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
|
|
40778
|
+
(ax - px) * (by - py) >= (bx - px) * (ay - py) &&
|
|
40779
|
+
(bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
40780
|
+
}
|
|
40781
|
+
|
|
40782
|
+
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
40783
|
+
function isValidDiagonal(a, b) {
|
|
40784
|
+
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
|
|
40785
|
+
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
40786
|
+
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
40787
|
+
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
40788
|
+
}
|
|
40789
|
+
|
|
40790
|
+
// signed area of a triangle
|
|
40791
|
+
function area(p, q, r) {
|
|
40792
|
+
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
40793
|
+
}
|
|
40794
|
+
|
|
40795
|
+
// check if two points are equal
|
|
40796
|
+
function equals(p1, p2) {
|
|
40797
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
40798
|
+
}
|
|
40799
|
+
|
|
40800
|
+
// check if two segments intersect
|
|
40801
|
+
function intersects(p1, q1, p2, q2) {
|
|
40802
|
+
const o1 = sign$2(area(p1, q1, p2));
|
|
40803
|
+
const o2 = sign$2(area(p1, q1, q2));
|
|
40804
|
+
const o3 = sign$2(area(p2, q2, p1));
|
|
40805
|
+
const o4 = sign$2(area(p2, q2, q1));
|
|
40806
|
+
|
|
40807
|
+
if (o1 !== o2 && o3 !== o4) return true; // general case
|
|
40808
|
+
|
|
40809
|
+
if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
40810
|
+
if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
40811
|
+
if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
40812
|
+
if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
40813
|
+
|
|
40814
|
+
return false;
|
|
40815
|
+
}
|
|
40816
|
+
|
|
40817
|
+
// for collinear points p, q, r, check if point q lies on segment pr
|
|
40818
|
+
function onSegment(p, q, r) {
|
|
40819
|
+
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
40820
|
+
}
|
|
40821
|
+
|
|
40822
|
+
function sign$2(num) {
|
|
40823
|
+
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
40824
|
+
}
|
|
40825
|
+
|
|
40826
|
+
// check if a polygon diagonal intersects any polygon segments
|
|
40827
|
+
function intersectsPolygon(a, b) {
|
|
40828
|
+
let p = a;
|
|
40829
|
+
do {
|
|
40830
|
+
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
|
|
40831
|
+
intersects(p, p.next, a, b)) return true;
|
|
40832
|
+
p = p.next;
|
|
40833
|
+
} while (p !== a);
|
|
40834
|
+
|
|
40835
|
+
return false;
|
|
40836
|
+
}
|
|
40837
|
+
|
|
40838
|
+
// check if a polygon diagonal is locally inside the polygon
|
|
40839
|
+
function locallyInside(a, b) {
|
|
40840
|
+
return area(a.prev, a, a.next) < 0 ?
|
|
40841
|
+
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
|
|
40842
|
+
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
40843
|
+
}
|
|
40844
|
+
|
|
40845
|
+
// check if the middle point of a polygon diagonal is inside the polygon
|
|
40846
|
+
function middleInside(a, b) {
|
|
40847
|
+
let p = a;
|
|
40848
|
+
let inside = false;
|
|
40849
|
+
const px = (a.x + b.x) / 2;
|
|
40850
|
+
const py = (a.y + b.y) / 2;
|
|
40851
|
+
do {
|
|
40852
|
+
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
|
|
40853
|
+
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
|
|
40854
|
+
inside = !inside;
|
|
40855
|
+
p = p.next;
|
|
40856
|
+
} while (p !== a);
|
|
40857
|
+
|
|
40858
|
+
return inside;
|
|
40859
|
+
}
|
|
40860
|
+
|
|
40861
|
+
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
40862
|
+
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
40863
|
+
function splitPolygon(a, b) {
|
|
40864
|
+
const a2 = createNode(a.i, a.x, a.y),
|
|
40865
|
+
b2 = createNode(b.i, b.x, b.y),
|
|
40866
|
+
an = a.next,
|
|
40867
|
+
bp = b.prev;
|
|
40868
|
+
|
|
40869
|
+
a.next = b;
|
|
40870
|
+
b.prev = a;
|
|
40871
|
+
|
|
40872
|
+
a2.next = an;
|
|
40873
|
+
an.prev = a2;
|
|
40874
|
+
|
|
40875
|
+
b2.next = a2;
|
|
40876
|
+
a2.prev = b2;
|
|
40877
|
+
|
|
40878
|
+
bp.next = b2;
|
|
40879
|
+
b2.prev = bp;
|
|
40880
|
+
|
|
40881
|
+
return b2;
|
|
40882
|
+
}
|
|
40883
|
+
|
|
40884
|
+
// create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
40885
|
+
function insertNode(i, x, y, last) {
|
|
40886
|
+
const p = createNode(i, x, y);
|
|
40887
|
+
|
|
40888
|
+
if (!last) {
|
|
40889
|
+
p.prev = p;
|
|
40890
|
+
p.next = p;
|
|
40891
|
+
|
|
40892
|
+
} else {
|
|
40893
|
+
p.next = last.next;
|
|
40894
|
+
p.prev = last;
|
|
40895
|
+
last.next.prev = p;
|
|
40896
|
+
last.next = p;
|
|
40897
|
+
}
|
|
40898
|
+
return p;
|
|
40899
|
+
}
|
|
40900
|
+
|
|
40901
|
+
function removeNode(p) {
|
|
40902
|
+
p.next.prev = p.prev;
|
|
40903
|
+
p.prev.next = p.next;
|
|
40904
|
+
|
|
40905
|
+
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
|
|
40906
|
+
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
|
|
40907
|
+
}
|
|
40908
|
+
|
|
40909
|
+
function createNode(i, x, y) {
|
|
40910
|
+
return {
|
|
40911
|
+
i, // vertex index in coordinates array
|
|
40912
|
+
x, y, // vertex coordinates
|
|
40913
|
+
prev: null, // previous and next vertex nodes in a polygon ring
|
|
40914
|
+
next: null,
|
|
40915
|
+
z: 0, // z-order curve value
|
|
40916
|
+
prevZ: null, // previous and next nodes in z-order
|
|
40917
|
+
nextZ: null,
|
|
40918
|
+
steiner: false // indicates whether this is a steiner point
|
|
40919
|
+
};
|
|
40920
|
+
}
|
|
40921
|
+
|
|
40922
|
+
function signedArea(data, start, end, dim) {
|
|
40923
|
+
let sum = 0;
|
|
40924
|
+
for (let i = start, j = end - dim; i < end; i += dim) {
|
|
40925
|
+
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
40926
|
+
j = i;
|
|
40927
|
+
}
|
|
40928
|
+
return sum;
|
|
40929
|
+
}
|
|
40930
|
+
|
|
40175
40931
|
// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
|
|
40176
40932
|
function flatten$1(data) {
|
|
40177
40933
|
const vertices = [];
|
|
@@ -42754,14 +43510,14 @@ void main() {
|
|
|
42754
43510
|
return result;
|
|
42755
43511
|
};
|
|
42756
43512
|
|
|
42757
|
-
var THREE$
|
|
43513
|
+
var THREE$k = typeof window !== 'undefined' && window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
42758
43514
|
: {
|
|
42759
43515
|
BufferGeometry: BufferGeometry,
|
|
42760
43516
|
Float32BufferAttribute: Float32BufferAttribute
|
|
42761
43517
|
};
|
|
42762
43518
|
|
|
42763
43519
|
// support both modes for backwards threejs compatibility
|
|
42764
|
-
var setAttributeFn$
|
|
43520
|
+
var setAttributeFn$1 = new THREE$k.BufferGeometry().setAttribute ? 'setAttribute' : 'addAttribute';
|
|
42765
43521
|
var GeoJsonGeometry = /*#__PURE__*/function (_THREE$BufferGeometry) {
|
|
42766
43522
|
function GeoJsonGeometry(geoJson) {
|
|
42767
43523
|
var _this;
|
|
@@ -42803,7 +43559,7 @@ void main() {
|
|
|
42803
43559
|
|
|
42804
43560
|
// build geometry
|
|
42805
43561
|
indices.length && _this.setIndex(indices);
|
|
42806
|
-
vertices.length && _this[setAttributeFn$
|
|
43562
|
+
vertices.length && _this[setAttributeFn$1]('position', new THREE$k.Float32BufferAttribute(vertices, 3));
|
|
42807
43563
|
|
|
42808
43564
|
//
|
|
42809
43565
|
|
|
@@ -42930,7 +43686,7 @@ void main() {
|
|
|
42930
43686
|
}
|
|
42931
43687
|
_inherits$2(GeoJsonGeometry, _THREE$BufferGeometry);
|
|
42932
43688
|
return _createClass$2(GeoJsonGeometry);
|
|
42933
|
-
}(THREE$
|
|
43689
|
+
}(THREE$k.BufferGeometry); //
|
|
42934
43690
|
function concatGroup(main, extra) {
|
|
42935
43691
|
var prevVertCnt = Math.round(main.vertices.length / 3);
|
|
42936
43692
|
concatArr(main.vertices, extra.vertices);
|
|
@@ -47159,699 +47915,6 @@ void main() {
|
|
|
47159
47915
|
return linearish(scale);
|
|
47160
47916
|
}
|
|
47161
47917
|
|
|
47162
|
-
var earcut$1 = {exports: {}};
|
|
47163
|
-
|
|
47164
|
-
var hasRequiredEarcut;
|
|
47165
|
-
|
|
47166
|
-
function requireEarcut () {
|
|
47167
|
-
if (hasRequiredEarcut) return earcut$1.exports;
|
|
47168
|
-
hasRequiredEarcut = 1;
|
|
47169
|
-
|
|
47170
|
-
earcut$1.exports = earcut;
|
|
47171
|
-
earcut$1.exports.default = earcut;
|
|
47172
|
-
|
|
47173
|
-
function earcut(data, holeIndices, dim) {
|
|
47174
|
-
|
|
47175
|
-
dim = dim || 2;
|
|
47176
|
-
|
|
47177
|
-
var hasHoles = holeIndices && holeIndices.length,
|
|
47178
|
-
outerLen = hasHoles ? holeIndices[0] * dim : data.length,
|
|
47179
|
-
outerNode = linkedList(data, 0, outerLen, dim, true),
|
|
47180
|
-
triangles = [];
|
|
47181
|
-
|
|
47182
|
-
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
|
|
47183
|
-
|
|
47184
|
-
var minX, minY, maxX, maxY, x, y, invSize;
|
|
47185
|
-
|
|
47186
|
-
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
47187
|
-
|
|
47188
|
-
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
47189
|
-
if (data.length > 80 * dim) {
|
|
47190
|
-
minX = maxX = data[0];
|
|
47191
|
-
minY = maxY = data[1];
|
|
47192
|
-
|
|
47193
|
-
for (var i = dim; i < outerLen; i += dim) {
|
|
47194
|
-
x = data[i];
|
|
47195
|
-
y = data[i + 1];
|
|
47196
|
-
if (x < minX) minX = x;
|
|
47197
|
-
if (y < minY) minY = y;
|
|
47198
|
-
if (x > maxX) maxX = x;
|
|
47199
|
-
if (y > maxY) maxY = y;
|
|
47200
|
-
}
|
|
47201
|
-
|
|
47202
|
-
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
|
|
47203
|
-
invSize = Math.max(maxX - minX, maxY - minY);
|
|
47204
|
-
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
47205
|
-
}
|
|
47206
|
-
|
|
47207
|
-
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
|
|
47208
|
-
|
|
47209
|
-
return triangles;
|
|
47210
|
-
}
|
|
47211
|
-
|
|
47212
|
-
// create a circular doubly linked list from polygon points in the specified winding order
|
|
47213
|
-
function linkedList(data, start, end, dim, clockwise) {
|
|
47214
|
-
var i, last;
|
|
47215
|
-
|
|
47216
|
-
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
|
|
47217
|
-
for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
47218
|
-
} else {
|
|
47219
|
-
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
47220
|
-
}
|
|
47221
|
-
|
|
47222
|
-
if (last && equals(last, last.next)) {
|
|
47223
|
-
removeNode(last);
|
|
47224
|
-
last = last.next;
|
|
47225
|
-
}
|
|
47226
|
-
|
|
47227
|
-
return last;
|
|
47228
|
-
}
|
|
47229
|
-
|
|
47230
|
-
// eliminate colinear or duplicate points
|
|
47231
|
-
function filterPoints(start, end) {
|
|
47232
|
-
if (!start) return start;
|
|
47233
|
-
if (!end) end = start;
|
|
47234
|
-
|
|
47235
|
-
var p = start,
|
|
47236
|
-
again;
|
|
47237
|
-
do {
|
|
47238
|
-
again = false;
|
|
47239
|
-
|
|
47240
|
-
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
47241
|
-
removeNode(p);
|
|
47242
|
-
p = end = p.prev;
|
|
47243
|
-
if (p === p.next) break;
|
|
47244
|
-
again = true;
|
|
47245
|
-
|
|
47246
|
-
} else {
|
|
47247
|
-
p = p.next;
|
|
47248
|
-
}
|
|
47249
|
-
} while (again || p !== end);
|
|
47250
|
-
|
|
47251
|
-
return end;
|
|
47252
|
-
}
|
|
47253
|
-
|
|
47254
|
-
// main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
47255
|
-
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
|
|
47256
|
-
if (!ear) return;
|
|
47257
|
-
|
|
47258
|
-
// interlink polygon nodes in z-order
|
|
47259
|
-
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
|
|
47260
|
-
|
|
47261
|
-
var stop = ear,
|
|
47262
|
-
prev, next;
|
|
47263
|
-
|
|
47264
|
-
// iterate through ears, slicing them one by one
|
|
47265
|
-
while (ear.prev !== ear.next) {
|
|
47266
|
-
prev = ear.prev;
|
|
47267
|
-
next = ear.next;
|
|
47268
|
-
|
|
47269
|
-
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
47270
|
-
// cut off the triangle
|
|
47271
|
-
triangles.push(prev.i / dim | 0);
|
|
47272
|
-
triangles.push(ear.i / dim | 0);
|
|
47273
|
-
triangles.push(next.i / dim | 0);
|
|
47274
|
-
|
|
47275
|
-
removeNode(ear);
|
|
47276
|
-
|
|
47277
|
-
// skipping the next vertex leads to less sliver triangles
|
|
47278
|
-
ear = next.next;
|
|
47279
|
-
stop = next.next;
|
|
47280
|
-
|
|
47281
|
-
continue;
|
|
47282
|
-
}
|
|
47283
|
-
|
|
47284
|
-
ear = next;
|
|
47285
|
-
|
|
47286
|
-
// if we looped through the whole remaining polygon and can't find any more ears
|
|
47287
|
-
if (ear === stop) {
|
|
47288
|
-
// try filtering points and slicing again
|
|
47289
|
-
if (!pass) {
|
|
47290
|
-
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
47291
|
-
|
|
47292
|
-
// if this didn't work, try curing all small self-intersections locally
|
|
47293
|
-
} else if (pass === 1) {
|
|
47294
|
-
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
|
|
47295
|
-
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
47296
|
-
|
|
47297
|
-
// as a last resort, try splitting the remaining polygon into two
|
|
47298
|
-
} else if (pass === 2) {
|
|
47299
|
-
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
47300
|
-
}
|
|
47301
|
-
|
|
47302
|
-
break;
|
|
47303
|
-
}
|
|
47304
|
-
}
|
|
47305
|
-
}
|
|
47306
|
-
|
|
47307
|
-
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
47308
|
-
function isEar(ear) {
|
|
47309
|
-
var a = ear.prev,
|
|
47310
|
-
b = ear,
|
|
47311
|
-
c = ear.next;
|
|
47312
|
-
|
|
47313
|
-
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
47314
|
-
|
|
47315
|
-
// now make sure we don't have other points inside the potential ear
|
|
47316
|
-
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
47317
|
-
|
|
47318
|
-
// triangle bbox; min & max are calculated like this for speed
|
|
47319
|
-
var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
47320
|
-
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
47321
|
-
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
47322
|
-
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
47323
|
-
|
|
47324
|
-
var p = c.next;
|
|
47325
|
-
while (p !== a) {
|
|
47326
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
47327
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
|
|
47328
|
-
area(p.prev, p, p.next) >= 0) return false;
|
|
47329
|
-
p = p.next;
|
|
47330
|
-
}
|
|
47331
|
-
|
|
47332
|
-
return true;
|
|
47333
|
-
}
|
|
47334
|
-
|
|
47335
|
-
function isEarHashed(ear, minX, minY, invSize) {
|
|
47336
|
-
var a = ear.prev,
|
|
47337
|
-
b = ear,
|
|
47338
|
-
c = ear.next;
|
|
47339
|
-
|
|
47340
|
-
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
47341
|
-
|
|
47342
|
-
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
47343
|
-
|
|
47344
|
-
// triangle bbox; min & max are calculated like this for speed
|
|
47345
|
-
var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
47346
|
-
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
47347
|
-
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
47348
|
-
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
47349
|
-
|
|
47350
|
-
// z-order range for the current triangle bbox;
|
|
47351
|
-
var minZ = zOrder(x0, y0, minX, minY, invSize),
|
|
47352
|
-
maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
47353
|
-
|
|
47354
|
-
var p = ear.prevZ,
|
|
47355
|
-
n = ear.nextZ;
|
|
47356
|
-
|
|
47357
|
-
// look for points inside the triangle in both directions
|
|
47358
|
-
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
47359
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
47360
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
47361
|
-
p = p.prevZ;
|
|
47362
|
-
|
|
47363
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
47364
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
47365
|
-
n = n.nextZ;
|
|
47366
|
-
}
|
|
47367
|
-
|
|
47368
|
-
// look for remaining points in decreasing z-order
|
|
47369
|
-
while (p && p.z >= minZ) {
|
|
47370
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
47371
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
47372
|
-
p = p.prevZ;
|
|
47373
|
-
}
|
|
47374
|
-
|
|
47375
|
-
// look for remaining points in increasing z-order
|
|
47376
|
-
while (n && n.z <= maxZ) {
|
|
47377
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
47378
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
47379
|
-
n = n.nextZ;
|
|
47380
|
-
}
|
|
47381
|
-
|
|
47382
|
-
return true;
|
|
47383
|
-
}
|
|
47384
|
-
|
|
47385
|
-
// go through all polygon nodes and cure small local self-intersections
|
|
47386
|
-
function cureLocalIntersections(start, triangles, dim) {
|
|
47387
|
-
var p = start;
|
|
47388
|
-
do {
|
|
47389
|
-
var a = p.prev,
|
|
47390
|
-
b = p.next.next;
|
|
47391
|
-
|
|
47392
|
-
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
47393
|
-
|
|
47394
|
-
triangles.push(a.i / dim | 0);
|
|
47395
|
-
triangles.push(p.i / dim | 0);
|
|
47396
|
-
triangles.push(b.i / dim | 0);
|
|
47397
|
-
|
|
47398
|
-
// remove two nodes involved
|
|
47399
|
-
removeNode(p);
|
|
47400
|
-
removeNode(p.next);
|
|
47401
|
-
|
|
47402
|
-
p = start = b;
|
|
47403
|
-
}
|
|
47404
|
-
p = p.next;
|
|
47405
|
-
} while (p !== start);
|
|
47406
|
-
|
|
47407
|
-
return filterPoints(p);
|
|
47408
|
-
}
|
|
47409
|
-
|
|
47410
|
-
// try splitting polygon into two and triangulate them independently
|
|
47411
|
-
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
47412
|
-
// look for a valid diagonal that divides the polygon into two
|
|
47413
|
-
var a = start;
|
|
47414
|
-
do {
|
|
47415
|
-
var b = a.next.next;
|
|
47416
|
-
while (b !== a.prev) {
|
|
47417
|
-
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
47418
|
-
// split the polygon in two by the diagonal
|
|
47419
|
-
var c = splitPolygon(a, b);
|
|
47420
|
-
|
|
47421
|
-
// filter colinear points around the cuts
|
|
47422
|
-
a = filterPoints(a, a.next);
|
|
47423
|
-
c = filterPoints(c, c.next);
|
|
47424
|
-
|
|
47425
|
-
// run earcut on each half
|
|
47426
|
-
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
47427
|
-
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
47428
|
-
return;
|
|
47429
|
-
}
|
|
47430
|
-
b = b.next;
|
|
47431
|
-
}
|
|
47432
|
-
a = a.next;
|
|
47433
|
-
} while (a !== start);
|
|
47434
|
-
}
|
|
47435
|
-
|
|
47436
|
-
// link every hole into the outer loop, producing a single-ring polygon without holes
|
|
47437
|
-
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
47438
|
-
var queue = [],
|
|
47439
|
-
i, len, start, end, list;
|
|
47440
|
-
|
|
47441
|
-
for (i = 0, len = holeIndices.length; i < len; i++) {
|
|
47442
|
-
start = holeIndices[i] * dim;
|
|
47443
|
-
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
47444
|
-
list = linkedList(data, start, end, dim, false);
|
|
47445
|
-
if (list === list.next) list.steiner = true;
|
|
47446
|
-
queue.push(getLeftmost(list));
|
|
47447
|
-
}
|
|
47448
|
-
|
|
47449
|
-
queue.sort(compareX);
|
|
47450
|
-
|
|
47451
|
-
// process holes from left to right
|
|
47452
|
-
for (i = 0; i < queue.length; i++) {
|
|
47453
|
-
outerNode = eliminateHole(queue[i], outerNode);
|
|
47454
|
-
}
|
|
47455
|
-
|
|
47456
|
-
return outerNode;
|
|
47457
|
-
}
|
|
47458
|
-
|
|
47459
|
-
function compareX(a, b) {
|
|
47460
|
-
return a.x - b.x;
|
|
47461
|
-
}
|
|
47462
|
-
|
|
47463
|
-
// find a bridge between vertices that connects hole with an outer ring and and link it
|
|
47464
|
-
function eliminateHole(hole, outerNode) {
|
|
47465
|
-
var bridge = findHoleBridge(hole, outerNode);
|
|
47466
|
-
if (!bridge) {
|
|
47467
|
-
return outerNode;
|
|
47468
|
-
}
|
|
47469
|
-
|
|
47470
|
-
var bridgeReverse = splitPolygon(bridge, hole);
|
|
47471
|
-
|
|
47472
|
-
// filter collinear points around the cuts
|
|
47473
|
-
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
47474
|
-
return filterPoints(bridge, bridge.next);
|
|
47475
|
-
}
|
|
47476
|
-
|
|
47477
|
-
// David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
47478
|
-
function findHoleBridge(hole, outerNode) {
|
|
47479
|
-
var p = outerNode,
|
|
47480
|
-
hx = hole.x,
|
|
47481
|
-
hy = hole.y,
|
|
47482
|
-
qx = -Infinity,
|
|
47483
|
-
m;
|
|
47484
|
-
|
|
47485
|
-
// find a segment intersected by a ray from the hole's leftmost point to the left;
|
|
47486
|
-
// segment's endpoint with lesser x will be potential connection point
|
|
47487
|
-
do {
|
|
47488
|
-
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
47489
|
-
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
47490
|
-
if (x <= hx && x > qx) {
|
|
47491
|
-
qx = x;
|
|
47492
|
-
m = p.x < p.next.x ? p : p.next;
|
|
47493
|
-
if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
|
|
47494
|
-
}
|
|
47495
|
-
}
|
|
47496
|
-
p = p.next;
|
|
47497
|
-
} while (p !== outerNode);
|
|
47498
|
-
|
|
47499
|
-
if (!m) return null;
|
|
47500
|
-
|
|
47501
|
-
// look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
47502
|
-
// if there are no points found, we have a valid connection;
|
|
47503
|
-
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
47504
|
-
|
|
47505
|
-
var stop = m,
|
|
47506
|
-
mx = m.x,
|
|
47507
|
-
my = m.y,
|
|
47508
|
-
tanMin = Infinity,
|
|
47509
|
-
tan;
|
|
47510
|
-
|
|
47511
|
-
p = m;
|
|
47512
|
-
|
|
47513
|
-
do {
|
|
47514
|
-
if (hx >= p.x && p.x >= mx && hx !== p.x &&
|
|
47515
|
-
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
47516
|
-
|
|
47517
|
-
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
47518
|
-
|
|
47519
|
-
if (locallyInside(p, hole) &&
|
|
47520
|
-
(tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
|
|
47521
|
-
m = p;
|
|
47522
|
-
tanMin = tan;
|
|
47523
|
-
}
|
|
47524
|
-
}
|
|
47525
|
-
|
|
47526
|
-
p = p.next;
|
|
47527
|
-
} while (p !== stop);
|
|
47528
|
-
|
|
47529
|
-
return m;
|
|
47530
|
-
}
|
|
47531
|
-
|
|
47532
|
-
// whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
47533
|
-
function sectorContainsSector(m, p) {
|
|
47534
|
-
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
47535
|
-
}
|
|
47536
|
-
|
|
47537
|
-
// interlink polygon nodes in z-order
|
|
47538
|
-
function indexCurve(start, minX, minY, invSize) {
|
|
47539
|
-
var p = start;
|
|
47540
|
-
do {
|
|
47541
|
-
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
47542
|
-
p.prevZ = p.prev;
|
|
47543
|
-
p.nextZ = p.next;
|
|
47544
|
-
p = p.next;
|
|
47545
|
-
} while (p !== start);
|
|
47546
|
-
|
|
47547
|
-
p.prevZ.nextZ = null;
|
|
47548
|
-
p.prevZ = null;
|
|
47549
|
-
|
|
47550
|
-
sortLinked(p);
|
|
47551
|
-
}
|
|
47552
|
-
|
|
47553
|
-
// Simon Tatham's linked list merge sort algorithm
|
|
47554
|
-
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
47555
|
-
function sortLinked(list) {
|
|
47556
|
-
var i, p, q, e, tail, numMerges, pSize, qSize,
|
|
47557
|
-
inSize = 1;
|
|
47558
|
-
|
|
47559
|
-
do {
|
|
47560
|
-
p = list;
|
|
47561
|
-
list = null;
|
|
47562
|
-
tail = null;
|
|
47563
|
-
numMerges = 0;
|
|
47564
|
-
|
|
47565
|
-
while (p) {
|
|
47566
|
-
numMerges++;
|
|
47567
|
-
q = p;
|
|
47568
|
-
pSize = 0;
|
|
47569
|
-
for (i = 0; i < inSize; i++) {
|
|
47570
|
-
pSize++;
|
|
47571
|
-
q = q.nextZ;
|
|
47572
|
-
if (!q) break;
|
|
47573
|
-
}
|
|
47574
|
-
qSize = inSize;
|
|
47575
|
-
|
|
47576
|
-
while (pSize > 0 || (qSize > 0 && q)) {
|
|
47577
|
-
|
|
47578
|
-
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
47579
|
-
e = p;
|
|
47580
|
-
p = p.nextZ;
|
|
47581
|
-
pSize--;
|
|
47582
|
-
} else {
|
|
47583
|
-
e = q;
|
|
47584
|
-
q = q.nextZ;
|
|
47585
|
-
qSize--;
|
|
47586
|
-
}
|
|
47587
|
-
|
|
47588
|
-
if (tail) tail.nextZ = e;
|
|
47589
|
-
else list = e;
|
|
47590
|
-
|
|
47591
|
-
e.prevZ = tail;
|
|
47592
|
-
tail = e;
|
|
47593
|
-
}
|
|
47594
|
-
|
|
47595
|
-
p = q;
|
|
47596
|
-
}
|
|
47597
|
-
|
|
47598
|
-
tail.nextZ = null;
|
|
47599
|
-
inSize *= 2;
|
|
47600
|
-
|
|
47601
|
-
} while (numMerges > 1);
|
|
47602
|
-
|
|
47603
|
-
return list;
|
|
47604
|
-
}
|
|
47605
|
-
|
|
47606
|
-
// z-order of a point given coords and inverse of the longer side of data bbox
|
|
47607
|
-
function zOrder(x, y, minX, minY, invSize) {
|
|
47608
|
-
// coords are transformed into non-negative 15-bit integer range
|
|
47609
|
-
x = (x - minX) * invSize | 0;
|
|
47610
|
-
y = (y - minY) * invSize | 0;
|
|
47611
|
-
|
|
47612
|
-
x = (x | (x << 8)) & 0x00FF00FF;
|
|
47613
|
-
x = (x | (x << 4)) & 0x0F0F0F0F;
|
|
47614
|
-
x = (x | (x << 2)) & 0x33333333;
|
|
47615
|
-
x = (x | (x << 1)) & 0x55555555;
|
|
47616
|
-
|
|
47617
|
-
y = (y | (y << 8)) & 0x00FF00FF;
|
|
47618
|
-
y = (y | (y << 4)) & 0x0F0F0F0F;
|
|
47619
|
-
y = (y | (y << 2)) & 0x33333333;
|
|
47620
|
-
y = (y | (y << 1)) & 0x55555555;
|
|
47621
|
-
|
|
47622
|
-
return x | (y << 1);
|
|
47623
|
-
}
|
|
47624
|
-
|
|
47625
|
-
// find the leftmost node of a polygon ring
|
|
47626
|
-
function getLeftmost(start) {
|
|
47627
|
-
var p = start,
|
|
47628
|
-
leftmost = start;
|
|
47629
|
-
do {
|
|
47630
|
-
if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
|
|
47631
|
-
p = p.next;
|
|
47632
|
-
} while (p !== start);
|
|
47633
|
-
|
|
47634
|
-
return leftmost;
|
|
47635
|
-
}
|
|
47636
|
-
|
|
47637
|
-
// check if a point lies within a convex triangle
|
|
47638
|
-
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
47639
|
-
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
|
|
47640
|
-
(ax - px) * (by - py) >= (bx - px) * (ay - py) &&
|
|
47641
|
-
(bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
47642
|
-
}
|
|
47643
|
-
|
|
47644
|
-
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
47645
|
-
function isValidDiagonal(a, b) {
|
|
47646
|
-
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
|
|
47647
|
-
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
47648
|
-
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
47649
|
-
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
47650
|
-
}
|
|
47651
|
-
|
|
47652
|
-
// signed area of a triangle
|
|
47653
|
-
function area(p, q, r) {
|
|
47654
|
-
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
47655
|
-
}
|
|
47656
|
-
|
|
47657
|
-
// check if two points are equal
|
|
47658
|
-
function equals(p1, p2) {
|
|
47659
|
-
return p1.x === p2.x && p1.y === p2.y;
|
|
47660
|
-
}
|
|
47661
|
-
|
|
47662
|
-
// check if two segments intersect
|
|
47663
|
-
function intersects(p1, q1, p2, q2) {
|
|
47664
|
-
var o1 = sign(area(p1, q1, p2));
|
|
47665
|
-
var o2 = sign(area(p1, q1, q2));
|
|
47666
|
-
var o3 = sign(area(p2, q2, p1));
|
|
47667
|
-
var o4 = sign(area(p2, q2, q1));
|
|
47668
|
-
|
|
47669
|
-
if (o1 !== o2 && o3 !== o4) return true; // general case
|
|
47670
|
-
|
|
47671
|
-
if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
47672
|
-
if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
47673
|
-
if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
47674
|
-
if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
47675
|
-
|
|
47676
|
-
return false;
|
|
47677
|
-
}
|
|
47678
|
-
|
|
47679
|
-
// for collinear points p, q, r, check if point q lies on segment pr
|
|
47680
|
-
function onSegment(p, q, r) {
|
|
47681
|
-
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
47682
|
-
}
|
|
47683
|
-
|
|
47684
|
-
function sign(num) {
|
|
47685
|
-
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
47686
|
-
}
|
|
47687
|
-
|
|
47688
|
-
// check if a polygon diagonal intersects any polygon segments
|
|
47689
|
-
function intersectsPolygon(a, b) {
|
|
47690
|
-
var p = a;
|
|
47691
|
-
do {
|
|
47692
|
-
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
|
|
47693
|
-
intersects(p, p.next, a, b)) return true;
|
|
47694
|
-
p = p.next;
|
|
47695
|
-
} while (p !== a);
|
|
47696
|
-
|
|
47697
|
-
return false;
|
|
47698
|
-
}
|
|
47699
|
-
|
|
47700
|
-
// check if a polygon diagonal is locally inside the polygon
|
|
47701
|
-
function locallyInside(a, b) {
|
|
47702
|
-
return area(a.prev, a, a.next) < 0 ?
|
|
47703
|
-
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
|
|
47704
|
-
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
47705
|
-
}
|
|
47706
|
-
|
|
47707
|
-
// check if the middle point of a polygon diagonal is inside the polygon
|
|
47708
|
-
function middleInside(a, b) {
|
|
47709
|
-
var p = a,
|
|
47710
|
-
inside = false,
|
|
47711
|
-
px = (a.x + b.x) / 2,
|
|
47712
|
-
py = (a.y + b.y) / 2;
|
|
47713
|
-
do {
|
|
47714
|
-
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
|
|
47715
|
-
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
|
|
47716
|
-
inside = !inside;
|
|
47717
|
-
p = p.next;
|
|
47718
|
-
} while (p !== a);
|
|
47719
|
-
|
|
47720
|
-
return inside;
|
|
47721
|
-
}
|
|
47722
|
-
|
|
47723
|
-
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
47724
|
-
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
47725
|
-
function splitPolygon(a, b) {
|
|
47726
|
-
var a2 = new Node(a.i, a.x, a.y),
|
|
47727
|
-
b2 = new Node(b.i, b.x, b.y),
|
|
47728
|
-
an = a.next,
|
|
47729
|
-
bp = b.prev;
|
|
47730
|
-
|
|
47731
|
-
a.next = b;
|
|
47732
|
-
b.prev = a;
|
|
47733
|
-
|
|
47734
|
-
a2.next = an;
|
|
47735
|
-
an.prev = a2;
|
|
47736
|
-
|
|
47737
|
-
b2.next = a2;
|
|
47738
|
-
a2.prev = b2;
|
|
47739
|
-
|
|
47740
|
-
bp.next = b2;
|
|
47741
|
-
b2.prev = bp;
|
|
47742
|
-
|
|
47743
|
-
return b2;
|
|
47744
|
-
}
|
|
47745
|
-
|
|
47746
|
-
// create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
47747
|
-
function insertNode(i, x, y, last) {
|
|
47748
|
-
var p = new Node(i, x, y);
|
|
47749
|
-
|
|
47750
|
-
if (!last) {
|
|
47751
|
-
p.prev = p;
|
|
47752
|
-
p.next = p;
|
|
47753
|
-
|
|
47754
|
-
} else {
|
|
47755
|
-
p.next = last.next;
|
|
47756
|
-
p.prev = last;
|
|
47757
|
-
last.next.prev = p;
|
|
47758
|
-
last.next = p;
|
|
47759
|
-
}
|
|
47760
|
-
return p;
|
|
47761
|
-
}
|
|
47762
|
-
|
|
47763
|
-
function removeNode(p) {
|
|
47764
|
-
p.next.prev = p.prev;
|
|
47765
|
-
p.prev.next = p.next;
|
|
47766
|
-
|
|
47767
|
-
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
|
|
47768
|
-
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
|
|
47769
|
-
}
|
|
47770
|
-
|
|
47771
|
-
function Node(i, x, y) {
|
|
47772
|
-
// vertex index in coordinates array
|
|
47773
|
-
this.i = i;
|
|
47774
|
-
|
|
47775
|
-
// vertex coordinates
|
|
47776
|
-
this.x = x;
|
|
47777
|
-
this.y = y;
|
|
47778
|
-
|
|
47779
|
-
// previous and next vertex nodes in a polygon ring
|
|
47780
|
-
this.prev = null;
|
|
47781
|
-
this.next = null;
|
|
47782
|
-
|
|
47783
|
-
// z-order curve value
|
|
47784
|
-
this.z = 0;
|
|
47785
|
-
|
|
47786
|
-
// previous and next nodes in z-order
|
|
47787
|
-
this.prevZ = null;
|
|
47788
|
-
this.nextZ = null;
|
|
47789
|
-
|
|
47790
|
-
// indicates whether this is a steiner point
|
|
47791
|
-
this.steiner = false;
|
|
47792
|
-
}
|
|
47793
|
-
|
|
47794
|
-
// return a percentage difference between the polygon area and its triangulation area;
|
|
47795
|
-
// used to verify correctness of triangulation
|
|
47796
|
-
earcut.deviation = function (data, holeIndices, dim, triangles) {
|
|
47797
|
-
var hasHoles = holeIndices && holeIndices.length;
|
|
47798
|
-
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
47799
|
-
|
|
47800
|
-
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
|
|
47801
|
-
if (hasHoles) {
|
|
47802
|
-
for (var i = 0, len = holeIndices.length; i < len; i++) {
|
|
47803
|
-
var start = holeIndices[i] * dim;
|
|
47804
|
-
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
47805
|
-
polygonArea -= Math.abs(signedArea(data, start, end, dim));
|
|
47806
|
-
}
|
|
47807
|
-
}
|
|
47808
|
-
|
|
47809
|
-
var trianglesArea = 0;
|
|
47810
|
-
for (i = 0; i < triangles.length; i += 3) {
|
|
47811
|
-
var a = triangles[i] * dim;
|
|
47812
|
-
var b = triangles[i + 1] * dim;
|
|
47813
|
-
var c = triangles[i + 2] * dim;
|
|
47814
|
-
trianglesArea += Math.abs(
|
|
47815
|
-
(data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
|
|
47816
|
-
(data[a] - data[b]) * (data[c + 1] - data[a + 1]));
|
|
47817
|
-
}
|
|
47818
|
-
|
|
47819
|
-
return polygonArea === 0 && trianglesArea === 0 ? 0 :
|
|
47820
|
-
Math.abs((trianglesArea - polygonArea) / polygonArea);
|
|
47821
|
-
};
|
|
47822
|
-
|
|
47823
|
-
function signedArea(data, start, end, dim) {
|
|
47824
|
-
var sum = 0;
|
|
47825
|
-
for (var i = start, j = end - dim; i < end; i += dim) {
|
|
47826
|
-
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
47827
|
-
j = i;
|
|
47828
|
-
}
|
|
47829
|
-
return sum;
|
|
47830
|
-
}
|
|
47831
|
-
|
|
47832
|
-
// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
|
|
47833
|
-
earcut.flatten = function (data) {
|
|
47834
|
-
var dim = data[0][0].length,
|
|
47835
|
-
result = {vertices: [], holes: [], dimensions: dim},
|
|
47836
|
-
holeIndex = 0;
|
|
47837
|
-
|
|
47838
|
-
for (var i = 0; i < data.length; i++) {
|
|
47839
|
-
for (var j = 0; j < data[i].length; j++) {
|
|
47840
|
-
for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
|
|
47841
|
-
}
|
|
47842
|
-
if (i > 0) {
|
|
47843
|
-
holeIndex += data[i - 1].length;
|
|
47844
|
-
result.holes.push(holeIndex);
|
|
47845
|
-
}
|
|
47846
|
-
}
|
|
47847
|
-
return result;
|
|
47848
|
-
};
|
|
47849
|
-
return earcut$1.exports;
|
|
47850
|
-
}
|
|
47851
|
-
|
|
47852
|
-
var earcutExports = requireEarcut();
|
|
47853
|
-
var earcut = /*@__PURE__*/getDefaultExportFromCjs(earcutExports);
|
|
47854
|
-
|
|
47855
47918
|
const epsilon$1 = 1.1102230246251565e-16;
|
|
47856
47919
|
const splitter = 134217729;
|
|
47857
47920
|
const resulterrbound = (3 + 8 * epsilon$1) * epsilon$1;
|
|
@@ -48596,179 +48659,139 @@ void main() {
|
|
|
48596
48659
|
return p[1];
|
|
48597
48660
|
}
|
|
48598
48661
|
|
|
48599
|
-
|
|
48600
|
-
|
|
48601
|
-
|
|
48602
|
-
|
|
48603
|
-
|
|
48604
|
-
|
|
48605
|
-
|
|
48606
|
-
|
|
48607
|
-
|
|
48608
|
-
|
|
48609
|
-
|
|
48610
|
-
|
|
48611
|
-
|
|
48612
|
-
|
|
48613
|
-
|
|
48614
|
-
|
|
48615
|
-
|
|
48616
|
-
|
|
48617
|
-
|
|
48618
|
-
|
|
48619
|
-
|
|
48620
|
-
|
|
48621
|
-
if (
|
|
48622
|
-
|
|
48662
|
+
function pointInPolygon(p, polygon) {
|
|
48663
|
+
var i = 0;
|
|
48664
|
+
var ii = 0;
|
|
48665
|
+
var k = 0;
|
|
48666
|
+
var f = 0;
|
|
48667
|
+
var u1 = 0;
|
|
48668
|
+
var v1 = 0;
|
|
48669
|
+
var u2 = 0;
|
|
48670
|
+
var v2 = 0;
|
|
48671
|
+
var currentP = null;
|
|
48672
|
+
var nextP = null;
|
|
48673
|
+
|
|
48674
|
+
var x = p[0];
|
|
48675
|
+
var y = p[1];
|
|
48676
|
+
|
|
48677
|
+
var numContours = polygon.length;
|
|
48678
|
+
for (i; i < numContours; i++) {
|
|
48679
|
+
ii = 0;
|
|
48680
|
+
var contourLen = polygon[i].length - 1;
|
|
48681
|
+
var contour = polygon[i];
|
|
48682
|
+
|
|
48683
|
+
currentP = contour[0];
|
|
48684
|
+
if (currentP[0] !== contour[contourLen][0] &&
|
|
48685
|
+
currentP[1] !== contour[contourLen][1]) {
|
|
48686
|
+
throw new Error('First and last coordinates in a ring must be the same')
|
|
48623
48687
|
}
|
|
48624
|
-
}
|
|
48625
|
-
if (Array.isArray(coord) &&
|
|
48626
|
-
coord.length >= 2 &&
|
|
48627
|
-
!Array.isArray(coord[0]) &&
|
|
48628
|
-
!Array.isArray(coord[1])) {
|
|
48629
|
-
return coord;
|
|
48630
|
-
}
|
|
48631
|
-
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
48632
|
-
}
|
|
48633
|
-
/**
|
|
48634
|
-
* Get Geometry from Feature or Geometry Object
|
|
48635
|
-
*
|
|
48636
|
-
* @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
|
|
48637
|
-
* @returns {Geometry|null} GeoJSON Geometry Object
|
|
48638
|
-
* @throws {Error} if geojson is not a Feature or Geometry Object
|
|
48639
|
-
* @example
|
|
48640
|
-
* var point = {
|
|
48641
|
-
* "type": "Feature",
|
|
48642
|
-
* "properties": {},
|
|
48643
|
-
* "geometry": {
|
|
48644
|
-
* "type": "Point",
|
|
48645
|
-
* "coordinates": [110, 40]
|
|
48646
|
-
* }
|
|
48647
|
-
* }
|
|
48648
|
-
* var geom = turf.getGeom(point)
|
|
48649
|
-
* //={"type": "Point", "coordinates": [110, 40]}
|
|
48650
|
-
*/
|
|
48651
|
-
function getGeom(geojson) {
|
|
48652
|
-
if (geojson.type === "Feature") {
|
|
48653
|
-
return geojson.geometry;
|
|
48654
|
-
}
|
|
48655
|
-
return geojson;
|
|
48656
|
-
}
|
|
48657
48688
|
|
|
48658
|
-
|
|
48659
|
-
|
|
48660
|
-
|
|
48661
|
-
|
|
48662
|
-
|
|
48663
|
-
|
|
48664
|
-
|
|
48665
|
-
|
|
48666
|
-
|
|
48667
|
-
|
|
48668
|
-
|
|
48669
|
-
|
|
48670
|
-
|
|
48671
|
-
* @returns {boolean} `true` if the Point is inside the Polygon; `false` if the Point is not inside the Polygon
|
|
48672
|
-
* @example
|
|
48673
|
-
* var pt = turf.point([-77, 44]);
|
|
48674
|
-
* var poly = turf.polygon([[
|
|
48675
|
-
* [-81, 41],
|
|
48676
|
-
* [-81, 47],
|
|
48677
|
-
* [-72, 47],
|
|
48678
|
-
* [-72, 41],
|
|
48679
|
-
* [-81, 41]
|
|
48680
|
-
* ]]);
|
|
48681
|
-
*
|
|
48682
|
-
* turf.booleanPointInPolygon(pt, poly);
|
|
48683
|
-
* //= true
|
|
48684
|
-
*/
|
|
48685
|
-
function booleanPointInPolygon(point, polygon, options) {
|
|
48686
|
-
if (options === void 0) { options = {}; }
|
|
48687
|
-
// validation
|
|
48688
|
-
if (!point) {
|
|
48689
|
-
throw new Error("point is required");
|
|
48690
|
-
}
|
|
48691
|
-
if (!polygon) {
|
|
48692
|
-
throw new Error("polygon is required");
|
|
48693
|
-
}
|
|
48694
|
-
var pt = getCoord(point);
|
|
48695
|
-
var geom = getGeom(polygon);
|
|
48696
|
-
var type = geom.type;
|
|
48697
|
-
var bbox = polygon.bbox;
|
|
48698
|
-
var polys = geom.coordinates;
|
|
48699
|
-
// Quick elimination if point is not inside bbox
|
|
48700
|
-
if (bbox && inBBox(pt, bbox) === false) {
|
|
48701
|
-
return false;
|
|
48702
|
-
}
|
|
48703
|
-
// normalize to multipolygon
|
|
48704
|
-
if (type === "Polygon") {
|
|
48705
|
-
polys = [polys];
|
|
48706
|
-
}
|
|
48707
|
-
var insidePoly = false;
|
|
48708
|
-
for (var i = 0; i < polys.length && !insidePoly; i++) {
|
|
48709
|
-
// check if it is in the outer ring first
|
|
48710
|
-
if (inRing(pt, polys[i][0], options.ignoreBoundary)) {
|
|
48711
|
-
var inHole = false;
|
|
48712
|
-
var k = 1;
|
|
48713
|
-
// check for the point in any of the holes
|
|
48714
|
-
while (k < polys[i].length && !inHole) {
|
|
48715
|
-
if (inRing(pt, polys[i][k], !options.ignoreBoundary)) {
|
|
48716
|
-
inHole = true;
|
|
48717
|
-
}
|
|
48718
|
-
k++;
|
|
48689
|
+
u1 = currentP[0] - x;
|
|
48690
|
+
v1 = currentP[1] - y;
|
|
48691
|
+
|
|
48692
|
+
for (ii; ii < contourLen; ii++) {
|
|
48693
|
+
nextP = contour[ii + 1];
|
|
48694
|
+
|
|
48695
|
+
v2 = nextP[1] - y;
|
|
48696
|
+
|
|
48697
|
+
if ((v1 < 0 && v2 < 0) || (v1 > 0 && v2 > 0)) {
|
|
48698
|
+
currentP = nextP;
|
|
48699
|
+
v1 = v2;
|
|
48700
|
+
u1 = currentP[0] - x;
|
|
48701
|
+
continue
|
|
48719
48702
|
}
|
|
48720
|
-
|
|
48721
|
-
|
|
48703
|
+
|
|
48704
|
+
u2 = nextP[0] - p[0];
|
|
48705
|
+
|
|
48706
|
+
if (v2 > 0 && v1 <= 0) {
|
|
48707
|
+
f = (u1 * v2) - (u2 * v1);
|
|
48708
|
+
if (f > 0) { k = k + 1; }
|
|
48709
|
+
else if (f === 0) { return 0 }
|
|
48710
|
+
} else if (v1 > 0 && v2 <= 0) {
|
|
48711
|
+
f = (u1 * v2) - (u2 * v1);
|
|
48712
|
+
if (f < 0) { k = k + 1; }
|
|
48713
|
+
else if (f === 0) { return 0 }
|
|
48714
|
+
} else if (v2 === 0 && v1 < 0) {
|
|
48715
|
+
f = (u1 * v2) - (u2 * v1);
|
|
48716
|
+
if (f === 0) { return 0 }
|
|
48717
|
+
} else if (v1 === 0 && v2 < 0) {
|
|
48718
|
+
f = u1 * v2 - u2 * v1;
|
|
48719
|
+
if (f === 0) { return 0 }
|
|
48720
|
+
} else if (v1 === 0 && v2 === 0) {
|
|
48721
|
+
if (u2 <= 0 && u1 >= 0) {
|
|
48722
|
+
return 0
|
|
48723
|
+
} else if (u1 <= 0 && u2 >= 0) {
|
|
48724
|
+
return 0
|
|
48725
|
+
}
|
|
48722
48726
|
}
|
|
48727
|
+
currentP = nextP;
|
|
48728
|
+
v1 = v2;
|
|
48729
|
+
u1 = u2;
|
|
48723
48730
|
}
|
|
48724
48731
|
}
|
|
48725
|
-
|
|
48732
|
+
|
|
48733
|
+
if (k % 2 === 0) { return false }
|
|
48734
|
+
return true
|
|
48726
48735
|
}
|
|
48727
|
-
|
|
48728
|
-
|
|
48729
|
-
|
|
48730
|
-
|
|
48731
|
-
|
|
48732
|
-
|
|
48733
|
-
|
|
48734
|
-
|
|
48735
|
-
|
|
48736
|
-
function inRing(pt, ring, ignoreBoundary) {
|
|
48737
|
-
var isInside = false;
|
|
48738
|
-
if (ring[0][0] === ring[ring.length - 1][0] &&
|
|
48739
|
-
ring[0][1] === ring[ring.length - 1][1]) {
|
|
48740
|
-
ring = ring.slice(0, ring.length - 1);
|
|
48736
|
+
|
|
48737
|
+
// index.ts
|
|
48738
|
+
function getCoord(coord) {
|
|
48739
|
+
if (!coord) {
|
|
48740
|
+
throw new Error("coord is required");
|
|
48741
|
+
}
|
|
48742
|
+
if (!Array.isArray(coord)) {
|
|
48743
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
48744
|
+
return [...coord.geometry.coordinates];
|
|
48741
48745
|
}
|
|
48742
|
-
|
|
48743
|
-
|
|
48744
|
-
var yi = ring[i][1];
|
|
48745
|
-
var xj = ring[j][0];
|
|
48746
|
-
var yj = ring[j][1];
|
|
48747
|
-
var onBoundary = pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0 &&
|
|
48748
|
-
(xi - pt[0]) * (xj - pt[0]) <= 0 &&
|
|
48749
|
-
(yi - pt[1]) * (yj - pt[1]) <= 0;
|
|
48750
|
-
if (onBoundary) {
|
|
48751
|
-
return !ignoreBoundary;
|
|
48752
|
-
}
|
|
48753
|
-
var intersect = yi > pt[1] !== yj > pt[1] &&
|
|
48754
|
-
pt[0] < ((xj - xi) * (pt[1] - yi)) / (yj - yi) + xi;
|
|
48755
|
-
if (intersect) {
|
|
48756
|
-
isInside = !isInside;
|
|
48757
|
-
}
|
|
48746
|
+
if (coord.type === "Point") {
|
|
48747
|
+
return [...coord.coordinates];
|
|
48758
48748
|
}
|
|
48759
|
-
|
|
48749
|
+
}
|
|
48750
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
48751
|
+
return [...coord];
|
|
48752
|
+
}
|
|
48753
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
48754
|
+
}
|
|
48755
|
+
function getGeom(geojson) {
|
|
48756
|
+
if (geojson.type === "Feature") {
|
|
48757
|
+
return geojson.geometry;
|
|
48758
|
+
}
|
|
48759
|
+
return geojson;
|
|
48760
|
+
}
|
|
48761
|
+
|
|
48762
|
+
// index.ts
|
|
48763
|
+
function booleanPointInPolygon(point, polygon, options = {}) {
|
|
48764
|
+
if (!point) {
|
|
48765
|
+
throw new Error("point is required");
|
|
48766
|
+
}
|
|
48767
|
+
if (!polygon) {
|
|
48768
|
+
throw new Error("polygon is required");
|
|
48769
|
+
}
|
|
48770
|
+
const pt = getCoord(point);
|
|
48771
|
+
const geom = getGeom(polygon);
|
|
48772
|
+
const type = geom.type;
|
|
48773
|
+
const bbox = polygon.bbox;
|
|
48774
|
+
let polys = geom.coordinates;
|
|
48775
|
+
if (bbox && inBBox(pt, bbox) === false) {
|
|
48776
|
+
return false;
|
|
48777
|
+
}
|
|
48778
|
+
if (type === "Polygon") {
|
|
48779
|
+
polys = [polys];
|
|
48780
|
+
}
|
|
48781
|
+
let result = false;
|
|
48782
|
+
for (var i = 0; i < polys.length; ++i) {
|
|
48783
|
+
const polyResult = pointInPolygon(pt, polys[i]);
|
|
48784
|
+
if (polyResult === 0)
|
|
48785
|
+
return options.ignoreBoundary ? false : true;
|
|
48786
|
+
else if (polyResult)
|
|
48787
|
+
result = true;
|
|
48788
|
+
}
|
|
48789
|
+
return result;
|
|
48760
48790
|
}
|
|
48761
|
-
/**
|
|
48762
|
-
* inBBox
|
|
48763
|
-
*
|
|
48764
|
-
* @private
|
|
48765
|
-
* @param {Position} pt point [x,y]
|
|
48766
|
-
* @param {BBox} bbox BBox [west, south, east, north]
|
|
48767
|
-
* @returns {boolean} true/false if point is inside BBox
|
|
48768
|
-
*/
|
|
48769
48791
|
function inBBox(pt, bbox) {
|
|
48770
|
-
|
|
48792
|
+
return bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1];
|
|
48771
48793
|
}
|
|
48794
|
+
var turf_boolean_point_in_polygon_default = booleanPointInPolygon;
|
|
48772
48795
|
|
|
48773
48796
|
const epsilon = 1e-6;
|
|
48774
48797
|
|
|
@@ -50026,9 +50049,49 @@ void main() {
|
|
|
50026
50049
|
return data ? v(data) : v;
|
|
50027
50050
|
}
|
|
50028
50051
|
|
|
50052
|
+
function _arrayLikeToArray$2(r, a) {
|
|
50053
|
+
(null == a || a > r.length) && (a = r.length);
|
|
50054
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
50055
|
+
return n;
|
|
50056
|
+
}
|
|
50057
|
+
function _arrayWithHoles$2(r) {
|
|
50058
|
+
if (Array.isArray(r)) return r;
|
|
50059
|
+
}
|
|
50060
|
+
function _arrayWithoutHoles$2(r) {
|
|
50061
|
+
if (Array.isArray(r)) return _arrayLikeToArray$2(r);
|
|
50062
|
+
}
|
|
50063
|
+
function _assertThisInitialized$2(e) {
|
|
50064
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
50065
|
+
return e;
|
|
50066
|
+
}
|
|
50029
50067
|
function _callSuper$1(t, o, e) {
|
|
50030
50068
|
return o = _getPrototypeOf$2(o), _possibleConstructorReturn$1(t, _isNativeReflectConstruct$2() ? Reflect.construct(o, [], _getPrototypeOf$2(t).constructor) : o.apply(t, e));
|
|
50031
50069
|
}
|
|
50070
|
+
function _classCallCheck$1(a, n) {
|
|
50071
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
50072
|
+
}
|
|
50073
|
+
function _createClass$1(e, r, t) {
|
|
50074
|
+
return Object.defineProperty(e, "prototype", {
|
|
50075
|
+
writable: !1
|
|
50076
|
+
}), e;
|
|
50077
|
+
}
|
|
50078
|
+
function _getPrototypeOf$2(t) {
|
|
50079
|
+
return _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
50080
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
50081
|
+
}, _getPrototypeOf$2(t);
|
|
50082
|
+
}
|
|
50083
|
+
function _inherits$1(t, e) {
|
|
50084
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
50085
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
50086
|
+
constructor: {
|
|
50087
|
+
value: t,
|
|
50088
|
+
writable: !0,
|
|
50089
|
+
configurable: !0
|
|
50090
|
+
}
|
|
50091
|
+
}), Object.defineProperty(t, "prototype", {
|
|
50092
|
+
writable: !1
|
|
50093
|
+
}), e && _setPrototypeOf$2(t, e);
|
|
50094
|
+
}
|
|
50032
50095
|
function _isNativeReflectConstruct$2() {
|
|
50033
50096
|
try {
|
|
50034
50097
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
@@ -50037,6 +50100,9 @@ void main() {
|
|
|
50037
50100
|
return !!t;
|
|
50038
50101
|
})();
|
|
50039
50102
|
}
|
|
50103
|
+
function _iterableToArray$2(r) {
|
|
50104
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
50105
|
+
}
|
|
50040
50106
|
function _iterableToArrayLimit$2(r, l) {
|
|
50041
50107
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
50042
50108
|
if (null != t) {
|
|
@@ -50061,93 +50127,34 @@ void main() {
|
|
|
50061
50127
|
return a;
|
|
50062
50128
|
}
|
|
50063
50129
|
}
|
|
50064
|
-
function
|
|
50065
|
-
|
|
50066
|
-
throw new TypeError("Cannot call a class as a function");
|
|
50067
|
-
}
|
|
50130
|
+
function _nonIterableRest$2() {
|
|
50131
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50068
50132
|
}
|
|
50069
|
-
function
|
|
50070
|
-
|
|
50071
|
-
writable: false
|
|
50072
|
-
});
|
|
50073
|
-
return Constructor;
|
|
50133
|
+
function _nonIterableSpread$2() {
|
|
50134
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50074
50135
|
}
|
|
50075
|
-
function
|
|
50076
|
-
if (typeof
|
|
50077
|
-
|
|
50078
|
-
|
|
50079
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
50080
|
-
constructor: {
|
|
50081
|
-
value: subClass,
|
|
50082
|
-
writable: true,
|
|
50083
|
-
configurable: true
|
|
50084
|
-
}
|
|
50085
|
-
});
|
|
50086
|
-
Object.defineProperty(subClass, "prototype", {
|
|
50087
|
-
writable: false
|
|
50088
|
-
});
|
|
50089
|
-
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
50136
|
+
function _possibleConstructorReturn$1(t, e) {
|
|
50137
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
50138
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
50139
|
+
return _assertThisInitialized$2(t);
|
|
50090
50140
|
}
|
|
50091
|
-
function
|
|
50092
|
-
|
|
50093
|
-
return
|
|
50094
|
-
};
|
|
50095
|
-
return _getPrototypeOf$2(o);
|
|
50141
|
+
function _setPrototypeOf$2(t, e) {
|
|
50142
|
+
return _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
50143
|
+
return t.__proto__ = e, t;
|
|
50144
|
+
}, _setPrototypeOf$2(t, e);
|
|
50096
50145
|
}
|
|
50097
|
-
function
|
|
50098
|
-
|
|
50099
|
-
o.__proto__ = p;
|
|
50100
|
-
return o;
|
|
50101
|
-
};
|
|
50102
|
-
return _setPrototypeOf$2(o, p);
|
|
50146
|
+
function _slicedToArray$2(r, e) {
|
|
50147
|
+
return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest$2();
|
|
50103
50148
|
}
|
|
50104
|
-
function
|
|
50105
|
-
|
|
50106
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
50107
|
-
}
|
|
50108
|
-
return self;
|
|
50149
|
+
function _toConsumableArray$2(r) {
|
|
50150
|
+
return _arrayWithoutHoles$2(r) || _iterableToArray$2(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread$2();
|
|
50109
50151
|
}
|
|
50110
|
-
function
|
|
50111
|
-
if (
|
|
50112
|
-
return
|
|
50113
|
-
|
|
50114
|
-
|
|
50152
|
+
function _unsupportedIterableToArray$2(r, a) {
|
|
50153
|
+
if (r) {
|
|
50154
|
+
if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
|
|
50155
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
50156
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
|
|
50115
50157
|
}
|
|
50116
|
-
return _assertThisInitialized$2(self);
|
|
50117
|
-
}
|
|
50118
|
-
function _slicedToArray$2(arr, i) {
|
|
50119
|
-
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2();
|
|
50120
|
-
}
|
|
50121
|
-
function _toConsumableArray$2(arr) {
|
|
50122
|
-
return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread$2();
|
|
50123
|
-
}
|
|
50124
|
-
function _arrayWithoutHoles$2(arr) {
|
|
50125
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$2(arr);
|
|
50126
|
-
}
|
|
50127
|
-
function _arrayWithHoles$2(arr) {
|
|
50128
|
-
if (Array.isArray(arr)) return arr;
|
|
50129
|
-
}
|
|
50130
|
-
function _iterableToArray$2(iter) {
|
|
50131
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
50132
|
-
}
|
|
50133
|
-
function _unsupportedIterableToArray$2(o, minLen) {
|
|
50134
|
-
if (!o) return;
|
|
50135
|
-
if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
|
|
50136
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50137
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
50138
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
50139
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
|
|
50140
|
-
}
|
|
50141
|
-
function _arrayLikeToArray$2(arr, len) {
|
|
50142
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
50143
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
50144
|
-
return arr2;
|
|
50145
|
-
}
|
|
50146
|
-
function _nonIterableSpread$2() {
|
|
50147
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50148
|
-
}
|
|
50149
|
-
function _nonIterableRest$2() {
|
|
50150
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50151
50158
|
}
|
|
50152
50159
|
|
|
50153
50160
|
function geoPolygonTriangulate(polygon) {
|
|
@@ -50209,10 +50216,10 @@ void main() {
|
|
|
50209
50216
|
});
|
|
50210
50217
|
} else if (!innerPoints.length) {
|
|
50211
50218
|
// earcut triangulation slightly more performing if it's only using the polygon perimeter
|
|
50212
|
-
var
|
|
50213
|
-
vertices =
|
|
50214
|
-
|
|
50215
|
-
holes =
|
|
50219
|
+
var _earcutFlatten = flatten$1(contour),
|
|
50220
|
+
vertices = _earcutFlatten.vertices,
|
|
50221
|
+
_earcutFlatten$holes = _earcutFlatten.holes,
|
|
50222
|
+
holes = _earcutFlatten$holes === void 0 ? [] : _earcutFlatten$holes;
|
|
50216
50223
|
indices = earcut(vertices, holes, 2);
|
|
50217
50224
|
} else {
|
|
50218
50225
|
// use delaunator
|
|
@@ -50359,19 +50366,18 @@ void main() {
|
|
|
50359
50366
|
function pointInside(pnt, polygon) {
|
|
50360
50367
|
var crossesPoleOrAntimeridian = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
50361
50368
|
// turf method is more performing but malfunctions if polygon includes a pole (lat = 90 | -90) or crosses the antimeridian (lng = 180 | -180)
|
|
50362
|
-
return crossesPoleOrAntimeridian ? geoContains(polygon, pnt) :
|
|
50369
|
+
return crossesPoleOrAntimeridian ? geoContains(polygon, pnt) : turf_boolean_point_in_polygon_default(pnt, polygon);
|
|
50363
50370
|
}
|
|
50364
50371
|
|
|
50365
|
-
var THREE$
|
|
50372
|
+
var THREE$j = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
50366
50373
|
: {
|
|
50367
50374
|
BufferGeometry: BufferGeometry,
|
|
50368
50375
|
Float32BufferAttribute: Float32BufferAttribute
|
|
50369
50376
|
};
|
|
50370
50377
|
|
|
50371
50378
|
// support both modes for backwards threejs compatibility
|
|
50372
|
-
var setAttributeFn
|
|
50379
|
+
var setAttributeFn = new THREE$j.BufferGeometry().setAttribute ? 'setAttribute' : 'addAttribute';
|
|
50373
50380
|
var ConicPolygonBufferGeometry = /*#__PURE__*/function (_THREE$BufferGeometry) {
|
|
50374
|
-
_inherits$1(ConicPolygonBufferGeometry, _THREE$BufferGeometry);
|
|
50375
50381
|
function ConicPolygonBufferGeometry(polygonGeoJson, startHeight, endHeight, closedBottom, closedTop, includeSides, curvatureResolution) {
|
|
50376
50382
|
var _this;
|
|
50377
50383
|
_classCallCheck$1(this, ConicPolygonBufferGeometry);
|
|
@@ -50423,8 +50429,8 @@ void main() {
|
|
|
50423
50429
|
|
|
50424
50430
|
// build geometry
|
|
50425
50431
|
_this.setIndex(indices);
|
|
50426
|
-
_this[setAttributeFn
|
|
50427
|
-
_this[setAttributeFn
|
|
50432
|
+
_this[setAttributeFn]('position', new THREE$j.Float32BufferAttribute(vertices, 3));
|
|
50433
|
+
_this[setAttributeFn]('uv', new THREE$j.Float32BufferAttribute(uvs, 2));
|
|
50428
50434
|
|
|
50429
50435
|
// auto-calculate normals
|
|
50430
50436
|
_this.computeVertexNormals();
|
|
@@ -50441,7 +50447,7 @@ void main() {
|
|
|
50441
50447
|
});
|
|
50442
50448
|
});
|
|
50443
50449
|
// returns { vertices, holes, coordinates }. Each point generates 3 vertice items (x,y,z).
|
|
50444
|
-
return
|
|
50450
|
+
return flatten$1(coords3d);
|
|
50445
50451
|
}
|
|
50446
50452
|
function generateTorso() {
|
|
50447
50453
|
var _generateVertices = generateVertices(contour, startHeight),
|
|
@@ -50487,8 +50493,9 @@ void main() {
|
|
|
50487
50493
|
}
|
|
50488
50494
|
return _this;
|
|
50489
50495
|
}
|
|
50496
|
+
_inherits$1(ConicPolygonBufferGeometry, _THREE$BufferGeometry);
|
|
50490
50497
|
return _createClass$1(ConicPolygonBufferGeometry);
|
|
50491
|
-
}(THREE$
|
|
50498
|
+
}(THREE$j.BufferGeometry); //
|
|
50492
50499
|
function polar2Cartesian$1(lat, lng) {
|
|
50493
50500
|
var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
50494
50501
|
var phi = (90 - lat) * Math.PI / 180;
|
|
@@ -65923,201 +65930,257 @@ void main() {
|
|
|
65923
65930
|
var yaotExports = requireYaot();
|
|
65924
65931
|
var yaOctree = /*@__PURE__*/getDefaultExportFromCjs(yaotExports);
|
|
65925
65932
|
|
|
65926
|
-
const
|
|
65927
|
-
|
|
65928
|
-
Box3,
|
|
65929
|
-
BufferGeometry,
|
|
65930
|
-
Float32BufferAttribute,
|
|
65931
|
-
InstancedBufferGeometry,
|
|
65932
|
-
InstancedInterleavedBuffer,
|
|
65933
|
-
InterleavedBufferAttribute,
|
|
65934
|
-
Sphere,
|
|
65935
|
-
Vector3,
|
|
65936
|
-
WireframeGeometry
|
|
65937
|
-
};
|
|
65933
|
+
const _box$1 = new Box3();
|
|
65934
|
+
const _vector = new Vector3();
|
|
65938
65935
|
|
|
65939
|
-
|
|
65940
|
-
var setAttributeFn$1 = new THREE$2$1.BufferGeometry().setAttribute ? 'setAttribute' : 'addAttribute';
|
|
65941
|
-
const _box$1 = new THREE$2$1.Box3();
|
|
65942
|
-
const _vector = new THREE$2$1.Vector3();
|
|
65943
|
-
class LineSegmentsGeometry extends THREE$2$1.InstancedBufferGeometry {
|
|
65944
|
-
constructor() {
|
|
65945
|
-
super();
|
|
65946
|
-
this.type = 'LineSegmentsGeometry';
|
|
65947
|
-
const positions = [-1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, -1, 0];
|
|
65948
|
-
const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2];
|
|
65949
|
-
const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5];
|
|
65950
|
-
this.setIndex(index);
|
|
65951
|
-
this[setAttributeFn$1]('position', new THREE$2$1.Float32BufferAttribute(positions, 3));
|
|
65952
|
-
this[setAttributeFn$1]('uv', new THREE$2$1.Float32BufferAttribute(uvs, 2));
|
|
65953
|
-
}
|
|
65954
|
-
applyMatrix4(matrix) {
|
|
65955
|
-
const start = this.attributes.instanceStart;
|
|
65956
|
-
const end = this.attributes.instanceEnd;
|
|
65957
|
-
if (start !== undefined) {
|
|
65958
|
-
start.applyMatrix4(matrix);
|
|
65959
|
-
end.applyMatrix4(matrix);
|
|
65960
|
-
start.needsUpdate = true;
|
|
65961
|
-
}
|
|
65962
|
-
if (this.boundingBox !== null) {
|
|
65963
|
-
this.computeBoundingBox();
|
|
65964
|
-
}
|
|
65965
|
-
if (this.boundingSphere !== null) {
|
|
65966
|
-
this.computeBoundingSphere();
|
|
65967
|
-
}
|
|
65968
|
-
return this;
|
|
65969
|
-
}
|
|
65970
|
-
setPositions(array) {
|
|
65971
|
-
let lineSegments;
|
|
65972
|
-
if (array instanceof Float32Array) {
|
|
65973
|
-
lineSegments = array;
|
|
65974
|
-
} else if (Array.isArray(array)) {
|
|
65975
|
-
lineSegments = new Float32Array(array);
|
|
65976
|
-
}
|
|
65977
|
-
const instanceBuffer = new THREE$2$1.InstancedInterleavedBuffer(lineSegments, 6, 1); // xyz, xyz
|
|
65936
|
+
class LineSegmentsGeometry extends InstancedBufferGeometry {
|
|
65978
65937
|
|
|
65979
|
-
|
|
65938
|
+
constructor() {
|
|
65980
65939
|
|
|
65981
|
-
|
|
65982
|
-
//
|
|
65940
|
+
super();
|
|
65983
65941
|
|
|
65984
|
-
|
|
65985
|
-
this.computeBoundingSphere();
|
|
65986
|
-
return this;
|
|
65987
|
-
}
|
|
65988
|
-
setColors(array) {
|
|
65989
|
-
let colors;
|
|
65990
|
-
if (array instanceof Float32Array) {
|
|
65991
|
-
colors = array;
|
|
65992
|
-
} else if (Array.isArray(array)) {
|
|
65993
|
-
colors = new Float32Array(array);
|
|
65994
|
-
}
|
|
65995
|
-
const instanceColorBuffer = new THREE$2$1.InstancedInterleavedBuffer(colors, 6, 1); // rgb, rgb
|
|
65942
|
+
this.isLineSegmentsGeometry = true;
|
|
65996
65943
|
|
|
65997
|
-
|
|
65944
|
+
this.type = 'LineSegmentsGeometry';
|
|
65998
65945
|
|
|
65999
|
-
|
|
65946
|
+
const positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
|
|
65947
|
+
const uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
|
|
65948
|
+
const index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
|
66000
65949
|
|
|
66001
|
-
|
|
66002
|
-
|
|
66003
|
-
|
|
66004
|
-
this.setPositions(geometry.attributes.position.array);
|
|
66005
|
-
return this;
|
|
66006
|
-
}
|
|
66007
|
-
fromEdgesGeometry(geometry) {
|
|
66008
|
-
this.setPositions(geometry.attributes.position.array);
|
|
66009
|
-
return this;
|
|
66010
|
-
}
|
|
66011
|
-
fromMesh(mesh) {
|
|
66012
|
-
this.fromWireframeGeometry(new THREE$2$1.WireframeGeometry(mesh.geometry)); // set colors, maybe
|
|
65950
|
+
this.setIndex( index );
|
|
65951
|
+
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
|
65952
|
+
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
66013
65953
|
|
|
66014
|
-
|
|
66015
|
-
|
|
66016
|
-
|
|
66017
|
-
|
|
66018
|
-
|
|
66019
|
-
|
|
66020
|
-
|
|
66021
|
-
|
|
66022
|
-
|
|
66023
|
-
|
|
65954
|
+
}
|
|
65955
|
+
|
|
65956
|
+
applyMatrix4( matrix ) {
|
|
65957
|
+
|
|
65958
|
+
const start = this.attributes.instanceStart;
|
|
65959
|
+
const end = this.attributes.instanceEnd;
|
|
65960
|
+
|
|
65961
|
+
if ( start !== undefined ) {
|
|
65962
|
+
|
|
65963
|
+
start.applyMatrix4( matrix );
|
|
65964
|
+
|
|
65965
|
+
end.applyMatrix4( matrix );
|
|
65966
|
+
|
|
65967
|
+
start.needsUpdate = true;
|
|
65968
|
+
|
|
65969
|
+
}
|
|
65970
|
+
|
|
65971
|
+
if ( this.boundingBox !== null ) {
|
|
65972
|
+
|
|
65973
|
+
this.computeBoundingBox();
|
|
65974
|
+
|
|
65975
|
+
}
|
|
65976
|
+
|
|
65977
|
+
if ( this.boundingSphere !== null ) {
|
|
65978
|
+
|
|
65979
|
+
this.computeBoundingSphere();
|
|
65980
|
+
|
|
65981
|
+
}
|
|
65982
|
+
|
|
65983
|
+
return this;
|
|
65984
|
+
|
|
65985
|
+
}
|
|
65986
|
+
|
|
65987
|
+
setPositions( array ) {
|
|
65988
|
+
|
|
65989
|
+
let lineSegments;
|
|
65990
|
+
|
|
65991
|
+
if ( array instanceof Float32Array ) {
|
|
65992
|
+
|
|
65993
|
+
lineSegments = array;
|
|
65994
|
+
|
|
65995
|
+
} else if ( Array.isArray( array ) ) {
|
|
65996
|
+
|
|
65997
|
+
lineSegments = new Float32Array( array );
|
|
65998
|
+
|
|
65999
|
+
}
|
|
66000
|
+
|
|
66001
|
+
const instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
|
66002
|
+
|
|
66003
|
+
this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
|
66004
|
+
this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
|
66005
|
+
|
|
66006
|
+
//
|
|
66007
|
+
|
|
66008
|
+
this.computeBoundingBox();
|
|
66009
|
+
this.computeBoundingSphere();
|
|
66010
|
+
|
|
66011
|
+
return this;
|
|
66012
|
+
|
|
66013
|
+
}
|
|
66014
|
+
|
|
66015
|
+
setColors( array ) {
|
|
66016
|
+
|
|
66017
|
+
let colors;
|
|
66018
|
+
|
|
66019
|
+
if ( array instanceof Float32Array ) {
|
|
66020
|
+
|
|
66021
|
+
colors = array;
|
|
66022
|
+
|
|
66023
|
+
} else if ( Array.isArray( array ) ) {
|
|
66024
|
+
|
|
66025
|
+
colors = new Float32Array( array );
|
|
66026
|
+
|
|
66027
|
+
}
|
|
66028
|
+
|
|
66029
|
+
const instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
|
66030
|
+
|
|
66031
|
+
this.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
|
66032
|
+
this.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
|
66033
|
+
|
|
66034
|
+
return this;
|
|
66035
|
+
|
|
66036
|
+
}
|
|
66037
|
+
|
|
66038
|
+
fromWireframeGeometry( geometry ) {
|
|
66039
|
+
|
|
66040
|
+
this.setPositions( geometry.attributes.position.array );
|
|
66041
|
+
|
|
66042
|
+
return this;
|
|
66043
|
+
|
|
66044
|
+
}
|
|
66045
|
+
|
|
66046
|
+
fromEdgesGeometry( geometry ) {
|
|
66047
|
+
|
|
66048
|
+
this.setPositions( geometry.attributes.position.array );
|
|
66049
|
+
|
|
66050
|
+
return this;
|
|
66051
|
+
|
|
66052
|
+
}
|
|
66053
|
+
|
|
66054
|
+
fromMesh( mesh ) {
|
|
66055
|
+
|
|
66056
|
+
this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
|
|
66057
|
+
|
|
66058
|
+
// set colors, maybe
|
|
66059
|
+
|
|
66060
|
+
return this;
|
|
66061
|
+
|
|
66062
|
+
}
|
|
66063
|
+
|
|
66064
|
+
fromLineSegments( lineSegments ) {
|
|
66065
|
+
|
|
66066
|
+
const geometry = lineSegments.geometry;
|
|
66067
|
+
|
|
66068
|
+
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
66069
|
+
|
|
66070
|
+
// set colors, maybe
|
|
66071
|
+
|
|
66072
|
+
return this;
|
|
66073
|
+
|
|
66074
|
+
}
|
|
66075
|
+
|
|
66076
|
+
computeBoundingBox() {
|
|
66077
|
+
|
|
66078
|
+
if ( this.boundingBox === null ) {
|
|
66079
|
+
|
|
66080
|
+
this.boundingBox = new Box3();
|
|
66081
|
+
|
|
66082
|
+
}
|
|
66083
|
+
|
|
66084
|
+
const start = this.attributes.instanceStart;
|
|
66085
|
+
const end = this.attributes.instanceEnd;
|
|
66086
|
+
|
|
66087
|
+
if ( start !== undefined && end !== undefined ) {
|
|
66088
|
+
|
|
66089
|
+
this.boundingBox.setFromBufferAttribute( start );
|
|
66090
|
+
|
|
66091
|
+
_box$1.setFromBufferAttribute( end );
|
|
66092
|
+
|
|
66093
|
+
this.boundingBox.union( _box$1 );
|
|
66094
|
+
|
|
66095
|
+
}
|
|
66096
|
+
|
|
66097
|
+
}
|
|
66098
|
+
|
|
66099
|
+
computeBoundingSphere() {
|
|
66100
|
+
|
|
66101
|
+
if ( this.boundingSphere === null ) {
|
|
66102
|
+
|
|
66103
|
+
this.boundingSphere = new Sphere();
|
|
66104
|
+
|
|
66105
|
+
}
|
|
66106
|
+
|
|
66107
|
+
if ( this.boundingBox === null ) {
|
|
66108
|
+
|
|
66109
|
+
this.computeBoundingBox();
|
|
66110
|
+
|
|
66111
|
+
}
|
|
66112
|
+
|
|
66113
|
+
const start = this.attributes.instanceStart;
|
|
66114
|
+
const end = this.attributes.instanceEnd;
|
|
66115
|
+
|
|
66116
|
+
if ( start !== undefined && end !== undefined ) {
|
|
66117
|
+
|
|
66118
|
+
const center = this.boundingSphere.center;
|
|
66119
|
+
|
|
66120
|
+
this.boundingBox.getCenter( center );
|
|
66121
|
+
|
|
66122
|
+
let maxRadiusSq = 0;
|
|
66123
|
+
|
|
66124
|
+
for ( let i = 0, il = start.count; i < il; i ++ ) {
|
|
66125
|
+
|
|
66126
|
+
_vector.fromBufferAttribute( start, i );
|
|
66127
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
66128
|
+
|
|
66129
|
+
_vector.fromBufferAttribute( end, i );
|
|
66130
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
66131
|
+
|
|
66132
|
+
}
|
|
66133
|
+
|
|
66134
|
+
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
66135
|
+
|
|
66136
|
+
if ( isNaN( this.boundingSphere.radius ) ) {
|
|
66137
|
+
|
|
66138
|
+
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
|
|
66139
|
+
|
|
66140
|
+
}
|
|
66141
|
+
|
|
66142
|
+
}
|
|
66143
|
+
|
|
66144
|
+
}
|
|
66145
|
+
|
|
66146
|
+
toJSON() {
|
|
66147
|
+
|
|
66148
|
+
// todo
|
|
66149
|
+
|
|
66150
|
+
}
|
|
66151
|
+
|
|
66152
|
+
applyMatrix( matrix ) {
|
|
66153
|
+
|
|
66154
|
+
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
|
|
66155
|
+
|
|
66156
|
+
return this.applyMatrix4( matrix );
|
|
66157
|
+
|
|
66158
|
+
}
|
|
66024
66159
|
|
|
66025
|
-
return this;
|
|
66026
|
-
}
|
|
66027
|
-
computeBoundingBox() {
|
|
66028
|
-
if (this.boundingBox === null) {
|
|
66029
|
-
this.boundingBox = new THREE$2$1.Box3();
|
|
66030
|
-
}
|
|
66031
|
-
const start = this.attributes.instanceStart;
|
|
66032
|
-
const end = this.attributes.instanceEnd;
|
|
66033
|
-
if (start !== undefined && end !== undefined) {
|
|
66034
|
-
this.boundingBox.setFromBufferAttribute(start);
|
|
66035
|
-
_box$1.setFromBufferAttribute(end);
|
|
66036
|
-
this.boundingBox.union(_box$1);
|
|
66037
|
-
}
|
|
66038
|
-
}
|
|
66039
|
-
computeBoundingSphere() {
|
|
66040
|
-
if (this.boundingSphere === null) {
|
|
66041
|
-
this.boundingSphere = new THREE$2$1.Sphere();
|
|
66042
|
-
}
|
|
66043
|
-
if (this.boundingBox === null) {
|
|
66044
|
-
this.computeBoundingBox();
|
|
66045
|
-
}
|
|
66046
|
-
const start = this.attributes.instanceStart;
|
|
66047
|
-
const end = this.attributes.instanceEnd;
|
|
66048
|
-
if (start !== undefined && end !== undefined) {
|
|
66049
|
-
const center = this.boundingSphere.center;
|
|
66050
|
-
this.boundingBox.getCenter(center);
|
|
66051
|
-
let maxRadiusSq = 0;
|
|
66052
|
-
for (let i = 0, il = start.count; i < il; i++) {
|
|
66053
|
-
_vector.fromBufferAttribute(start, i);
|
|
66054
|
-
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector));
|
|
66055
|
-
_vector.fromBufferAttribute(end, i);
|
|
66056
|
-
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector));
|
|
66057
|
-
}
|
|
66058
|
-
this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
|
|
66059
|
-
if (isNaN(this.boundingSphere.radius)) {
|
|
66060
|
-
console.error('THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this);
|
|
66061
|
-
}
|
|
66062
|
-
}
|
|
66063
|
-
}
|
|
66064
|
-
toJSON() {// todo
|
|
66065
|
-
}
|
|
66066
|
-
applyMatrix(matrix) {
|
|
66067
|
-
console.warn('THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().');
|
|
66068
|
-
return this.applyMatrix4(matrix);
|
|
66069
|
-
}
|
|
66070
66160
|
}
|
|
66071
|
-
LineSegmentsGeometry.prototype.isLineSegmentsGeometry = true;
|
|
66072
66161
|
|
|
66073
|
-
|
|
66074
|
-
|
|
66075
|
-
|
|
66076
|
-
|
|
66077
|
-
|
|
66078
|
-
|
|
66079
|
-
|
|
66080
|
-
|
|
66081
|
-
|
|
66082
|
-
* resolution: <Vector2>, // to be set by renderer
|
|
66083
|
-
* }
|
|
66084
|
-
*/
|
|
66162
|
+
UniformsLib.line = {
|
|
66163
|
+
|
|
66164
|
+
worldUnits: { value: 1 },
|
|
66165
|
+
linewidth: { value: 1 },
|
|
66166
|
+
resolution: { value: new Vector2( 1, 1 ) },
|
|
66167
|
+
dashOffset: { value: 0 },
|
|
66168
|
+
dashScale: { value: 1 },
|
|
66169
|
+
dashSize: { value: 1 },
|
|
66170
|
+
gapSize: { value: 1 } // todo FIX - maybe change to totalSize
|
|
66085
66171
|
|
|
66086
|
-
const THREE$1$1 = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
66087
|
-
: {
|
|
66088
|
-
ShaderLib,
|
|
66089
|
-
ShaderMaterial,
|
|
66090
|
-
UniformsLib,
|
|
66091
|
-
UniformsUtils,
|
|
66092
|
-
Vector2
|
|
66093
|
-
};
|
|
66094
|
-
THREE$1$1.UniformsLib.line = {
|
|
66095
|
-
worldUnits: {
|
|
66096
|
-
value: 1
|
|
66097
|
-
},
|
|
66098
|
-
linewidth: {
|
|
66099
|
-
value: 1
|
|
66100
|
-
},
|
|
66101
|
-
resolution: {
|
|
66102
|
-
value: new THREE$1$1.Vector2(1, 1)
|
|
66103
|
-
},
|
|
66104
|
-
dashScale: {
|
|
66105
|
-
value: 1
|
|
66106
|
-
},
|
|
66107
|
-
dashSize: {
|
|
66108
|
-
value: 1
|
|
66109
|
-
},
|
|
66110
|
-
dashOffset: {
|
|
66111
|
-
value: 0
|
|
66112
|
-
},
|
|
66113
|
-
gapSize: {
|
|
66114
|
-
value: 1
|
|
66115
|
-
} // todo FIX - maybe change to totalSize
|
|
66116
66172
|
};
|
|
66117
|
-
|
|
66118
|
-
|
|
66119
|
-
|
|
66120
|
-
|
|
66173
|
+
|
|
66174
|
+
ShaderLib[ 'line' ] = {
|
|
66175
|
+
|
|
66176
|
+
uniforms: UniformsUtils.merge( [
|
|
66177
|
+
UniformsLib.common,
|
|
66178
|
+
UniformsLib.fog,
|
|
66179
|
+
UniformsLib.line
|
|
66180
|
+
] ),
|
|
66181
|
+
|
|
66182
|
+
vertexShader:
|
|
66183
|
+
/* glsl */`
|
|
66121
66184
|
#include <common>
|
|
66122
66185
|
#include <color_pars_vertex>
|
|
66123
66186
|
#include <fog_pars_vertex>
|
|
@@ -66133,10 +66196,23 @@ void main() {
|
|
|
66133
66196
|
attribute vec3 instanceColorStart;
|
|
66134
66197
|
attribute vec3 instanceColorEnd;
|
|
66135
66198
|
|
|
66136
|
-
|
|
66137
|
-
|
|
66138
|
-
|
|
66139
|
-
|
|
66199
|
+
#ifdef WORLD_UNITS
|
|
66200
|
+
|
|
66201
|
+
varying vec4 worldPos;
|
|
66202
|
+
varying vec3 worldStart;
|
|
66203
|
+
varying vec3 worldEnd;
|
|
66204
|
+
|
|
66205
|
+
#ifdef USE_DASH
|
|
66206
|
+
|
|
66207
|
+
varying vec2 vUv;
|
|
66208
|
+
|
|
66209
|
+
#endif
|
|
66210
|
+
|
|
66211
|
+
#else
|
|
66212
|
+
|
|
66213
|
+
varying vec2 vUv;
|
|
66214
|
+
|
|
66215
|
+
#endif
|
|
66140
66216
|
|
|
66141
66217
|
#ifdef USE_DASH
|
|
66142
66218
|
|
|
@@ -66173,19 +66249,26 @@ void main() {
|
|
|
66173
66249
|
#ifdef USE_DASH
|
|
66174
66250
|
|
|
66175
66251
|
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
66252
|
+
vUv = uv;
|
|
66176
66253
|
|
|
66177
66254
|
#endif
|
|
66178
66255
|
|
|
66179
66256
|
float aspect = resolution.x / resolution.y;
|
|
66180
66257
|
|
|
66181
|
-
vUv = uv;
|
|
66182
|
-
|
|
66183
66258
|
// camera space
|
|
66184
66259
|
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
66185
66260
|
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
66186
66261
|
|
|
66187
|
-
|
|
66188
|
-
|
|
66262
|
+
#ifdef WORLD_UNITS
|
|
66263
|
+
|
|
66264
|
+
worldStart = start.xyz;
|
|
66265
|
+
worldEnd = end.xyz;
|
|
66266
|
+
|
|
66267
|
+
#else
|
|
66268
|
+
|
|
66269
|
+
vUv = uv;
|
|
66270
|
+
|
|
66271
|
+
#endif
|
|
66189
66272
|
|
|
66190
66273
|
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
66191
66274
|
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
@@ -66225,94 +66308,77 @@ void main() {
|
|
|
66225
66308
|
|
|
66226
66309
|
#ifdef WORLD_UNITS
|
|
66227
66310
|
|
|
66228
|
-
// get the offset direction as perpendicular to the view vector
|
|
66229
66311
|
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
66230
|
-
vec3
|
|
66231
|
-
|
|
66232
|
-
|
|
66233
|
-
|
|
66234
|
-
|
|
66235
|
-
} else {
|
|
66236
|
-
|
|
66237
|
-
offset = normalize( cross( end.xyz, worldDir ) );
|
|
66238
|
-
|
|
66239
|
-
}
|
|
66240
|
-
|
|
66241
|
-
// sign flip
|
|
66242
|
-
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
66312
|
+
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
66313
|
+
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
66314
|
+
vec3 worldFwd = cross( worldDir, worldUp );
|
|
66315
|
+
worldPos = position.y < 0.5 ? start: end;
|
|
66243
66316
|
|
|
66244
|
-
|
|
66317
|
+
// height offset
|
|
66318
|
+
float hw = linewidth * 0.5;
|
|
66319
|
+
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
66245
66320
|
|
|
66246
66321
|
// don't extend the line if we're rendering dashes because we
|
|
66247
66322
|
// won't be rendering the endcaps
|
|
66248
66323
|
#ifndef USE_DASH
|
|
66249
66324
|
|
|
66250
|
-
//
|
|
66251
|
-
|
|
66252
|
-
end.xyz += worldDir * linewidth * 0.5;
|
|
66253
|
-
|
|
66254
|
-
// shift the position of the quad so it hugs the forward edge of the line
|
|
66255
|
-
offset.xy -= dir * forwardOffset;
|
|
66256
|
-
offset.z += 0.5;
|
|
66257
|
-
|
|
66258
|
-
#endif
|
|
66325
|
+
// cap extension
|
|
66326
|
+
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
66259
66327
|
|
|
66260
|
-
|
|
66261
|
-
|
|
66328
|
+
// add width to the box
|
|
66329
|
+
worldPos.xyz += worldFwd * hw;
|
|
66262
66330
|
|
|
66263
|
-
|
|
66331
|
+
// endcaps
|
|
66332
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
66264
66333
|
|
|
66265
|
-
|
|
66334
|
+
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
66266
66335
|
|
|
66267
|
-
|
|
66268
|
-
offset *= linewidth * 0.5;
|
|
66336
|
+
}
|
|
66269
66337
|
|
|
66270
|
-
|
|
66271
|
-
worldPos = ( position.y < 0.5 ) ? start : end;
|
|
66272
|
-
worldPos.xyz += offset;
|
|
66338
|
+
#endif
|
|
66273
66339
|
|
|
66274
66340
|
// project the worldpos
|
|
66275
66341
|
vec4 clip = projectionMatrix * worldPos;
|
|
66276
66342
|
|
|
66277
66343
|
// shift the depth of the projected points so the line
|
|
66278
|
-
//
|
|
66344
|
+
// segments overlap neatly
|
|
66279
66345
|
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
66280
66346
|
clip.z = clipPose.z * clip.w;
|
|
66281
66347
|
|
|
66282
66348
|
#else
|
|
66283
66349
|
|
|
66284
|
-
|
|
66285
|
-
|
|
66286
|
-
|
|
66287
|
-
|
|
66350
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
66351
|
+
// undo aspect ratio adjustment
|
|
66352
|
+
dir.x /= aspect;
|
|
66353
|
+
offset.x /= aspect;
|
|
66288
66354
|
|
|
66289
|
-
|
|
66290
|
-
|
|
66355
|
+
// sign flip
|
|
66356
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
66291
66357
|
|
|
66292
|
-
|
|
66293
|
-
|
|
66358
|
+
// endcaps
|
|
66359
|
+
if ( position.y < 0.0 ) {
|
|
66294
66360
|
|
|
66295
|
-
|
|
66361
|
+
offset += - dir;
|
|
66296
66362
|
|
|
66297
|
-
|
|
66363
|
+
} else if ( position.y > 1.0 ) {
|
|
66298
66364
|
|
|
66299
|
-
|
|
66365
|
+
offset += dir;
|
|
66300
66366
|
|
|
66301
|
-
|
|
66367
|
+
}
|
|
66302
66368
|
|
|
66303
|
-
|
|
66304
|
-
|
|
66369
|
+
// adjust for linewidth
|
|
66370
|
+
offset *= linewidth;
|
|
66305
66371
|
|
|
66306
|
-
|
|
66307
|
-
|
|
66372
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
66373
|
+
offset /= resolution.y;
|
|
66308
66374
|
|
|
66309
|
-
|
|
66310
|
-
|
|
66375
|
+
// select end
|
|
66376
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
66311
66377
|
|
|
66312
|
-
|
|
66313
|
-
|
|
66378
|
+
// back to clip space
|
|
66379
|
+
offset *= clip.w;
|
|
66314
66380
|
|
|
66315
|
-
|
|
66381
|
+
clip.xy += offset;
|
|
66316
66382
|
|
|
66317
66383
|
#endif
|
|
66318
66384
|
|
|
@@ -66326,8 +66392,9 @@ void main() {
|
|
|
66326
66392
|
|
|
66327
66393
|
}
|
|
66328
66394
|
`,
|
|
66329
|
-
|
|
66330
|
-
|
|
66395
|
+
|
|
66396
|
+
fragmentShader:
|
|
66397
|
+
/* glsl */`
|
|
66331
66398
|
uniform vec3 diffuse;
|
|
66332
66399
|
uniform float opacity;
|
|
66333
66400
|
uniform float linewidth;
|
|
@@ -66341,9 +66408,24 @@ void main() {
|
|
|
66341
66408
|
#endif
|
|
66342
66409
|
|
|
66343
66410
|
varying float vLineDistance;
|
|
66344
|
-
|
|
66345
|
-
|
|
66346
|
-
|
|
66411
|
+
|
|
66412
|
+
#ifdef WORLD_UNITS
|
|
66413
|
+
|
|
66414
|
+
varying vec4 worldPos;
|
|
66415
|
+
varying vec3 worldStart;
|
|
66416
|
+
varying vec3 worldEnd;
|
|
66417
|
+
|
|
66418
|
+
#ifdef USE_DASH
|
|
66419
|
+
|
|
66420
|
+
varying vec2 vUv;
|
|
66421
|
+
|
|
66422
|
+
#endif
|
|
66423
|
+
|
|
66424
|
+
#else
|
|
66425
|
+
|
|
66426
|
+
varying vec2 vUv;
|
|
66427
|
+
|
|
66428
|
+
#endif
|
|
66347
66429
|
|
|
66348
66430
|
#include <common>
|
|
66349
66431
|
#include <color_pars_fragment>
|
|
@@ -66351,8 +66433,6 @@ void main() {
|
|
|
66351
66433
|
#include <logdepthbuf_pars_fragment>
|
|
66352
66434
|
#include <clipping_planes_pars_fragment>
|
|
66353
66435
|
|
|
66354
|
-
varying vec2 vUv;
|
|
66355
|
-
|
|
66356
66436
|
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
66357
66437
|
|
|
66358
66438
|
float mua;
|
|
@@ -66411,7 +66491,7 @@ void main() {
|
|
|
66411
66491
|
|
|
66412
66492
|
#ifndef USE_DASH
|
|
66413
66493
|
|
|
66414
|
-
#ifdef
|
|
66494
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
66415
66495
|
|
|
66416
66496
|
float dnorm = fwidth( norm );
|
|
66417
66497
|
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
@@ -66426,11 +66506,11 @@ void main() {
|
|
|
66426
66506
|
|
|
66427
66507
|
#endif
|
|
66428
66508
|
|
|
66429
|
-
|
|
66509
|
+
#endif
|
|
66430
66510
|
|
|
66431
66511
|
#else
|
|
66432
66512
|
|
|
66433
|
-
#ifdef
|
|
66513
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
66434
66514
|
|
|
66435
66515
|
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
66436
66516
|
float a = vUv.x;
|
|
@@ -66446,15 +66526,15 @@ void main() {
|
|
|
66446
66526
|
|
|
66447
66527
|
#else
|
|
66448
66528
|
|
|
66449
|
-
|
|
66529
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
66450
66530
|
|
|
66451
|
-
|
|
66452
|
-
|
|
66453
|
-
|
|
66531
|
+
float a = vUv.x;
|
|
66532
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
66533
|
+
float len2 = a * a + b * b;
|
|
66454
66534
|
|
|
66455
|
-
|
|
66535
|
+
if ( len2 > 1.0 ) discard;
|
|
66456
66536
|
|
|
66457
|
-
|
|
66537
|
+
}
|
|
66458
66538
|
|
|
66459
66539
|
#endif
|
|
66460
66540
|
|
|
@@ -66475,400 +66555,653 @@ void main() {
|
|
|
66475
66555
|
}
|
|
66476
66556
|
`
|
|
66477
66557
|
};
|
|
66478
|
-
|
|
66479
|
-
|
|
66480
|
-
|
|
66481
|
-
|
|
66482
|
-
|
|
66483
|
-
|
|
66484
|
-
|
|
66485
|
-
|
|
66486
|
-
|
|
66487
|
-
|
|
66488
|
-
|
|
66489
|
-
|
|
66490
|
-
|
|
66491
|
-
|
|
66492
|
-
|
|
66493
|
-
|
|
66494
|
-
|
|
66495
|
-
|
|
66496
|
-
|
|
66497
|
-
|
|
66498
|
-
|
|
66499
|
-
|
|
66500
|
-
|
|
66501
|
-
|
|
66502
|
-
|
|
66503
|
-
|
|
66504
|
-
|
|
66505
|
-
|
|
66506
|
-
|
|
66507
|
-
|
|
66508
|
-
|
|
66509
|
-
|
|
66510
|
-
|
|
66511
|
-
|
|
66512
|
-
|
|
66513
|
-
|
|
66514
|
-
|
|
66515
|
-
|
|
66516
|
-
|
|
66517
|
-
|
|
66518
|
-
|
|
66519
|
-
|
|
66520
|
-
|
|
66521
|
-
|
|
66522
|
-
|
|
66523
|
-
|
|
66524
|
-
|
|
66525
|
-
|
|
66526
|
-
|
|
66527
|
-
|
|
66528
|
-
|
|
66529
|
-
|
|
66530
|
-
|
|
66531
|
-
|
|
66532
|
-
|
|
66533
|
-
|
|
66534
|
-
|
|
66535
|
-
|
|
66536
|
-
|
|
66537
|
-
|
|
66538
|
-
|
|
66539
|
-
|
|
66540
|
-
|
|
66541
|
-
|
|
66542
|
-
|
|
66543
|
-
|
|
66544
|
-
|
|
66545
|
-
|
|
66546
|
-
|
|
66547
|
-
|
|
66548
|
-
|
|
66549
|
-
|
|
66550
|
-
|
|
66551
|
-
|
|
66552
|
-
|
|
66553
|
-
|
|
66554
|
-
|
|
66555
|
-
|
|
66556
|
-
|
|
66557
|
-
|
|
66558
|
-
|
|
66559
|
-
|
|
66560
|
-
|
|
66561
|
-
|
|
66562
|
-
|
|
66563
|
-
|
|
66564
|
-
|
|
66565
|
-
|
|
66566
|
-
|
|
66567
|
-
|
|
66568
|
-
|
|
66569
|
-
|
|
66570
|
-
|
|
66571
|
-
|
|
66572
|
-
|
|
66573
|
-
|
|
66574
|
-
|
|
66575
|
-
|
|
66576
|
-
|
|
66577
|
-
|
|
66578
|
-
|
|
66579
|
-
|
|
66580
|
-
|
|
66581
|
-
|
|
66582
|
-
|
|
66583
|
-
|
|
66584
|
-
|
|
66585
|
-
|
|
66586
|
-
|
|
66587
|
-
|
|
66588
|
-
|
|
66589
|
-
|
|
66590
|
-
|
|
66591
|
-
|
|
66592
|
-
|
|
66593
|
-
|
|
66594
|
-
|
|
66595
|
-
|
|
66596
|
-
|
|
66597
|
-
|
|
66598
|
-
|
|
66599
|
-
|
|
66600
|
-
|
|
66601
|
-
|
|
66602
|
-
|
|
66603
|
-
|
|
66604
|
-
|
|
66605
|
-
|
|
66606
|
-
|
|
66607
|
-
|
|
66608
|
-
|
|
66609
|
-
|
|
66558
|
+
|
|
66559
|
+
class LineMaterial extends ShaderMaterial {
|
|
66560
|
+
|
|
66561
|
+
constructor( parameters ) {
|
|
66562
|
+
|
|
66563
|
+
super( {
|
|
66564
|
+
|
|
66565
|
+
type: 'LineMaterial',
|
|
66566
|
+
|
|
66567
|
+
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
|
|
66568
|
+
|
|
66569
|
+
vertexShader: ShaderLib[ 'line' ].vertexShader,
|
|
66570
|
+
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
|
|
66571
|
+
|
|
66572
|
+
clipping: true // required for clipping support
|
|
66573
|
+
|
|
66574
|
+
} );
|
|
66575
|
+
|
|
66576
|
+
this.isLineMaterial = true;
|
|
66577
|
+
|
|
66578
|
+
this.setValues( parameters );
|
|
66579
|
+
|
|
66580
|
+
}
|
|
66581
|
+
|
|
66582
|
+
get color() {
|
|
66583
|
+
|
|
66584
|
+
return this.uniforms.diffuse.value;
|
|
66585
|
+
|
|
66586
|
+
}
|
|
66587
|
+
|
|
66588
|
+
set color( value ) {
|
|
66589
|
+
|
|
66590
|
+
this.uniforms.diffuse.value = value;
|
|
66591
|
+
|
|
66592
|
+
}
|
|
66593
|
+
|
|
66594
|
+
get worldUnits() {
|
|
66595
|
+
|
|
66596
|
+
return 'WORLD_UNITS' in this.defines;
|
|
66597
|
+
|
|
66598
|
+
}
|
|
66599
|
+
|
|
66600
|
+
set worldUnits( value ) {
|
|
66601
|
+
|
|
66602
|
+
if ( value === true ) {
|
|
66603
|
+
|
|
66604
|
+
this.defines.WORLD_UNITS = '';
|
|
66605
|
+
|
|
66606
|
+
} else {
|
|
66607
|
+
|
|
66608
|
+
delete this.defines.WORLD_UNITS;
|
|
66609
|
+
|
|
66610
|
+
}
|
|
66611
|
+
|
|
66612
|
+
}
|
|
66613
|
+
|
|
66614
|
+
get linewidth() {
|
|
66615
|
+
|
|
66616
|
+
return this.uniforms.linewidth.value;
|
|
66617
|
+
|
|
66618
|
+
}
|
|
66619
|
+
|
|
66620
|
+
set linewidth( value ) {
|
|
66621
|
+
|
|
66622
|
+
if ( ! this.uniforms.linewidth ) return;
|
|
66623
|
+
this.uniforms.linewidth.value = value;
|
|
66624
|
+
|
|
66625
|
+
}
|
|
66626
|
+
|
|
66627
|
+
get dashed() {
|
|
66628
|
+
|
|
66629
|
+
return 'USE_DASH' in this.defines;
|
|
66630
|
+
|
|
66631
|
+
}
|
|
66632
|
+
|
|
66633
|
+
set dashed( value ) {
|
|
66634
|
+
|
|
66635
|
+
if ( ( value === true ) !== this.dashed ) {
|
|
66636
|
+
|
|
66637
|
+
this.needsUpdate = true;
|
|
66638
|
+
|
|
66639
|
+
}
|
|
66640
|
+
|
|
66641
|
+
if ( value === true ) {
|
|
66642
|
+
|
|
66643
|
+
this.defines.USE_DASH = '';
|
|
66644
|
+
|
|
66645
|
+
} else {
|
|
66646
|
+
|
|
66647
|
+
delete this.defines.USE_DASH;
|
|
66648
|
+
|
|
66649
|
+
}
|
|
66650
|
+
|
|
66651
|
+
}
|
|
66652
|
+
|
|
66653
|
+
get dashScale() {
|
|
66654
|
+
|
|
66655
|
+
return this.uniforms.dashScale.value;
|
|
66656
|
+
|
|
66657
|
+
}
|
|
66658
|
+
|
|
66659
|
+
set dashScale( value ) {
|
|
66660
|
+
|
|
66661
|
+
this.uniforms.dashScale.value = value;
|
|
66662
|
+
|
|
66663
|
+
}
|
|
66664
|
+
|
|
66665
|
+
get dashSize() {
|
|
66666
|
+
|
|
66667
|
+
return this.uniforms.dashSize.value;
|
|
66668
|
+
|
|
66669
|
+
}
|
|
66670
|
+
|
|
66671
|
+
set dashSize( value ) {
|
|
66672
|
+
|
|
66673
|
+
this.uniforms.dashSize.value = value;
|
|
66674
|
+
|
|
66675
|
+
}
|
|
66676
|
+
|
|
66677
|
+
get dashOffset() {
|
|
66678
|
+
|
|
66679
|
+
return this.uniforms.dashOffset.value;
|
|
66680
|
+
|
|
66681
|
+
}
|
|
66682
|
+
|
|
66683
|
+
set dashOffset( value ) {
|
|
66684
|
+
|
|
66685
|
+
this.uniforms.dashOffset.value = value;
|
|
66686
|
+
|
|
66687
|
+
}
|
|
66688
|
+
|
|
66689
|
+
get gapSize() {
|
|
66690
|
+
|
|
66691
|
+
return this.uniforms.gapSize.value;
|
|
66692
|
+
|
|
66693
|
+
}
|
|
66694
|
+
|
|
66695
|
+
set gapSize( value ) {
|
|
66696
|
+
|
|
66697
|
+
this.uniforms.gapSize.value = value;
|
|
66698
|
+
|
|
66699
|
+
}
|
|
66700
|
+
|
|
66701
|
+
get opacity() {
|
|
66702
|
+
|
|
66703
|
+
return this.uniforms.opacity.value;
|
|
66704
|
+
|
|
66705
|
+
}
|
|
66706
|
+
|
|
66707
|
+
set opacity( value ) {
|
|
66708
|
+
|
|
66709
|
+
if ( ! this.uniforms ) return;
|
|
66710
|
+
this.uniforms.opacity.value = value;
|
|
66711
|
+
|
|
66712
|
+
}
|
|
66713
|
+
|
|
66714
|
+
get resolution() {
|
|
66715
|
+
|
|
66716
|
+
return this.uniforms.resolution.value;
|
|
66717
|
+
|
|
66718
|
+
}
|
|
66719
|
+
|
|
66720
|
+
set resolution( value ) {
|
|
66721
|
+
|
|
66722
|
+
this.uniforms.resolution.value.copy( value );
|
|
66723
|
+
|
|
66724
|
+
}
|
|
66725
|
+
|
|
66726
|
+
get alphaToCoverage() {
|
|
66727
|
+
|
|
66728
|
+
return 'USE_ALPHA_TO_COVERAGE' in this.defines;
|
|
66729
|
+
|
|
66730
|
+
}
|
|
66731
|
+
|
|
66732
|
+
set alphaToCoverage( value ) {
|
|
66733
|
+
|
|
66734
|
+
if ( ! this.defines ) return;
|
|
66735
|
+
|
|
66736
|
+
if ( ( value === true ) !== this.alphaToCoverage ) {
|
|
66737
|
+
|
|
66738
|
+
this.needsUpdate = true;
|
|
66739
|
+
|
|
66740
|
+
}
|
|
66741
|
+
|
|
66742
|
+
if ( value === true ) {
|
|
66743
|
+
|
|
66744
|
+
this.defines.USE_ALPHA_TO_COVERAGE = '';
|
|
66745
|
+
|
|
66746
|
+
} else {
|
|
66747
|
+
|
|
66748
|
+
delete this.defines.USE_ALPHA_TO_COVERAGE;
|
|
66749
|
+
|
|
66750
|
+
}
|
|
66751
|
+
|
|
66752
|
+
}
|
|
66753
|
+
|
|
66610
66754
|
}
|
|
66611
|
-
LineMaterial.prototype.isLineMaterial = true;
|
|
66612
66755
|
|
|
66613
|
-
const
|
|
66614
|
-
: {
|
|
66615
|
-
Box3,
|
|
66616
|
-
BufferGeometry,
|
|
66617
|
-
InstancedInterleavedBuffer,
|
|
66618
|
-
InterleavedBufferAttribute,
|
|
66619
|
-
Line3,
|
|
66620
|
-
MathUtils,
|
|
66621
|
-
Matrix4,
|
|
66622
|
-
Mesh,
|
|
66623
|
-
Sphere,
|
|
66624
|
-
Vector3,
|
|
66625
|
-
Vector4
|
|
66626
|
-
};
|
|
66756
|
+
const _viewport = new Vector4();
|
|
66627
66757
|
|
|
66628
|
-
|
|
66629
|
-
|
|
66630
|
-
const _start = new THREE$j.Vector3();
|
|
66631
|
-
const _end = new THREE$j.Vector3();
|
|
66632
|
-
const _start4 = new THREE$j.Vector4();
|
|
66633
|
-
const _end4 = new THREE$j.Vector4();
|
|
66634
|
-
const _ssOrigin = new THREE$j.Vector4();
|
|
66635
|
-
const _ssOrigin3 = new THREE$j.Vector3();
|
|
66636
|
-
const _mvMatrix = new THREE$j.Matrix4();
|
|
66637
|
-
const _line = new THREE$j.Line3();
|
|
66638
|
-
const _closestPoint = new THREE$j.Vector3();
|
|
66639
|
-
const _box = new THREE$j.Box3();
|
|
66640
|
-
const _sphere = new THREE$j.Sphere();
|
|
66641
|
-
const _clipToWorldVector = new THREE$j.Vector4();
|
|
66642
|
-
class LineSegments2 extends THREE$j.Mesh {
|
|
66643
|
-
constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({
|
|
66644
|
-
color: Math.random() * 0xffffff
|
|
66645
|
-
})) {
|
|
66646
|
-
super(geometry, material);
|
|
66647
|
-
this.type = 'LineSegments2';
|
|
66648
|
-
} // for backwards-compatability, but could be a method of LineSegmentsGeometry...
|
|
66649
|
-
|
|
66650
|
-
computeLineDistances() {
|
|
66651
|
-
const geometry = this.geometry;
|
|
66652
|
-
const instanceStart = geometry.attributes.instanceStart;
|
|
66653
|
-
const instanceEnd = geometry.attributes.instanceEnd;
|
|
66654
|
-
const lineDistances = new Float32Array(2 * instanceStart.count);
|
|
66655
|
-
for (let i = 0, j = 0, l = instanceStart.count; i < l; i++, j += 2) {
|
|
66656
|
-
_start.fromBufferAttribute(instanceStart, i);
|
|
66657
|
-
_end.fromBufferAttribute(instanceEnd, i);
|
|
66658
|
-
lineDistances[j] = j === 0 ? 0 : lineDistances[j - 1];
|
|
66659
|
-
lineDistances[j + 1] = lineDistances[j] + _start.distanceTo(_end);
|
|
66660
|
-
}
|
|
66661
|
-
const instanceDistanceBuffer = new THREE$j.InstancedInterleavedBuffer(lineDistances, 2, 1); // d0, d1
|
|
66758
|
+
const _start = new Vector3();
|
|
66759
|
+
const _end = new Vector3();
|
|
66662
66760
|
|
|
66663
|
-
|
|
66761
|
+
const _start4 = new Vector4();
|
|
66762
|
+
const _end4 = new Vector4();
|
|
66664
66763
|
|
|
66665
|
-
|
|
66764
|
+
const _ssOrigin = new Vector4();
|
|
66765
|
+
const _ssOrigin3 = new Vector3();
|
|
66766
|
+
const _mvMatrix = new Matrix4();
|
|
66767
|
+
const _line = new Line3();
|
|
66768
|
+
const _closestPoint = new Vector3();
|
|
66666
66769
|
|
|
66667
|
-
|
|
66668
|
-
|
|
66669
|
-
|
|
66670
|
-
if (raycaster.camera === null) {
|
|
66671
|
-
console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');
|
|
66672
|
-
}
|
|
66673
|
-
const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0;
|
|
66674
|
-
const ray = raycaster.ray;
|
|
66675
|
-
const camera = raycaster.camera;
|
|
66676
|
-
const projectionMatrix = camera.projectionMatrix;
|
|
66677
|
-
const matrixWorld = this.matrixWorld;
|
|
66678
|
-
const geometry = this.geometry;
|
|
66679
|
-
const material = this.material;
|
|
66680
|
-
const resolution = material.resolution;
|
|
66681
|
-
const lineWidth = material.linewidth + threshold;
|
|
66682
|
-
const instanceStart = geometry.attributes.instanceStart;
|
|
66683
|
-
const instanceEnd = geometry.attributes.instanceEnd; // camera forward is negative
|
|
66684
|
-
|
|
66685
|
-
const near = -camera.near; // clip space is [ - 1, 1 ] so multiply by two to get the full
|
|
66686
|
-
// width in clip space
|
|
66687
|
-
|
|
66688
|
-
const ssMaxWidth = 2.0 * Math.max(lineWidth / resolution.width, lineWidth / resolution.height); //
|
|
66689
|
-
// check if we intersect the sphere bounds
|
|
66690
|
-
|
|
66691
|
-
if (geometry.boundingSphere === null) {
|
|
66692
|
-
geometry.computeBoundingSphere();
|
|
66693
|
-
}
|
|
66694
|
-
_sphere.copy(geometry.boundingSphere).applyMatrix4(matrixWorld);
|
|
66695
|
-
const distanceToSphere = Math.max(camera.near, _sphere.distanceToPoint(ray.origin)); // get the w component to scale the world space line width
|
|
66770
|
+
const _box = new Box3();
|
|
66771
|
+
const _sphere = new Sphere();
|
|
66772
|
+
const _clipToWorldVector = new Vector4();
|
|
66696
66773
|
|
|
66697
|
-
|
|
66698
|
-
_clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w);
|
|
66699
|
-
_clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse); // increase the sphere bounds by the worst case line screen space width
|
|
66774
|
+
let _ray$1, _lineWidth;
|
|
66700
66775
|
|
|
66701
|
-
|
|
66702
|
-
|
|
66703
|
-
|
|
66704
|
-
|
|
66705
|
-
|
|
66706
|
-
|
|
66776
|
+
// Returns the margin required to expand by in world space given the distance from the camera,
|
|
66777
|
+
// line width, resolution, and camera projection
|
|
66778
|
+
function getWorldSpaceHalfWidth( camera, distance, resolution ) {
|
|
66779
|
+
|
|
66780
|
+
// transform into clip space, adjust the x and y values by the pixel width offset, then
|
|
66781
|
+
// transform back into world space to get world offset. Note clip space is [-1, 1] so full
|
|
66782
|
+
// width does not need to be halved.
|
|
66783
|
+
_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );
|
|
66784
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
66785
|
+
_clipToWorldVector.x = _lineWidth / resolution.width;
|
|
66786
|
+
_clipToWorldVector.y = _lineWidth / resolution.height;
|
|
66787
|
+
_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );
|
|
66788
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
66789
|
+
|
|
66790
|
+
return Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );
|
|
66791
|
+
|
|
66792
|
+
}
|
|
66793
|
+
|
|
66794
|
+
function raycastWorldUnits( lineSegments, intersects ) {
|
|
66795
|
+
|
|
66796
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
66797
|
+
const geometry = lineSegments.geometry;
|
|
66798
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
66799
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
66800
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
66801
|
+
|
|
66802
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
66803
|
+
|
|
66804
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
66805
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
66806
|
+
|
|
66807
|
+
_line.applyMatrix4( matrixWorld );
|
|
66808
|
+
|
|
66809
|
+
const pointOnLine = new Vector3();
|
|
66810
|
+
const point = new Vector3();
|
|
66811
|
+
|
|
66812
|
+
_ray$1.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
66813
|
+
const isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;
|
|
66814
|
+
|
|
66815
|
+
if ( isInside ) {
|
|
66816
|
+
|
|
66817
|
+
intersects.push( {
|
|
66818
|
+
point,
|
|
66819
|
+
pointOnLine,
|
|
66820
|
+
distance: _ray$1.origin.distanceTo( point ),
|
|
66821
|
+
object: lineSegments,
|
|
66822
|
+
face: null,
|
|
66823
|
+
faceIndex: i,
|
|
66824
|
+
uv: null,
|
|
66825
|
+
uv1: null,
|
|
66826
|
+
} );
|
|
66827
|
+
|
|
66828
|
+
}
|
|
66829
|
+
|
|
66830
|
+
}
|
|
66831
|
+
|
|
66832
|
+
}
|
|
66833
|
+
|
|
66834
|
+
function raycastScreenSpace( lineSegments, camera, intersects ) {
|
|
66835
|
+
|
|
66836
|
+
const projectionMatrix = camera.projectionMatrix;
|
|
66837
|
+
const material = lineSegments.material;
|
|
66838
|
+
const resolution = material.resolution;
|
|
66839
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
66840
|
+
|
|
66841
|
+
const geometry = lineSegments.geometry;
|
|
66842
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
66843
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
66844
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
66845
|
+
|
|
66846
|
+
const near = - camera.near;
|
|
66847
|
+
|
|
66848
|
+
//
|
|
66849
|
+
|
|
66850
|
+
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
66851
|
+
// sitting at the camera origin which will cause "w" to be 0 when
|
|
66852
|
+
// applying the projection matrix.
|
|
66853
|
+
_ray$1.at( 1, _ssOrigin );
|
|
66854
|
+
|
|
66855
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
66856
|
+
_ssOrigin.w = 1;
|
|
66857
|
+
_ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
|
66858
|
+
_ssOrigin.applyMatrix4( projectionMatrix );
|
|
66859
|
+
_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );
|
|
66860
|
+
|
|
66861
|
+
// screen space
|
|
66862
|
+
_ssOrigin.x *= resolution.x / 2;
|
|
66863
|
+
_ssOrigin.y *= resolution.y / 2;
|
|
66864
|
+
_ssOrigin.z = 0;
|
|
66865
|
+
|
|
66866
|
+
_ssOrigin3.copy( _ssOrigin );
|
|
66867
|
+
|
|
66868
|
+
_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
|
66869
|
+
|
|
66870
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
66871
|
+
|
|
66872
|
+
_start4.fromBufferAttribute( instanceStart, i );
|
|
66873
|
+
_end4.fromBufferAttribute( instanceEnd, i );
|
|
66874
|
+
|
|
66875
|
+
_start4.w = 1;
|
|
66876
|
+
_end4.w = 1;
|
|
66877
|
+
|
|
66878
|
+
// camera space
|
|
66879
|
+
_start4.applyMatrix4( _mvMatrix );
|
|
66880
|
+
_end4.applyMatrix4( _mvMatrix );
|
|
66881
|
+
|
|
66882
|
+
// skip the segment if it's entirely behind the camera
|
|
66883
|
+
const isBehindCameraNear = _start4.z > near && _end4.z > near;
|
|
66884
|
+
if ( isBehindCameraNear ) {
|
|
66885
|
+
|
|
66886
|
+
continue;
|
|
66887
|
+
|
|
66888
|
+
}
|
|
66889
|
+
|
|
66890
|
+
// trim the segment if it extends behind camera near
|
|
66891
|
+
if ( _start4.z > near ) {
|
|
66892
|
+
|
|
66893
|
+
const deltaDist = _start4.z - _end4.z;
|
|
66894
|
+
const t = ( _start4.z - near ) / deltaDist;
|
|
66895
|
+
_start4.lerp( _end4, t );
|
|
66896
|
+
|
|
66897
|
+
} else if ( _end4.z > near ) {
|
|
66898
|
+
|
|
66899
|
+
const deltaDist = _end4.z - _start4.z;
|
|
66900
|
+
const t = ( _end4.z - near ) / deltaDist;
|
|
66901
|
+
_end4.lerp( _start4, t );
|
|
66902
|
+
|
|
66903
|
+
}
|
|
66904
|
+
|
|
66905
|
+
// clip space
|
|
66906
|
+
_start4.applyMatrix4( projectionMatrix );
|
|
66907
|
+
_end4.applyMatrix4( projectionMatrix );
|
|
66908
|
+
|
|
66909
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
66910
|
+
_start4.multiplyScalar( 1 / _start4.w );
|
|
66911
|
+
_end4.multiplyScalar( 1 / _end4.w );
|
|
66912
|
+
|
|
66913
|
+
// screen space
|
|
66914
|
+
_start4.x *= resolution.x / 2;
|
|
66915
|
+
_start4.y *= resolution.y / 2;
|
|
66916
|
+
|
|
66917
|
+
_end4.x *= resolution.x / 2;
|
|
66918
|
+
_end4.y *= resolution.y / 2;
|
|
66919
|
+
|
|
66920
|
+
// create 2d segment
|
|
66921
|
+
_line.start.copy( _start4 );
|
|
66922
|
+
_line.start.z = 0;
|
|
66923
|
+
|
|
66924
|
+
_line.end.copy( _end4 );
|
|
66925
|
+
_line.end.z = 0;
|
|
66926
|
+
|
|
66927
|
+
// get closest point on ray to segment
|
|
66928
|
+
const param = _line.closestPointToPointParameter( _ssOrigin3, true );
|
|
66929
|
+
_line.at( param, _closestPoint );
|
|
66930
|
+
|
|
66931
|
+
// check if the intersection point is within clip space
|
|
66932
|
+
const zPos = MathUtils.lerp( _start4.z, _end4.z, param );
|
|
66933
|
+
const isInClipSpace = zPos >= - 1 && zPos <= 1;
|
|
66934
|
+
|
|
66935
|
+
const isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;
|
|
66936
|
+
|
|
66937
|
+
if ( isInClipSpace && isInside ) {
|
|
66938
|
+
|
|
66939
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
66940
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
66941
|
+
|
|
66942
|
+
_line.start.applyMatrix4( matrixWorld );
|
|
66943
|
+
_line.end.applyMatrix4( matrixWorld );
|
|
66944
|
+
|
|
66945
|
+
const pointOnLine = new Vector3();
|
|
66946
|
+
const point = new Vector3();
|
|
66947
|
+
|
|
66948
|
+
_ray$1.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
66949
|
+
|
|
66950
|
+
intersects.push( {
|
|
66951
|
+
point: point,
|
|
66952
|
+
pointOnLine: pointOnLine,
|
|
66953
|
+
distance: _ray$1.origin.distanceTo( point ),
|
|
66954
|
+
object: lineSegments,
|
|
66955
|
+
face: null,
|
|
66956
|
+
faceIndex: i,
|
|
66957
|
+
uv: null,
|
|
66958
|
+
uv1: null,
|
|
66959
|
+
} );
|
|
66960
|
+
|
|
66961
|
+
}
|
|
66962
|
+
|
|
66963
|
+
}
|
|
66964
|
+
|
|
66965
|
+
}
|
|
66966
|
+
|
|
66967
|
+
class LineSegments2 extends Mesh {
|
|
66968
|
+
|
|
66969
|
+
constructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
66970
|
+
|
|
66971
|
+
super( geometry, material );
|
|
66972
|
+
|
|
66973
|
+
this.isLineSegments2 = true;
|
|
66974
|
+
|
|
66975
|
+
this.type = 'LineSegments2';
|
|
66976
|
+
|
|
66977
|
+
}
|
|
66978
|
+
|
|
66979
|
+
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
66980
|
+
|
|
66981
|
+
computeLineDistances() {
|
|
66982
|
+
|
|
66983
|
+
const geometry = this.geometry;
|
|
66984
|
+
|
|
66985
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
66986
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
66987
|
+
const lineDistances = new Float32Array( 2 * instanceStart.count );
|
|
66988
|
+
|
|
66989
|
+
for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
|
|
66990
|
+
|
|
66991
|
+
_start.fromBufferAttribute( instanceStart, i );
|
|
66992
|
+
_end.fromBufferAttribute( instanceEnd, i );
|
|
66993
|
+
|
|
66994
|
+
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
|
66995
|
+
lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
|
|
66996
|
+
|
|
66997
|
+
}
|
|
66998
|
+
|
|
66999
|
+
const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
67000
|
+
|
|
67001
|
+
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
67002
|
+
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
67003
|
+
|
|
67004
|
+
return this;
|
|
67005
|
+
|
|
67006
|
+
}
|
|
67007
|
+
|
|
67008
|
+
raycast( raycaster, intersects ) {
|
|
67009
|
+
|
|
67010
|
+
const worldUnits = this.material.worldUnits;
|
|
67011
|
+
const camera = raycaster.camera;
|
|
67012
|
+
|
|
67013
|
+
if ( camera === null && ! worldUnits ) {
|
|
67014
|
+
|
|
67015
|
+
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );
|
|
67016
|
+
|
|
67017
|
+
}
|
|
67018
|
+
|
|
67019
|
+
const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
|
|
67020
|
+
|
|
67021
|
+
_ray$1 = raycaster.ray;
|
|
67022
|
+
|
|
67023
|
+
const matrixWorld = this.matrixWorld;
|
|
67024
|
+
const geometry = this.geometry;
|
|
67025
|
+
const material = this.material;
|
|
67026
|
+
|
|
67027
|
+
_lineWidth = material.linewidth + threshold;
|
|
67028
|
+
|
|
67029
|
+
// check if we intersect the sphere bounds
|
|
67030
|
+
if ( geometry.boundingSphere === null ) {
|
|
67031
|
+
|
|
67032
|
+
geometry.computeBoundingSphere();
|
|
67033
|
+
|
|
67034
|
+
}
|
|
67035
|
+
|
|
67036
|
+
_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );
|
|
67037
|
+
|
|
67038
|
+
// increase the sphere bounds by the worst case line screen space width
|
|
67039
|
+
let sphereMargin;
|
|
67040
|
+
if ( worldUnits ) {
|
|
67041
|
+
|
|
67042
|
+
sphereMargin = _lineWidth * 0.5;
|
|
67043
|
+
|
|
67044
|
+
} else {
|
|
67045
|
+
|
|
67046
|
+
const distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray$1.origin ) );
|
|
67047
|
+
sphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );
|
|
67048
|
+
|
|
67049
|
+
}
|
|
67050
|
+
|
|
67051
|
+
_sphere.radius += sphereMargin;
|
|
67052
|
+
|
|
67053
|
+
if ( _ray$1.intersectsSphere( _sphere ) === false ) {
|
|
67054
|
+
|
|
67055
|
+
return;
|
|
67056
|
+
|
|
67057
|
+
}
|
|
67058
|
+
|
|
67059
|
+
// check if we intersect the box bounds
|
|
67060
|
+
if ( geometry.boundingBox === null ) {
|
|
67061
|
+
|
|
67062
|
+
geometry.computeBoundingBox();
|
|
67063
|
+
|
|
67064
|
+
}
|
|
67065
|
+
|
|
67066
|
+
_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );
|
|
67067
|
+
|
|
67068
|
+
// increase the box bounds by the worst case line width
|
|
67069
|
+
let boxMargin;
|
|
67070
|
+
if ( worldUnits ) {
|
|
67071
|
+
|
|
67072
|
+
boxMargin = _lineWidth * 0.5;
|
|
67073
|
+
|
|
67074
|
+
} else {
|
|
67075
|
+
|
|
67076
|
+
const distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray$1.origin ) );
|
|
67077
|
+
boxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );
|
|
67078
|
+
|
|
67079
|
+
}
|
|
67080
|
+
|
|
67081
|
+
_box.expandByScalar( boxMargin );
|
|
67082
|
+
|
|
67083
|
+
if ( _ray$1.intersectsBox( _box ) === false ) {
|
|
67084
|
+
|
|
67085
|
+
return;
|
|
67086
|
+
|
|
67087
|
+
}
|
|
67088
|
+
|
|
67089
|
+
if ( worldUnits ) {
|
|
67090
|
+
|
|
67091
|
+
raycastWorldUnits( this, intersects );
|
|
67092
|
+
|
|
67093
|
+
} else {
|
|
67094
|
+
|
|
67095
|
+
raycastScreenSpace( this, camera, intersects );
|
|
67096
|
+
|
|
67097
|
+
}
|
|
67098
|
+
|
|
67099
|
+
}
|
|
67100
|
+
|
|
67101
|
+
onBeforeRender( renderer ) {
|
|
67102
|
+
|
|
67103
|
+
const uniforms = this.material.uniforms;
|
|
67104
|
+
|
|
67105
|
+
if ( uniforms && uniforms.resolution ) {
|
|
67106
|
+
|
|
67107
|
+
renderer.getViewport( _viewport );
|
|
67108
|
+
this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
|
|
67109
|
+
|
|
67110
|
+
}
|
|
67111
|
+
|
|
67112
|
+
}
|
|
66707
67113
|
|
|
66708
|
-
if (geometry.boundingBox === null) {
|
|
66709
|
-
geometry.computeBoundingBox();
|
|
66710
|
-
}
|
|
66711
|
-
_box.copy(geometry.boundingBox).applyMatrix4(matrixWorld);
|
|
66712
|
-
const distanceToBox = Math.max(camera.near, _box.distanceToPoint(ray.origin)); // get the w component to scale the world space line width
|
|
66713
|
-
|
|
66714
|
-
_clipToWorldVector.set(0, 0, -distanceToBox, 1.0).applyMatrix4(camera.projectionMatrix);
|
|
66715
|
-
_clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w);
|
|
66716
|
-
_clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse); // increase the sphere bounds by the worst case line screen space width
|
|
66717
|
-
|
|
66718
|
-
const boxMargin = Math.abs(ssMaxWidth / _clipToWorldVector.w) * 0.5;
|
|
66719
|
-
_box.max.x += boxMargin;
|
|
66720
|
-
_box.max.y += boxMargin;
|
|
66721
|
-
_box.max.z += boxMargin;
|
|
66722
|
-
_box.min.x -= boxMargin;
|
|
66723
|
-
_box.min.y -= boxMargin;
|
|
66724
|
-
_box.min.z -= boxMargin;
|
|
66725
|
-
if (raycaster.ray.intersectsBox(_box) === false) {
|
|
66726
|
-
return;
|
|
66727
|
-
} //
|
|
66728
|
-
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
66729
|
-
// sitting at the camera origin which will cause "w" to be 0 when
|
|
66730
|
-
// applying the projection matrix.
|
|
66731
|
-
|
|
66732
|
-
ray.at(1, _ssOrigin); // ndc space [ - 1.0, 1.0 ]
|
|
66733
|
-
|
|
66734
|
-
_ssOrigin.w = 1;
|
|
66735
|
-
_ssOrigin.applyMatrix4(camera.matrixWorldInverse);
|
|
66736
|
-
_ssOrigin.applyMatrix4(projectionMatrix);
|
|
66737
|
-
_ssOrigin.multiplyScalar(1 / _ssOrigin.w); // screen space
|
|
66738
|
-
|
|
66739
|
-
_ssOrigin.x *= resolution.x / 2;
|
|
66740
|
-
_ssOrigin.y *= resolution.y / 2;
|
|
66741
|
-
_ssOrigin.z = 0;
|
|
66742
|
-
_ssOrigin3.copy(_ssOrigin);
|
|
66743
|
-
_mvMatrix.multiplyMatrices(camera.matrixWorldInverse, matrixWorld);
|
|
66744
|
-
for (let i = 0, l = instanceStart.count; i < l; i++) {
|
|
66745
|
-
_start4.fromBufferAttribute(instanceStart, i);
|
|
66746
|
-
_end4.fromBufferAttribute(instanceEnd, i);
|
|
66747
|
-
_start4.w = 1;
|
|
66748
|
-
_end4.w = 1; // camera space
|
|
66749
|
-
|
|
66750
|
-
_start4.applyMatrix4(_mvMatrix);
|
|
66751
|
-
_end4.applyMatrix4(_mvMatrix); // skip the segment if it's entirely behind the camera
|
|
66752
|
-
|
|
66753
|
-
var isBehindCameraNear = _start4.z > near && _end4.z > near;
|
|
66754
|
-
if (isBehindCameraNear) {
|
|
66755
|
-
continue;
|
|
66756
|
-
} // trim the segment if it extends behind camera near
|
|
66757
|
-
|
|
66758
|
-
if (_start4.z > near) {
|
|
66759
|
-
const deltaDist = _start4.z - _end4.z;
|
|
66760
|
-
const t = (_start4.z - near) / deltaDist;
|
|
66761
|
-
_start4.lerp(_end4, t);
|
|
66762
|
-
} else if (_end4.z > near) {
|
|
66763
|
-
const deltaDist = _end4.z - _start4.z;
|
|
66764
|
-
const t = (_end4.z - near) / deltaDist;
|
|
66765
|
-
_end4.lerp(_start4, t);
|
|
66766
|
-
} // clip space
|
|
66767
|
-
|
|
66768
|
-
_start4.applyMatrix4(projectionMatrix);
|
|
66769
|
-
_end4.applyMatrix4(projectionMatrix); // ndc space [ - 1.0, 1.0 ]
|
|
66770
|
-
|
|
66771
|
-
_start4.multiplyScalar(1 / _start4.w);
|
|
66772
|
-
_end4.multiplyScalar(1 / _end4.w); // screen space
|
|
66773
|
-
|
|
66774
|
-
_start4.x *= resolution.x / 2;
|
|
66775
|
-
_start4.y *= resolution.y / 2;
|
|
66776
|
-
_end4.x *= resolution.x / 2;
|
|
66777
|
-
_end4.y *= resolution.y / 2; // create 2d segment
|
|
66778
|
-
|
|
66779
|
-
_line.start.copy(_start4);
|
|
66780
|
-
_line.start.z = 0;
|
|
66781
|
-
_line.end.copy(_end4);
|
|
66782
|
-
_line.end.z = 0; // get closest point on ray to segment
|
|
66783
|
-
|
|
66784
|
-
const param = _line.closestPointToPointParameter(_ssOrigin3, true);
|
|
66785
|
-
_line.at(param, _closestPoint); // check if the intersection point is within clip space
|
|
66786
|
-
|
|
66787
|
-
const zPos = THREE$j.MathUtils.lerp(_start4.z, _end4.z, param);
|
|
66788
|
-
const isInClipSpace = zPos >= -1 && zPos <= 1;
|
|
66789
|
-
const isInside = _ssOrigin3.distanceTo(_closestPoint) < lineWidth * 0.5;
|
|
66790
|
-
if (isInClipSpace && isInside) {
|
|
66791
|
-
_line.start.fromBufferAttribute(instanceStart, i);
|
|
66792
|
-
_line.end.fromBufferAttribute(instanceEnd, i);
|
|
66793
|
-
_line.start.applyMatrix4(matrixWorld);
|
|
66794
|
-
_line.end.applyMatrix4(matrixWorld);
|
|
66795
|
-
const pointOnLine = new THREE$j.Vector3();
|
|
66796
|
-
const point = new THREE$j.Vector3();
|
|
66797
|
-
ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine);
|
|
66798
|
-
intersects.push({
|
|
66799
|
-
point: point,
|
|
66800
|
-
pointOnLine: pointOnLine,
|
|
66801
|
-
distance: ray.origin.distanceTo(point),
|
|
66802
|
-
object: this,
|
|
66803
|
-
face: null,
|
|
66804
|
-
faceIndex: i,
|
|
66805
|
-
uv: null,
|
|
66806
|
-
uv2: null
|
|
66807
|
-
});
|
|
66808
|
-
}
|
|
66809
|
-
}
|
|
66810
|
-
}
|
|
66811
67114
|
}
|
|
66812
|
-
LineSegments2.prototype.LineSegments2 = true;
|
|
66813
67115
|
|
|
66814
67116
|
class LineGeometry extends LineSegmentsGeometry {
|
|
66815
|
-
constructor() {
|
|
66816
|
-
super();
|
|
66817
|
-
this.type = 'LineGeometry';
|
|
66818
|
-
}
|
|
66819
|
-
setPositions(array) {
|
|
66820
|
-
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
|
|
66821
|
-
var length = array.length - 3;
|
|
66822
|
-
var points = new Float32Array(2 * length);
|
|
66823
|
-
for (var i = 0; i < length; i += 3) {
|
|
66824
|
-
points[2 * i] = array[i];
|
|
66825
|
-
points[2 * i + 1] = array[i + 1];
|
|
66826
|
-
points[2 * i + 2] = array[i + 2];
|
|
66827
|
-
points[2 * i + 3] = array[i + 3];
|
|
66828
|
-
points[2 * i + 4] = array[i + 4];
|
|
66829
|
-
points[2 * i + 5] = array[i + 5];
|
|
66830
|
-
}
|
|
66831
|
-
super.setPositions(points);
|
|
66832
|
-
return this;
|
|
66833
|
-
}
|
|
66834
|
-
setColors(array) {
|
|
66835
|
-
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
|
66836
|
-
var length = array.length - 3;
|
|
66837
|
-
var colors = new Float32Array(2 * length);
|
|
66838
|
-
for (var i = 0; i < length; i += 3) {
|
|
66839
|
-
colors[2 * i] = array[i];
|
|
66840
|
-
colors[2 * i + 1] = array[i + 1];
|
|
66841
|
-
colors[2 * i + 2] = array[i + 2];
|
|
66842
|
-
colors[2 * i + 3] = array[i + 3];
|
|
66843
|
-
colors[2 * i + 4] = array[i + 4];
|
|
66844
|
-
colors[2 * i + 5] = array[i + 5];
|
|
66845
|
-
}
|
|
66846
|
-
super.setColors(colors);
|
|
66847
|
-
return this;
|
|
66848
|
-
}
|
|
66849
|
-
fromLine(line) {
|
|
66850
|
-
var geometry = line.geometry;
|
|
66851
|
-
if (geometry.isGeometry) {
|
|
66852
|
-
console.error('THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.');
|
|
66853
|
-
return;
|
|
66854
|
-
} else if (geometry.isBufferGeometry) {
|
|
66855
|
-
this.setPositions(geometry.attributes.position.array); // assumes non-indexed
|
|
66856
|
-
} // set colors, maybe
|
|
66857
67117
|
|
|
66858
|
-
|
|
66859
|
-
|
|
67118
|
+
constructor() {
|
|
67119
|
+
|
|
67120
|
+
super();
|
|
67121
|
+
|
|
67122
|
+
this.isLineGeometry = true;
|
|
67123
|
+
|
|
67124
|
+
this.type = 'LineGeometry';
|
|
67125
|
+
|
|
67126
|
+
}
|
|
67127
|
+
|
|
67128
|
+
setPositions( array ) {
|
|
67129
|
+
|
|
67130
|
+
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
|
|
67131
|
+
|
|
67132
|
+
const length = array.length - 3;
|
|
67133
|
+
const points = new Float32Array( 2 * length );
|
|
67134
|
+
|
|
67135
|
+
for ( let i = 0; i < length; i += 3 ) {
|
|
67136
|
+
|
|
67137
|
+
points[ 2 * i ] = array[ i ];
|
|
67138
|
+
points[ 2 * i + 1 ] = array[ i + 1 ];
|
|
67139
|
+
points[ 2 * i + 2 ] = array[ i + 2 ];
|
|
67140
|
+
|
|
67141
|
+
points[ 2 * i + 3 ] = array[ i + 3 ];
|
|
67142
|
+
points[ 2 * i + 4 ] = array[ i + 4 ];
|
|
67143
|
+
points[ 2 * i + 5 ] = array[ i + 5 ];
|
|
67144
|
+
|
|
67145
|
+
}
|
|
67146
|
+
|
|
67147
|
+
super.setPositions( points );
|
|
67148
|
+
|
|
67149
|
+
return this;
|
|
67150
|
+
|
|
67151
|
+
}
|
|
67152
|
+
|
|
67153
|
+
setColors( array ) {
|
|
67154
|
+
|
|
67155
|
+
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
|
67156
|
+
|
|
67157
|
+
const length = array.length - 3;
|
|
67158
|
+
const colors = new Float32Array( 2 * length );
|
|
67159
|
+
|
|
67160
|
+
for ( let i = 0; i < length; i += 3 ) {
|
|
67161
|
+
|
|
67162
|
+
colors[ 2 * i ] = array[ i ];
|
|
67163
|
+
colors[ 2 * i + 1 ] = array[ i + 1 ];
|
|
67164
|
+
colors[ 2 * i + 2 ] = array[ i + 2 ];
|
|
67165
|
+
|
|
67166
|
+
colors[ 2 * i + 3 ] = array[ i + 3 ];
|
|
67167
|
+
colors[ 2 * i + 4 ] = array[ i + 4 ];
|
|
67168
|
+
colors[ 2 * i + 5 ] = array[ i + 5 ];
|
|
67169
|
+
|
|
67170
|
+
}
|
|
67171
|
+
|
|
67172
|
+
super.setColors( colors );
|
|
67173
|
+
|
|
67174
|
+
return this;
|
|
67175
|
+
|
|
67176
|
+
}
|
|
67177
|
+
|
|
67178
|
+
fromLine( line ) {
|
|
67179
|
+
|
|
67180
|
+
const geometry = line.geometry;
|
|
67181
|
+
|
|
67182
|
+
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
67183
|
+
|
|
67184
|
+
// set colors, maybe
|
|
67185
|
+
|
|
67186
|
+
return this;
|
|
67187
|
+
|
|
67188
|
+
}
|
|
67189
|
+
|
|
66860
67190
|
}
|
|
66861
|
-
LineGeometry.prototype.isLineGeometry = true;
|
|
66862
67191
|
|
|
66863
67192
|
class Line2 extends LineSegments2 {
|
|
66864
|
-
|
|
66865
|
-
|
|
66866
|
-
|
|
66867
|
-
|
|
66868
|
-
|
|
66869
|
-
|
|
67193
|
+
|
|
67194
|
+
constructor( geometry = new LineGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
67195
|
+
|
|
67196
|
+
super( geometry, material );
|
|
67197
|
+
|
|
67198
|
+
this.isLine2 = true;
|
|
67199
|
+
|
|
67200
|
+
this.type = 'Line2';
|
|
67201
|
+
|
|
67202
|
+
}
|
|
67203
|
+
|
|
66870
67204
|
}
|
|
66871
|
-
Line2.prototype.isLine2 = true;
|
|
66872
67205
|
|
|
66873
67206
|
/**
|
|
66874
67207
|
* Text = 3D Text
|
|
@@ -71290,23 +71623,43 @@ void main() {
|
|
|
71290
71623
|
|
|
71291
71624
|
function onMouseDown$1( event ) {
|
|
71292
71625
|
|
|
71293
|
-
|
|
71626
|
+
let mouseAction;
|
|
71294
71627
|
|
|
71295
|
-
|
|
71628
|
+
switch ( event.button ) {
|
|
71296
71629
|
|
|
71297
|
-
|
|
71298
|
-
|
|
71299
|
-
|
|
71630
|
+
case 0:
|
|
71631
|
+
mouseAction = this.mouseButtons.LEFT;
|
|
71632
|
+
break;
|
|
71300
71633
|
|
|
71301
|
-
|
|
71302
|
-
|
|
71303
|
-
|
|
71634
|
+
case 1:
|
|
71635
|
+
mouseAction = this.mouseButtons.MIDDLE;
|
|
71636
|
+
break;
|
|
71304
71637
|
|
|
71305
|
-
|
|
71306
|
-
|
|
71307
|
-
|
|
71638
|
+
case 2:
|
|
71639
|
+
mouseAction = this.mouseButtons.RIGHT;
|
|
71640
|
+
break;
|
|
71308
71641
|
|
|
71309
|
-
|
|
71642
|
+
default:
|
|
71643
|
+
mouseAction = - 1;
|
|
71644
|
+
|
|
71645
|
+
}
|
|
71646
|
+
|
|
71647
|
+
switch ( mouseAction ) {
|
|
71648
|
+
|
|
71649
|
+
case MOUSE.DOLLY:
|
|
71650
|
+
this.state = _STATE$1.ZOOM;
|
|
71651
|
+
break;
|
|
71652
|
+
|
|
71653
|
+
case MOUSE.ROTATE:
|
|
71654
|
+
this.state = _STATE$1.ROTATE;
|
|
71655
|
+
break;
|
|
71656
|
+
|
|
71657
|
+
case MOUSE.PAN:
|
|
71658
|
+
this.state = _STATE$1.PAN;
|
|
71659
|
+
break;
|
|
71660
|
+
|
|
71661
|
+
default:
|
|
71662
|
+
this.state = _STATE$1.NONE;
|
|
71310
71663
|
|
|
71311
71664
|
}
|
|
71312
71665
|
|